Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(web): ChatComposer compiles with no manual memoization #20397

Mergedjuliusmarmingemerged 3 commits intochatview-split/sidebar-compiles fromrefs/pull/20397/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

The native React Compiler skipped ChatComposer.tsx with 17 bailouts. It now compiles and joins the strict REACT_COMPILED_FILES list: no manual memoization (29 useMemo/useCallback removed), no effects that copy values into state, and no disable comments. REACT_COMPILED_FILES_PENDING_LINT is now empty and has been deleted.

Compile fixes:

  • Refs read in render: nine latest-value refs are written in useLayoutEffect. useRestingComposerControlsLayout reads host directly.
  • try/finally:
    • The attachment download moved to downloadAttachmentBlob.
    • Attachment import, stash, and add use .finally().
    • The dropped-thread import uses settlePromise.

Effects became render-time logic:

  • The cursor clamp, length error, and provider-input error follow their inputs.
  • Menu highlight is stored already resolved.
  • The draft/thread switch reset reads from props instead of promptRef.
  • The tasks drawer and stash menu close during render.
  • Recalled prompt history carries the draft key it was recalled in.
  • The resting-controls measurement is one layout effect that sets state from its resize observer.
  • The workspace snapshot refresh lives in useProviderWorkspaceSnapshotRefresh. It re-checks the TTL when the user types instead of depending on prompt.

Keeping the model picker memoized. Removing the memos alone left 32 values uncached, including every prop of the model picker, so it re-rendered on each keystroke. The compiler can't cache values passed to plain functions across later hook calls. The provider selection, model options, provider state and image groups now come from small hooks marked "use memo", since they call no hooks themselves. Skills and slash commands fall back to stable empty lists.

Measured in the dev app, typing 19 characters:

ComponentRenders
ProviderModelPicker0
ComposerPromptEditor wrapper0
ChatComposer19
Sidebar draft preview20

Totals: 747 renders across 21 commits.

Tests: the composer helper tests, ChatView.logic and reactCompiledFiles pass. Typecheck and lint are clean.

🤖 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. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

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

      This comment will update automatically after the next completed run.

    4. juliusmarminge changed the title

    5. Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — This PR makes a broad React Compiler migration in the production ChatComposer, replacing manual memoization and effect-driven synchronization across rendering, refresh, menu, draft, attachment, and animation behavior. The resulting runtime and interaction surface is substantial enough to require human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    6. juliusmarminge merged thise925fe7

    7. juliusmarminge closed this

Sign in to join this conversation.