fix(web): handle macOS Home and End in composer#2508
fix(web): handle macOS Home and End in composer#2508GuilhermeVieiraDev wants to merge 3 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved Self-contained macOS keyboard handling fix that adds Home/End key support in the composer. Uses standard browser selection APIs and follows existing plugin patterns. Low risk with no security or infrastructure impact. You can customize Macroscope's approvability policy. Learn more. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cd495b7. Configure here.
Dismissing prior approval to re-evaluate 6d566f4

What Changed
Fixed the composer Home/End key behavior on macOS external keyboards.
The composer now handles plain Home/End inside the Lexical editor on macOS by asking the browser to move the DOM selection to the visual line boundary, then syncing that selection back into Lexical. Modifier variants like Cmd/Ctrl/Option + Home/End are left alone, and non-macOS platforms keep their native behavior.
Why
On Linux, Home/End already move to the start/end of the current visual line in the composer. On macOS with external keyboards, the same keys were not moving the caret inside the contenteditable editor.
UI Changes
Screen.Recording.2026-05-05.at.00.13.05.mov
Checklist
Note
Low Risk
Small, macOS-only keyboard handler in the composer with no auth, data, or API impact.
Overview
Adds
ComposerHomeEndKeyPluginto the Lexical composer so plain Home/End on macOS (e.g. external keyboards) move the caret to the start/end of the current visual line, matching behavior users already get on Linux.On macOS only, the plugin handles unmodified Home/End when focus is in the editor: it uses
Selection.modifywithlineboundary, then syncs the DOM selection back into Lexical via$createRangeSelectionFromDom. Shift+Home/End extends the selection; Cmd/Ctrl/Option combinations and IME composition are left to native handling. Other platforms are unchanged.Reviewed by Cursor Bugbot for commit 6d566f4. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix Home and End key behavior in the composer on macOS
On macOS, the Home and End keys do not natively move the caret to the line boundary in browser text editors. This adds a
ComposerHomeEndKeyPluginin ComposerPromptEditor.tsx that intercepts unmodified Home/End keypresses at high priority, usesSelection.modifyto move or extend the native selection to the line boundary, then syncs the result back into Lexical via$createRangeSelectionFromDom. Shift+Home/End extends the selection rather than collapsing it.Macroscope summarized 6d566f4.