Skip to content

refactor(chat): drop code the voice removal left unreachable - #6218

Merged
waleedlatif1 merged 1 commit into
stagingfrom
chore/chat-cleanup-after-voice-removal
Aug 3, 2026
Merged

refactor(chat): drop code the voice removal left unreachable#6218
waleedlatif1 merged 1 commit into
stagingfrom
chore/chat-cleanup-after-voice-removal

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

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 the chatId branch gone, billingAttribution is always resolved, so four billingAttribution ? … : … guards and the checkActorUsageLimits fallback were unreachable. Removed, 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; 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.

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:

  • ChatMessageContainer is memo()-wrapped but chat.tsx passes scrollToBottom as an inline arrow, defeating it on every render. Fixing it properly means either memoizing the props chain or dropping the memo() — worth measuring first.
  • welcomeChatMessage's useMemo stabilizes nothing today, but that changes if the above is fixed.
  • Five useCallbacks in input.tsx are unobserved (emcn's Button is forwardRef, not memo; the rest are native handlers).

Also left alone: the input wrapper <div> in chat.tsx is arguably vestigial since ChatInput positions itself fixed, but its padding may be doing real spacing work — that needs a visual check, not a grep.

Type of Change

  • Refactor / dead code removal

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

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

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.
@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 3, 2026 7:08pm

Request Review

@cursor

cursor Bot commented Aug 3, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Dead-code and comment-only cleanup with tests passing; speech billing path is simplified but still workspace-scoped with the same attribution checks.

Overview
Follow-up cleanup after voice mode was removed: strips unreachable branches and unused symbols across chat UI, streaming, and the speech token API—no intended behavior change.

Deployed chat (chat.tsx) drops parent inputValue state and optional handleSendMessage args; sends always come from ChatInput with an explicit message string.

use-chat-streaming removes the unused messageIdMap bookkeeping and stops exporting setIsStreamingResponse (only used inside the hook).

/api/speech/token always resolves workspace billing attribution (workspace is mandatory), so conditional billingAttribution guards and the checkActorUsageLimits fallback are removed along with related test mocks.

Minor comment/doc trims in chat input JSX, the speech contract, and lib/speech/config.

Reviewed by Cursor Bugbot for commit ad3a5f3. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes state, mappings, return properties, conditional billing fallbacks, imports, mocks, and comments left unreachable after voice mode was removed.

  • Makes the deployed-chat send handler require the explicit value already supplied by ChatInput.
  • Removes write-only streaming message-ID bookkeeping and an unused returned state setter.
  • Simplifies speech-token usage enforcement and recording around the billing attribution already resolved for every successful request.
  • Cleans up redundant comments and trailing whitespace.

Confidence Score: 5/5

The 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.

Important Files Changed

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

@waleedlatif1
waleedlatif1 merged commit 83988c1 into staging Aug 3, 2026
21 checks passed
@waleedlatif1
waleedlatif1 deleted the chore/chat-cleanup-after-voice-removal branch August 3, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant