Skip to content
Source
Sign inSign up
pingdotgg/t3code

refactor(web): split two self-contained phases out of onSend #20321

Mergedjuliusmarmingemerged 1 commit intochatview-split/worktree-setup fromrefs/pull/20321/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Part 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 (in ChatView.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 in start and openThread.

Behavior is unchanged. ChatView.logic tests pass (131).

Stack progress

LayerChatView linesChatView component bodyCompiler on ChatViewFiles held to strict compiler lint
main11,66010,007crashes (internal error)0
#20161 pending approvals and questions hook11,2229,624crashes (internal error)0
#20164 terminal drawer and panel file10,6149,624crashes (internal error)0
#20289 one terminal open/close hook10,4669,481crashes (internal error)0
#20292 compile-required lint list10,4669,481crashes (internal error)2
#20294 pending hook compiles10,4669,481crashes (internal error)3
#20296 /usage-limits panel hook10,3979,416crashes (internal error)4
#20304 queued-message editing hook10,1729,200crashes (internal error)5
#20308 linked pull request hook10,0789,106crashes (internal error)6
#20309 proactive panel hook9,9508,984crashes (internal error)7
#20312 agent-opened previews hook9,8558,890crashes (internal error)8
#20315 right panel close hook9,7438,779crashes (internal error)9
#20316 worktree setup hook9,6608,695crashes (internal error)10
→ #20321 two onSend phases split out9,6608,613crashes (internal error)10
#20340 compiler no longer crashes on ChatView9,6478,599skips (32 reasons)10
#20379 ChatView compiles9,6168,469compiles11
#20380 re-render fixes from profiling9,6618,514compiles11
#20392 provider pushes keep identity9,6288,481compiles11
#20393 keyboard shortcuts command map9,3408,265compiles13
#20396 Sidebar compiles, no manual memos9,3408,265compiles14
#20397 ChatComposer compiles9,3408,265compiles14
#20401 project script editing hook9,1108,049compiles15
#20402 MessagesTimeline compiles9,1108,049compiles16
#20418 ChatView strict: no memos, no sync effects8,9017,855compiles17

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)


Devin Review
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge added labelsmacroscope-review

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at bd54ae3

      Macroscope'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 d4e5a4b. Prior analysis still applies.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      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.ts
      • apps/web/src/components/ChatView.logic.ts
      • apps/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.ts
      mergeDirectPreviewAnnotation avoids 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.tsx
      startFanoutThread retains 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 retry

      Suggested 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: Passed 3 · Failed 1
      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Description checkWarningThe 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 Passed checks: 3 passed
      Check nameStatusExplanation
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Title checkPassedThe 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
      Comment `@coderabbitai help` to get the list of available commands.
    5. Thread transfer impact

      ⚠️ The latest CI run did not produce a thread transfer result for d4e5a4b.

      This comment will update automatically after the next completed run.

    6. juliusmarminge merged thiscbee9c9

    7. juliusmarminge closed this

Sign in to join this conversation.