#42
Route Focus and Smart Compose through AI Gateway
Summary
- route Focus classification through
typesafe-ai/jevvia Vercel AI Gateway - evaluate inbox summaries first, then refine only low-confidence threads with bounded message content
- route Smart Compose through the same Redakt-managed Gateway and simplify AI consent/settings
- remove legacy provider-key handling, update privacy/deployment docs, and purge stored legacy key fields
Verification
corepack pnpm test(169 passing)corepack pnpm exec eslint ...corepack pnpm exec next typegen && corepack pnpm exec tsc --noEmitcorepack pnpm build- live Jev evaluation smoke test
- live structured Smart Compose smoke test through Gateway
- browser verification of AI settings and Focus in demo mode
Deployment
AI_GATEWAY_API_KEY is configured on the Railway Redakt production and staging services. This PR does not trigger a deployment.
Activity
5c2b5709 into main2mo agostylessh deleted
stylessh/jev-focus-gateway branch2mo agomikeyreviewed2mo ago
Summary
Focus and Smart Compose are cleanly re-plumbed onto AI Gateway (
typesafe-ai/jevviaexperimental_evaluate, Gemini Flash-Lite viagenerateText), and the BYOK removal is thorough — no dangling references to the old provider/credential types, the consent version bump correctly forces re-consent, the data-purge migration is a straightforward one-way null-out, and privacy/terms copy was updated to match the new data flow. The two-phase Focus design (cheap summary pass, detail refinement only forconfidence < 0.72) and theevaluate()/generateText()usage both match the documented AI Gateway API shapes.One correctness regression in
lib/ai/compose.ts(see inline comment) should block merge: the JSON schema sent to the model no longer bounds block/run/text sizes, but the runtime validator still rejects output that exceeds the old bounds, so legitimate Smart Compose output can now start failing with a user-facing "invalid writing suggestion" 502.Two minor, non-blocking follow-ups:
lib/db/schema.tsstill declaresprovider,model,encryptedApiKey,apiKeyHintcolumns onaiSettings. The migration nulls the data but the columns and theirnotNull().default(...)aren't dropped — dead schema surface after this PR removes every reader/writer of those fields except the purge migration itself.app/api/settings/ai/route.ts'sDELETEhandler has no remaining caller now that the "Remove API key" dialog was removed fromcomponents/settings/ai-settings.tsx. Not broken (it still resets consent/enabled meaningfully), just unreachable from the UI — worth a follow-up decision on whether to keep it as a documented API or drop it.Tests, lint, typecheck, and build are reported green per the PR description; I did not re-run them.