refactor(web): let the React Compiler compile usePendingThreadRequests #20294
chatview-split/compiler-ratchet fromrefs/pull/20294/head·merged by juliusmarminge View on GitHubProblem. usePendingThreadRequests, extracted from ChatView in #20161, passed promptRef into a factory during render. The compiler can't verify that ref read, so it skipped the whole hook, and its 9 useMemos were still needed.
Fix.
- The custom-answer setter now gets a stable
writePromptfunction instead of the ref. - The manual
useMemocalls are gone. - The hook is added to the compile-required lint list from #20292.
I checked the compiler output: the hook used to have no memo cache and now has one. Pending-input tests pass (38).
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
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Approved at
217e492Macroscope's review found this PR approvable — This is a focused compiler-enablement refactor that preserves the hook’s existing behavior while replacing manual memoization with compiler-generated memoization. The accompanying configuration change only makes compiler compatibility errors enforceable for this file.
No code changes detected at
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).62ee42d. Prior analysis still applies.Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
ℹ️ No successful
mainbaseline artifact is available yet. This run establishes the initial measurement.Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire — 5.0 KiB — 6.8 KiB ✅ Codex Thread snapshot wire — 3.8 KiB — 4.9 KiB ✅ Codex Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅ Codex Live turn WebSocket decoded — 20.9 KiB — 29.3 KiB ✅ Codex Live turn messages — 2 — 8 ✅ Claude Total thread wire — 5.0 KiB — 6.8 KiB ✅ Claude Thread snapshot wire — 3.8 KiB — 4.9 KiB ✅ Claude Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅ Claude Live turn WebSocket decoded — 21.2 KiB — 29.3 KiB ✅ Claude Live turn messages — 2 — 8 ✅ Baseline: unavailable · PR result:
62ee42d· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
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:
eaeb657f-1337-46ee-9d16-ea42095ca0c4
📥 Commits
-
Reviewing files that changed from the base of the PR and between a7807fd649ce900a2326bea73794d513fd1aaa27 and 62ee42d28e9767301bf888a0afdc966320ea0629.
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:
7d92e45a-5538-481a-ab59-1998097bcdd6
📥 Commits
-
Reviewing files that changed from the base of the PR and between 3be52df2b0457a7696a4efe69c277315cf36bb3b and a7807fd649ce900a2326bea73794d513fd1aaa27.
📒 Files selected for processing: 2
-
apps/web/src/components/chat/usePendingThreadRequests.tsvite.config.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
-
📝 Walkthrough
-
The hook now recalculates pending request data during render instead of memoizing it. Its custom-answer setter writes prompt changes through a stable callback. The Vite configuration adds the hook to the React Compiler lint override.
Changes: Pending thread request hook
Layer / File(s) Summary Render-time request derivations
apps/web/src/components/chat/usePendingThreadRequests.tsPending requests, attachment draft keys, active answers, progress, and resolved answers are calculated during render without useMemo.Custom-answer prompt writer
apps/web/src/components/chat/usePendingThreadRequests.ts,vite.config.tsThe custom-answer setter writes through a callback that updates promptRef.current. The Vite override adds the hook to the React Compiler lint set.Priority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Refactor
Suggested reviewers:
maria-rcks
Merge Risk: ⚪ Minimal · up to
a7807-
The hook recalculates pending-request data and routes custom-answer prompt writes through a stable callback. The inspected cleanup behavior reveals no material regression, so no actionable merge-blocking risk is established.
Pre-merge checks:
4-
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: enabling React Compiler compilation for usePendingThreadRequests. Description check The description clearly explains the problem, implementation, compiler impact, and test result. It does not include a dedicated Scope and approval section or explicit approval/link evidence, but it is… Full details: Description check
-
Explanation
The description clearly explains the problem, implementation, compiler impact, and test result. It does not include a dedicated Scope and approval section or explicit approval/link evidence, but it is otherwise sufficiently complete and focused.
-
✨ 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
-
juliusmarminge merged thisf7916ad
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes