From a062febf2e03aefff5ab80aeafdb2c0c7a19a5fe Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 6 Sep 2026 01:02:17 +0000 Subject: [PATCH 1/3] Cut unused UI kit and fix the review-loop defects Remove the unused shadcn/Next leftovers that never rendered in Relay. Keep the job-history contract: user-scoped records, exact acceptance, and imports that cannot grant approval. A 401 now clears private workspace state and ignores stale responses. Selecting a job loads that job's review events beyond the global 200. Packets and draft results work for valid jobs without a posting URL. Closes #7 Closes #8 Closes #9 Co-authored-by: Seth Carlson --- ARCHITECTURE.md | 4 +- app/api/workspace/route.ts | 25 +- app/connections.tsx | 12 +- app/globals.css | 1 - app/workspace.tsx | 214 +- components.json | 25 - components/ui/accordion.tsx | 78 - components/ui/alert-dialog.tsx | 187 -- components/ui/alert.tsx | 76 - components/ui/aspect-ratio.tsx | 22 - components/ui/attachment.tsx | 207 -- components/ui/avatar.tsx | 109 - components/ui/badge.tsx | 52 - components/ui/breadcrumb.tsx | 122 - components/ui/bubble.tsx | 128 - components/ui/button-group.tsx | 87 - components/ui/button.tsx | 58 - components/ui/calendar.tsx | 231 -- components/ui/card.tsx | 103 - components/ui/carousel.tsx | 242 -- components/ui/chart.tsx | 373 --- components/ui/checkbox.tsx | 28 - components/ui/collapsible.tsx | 21 - components/ui/combobox.tsx | 300 --- components/ui/command.tsx | 193 -- components/ui/context-menu.tsx | 272 --- components/ui/dialog.tsx | 159 -- components/ui/direction.tsx | 6 - components/ui/drawer.tsx | 228 -- components/ui/dropdown-menu.tsx | 272 --- components/ui/empty.tsx | 104 - components/ui/field.tsx | 238 -- components/ui/hover-card.tsx | 51 - components/ui/input-group.tsx | 158 -- components/ui/input-otp.tsx | 86 - components/ui/input.tsx | 20 - components/ui/item.tsx | 201 -- components/ui/kbd.tsx | 26 - components/ui/label.tsx | 20 - components/ui/marker.tsx | 71 - components/ui/menubar.tsx | 284 --- components/ui/message-scroller.tsx | 130 -- components/ui/message.tsx | 92 - components/ui/native-select.tsx | 65 - components/ui/navigation-menu.tsx | 171 -- components/ui/pagination.tsx | 133 -- components/ui/popover.tsx | 90 - components/ui/progress.tsx | 83 - components/ui/radio-group.tsx | 38 - components/ui/resizable.tsx | 50 - components/ui/scroll-area.tsx | 55 - components/ui/select.tsx | 202 -- components/ui/separator.tsx | 25 - components/ui/sheet.tsx | 137 -- components/ui/sidebar.tsx | 723 ------ components/ui/skeleton.tsx | 13 - components/ui/slider.tsx | 52 - components/ui/spinner.tsx | 16 - components/ui/switch.tsx | 32 - components/ui/table.tsx | 116 - components/ui/tabs.tsx | 82 - components/ui/textarea.tsx | 18 - components/ui/toast.tsx | 229 -- components/ui/toggle-group.tsx | 89 - components/ui/toggle.tsx | 45 - components/ui/tooltip.tsx | 66 - docs/threat-model.md | 2 +- hooks/use-mobile.ts | 21 - integrations/OBSIDIAN.md | 2 +- integrations/README.md | 2 +- integrations/connectors.mjs | 9 +- lib/domain.ts | 13 + lib/integration-files.ts | 7 +- lib/obsidian.ts | 26 +- lib/utils.ts | 6 - lib/workspace-refresh.ts | 143 ++ next.config.ts | 5 - package.json | 26 +- pnpm-lock.yaml | 3477 +--------------------------- tests/api.test.mjs | 48 + tests/connectors.test.mjs | 22 + tests/domain.test.mjs | 34 + tests/e2e/workspace.spec.ts | 2 + tests/obsidian.test.mjs | 62 + tests/workspace-events.test.mjs | 110 + tests/workspace-refresh.test.mjs | 225 ++ tsconfig.json | 14 +- vite.config.ts | 2 - 88 files changed, 872 insertions(+), 11232 deletions(-) delete mode 100644 components.json delete mode 100644 components/ui/accordion.tsx delete mode 100644 components/ui/alert-dialog.tsx delete mode 100644 components/ui/alert.tsx delete mode 100644 components/ui/aspect-ratio.tsx delete mode 100644 components/ui/attachment.tsx delete mode 100644 components/ui/avatar.tsx delete mode 100644 components/ui/badge.tsx delete mode 100644 components/ui/breadcrumb.tsx delete mode 100644 components/ui/bubble.tsx delete mode 100644 components/ui/button-group.tsx delete mode 100644 components/ui/button.tsx delete mode 100644 components/ui/calendar.tsx delete mode 100644 components/ui/card.tsx delete mode 100644 components/ui/carousel.tsx delete mode 100644 components/ui/chart.tsx delete mode 100644 components/ui/checkbox.tsx delete mode 100644 components/ui/collapsible.tsx delete mode 100644 components/ui/combobox.tsx delete mode 100644 components/ui/command.tsx delete mode 100644 components/ui/context-menu.tsx delete mode 100644 components/ui/dialog.tsx delete mode 100644 components/ui/direction.tsx delete mode 100644 components/ui/drawer.tsx delete mode 100644 components/ui/dropdown-menu.tsx delete mode 100644 components/ui/empty.tsx delete mode 100644 components/ui/field.tsx delete mode 100644 components/ui/hover-card.tsx delete mode 100644 components/ui/input-group.tsx delete mode 100644 components/ui/input-otp.tsx delete mode 100644 components/ui/input.tsx delete mode 100644 components/ui/item.tsx delete mode 100644 components/ui/kbd.tsx delete mode 100644 components/ui/label.tsx delete mode 100644 components/ui/marker.tsx delete mode 100644 components/ui/menubar.tsx delete mode 100644 components/ui/message-scroller.tsx delete mode 100644 components/ui/message.tsx delete mode 100644 components/ui/native-select.tsx delete mode 100644 components/ui/navigation-menu.tsx delete mode 100644 components/ui/pagination.tsx delete mode 100644 components/ui/popover.tsx delete mode 100644 components/ui/progress.tsx delete mode 100644 components/ui/radio-group.tsx delete mode 100644 components/ui/resizable.tsx delete mode 100644 components/ui/scroll-area.tsx delete mode 100644 components/ui/select.tsx delete mode 100644 components/ui/separator.tsx delete mode 100644 components/ui/sheet.tsx delete mode 100644 components/ui/sidebar.tsx delete mode 100644 components/ui/skeleton.tsx delete mode 100644 components/ui/slider.tsx delete mode 100644 components/ui/spinner.tsx delete mode 100644 components/ui/switch.tsx delete mode 100644 components/ui/table.tsx delete mode 100644 components/ui/tabs.tsx delete mode 100644 components/ui/textarea.tsx delete mode 100644 components/ui/toast.tsx delete mode 100644 components/ui/toggle-group.tsx delete mode 100644 components/ui/toggle.tsx delete mode 100644 components/ui/tooltip.tsx delete mode 100644 hooks/use-mobile.ts delete mode 100644 lib/utils.ts create mode 100644 lib/workspace-refresh.ts delete mode 100644 next.config.ts create mode 100644 tests/workspace-events.test.mjs create mode 100644 tests/workspace-refresh.test.mjs diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 88d6687..fa8e7e3 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -6,7 +6,7 @@ Relay is a review workspace for job research and drafts. It stores opportunity h The React interface runs through Vinext. The server runs on Cloudflare Workers with D1 persistence. `app/chatgpt-auth.ts` resolves the identity supplied by the trusted Sites authentication gateway. `/api/workspace` scopes reads and mutations to that owner. The local development sign-in is simulated and must not be exposed publicly. -`jobs` stores canonical posting identity, status, draft, accepted text, blockers and version. `observations` preserves imported source records and revisions. `events` records workspace review actions. Database declarations are in `db/schema.ts`; ordered SQL migrations are in `drizzle/`. Obsidian adds no tables or migrations. +`jobs` stores canonical posting identity, status, draft, accepted text, blockers and version. `observations` preserves imported source records and revisions. `events` records workspace review actions. Initial workspace reads return at most 200 recent events. Selecting a job loads that job's events with the same bound, so older accepted-draft history stays retrievable. Database declarations are in `db/schema.ts`; ordered SQL migrations are in `drizzle/`. Obsidian adds no tables or migrations. The application has no server-side access to a local Obsidian vault and requires no new provider credentials for Markdown handoffs. The repository's `.openai/hosting.json` declares logical storage bindings only; publishing to GitHub does not create a hosted Relay service. @@ -33,7 +33,7 @@ flowchart LR Obsidian research notes own their editable source text. Relay owns the imported observations, application status and acceptance record. A downloaded context file is a dated reference copy, never a second live status authority. -`lib/domain.ts` validates imported rows and canonicalizes job URLs. Known Greenhouse aliases match; tracking parameters are removed from other posting identities. Different job-board URLs are not universally deduplicated. An Obsidian note uses `obsidian:` for source identity and its posting URL for job identity. Duplicate observation identity also includes owner, job, name, source status and note text; edited notes retain earlier observations. +`lib/domain.ts` validates imported rows and canonicalizes job URLs. Known Greenhouse aliases match; tracking parameters are removed from other posting identities. Different job-board URLs are not universally deduplicated. Jobs without a posting URL keep a source-based identity (`source:`). Packets and draft results must match that identity; they cannot claim a posting URL for a source-identity job. An Obsidian note uses `obsidian:` for source identity and its posting URL for job identity. Duplicate observation identity also includes owner, job, name, source status and note text; edited notes retain earlier observations. All Obsidian research rows enter with source status Held regardless of status-like properties. Existing job status, draft and exact acceptance are preserved by the established import rules. New jobs start Held. Existing import operations advance job versions, so reimported research can invalidate an outstanding draft packet even when no new observation is created. diff --git a/app/api/workspace/route.ts b/app/api/workspace/route.ts index 8f876e6..2fe0340 100644 --- a/app/api/workspace/route.ts +++ b/app/api/workspace/route.ts @@ -14,9 +14,13 @@ import { packets } from '../../../lib/packets'; export const dynamic = 'force-dynamic'; const reply = (data: unknown, status = 200) => Response.json(data, { status, headers: { 'Cache-Control': 'no-store' } }); -export async function GET() { +const JOB_ID = /^[A-Za-z0-9][A-Za-z0-9._-]{0,199}$/; +export async function GET(request: Request) { const user = (await getChatGPTUser())?.userId; if (!user) return reply({ error: 'Sign in to open your workspace.' }, 401); + const jobId = new URL(request.url).searchParams.get('job') || ''; + if (jobId && !JOB_ID.test(jobId)) + return reply({ error: 'Invalid job.' }, 400); const db = database(); const jobs = await db .prepare('SELECT * FROM jobs WHERE owner=? ORDER BY updated DESC,name') @@ -26,12 +30,19 @@ export async function GET() { .prepare('SELECT * FROM observations WHERE owner=? ORDER BY created') .bind(user) .all(); - const events = await db - .prepare( - 'SELECT * FROM events WHERE owner=? ORDER BY created DESC LIMIT 200', - ) - .bind(user) - .all(); + const events = jobId + ? await db + .prepare( + 'SELECT * FROM events WHERE owner=? AND job_id=? ORDER BY created DESC LIMIT 200', + ) + .bind(user, jobId) + .all() + : await db + .prepare( + 'SELECT * FROM events WHERE owner=? ORDER BY created DESC LIMIT 200', + ) + .bind(user) + .all(); return reply({ jobs: jobs.results, sources: sources.results, diff --git a/app/connections.tsx b/app/connections.tsx index d41eff1..7286cb6 100644 --- a/app/connections.tsx +++ b/app/connections.tsx @@ -36,7 +36,7 @@ export function Connections({ id: string; job_key: string; name: string; - url: string; + url: string | null; version: number; status: string; session?: string; @@ -120,10 +120,14 @@ export function Connections({ className="secondary" disabled={!current?.url} onClick={() => { - if (!current) return; + if (!current?.url) return; const id = crypto.randomUUID(); downloadFile( - obsidianResearchNote(current, workflow, id), + obsidianResearchNote( + { name: current.name, url: current.url }, + workflow, + id, + ), `relay-${workflow}-${id}.md`, 'text/markdown', ); @@ -165,7 +169,7 @@ export function Connections({ ))} + {!signedOut && ( + // oxlint-disable-next-line next/no-html-link-for-pages -- Sites and Access logout need top-level navigation. + + Sign out + + )}
History stays with the job.

@@ -241,43 +294,47 @@ export default function Workspace() {

Make your next move.

One opportunity. One history. A clear next action.

- + {!signedOut && ( + + )} -
-
- Opportunities - {jobs.length.toString().padStart(2, '0')} - Unique job records -
-
- Ready for your review - - {jobs - .filter((j) => j.status === 'Held') - .length.toString() - .padStart(2, '0')} - - Evidence before action -
-
- History preserved - - {(sources.length - jobs.length).toString().padStart(2, '0')} - - Repeat records consolidated -
-
- - Decisions carry forward. - Rediscovery never resets a submitted job. -
-
+ {!signedOut && ( +
+
+ Opportunities + {jobs.length.toString().padStart(2, '0')} + Unique job records +
+
+ Ready for your review + + {jobs + .filter((j) => j.status === 'Held') + .length.toString() + .padStart(2, '0')} + + Evidence before action +
+
+ History preserved + + {(sources.length - jobs.length).toString().padStart(2, '0')} + + Repeat records consolidated +
+
+ + Decisions carry forward. + Rediscovery never resets a submitted job. +
+
+ )} {message && (
{message} @@ -342,7 +399,7 @@ export default function Workspace() { openImport={() => setShowImport(true)} /> )} - {showImport && ( + {showImport && !signedOut && (

Import research

@@ -400,7 +457,7 @@ export default function Workspace() {

)} - {report && ( + {report && !signedOut && (
Research check @@ -424,7 +481,7 @@ export default function Workspace() {
)} - {jobs.length > 0 && ( + {jobs.length > 0 && !signedOut && ( <>
@@ -471,7 +528,10 @@ export default function Workspace() { - ); -} - -function CarouselNext({ - className, - variant = 'outline', - size = 'icon-sm', - ...props -}: React.ComponentProps) { - const { orientation, scrollNext, canScrollNext } = useCarousel(); - - return ( - - ); -} - -export { - type CarouselApi, - Carousel, - CarouselContent, - CarouselItem, - CarouselPrevious, - CarouselNext, - useCarousel, -}; diff --git a/components/ui/chart.tsx b/components/ui/chart.tsx deleted file mode 100644 index 0680cf0..0000000 --- a/components/ui/chart.tsx +++ /dev/null @@ -1,373 +0,0 @@ -'use client'; - -import * as React from 'react'; -import * as RechartsPrimitive from 'recharts'; -import type { TooltipValueType } from 'recharts'; - -import { cn } from '@/lib/utils'; - -// Format: { THEME_NAME: CSS_SELECTOR } -const THEMES = { light: '', dark: '.dark' } as const; - -const INITIAL_DIMENSION = { width: 320, height: 200 } as const; -type TooltipNameType = number | string; - -export type ChartConfig = Record< - string, - { - label?: React.ReactNode; - icon?: React.ComponentType; - } & ( - | { color?: string; theme?: never } - | { color?: never; theme: Record } - ) ->; - -type ChartContextProps = { - config: ChartConfig; -}; - -const ChartContext = React.createContext(null); - -function useChart() { - const context = React.useContext(ChartContext); - - if (!context) { - throw new Error('useChart must be used within a '); - } - - return context; -} - -function ChartContainer({ - id, - className, - children, - config, - initialDimension = INITIAL_DIMENSION, - ...props -}: React.ComponentProps<'div'> & { - config: ChartConfig; - children: React.ComponentProps< - typeof RechartsPrimitive.ResponsiveContainer - >['children']; - initialDimension?: { - width: number; - height: number; - }; -}) { - const uniqueId = React.useId(); - const chartId = `chart-${id ?? uniqueId.replace(/:/g, '')}`; - - return ( - -
- - - {children} - -
-
- ); -} - -const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => { - const colorConfig = Object.entries(config).filter( - ([, config]) => config.theme ?? config.color, - ); - - if (!colorConfig.length) { - return null; - } - - return ( -