refactor(api): remove legacy POST /api/chat streaming endpoint

Merged
AR
5mo ago
+26-1435

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:check clean
  • pnpm test green for lib/chat, lib/credits, lib/emails
  • Confirm /api/chat/workflow and /api/chat/generate still 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.ts and their tests.
    • Removed orphaned modules: lib/emails/extractSendEmailResults.ts, lib/messages/validateMessages.ts (duplicate of lib/chat/validateMessages.ts), lib/supabase/memories/upsertMemory.ts, lib/messages/getLatestUserMessageText.ts and its test.
    • Trimmed chatEndToEnd.test.ts to validate/setup/credits only; dropped post-completion coverage and the upsertMemory mock.
    • Minor comment tweaks in validateChatRequest and handleChatCredits.
  • Migration

    • Merge after the frontend removes /api/chat calls (chat#1765).
    • Verify /api/chat/workflow and /api/chat/generate on the preview deployment.
    • Run pnpm lint:check and pnpm test for lib/chat and lib/credits.

Summary by CodeRabbit

  • Removed Features

    • Removed the /api/chat endpoint, 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.
  • Documentation

    • Updated inline comments clarifying message ID handling and credit parameter descriptions.