refactor(api): remove legacy POST /api/chat streaming endpoint
Merged
AR
5mo ago+26+26+01234567890123456789-1435-1435-0123456789012345678901234567890123456789
Removes the legacy POST /api/chat streaming endpoint and all code that only it reached, now that the frontend's legacy transport is being dropped in chat#1765.
Deleted: the route, handleChatStream, handleChatCompletion, handleSendEmailToolOutputs, and their tests. Shared helpers used by /api/chat/workflow, /api/chat/generate, the stop route, Slack, and email flows are untouched.
⚠️ Merge after chat#1765 (which removes the frontend's /api/chat calls).
Test plan
-
pnpm lint:checkclean -
pnpm testgreen for lib/chat, lib/credits, lib/emails - Confirm
/api/chat/workflowand/api/chat/generatestill work on the Vercel preview
Summary by cubic
Remove the legacy POST /api/chat streaming endpoint and route all chat traffic through /api/chat/workflow and /api/chat/generate. Clean up dead code and slim tests to lower surface area and duplication.
-
Refactors
- Deleted
app/api/chat/route.ts,lib/chat/handleChatStream.ts,lib/chat/handleChatCompletion.ts,lib/emails/handleSendEmailToolOutputs.tsand their tests. - Removed orphaned modules:
lib/emails/extractSendEmailResults.ts,lib/messages/validateMessages.ts(duplicate oflib/chat/validateMessages.ts),lib/supabase/memories/upsertMemory.ts,lib/messages/getLatestUserMessageText.tsand its test. - Trimmed
chatEndToEnd.test.tsto validate/setup/credits only; dropped post-completion coverage and theupsertMemorymock. - Minor comment tweaks in
validateChatRequestandhandleChatCredits.
- Deleted
-
Migration
- Merge after the frontend removes
/api/chatcalls (chat#1765). - Verify
/api/chat/workflowand/api/chat/generateon the preview deployment. - Run
pnpm lint:checkandpnpm testforlib/chatandlib/credits.
- Merge after the frontend removes
Summary by CodeRabbit
-
Removed Features
- Removed the
/api/chatendpoint, including request handling and CORS preflight support. - Removed chat completion and streaming functionality from the chat API.
- Removed email tool output integration from chat responses.
- Removed the
-
Documentation
- Updated inline comments clarifying message ID handling and credit parameter descriptions.