refactor(chat): drop code the voice removal left unreachable - #6218
Conversation
Full-file cleanup pass over the files voice mode was removed from. - /api/speech/token: with the chatId branch gone, billingAttribution is always resolved, so four `billingAttribution ? ... : ...` guards and the checkActorUsageLimits fallback were unreachable. Removed, along with the now-unused imports and test mock. - chat.tsx: the inputValue state had one remaining writer (`''`) and no reader — ChatInput has owned its own input value since it went uncontrolled, and removing the voice-transcript caller left handleSendMessage always receiving an explicit message. - use-chat-streaming: messageIdMap was written in three frame handlers and never read, and setIsStreamingResponse was returned but never destructured by the only consumer. - Comments: dropped JSX section labels that restate the element beneath them and TSDoc that restates the identifier; narrowed the speech contract's workspaceId doc, which existed to contrast with the removed chatId field.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview Deployed chat (
Minor comment/doc trims in chat input JSX, the speech contract, and Reviewed by Cursor Bugbot for commit ad3a5f3. Configure here. |
Greptile SummaryThis PR removes state, mappings, return properties, conditional billing fallbacks, imports, mocks, and comments left unreachable after voice mode was removed.
Confidence Score: 5/5The PR appears safe to merge because the removed branches, state, mappings, and API surface have no reachable consumers or behavioral effect. The chat caller always provides an explicit string, streaming state remains internally managed, and speech billing attribution was already resolved before every simplified conditional.
|
| Filename | Overview |
|---|---|
| apps/sim/app/(interfaces)/chat/[identifier]/chat.tsx | Removes unread parent input state and formalizes the explicit message-value contract already satisfied by the only caller. |
| apps/sim/app/(interfaces)/chat/hooks/use-chat-streaming.ts | Removes write-only frame bookkeeping and an unused public setter without changing internal streaming-state transitions. |
| apps/sim/app/api/speech/token/route.ts | Collapses conditionals around billing attribution that was already guaranteed after successful resolution. |
| apps/sim/app/api/speech/token/route.test.ts | Removes the mock for the unreachable actor-limit fallback while preserving coverage of successful attribution and membership rejection. |
| apps/sim/app/(interfaces)/chat/components/input/input.tsx | Removes only redundant JSX section comments. |
| apps/sim/lib/api/contracts/media/speech.ts | Narrows documentation for the unchanged optional workspace identifier. |
| apps/sim/lib/core/config/env.ts | Removes trailing whitespace without changing environment validation. |
| apps/sim/lib/speech/config.ts | Condenses documentation without changing speech-provider detection. |
Reviews (1): Last reviewed commit: "refactor(chat): drop code the voice remo..." | Re-trigger Greptile
Summary
Follow-up to #6215. Full-file cleanup pass over the files voice mode was removed from — not just the diff.
/api/speech/token: with thechatIdbranch gone,billingAttributionis always resolved, so fourbillingAttribution ? … : …guards and thecheckActorUsageLimitsfallback were unreachable. Removed, with the now-unused imports and test mock.chat.tsx: theinputValuestate had one remaining writer ('') and no reader.ChatInputhas owned its own input value since it went uncontrolled, and removing the voice-transcript caller lefthandleSendMessagealways receiving an explicit message.use-chat-streaming:messageIdMapwas written in three frame handlers and never read;setIsStreamingResponsewas returned but never destructured by the only consumer.workspaceIddoc, which existed to contrast with the removedchatId.Deliberately not included
Three findings were real but are pre-existing and perf-shaped, so they want their own measured change rather than riding along here:
ChatMessageContainerismemo()-wrapped butchat.tsxpassesscrollToBottomas an inline arrow, defeating it on every render. Fixing it properly means either memoizing the props chain or dropping thememo()— worth measuring first.welcomeChatMessage'suseMemostabilizes nothing today, but that changes if the above is fixed.useCallbacks ininput.tsxare unobserved (emcn'sButtonisforwardRef, notmemo; the rest are native handlers).Also left alone: the input wrapper
<div>inchat.tsxis arguably vestigial sinceChatInputpositions itselffixed, but its padding may be doing real spacing work — that needs a visual check, not a grep.Type of Change
Testing
555 tests pass across chat, speech, settings, usage-logs and billing. Typecheck clean on
apps/sim; all lint tasks pass. No behavior change intended — every removal is a symbol with zero readers or an unreachable branch.Checklist