Skip to content

Optimize composer command key bindings#3570

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/component-performance-optimization-296f
Draft

Optimize composer command key bindings#3570
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/component-performance-optimization-296f

Conversation

@cursor

@cursor cursor Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

What Changed

Replaced the render-only ComposerCommandKeyPlugin component with a named useComposerCommandKeyBindings hook in ComposerPromptEditor.

Why

React Scan showed the command key plugin rerendering on every composer keystroke even though it only exists to register Lexical keyboard commands. The new hook registers those commands once against the Lexical editor and uses useEffectEvent to call the latest handler, removing that component from the typing render path while preserving Arrow/Enter/Tab behavior.

React Doctor was run for Performance/Maintainability. Its broad scan surfaced migration-scale existing findings; this PR addresses the manually confirmed composer hot spot and keeps scope focused.

UI Changes

No visual UI change.

React Scan before/after recordings captured with the render-count overlay enabled:

  • Before: react_scan_composer_before_effect_fix.mp4ComposerCommandKeyPlugin increments during typing.
  • After: react_scan_composer_after_command_hook.mp4ComposerCommandKeyPlugin count stays flat during typing.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Validation:

  • npx -y react-doctor@latest apps/web --diff main --category Performance --category Maintainability --no-telemetry --offline --verbose --blocking none
  • NODE_OPTIONS="--experimental-strip-types" corepack pnpm exec vp check
  • corepack pnpm exec vp run typecheck
Open in Web View Automation 

Note

Replace ComposerCommandKeyPlugin with useComposerCommandKeyBindings hook in composer editor

Migrates command key binding logic from the ComposerCommandKeyPlugin React component into a useComposerCommandKeyBindings hook in ComposerPromptEditor.tsx. The hook registers handlers for arrow, enter, and tab commands at COMMAND_PRIORITY_HIGH and cleans them up on unmount, replacing the equivalent useEffect logic in the removed plugin component.

Macroscope summarized 7154e7c.

Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant