refactor(web): split two self-contained phases out of onSend #20321
chatview-split/worktree-setup fromrefs/pull/20321/head·merged by juliusmarminge View on GitHubPart of the ChatView split so the React Compiler can compile it. onSend is the largest statement in ChatView (about 1,270 lines and 106 closure inputs). This layer moves out two phases that don't depend on the rest of it:
mergeDirectPreviewAnnotation(inChatView.logic): adds a directly sent preview annotation to the composer's images and annotations, and only claims the screenshot crop when it actually fits under the attachment cap. Now pure, with tests for room, a full cap, and an annotation that's already in the draft.startFanoutThread(module function): starts one thread of a multiple-model send. It includes the guard that stops a request which may already have reached the server from being re-sent as a duplicate, plus the failure toast with its "Open thread" and "Allow retry" actions. ChatView passes instartandopenThread.
Behavior is unchanged. ChatView.logic tests pass (131).
Stack progress#
| Layer | ChatView lines | ChatView component body | Compiler on ChatView | Files held to strict compiler lint |
|---|---|---|---|---|
| main | 11,660 | 10,007 | crashes (internal error) | 0 |
| #20161 pending approvals and questions hook | 11,222 | 9,624 | crashes (internal error) | 0 |
| #20164 terminal drawer and panel file | 10,614 | 9,624 | crashes (internal error) | 0 |
| #20289 one terminal open/close hook | 10,466 | 9,481 | crashes (internal error) | 0 |
| #20292 compile-required lint list | 10,466 | 9,481 | crashes (internal error) | 2 |
| #20294 pending hook compiles | 10,466 | 9,481 | crashes (internal error) | 3 |
| #20296 /usage-limits panel hook | 10,397 | 9,416 | crashes (internal error) | 4 |
| #20304 queued-message editing hook | 10,172 | 9,200 | crashes (internal error) | 5 |
| #20308 linked pull request hook | 10,078 | 9,106 | crashes (internal error) | 6 |
| #20309 proactive panel hook | 9,950 | 8,984 | crashes (internal error) | 7 |
| #20312 agent-opened previews hook | 9,855 | 8,890 | crashes (internal error) | 8 |
| #20315 right panel close hook | 9,743 | 8,779 | crashes (internal error) | 9 |
| #20316 worktree setup hook | 9,660 | 8,695 | crashes (internal error) | 10 |
| → #20321 two onSend phases split out | 9,660 | 8,613 | crashes (internal error) | 10 |
| #20340 compiler no longer crashes on ChatView | 9,647 | 8,599 | skips (32 reasons) | 10 |
| #20379 ChatView compiles | 9,616 | 8,469 | compiles | 11 |
| #20380 re-render fixes from profiling | 9,661 | 8,514 | compiles | 11 |
| #20392 provider pushes keep identity | 9,628 | 8,481 | compiles | 11 |
| #20393 keyboard shortcuts command map | 9,340 | 8,265 | compiles | 13 |
| #20396 Sidebar compiles, no manual memos | 9,340 | 8,265 | compiles | 14 |
| #20397 ChatComposer compiles | 9,340 | 8,265 | compiles | 14 |
| #20401 project script editing hook | 9,110 | 8,049 | compiles | 15 |
| #20402 MessagesTimeline compiles | 9,110 | 8,049 | compiles | 16 |
| #20418 ChatView strict: no memos, no sync effects | 8,901 | 7,855 | compiles | 17 |
Measured with the native React Compiler (oxc-transform-react) on each layer's ChatView.tsx. "Crashes" means it hit an internal codegen error and left ChatView uncompiled; "skips" means it reported reasons it could not compile it. Strict files must compile with no bailouts, no manual memoization and no effect-rule violations; lint and reactCompiledFiles.test.ts enforce it.
🤖 Generated with Claude Code (Claude Opus 5.5)
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
juliusmarminge added labelsmacroscope-review
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
Approvability#
Verdict: Approved at
bd54ae3Macroscope's review found this PR approvable — This PR isolates existing preview-annotation and multi-model fanout logic without introducing new product behavior, schemas, defaults, or infrastructure changes. The production flow remains functionally equivalent, and focused tests cover the extracted annotation logic.
No code changes detected at
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).d4e5a4b. Prior analysis still applies.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:
2afb8080-4361-4c48-aaa6-d9a14c415670
📥 Commits
-
Reviewing files that changed from the base of the PR and between fb7fbe2d7002823d50d31f0d6e88fdf7892981ca and bd54ae3a5ca3b9483426df32c5ca4c079a54d1ac.
📒 Files selected for processing: 3
-
apps/web/src/components/ChatView.logic.test.tsapps/web/src/components/ChatView.logic.tsapps/web/src/components/ChatView.tsx
Limit details: You’ve used all 10 included reviews currently available.
-
📝 Walkthrough
-
ChatView now merges direct preview annotations with composer attachments and handles uncertain outcomes when starting model-specific fanout threads.
Changes: Chat send handling
Layer / File(s) Summary Direct preview annotation merging
apps/web/src/components/ChatView.logic.ts,apps/web/src/components/ChatView.tsx,apps/web/src/components/ChatView.logic.test.tsmergeDirectPreviewAnnotationavoids duplicate images and annotations, respects the attachment limit, and supplies outgoing images and annotations. Tests cover available capacity, a full attachment limit, and an existing annotation.Fanout thread retry handling
apps/web/src/components/ChatView.tsxstartFanoutThreadretains a stable target ID when a request may have reached the server. The failure actions can open the retained thread or allow a potentially duplicating retry. Bootstrap failures that indicate deletion or non-creation are treated as not having started.Priority: ⬇️ Low
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Refactor
Sequence Diagram(s)#
sequenceDiagram participant ChatView participant startFanoutThread participant ThreadBootstrap participant FailureToast ChatView->>startFanoutThread: Start a model-specific thread startFanoutThread->>ThreadBootstrap: Submit start-turn request with stable target ID ThreadBootstrap-->>startFanoutThread: Return bootstrap result startFanoutThread-->>ChatView: Return success or retained-thread failure ChatView->>FailureToast: Offer thread navigation or confirmed retrySuggested reviewers:
t3dotgg
Merge Risk: ⚪ Minimal · up to
bd54a-
This refactor moves direct preview annotation merging and fanout thread startup out of onSend. No actionable merge-blocking risk was identified in the supplied context.
Pre-merge checks:
3 · 1-
Failed checks: 1 warningCheck name Status Explanation Resolution Description check The description explains the change and identifies focused tests, but it does not use the required Problem, Change, Scope and approval, and Verification sections. It also omits the required issue or m… Rewrite the description using the required template headings. Add the problem and expected behavior, explain the change, provide the triaged issue or explicit maintainer approval with context, and list the focused test commands and observed… Passed checks: 3 passed-
Check name Status Explanation Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Title check The title clearly and concisely describes the main change: splitting two self-contained phases out of ChatView's onSend function.
Full details: Description check
-
Explanation
The description explains the change and identifies focused tests, but it does not use the required Problem, Change, Scope and approval, and Verification sections. It also omits the required issue or maintainer approval reference and gives insufficient verification detail beyond stating that 131 tests pass.
Resolution
Rewrite the description using the required template headings. Add the problem and expected behavior, explain the change, provide the triaged issue or explicit maintainer approval with context, and list the focused test commands and observed results. State any checks that were not run.
-
- Fix all pre-merge checks with AI
✨ 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
-
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge merged thiscbee9c9
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed