Skip to content

fix(web): handle macOS Home and End in composer#2508

Open
GuilhermeVieiraDev wants to merge 3 commits into
pingdotgg:mainfrom
GuilhermeVieiraDev:fix/macos-home-end-composer
Open

fix(web): handle macOS Home and End in composer#2508
GuilhermeVieiraDev wants to merge 3 commits into
pingdotgg:mainfrom
GuilhermeVieiraDev:fix/macos-home-end-composer

Conversation

@GuilhermeVieiraDev
Copy link
Copy Markdown
Contributor

@GuilhermeVieiraDev GuilhermeVieiraDev commented May 4, 2026

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

  • 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

Note

Low Risk
Small, macOS-only keyboard handler in the composer with no auth, data, or API impact.

Overview
Adds ComposerHomeEndKeyPlugin to 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.modify with lineboundary, 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 ComposerHomeEndKeyPlugin in ComposerPromptEditor.tsx that intercepts unmodified Home/End keypresses at high priority, uses Selection.modify to 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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9a21cf1b-fa10-4ad1-97c8-acda51d9ebe8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels May 4, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes May 4, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 4, 2026

Approvability

Verdict: 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.

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread apps/web/src/components/ComposerPromptEditor.tsx Outdated
@macroscopeapp macroscopeapp Bot dismissed their stale review June 4, 2026 22:08

Dismissing prior approval to re-evaluate 6d566f4

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:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant