refactor(web): multiple-model sends live in their own hook#23094
Third layer of splitting useComposerSend.
The multiple-model start and its recovery move into useMultipleModelSend. Recovery means keeping failed models selected and restoring the prompt, either into this composer or through the "Restore prompt" toast. The hook owns its start command, navigate, and the fan-out selection atom, so ChatView no longer passes setMultipleModelSelections. Building a turn's attachments (upload records, or inlined data URLs) is now the plain prepareTurnAttachments in chatViewSend.ts. Both the single-thread and multiple-model paths use it.
| before | after | |
|---|---|---|
useComposerSend.ts lines | 1,553 | 1,377 |
useComposerSend input fields | 77 | 76 |
Render boundaries are unchanged.
Tested in this worktree's dev server (isolated .t3, throwaway git repo as the project) with the whole stack applied: plain send from a draft (new thread), send with an image, queued follow-up and Ctrl+Enter steer during a running turn, resume of a stopped run, plan refinement and "Implement in a new thread" (legacy plan mode on), and a two-model start (two threads, two worktrees). All replies arrived and nothing errored. Also ran apps/web typecheck, lint on changed files (only the pre-existing prefer-set-has warning in useComposerSend.ts remains) and the React Compiler coverage test for changed files (0 bailouts).
🤖 Generated with Claude Code
Checks
- SuccessfulCodeRabbitGitHub
Review completed
- Successful
Skipped - Not affected
- Skipped
- Skipped
- Skipped
- SuccessfulRemove preview downloadGitHub
- SuccessfulLabel PR 23094GitHub
- Successful
- Skipped
- SuccessfulLabel PR sizeGitHub
- Successful
- Successful
- SuccessfulPrepare PR size configGitHub
- SuccessfulCollect PR targetsGitHub
- Successful
- SuccessfulNative fingerprint diffGitHub
- SuccessfulCheckGitHub
- Skipped
- SuccessfulLabel PR sizeGitHub
- SkippedRelease SmokeGitHub
- Skipped
- SkippedRustGitHub
- SuccessfulBuild and TypecheckGitHub
- SuccessfulTestGitHub
- SuccessfulTest WebGitHub
- SuccessfulLabel PR 23094GitHub
- SkippedEAS PreviewGitHub
- SuccessfulNative fingerprint diffGitHub
- SuccessfulTest Server 8GitHub
- SuccessfulTest Server 7GitHub
- SuccessfulTest Server 6GitHub
- SuccessfulTest Server 2GitHub
- SuccessfulTest Server 5GitHub
- SuccessfulTest Server 1GitHub
- SuccessfulTest Server 4GitHub
- SuccessfulChangesGitHub
- SuccessfulTest Server 3GitHub
- SuccessfulLintGitHub
- SuccessfulPrepare PR size configGitHub
- SuccessfulCollect PR targetsGitHub
Added 1 commit
- refactor(web): multiple-model sends live in their own hook70d001c
Approvability
Verdict: Approved at 70d001c
Macroscope's review found this PR approvable — This PR extracts the existing multiple-model send flow and attachment preparation into focused hooks/helpers without changing the normal send path or introducing a new capability. The runtime side effects and recovery behavior remain equivalent to the prior implementation.
You can add or adjust custom eligibility rules. Learn more.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Team
- Run ID:
84c74401-b44d-493c-b5e4-d6af4c43cad1
📥 Commits
Reviewing files that changed from the base of the PR and between 9927f9e40537f202f9d8ca68f1f415a5b123bc86 and 70d001c0c38d5e2eaf823da1e55d66b35777684b.
📒 Files selected for processing: 4
apps/web/src/components/ChatView.tsxapps/web/src/components/chat/chatViewSend.tsapps/web/src/components/chat/useComposerSend.tsapps/web/src/components/chat/useMultipleModelSend.ts
💤 Files with no reviewable changes: 1
- apps/web/src/components/ChatView.tsx
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
📝 Walkthrough
The composer now delegates multi-model sends to a dedicated hook. Attachment preparation is handled by a helper. The hook starts selected-model threads and manages send results, failed selections, and draft recovery.
Changes: Multi-model send flow
Layer / File(s) Summary Attachment preparation and composer wiring
apps/web/src/components/chat/chatViewSend.ts,apps/web/src/components/chat/useComposerSend.ts,apps/web/src/components/ChatView.tsxprepareTurnAttachmentsresolves uploaded attachments or converts supported images to data URLs.useComposerSendwires the helper and extracted sender; it no longer receives the multiple-model selection setter.Multi-model send setup and validation
apps/web/src/components/chat/useMultipleModelSend.ts,apps/web/src/components/chat/useComposerSend.tsThe new hook receives send dependencies, validates attachments and files, builds outgoing context, and clears the composer before starting sends. useComposerSenddelegates the multi-model send operation to the hook.Thread startup and recovery
apps/web/src/components/chat/useMultipleModelSend.tsThe hook starts threads for selected models, navigates to successful threads, tracks failures, restores eligible selections and drafts, and cleans up send state. Priority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Refactor
Merge Risk: ⚪ Minimal · up to 70d00
This refactor moves multiple-model sending into its own hook without a visible change in behavior. No concrete merge-blocking issue was found.
Pre-merge checks: Passed 3 · Failed 1
Failed Failed checks: 1 warning
Check name Status Explanation Resolution Description check Warning The description clearly explains the code changes and includes detailed verification results. It does not provide the required Problem section or Scope and approval information, including issue or mai… Add a Problem section with the user or developer problem and expected behavior. Add a Scope and approval section with the linked issue or explicit maintainer approval, or explain why an approval exemption applies. Keep the existing Change a… Passed Passed checks: 3 passed
Check name Status Explanation Title check Passed The title clearly and concisely describes the primary change: moving multiple-model sends into a separate hook. Linked Issues check Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description clearly explains the code changes and includes detailed verification results. It does not provide the required Problem section or Scope and approval information, including issue or maintainer approval context.
Resolution
Add a Problem section with the user or developer problem and expected behavior. Add a Scope and approval section with the linked issue or explicit maintainer approval, or explain why an approval exemption applies. Keep the existing Change and Verification details.
✨ Finishing Touches
📝 Generate docstrings
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
- Commit to this branch
- Create a new PR
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.