fix(web): the branch toolbar and thread details panel stay cached while a reply streams#23103
While a reply streams, BranchToolbar and the thread details panel re-rendered on every update. useComposerSelection's onStartFromOriginChange closed over the whole activeThread shell, which changes with each streamed event, so both components got a new handler each time.
The handler now reads only the thread id, which the compiler can cache on.
Streaming a 12-line reply (median of 3, about 110 commits):
| Component | before | after |
|---|---|---|
| BranchToolbar | 10 | 0 |
| ThreadDetailsSection | 10 | 0 |
Total renders are noise-bound for streaming (2,866 before, 2,891 after; the runs swing by ±20% with response length).
Tested:
- apps/web typecheck and lint on the touched file.
- React Compiler: 0 bailouts on
useComposerSelection.ts. - Hands-on in a dev build, draft thread: switch the workspace to New worktree, open the base branch picker, and flip "Start from remote" off and back on.
🤖 Generated with Claude Code
Checks
- SuccessfulCodeRabbitGitHub
Review completed
- Successful
Skipped - Not affected
- Skipped
- Skipped
- Skipped
- SuccessfulRemove preview downloadGitHub
- Successful
- Successful
- Successful
- SuccessfulLabel PR 23103GitHub
- Skipped
- SuccessfulLabel PR sizeGitHub
- SuccessfulPrepare PR size configGitHub
- SuccessfulCollect PR targetsGitHub
- SuccessfulCheckGitHub
- Skipped
- SkippedRelease SmokeGitHub
- SkippedRustGitHub
- SuccessfulTest WebGitHub
- SuccessfulTestGitHub
- SuccessfulBuild and TypecheckGitHub
- Skipped
- SuccessfulLabel PR sizeGitHub
- SuccessfulLabel PR 23103GitHub
- SkippedEAS PreviewGitHub
- SuccessfulTest Server 2GitHub
- SuccessfulTest Server 8GitHub
- SuccessfulNative fingerprint diffGitHub
- SuccessfulTest Server 6GitHub
- SuccessfulTest Server 3GitHub
- SuccessfulTest Server 1GitHub
- SuccessfulTest Server 7GitHub
- SuccessfulChangesGitHub
- SuccessfulTest Server 4GitHub
- SuccessfulTest Server 5GitHub
- SuccessfulLintGitHub
- SuccessfulPrepare PR size configGitHub
- SuccessfulCollect PR targetsGitHub
Added 1 commit
- fix(web): the branch toolbar and thread details panel stay cached while a reply streams937507c
Approvability
Verdict: Approved at 937507c
Macroscope's review found this PR approvable — This is a focused one-file rendering-performance fix that preserves the handler’s behavior while avoiding unnecessary BranchToolbar and thread-details rerenders during streamed replies. It introduces no new capability, product-default change, or static-analysis suppression.
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:
bcaebd2e-d2d2-4edb-b0bc-3c4fe8827167
📥 Commits
Reviewing files that changed from the base of the PR and between 54349ea3e2f4799c90fdb701bfe12e55526bd618 and 937507c6a4cca85c0d72133ac4ddf7ff643172f5.
📒 Files selected for processing: 1
apps/web/src/components/chat/useComposerSelection.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
📝 Walkthrough
The start-from-origin callback now uses the active thread ID to update pending server-thread state. Local draft threads continue to update draft context.
Changes: Composer selection
Layer / File(s) Summary Start-from-origin update
apps/web/src/components/chat/useComposerSelection.tsThe callback uses the active thread ID for the server override check and pending-state update. Equality-based no-op updates and the local-draft fallback remain. Priority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Bug fix
Merge Risk: ⚪ Minimal · up to 93750
The change is mergeable; the callback optimization preserves existing behavior without an actionable correctness or runtime risk.
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 problem, change, measurements, verification, and agent usage. It does not include the required Scope and approval section or UI before/after screenshots, and it do… Add a Scope and approval section with the triaged issue or maintainer approval, or explain why this focused obvious bug qualifies for the exemption. Add clear before/after UI screenshots and a short recording if needed to demonstrate the st… Passed Passed checks: 3 passed
Check name Status Explanation Title check Passed The title clearly identifies the web performance fix: keeping the branch toolbar and thread details panel cached during streaming. 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 problem, change, measurements, verification, and agent usage. It does not include the required Scope and approval section or UI before/after screenshots, and it does not provide a recording for the streaming interaction.
Resolution
Add a Scope and approval section with the triaged issue or maintainer approval, or explain why this focused obvious bug qualifies for the exemption. Add clear before/after UI screenshots and a short recording if needed to demonstrate the streaming behavior.
✨ 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.