Repository navigation
Split the client AI module into per-feature files - #145
Conversation
Move src/lib/ai/client.ts into errors, request, sources and text, plus one file per feature under features/, mirroring supabase/functions/ai. Code moves byte for byte; 11 formerly private helpers gain an export so siblings can import them. client.ts is now an explicit re-export barrel with the same 39 names, so no caller changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a no-restricted-imports rule so app, e2e and agentic code cannot import ai/request, ai/errors, ai/sources, ai/text or ai/features/* directly. That restores the privacy the helpers had before the split. Point the docs and one fixture comment at the new layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The import guard missed specifiers with an extension (the repo allows `.ts` imports), trailing slashes, and dynamic import(). It also matched the server's same-named modules under supabase/functions/ai/. Dynamic imports now go through no-restricted-syntax with the same pattern. The docs now name streaming.ts as the second transport and request.ts as a place where responses are validated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
ℹ️ Recent review info
📝 Walkthrough
Note 🎁 Summarized by CodeRabbit Free
Comment |
|
GitHub Actions did not run on this PR. Every job stopped after 2 seconds with "recent account payments have failed". These are the local results at head
All 6 failures are the same 3 specs on desktop and mobile Chromium: |
Why
src/lib/ai/client.tswas 1,585 lines with every AI feature in one file. The server side was split per feature in #75. This does the same for the client, as item 11 ofplans/2026-10-01-next-15.md.What changed
client.ts.request.tsholds the one transport,callSupabaseAI.errors.tsholds the error classes,sources.tsthe discovered-source parsing and autosave, andtext.tsthe string helpers.src/lib/ai/features/, with the same seven names the server uses.client.tsnow only re-exports. It lists the same 39 names, so no caller or test changes. A lint rule stops app code from importing the files behind it.Scope
exportto 11 helpers that other files now need.callSupabaseAIhas an unreachableTimeoutErrorbranch.session-store.tsis out of scope, as the plan says.Tradeoffs
streaming.tsanderror-display.tsstill import from./client, not from the new files. Three page tests mock the whole of@/lib/ai/client. Iferror-display.tsimportederrors.tsdirectly, those tests would get the real error class instead of the mock.Blast Radius
The split touches every AI feature in the browser, but only the module layout changes. If something is wrong, it shows up as a broken import at build time or a failed AI request in the app. The payload check below rules out the second for every flow the verify recipes drive.
Verification
verify-debatelab drive all. Two runs onmainand one run on this branch give the same 140 requests, byte-identical after masking UUIDs, timestamps and HMAC signatures: sha256ca3e696c…all three times. As a check that the comparison can fail, a one-word change to the client's default factoids region changed the recorded payload while its recipe still passed.drive all: 66 passed, 4 skipped on bothmainand this branch, desktop and mobile Chromium, fake provider.npm test(31 files, 280 tests, no test file changed),typecheck,lint,buildanddocs:checkall pass locally. A partition script confirms each of the 79 original declarations appears exactly once with an unchanged body.🤖 Generated with Claude Code
Summary by CodeRabbit