Stabilize composer provider state while typing#3507
Merged
juliusmarminge merged 1 commit intoJun 22, 2026
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
juliusmarminge
marked this pull request as ready for review
June 22, 2026 19:38
Contributor
ApprovabilityVerdict: Approved This is a performance optimization that memoizes prompt injection state derivation, preventing unnecessary recomputation on every keystroke. The functional behavior remains identical—only the timing of when the state is computed changes. You can customize Macroscope's approvability policy. Learn more. |
juliusmarminge
deleted the
cursor/component-performance-optimization-7e06
branch
June 22, 2026 19:52
imabdulazeez
added a commit
to imabdulazeez/t3code
that referenced
this pull request
Jun 23, 2026
…top of upstream Incoming: pingdotgg#3480 (persistent word-wrap), pingdotgg#3507 (composer provider state), pingdotgg#3496 (mobile composer draft persistence). - Word-wrap feature converged with upstream's pingdotgg#3480: took upstream's wordWrap setting/wiring everywhere it overlapped (settings.ts, ChatMarkdown, FilePreviewPanel, DiffPanel, SettingsPanels, DesktopClientSettings.test). Removed the now-redundant word-wrap row from FORK-CHANGES.md. - Re-applied fork-only settings on top of upstream's settings.ts/test fixture (branch sort/sync, font pickers, VCS prompt instructions, auto-create-PR, changed-files-expanded, delete-remote-branch, buildTimestamp). - ChatComposer: upstream's pingdotgg#3507 provider-state refactor + fork's plan actions.
simonbetton
pushed a commit
to simonbetton/reviewer
that referenced
this pull request
Jun 29, 2026
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
none/ultrathink).Why
React Doctor and a manual hot-path pass pointed at the chat composer/model controls as a performance-sensitive typing path. Previously, every keystroke invalidated
getComposerProviderState, rebuilt provider option dispatch state, and changedselectedModelSelectionidentity even when the prompt did not cross the ultrathink boundary. The new dependency is stable for ordinary typing and only changes when prompt-injected effort state actually changes.React Doctor scan after the fix still reports the broader existing repo baseline (166 performance issues; top unrelated items include
HostedBrowserWebview,BranchToolbarBranchSelector, andChatView), so this PR intentionally fixes one focused hotspot.UI Changes
No intentional UI change. React Scan before/after recordings captured the real composer route with React Scan enabled:
react_scan_before_provider_state_count.mp4: before state, repeated[react-scan] getComposerProviderStatecount logs during typing.react_scan_after_provider_state_count.mp4: after state, React Scan remains active while ordinary typing no longer triggers those provider-state count logs.Checklist
Validation:
corepack pnpm --filter @t3tools/web test -- src/components/chat/composerProviderState.test.tsx(web unit suite passed)corepack pnpm exec vp checkcorepack pnpm exec vp run typecheckcorepack pnpm dlx react-doctor@latest --category performance --no-telemetry(completed; exits non-zero due existing baseline issues)Note
Stabilize composer provider state by separating prompt injection state from raw prompt string
ComposerPromptInjectionState(a'none' | 'ultrathink'union) andgetComposerPromptInjectionStatein composerProviderState.tsx to map a prompt string to a discrete state value.getComposerProviderStateto acceptpromptInjectionStateinstead ofprompt, defaulting to'none', so the provider state no longer recomputes on every keystroke.composerPromptInjectionStatein ChatComposer.tsx and passes it togetComposerProviderState, decoupling provider state changes from raw prompt edits.promptargument fromgetComposerProviderStatecall sites in modelSelection.ts, where no injection state is needed.Macroscope summarized 2655576.
Note
Low Risk
Focused memoization/API tweak on the composer typing path with unit tests; ultrathink styling logic is unchanged aside from when recomputation runs.
Overview
Reduces chat composer work on every keystroke by deriving provider/model dispatch state from a coarse prompt injection state (
none|ultrathink) instead of the full prompt string.getComposerPromptInjectionStatemaps the prompt viaisClaudeUltrathinkPrompt;getComposerProviderStatenow takespromptInjectionState(defaultnone) so ultrathink frame/chroma styling still toggles at the same boundary, but ordinary typing no longer invalidatesmodelOptionsForDispatchorselectedModelSelectionon each character.ChatComposermemoizes injection state separately and passes it into provider state;modelSelectioncall sites drop the unused emptypromptargument. Tests cover the new helper and updated ultrathink cases.Reviewed by Cursor Bugbot for commit 2655576. Bugbot is set up for automated code reviews on this repo. Configure here.