Optimize composer command key bindings#3570
Draft
cursor[bot] wants to merge 1 commit into
Draft
Conversation
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
Replaced the render-only
ComposerCommandKeyPlugincomponent with a nameduseComposerCommandKeyBindingshook inComposerPromptEditor.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
useEffectEventto 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:
react_scan_composer_before_effect_fix.mp4—ComposerCommandKeyPluginincrements during typing.react_scan_composer_after_command_hook.mp4—ComposerCommandKeyPlugincount stays flat during typing.Checklist
Validation:
npx -y react-doctor@latest apps/web --diff main --category Performance --category Maintainability --no-telemetry --offline --verbose --blocking noneNODE_OPTIONS="--experimental-strip-types" corepack pnpm exec vp checkcorepack pnpm exec vp run typecheckNote
Replace
ComposerCommandKeyPluginwithuseComposerCommandKeyBindingshook in composer editorMigrates command key binding logic from the
ComposerCommandKeyPluginReact component into auseComposerCommandKeyBindingshook in ComposerPromptEditor.tsx. The hook registers handlers for arrow, enter, and tab commands atCOMMAND_PRIORITY_HIGHand cleans them up on unmount, replacing the equivalentuseEffectlogic in the removed plugin component.Macroscope summarized 7154e7c.