refactor(web): move pending approvals and questions out of ChatView #20161
main fromrefs/pull/20161/head·merged by juliusmarminge View on GitHubChatView is one ~10,300-line function. The native React Compiler spends about 20s on it in every web build and then bails out with an internal error, so ChatView was never memoized. Splitting it up makes it something the compiler can handle; #20340 and #20379 at the top of this stack get it compiling. This is the first layer.
Change#
Pending approvals and user-input questions move out of ChatView into usePendingThreadRequests. That covers the derived requests, the in-progress answers and question index, the in-flight tracking, the respond, dismiss and navigate handlers, and the custom-answer setter factory.
- The code moves unchanged. The only edits are the hook's inputs and outputs, and
setThreadErroris now defined before the hook call. promptRefis added to oneuseMemodependency list, which lint asked for after the move. The ref object is stable, so this changes nothing at runtime.
Results#
The ChatView function body drops from ~10,000 to ~9,600 lines. Compile time doesn't measurably change at this layer: the native compiler crashed on ChatView before and after (see Stack progress), and its run-to-run spread (about ±2s) is larger than this layer's effect.
Verification#
- Typecheck passes. Lint warning counts for
ChatView.tsxmatchmain. - The ChatView logic tests and the pending approval and user-input panel tests pass (163 tests).
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
- 1
juliusmarminge changed the title
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
juliusmarminge added labelsmacroscope-review
Approvability#
Verdict: Approved at
ab7128cMacroscope's review found this PR approvable — This PR moves existing pending-approval and user-input behavior into a dedicated hook while preserving the same production wiring, commands, attachment handling, and rendered outputs. It introduces no new capability, schema, product default, deployment change, or static-analysis override.
No code changes detected at
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).ca4de9e. Prior analysis still applies.Important
Review skipped#
Review was skipped as selected files did not have any reviewable changes.
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Team
- Run ID:
f2bfb275-6443-473a-9914-d0d013841e8c
📥 Commits
-
Reviewing files that changed from the base of the PR and between ab7128ce59d460d2b77a486fc6638136709e1b92 and ca4de9e2ae7f399d33980d873feeba18b2ab4311.
You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
- 🔍 Trigger review
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:
8f31b2c6-d278-480c-ba49-93275af9a72b
📥 Commits
-
Reviewing files that changed from the base of the PR and between 9235a7bf0381aafa8cc97d8e38c3c7428c09c3df and ab7128ce59d460d2b77a486fc6638136709e1b92.
📒 Files selected for processing: 1
-
apps/web/src/components/ChatView.tsx
Limit details: You’ve used all 10 included reviews currently available.
-
📝 Walkthrough
-
ChatView delegates pending approval and user-input request handling to
usePendingThreadRequests. The hook derives pending requests, manages answer drafts and question navigation, and handles responses and dismissals.Changes: Pending thread requests
Layer / File(s) Summary Derive pending request state
apps/web/src/components/chat/usePendingThreadRequests.tsThe hook derives pending requests and answer state from the thread projection. It tracks question attachment drafts and attachment readiness. Manage answers and question navigation
apps/web/src/components/chat/usePendingThreadRequests.tsThe hook manages custom answers, option selection, and question navigation. Submit requests and connect ChatView
apps/web/src/components/chat/usePendingThreadRequests.ts,apps/web/src/components/ChatView.tsxThe hook handles approval responses, user-input submissions, and dismissal. ChatView passes the hook its thread, composer, and error inputs, then uses the returned state and callbacks. Priority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Refactor
Suggested reviewers:
t3dotgg,maria-rcks
Merge Risk: ⚪ Minimal · up to
ab712-
The pending-request extraction has no identified behavior regression and is ready to merge after normal checks.
Pre-merge checks:
3 · 1-
Failed checks: 1 warningCheck name Status Explanation Resolution Description check The description explains the change and includes specific verification results, but it omits the required Problem heading and the required Scope and approval section with an issue, discussion, or main… Add a Problem section with the expected behavior and relevant context. Add a Scope and approval section that links the triaged issue or maintainer approval, including the approval comment, or explain why this focused refactor qualifies for … 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 primary change: moving pending approvals and questions out of ChatView.
Full details: Description check
-
Explanation
The description explains the change and includes specific verification results, but it omits the required Problem heading and the required Scope and approval section with an issue, discussion, or maintainer approval reference.
Resolution
Add a Problem section with the expected behavior and relevant context. Add a Scope and approval section that links the triaged issue or maintainer approval, including the approval comment, or explain why this focused refactor qualifies for an exemption.
-
✨ 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 this043bc03
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed