From da9e2cf498d74594b12d247631220cf2fea94f1b Mon Sep 17 00:00:00 2001 From: euxaristia <25621994+euxaristia@users.noreply.github.com> Date: Wed, 29 Apr 2026 18:42:59 -0400 Subject: [PATCH] fix: make Home/End move caret to line edges in prompt input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The prompt is a contenteditable div whose default Home/End handling is unreliable across the editor's mixed inline content (text +
+ contenteditable=false pills), so fn+Left/Right on Magic Keyboards (and plain Home/End elsewhere) often did nothing useful. Route these keys through Selection.modify so they consistently move (or extend, with Shift) the caret to the line — or document, with Ctrl — boundary. --- packages/app/src/components/prompt-input.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/app/src/components/prompt-input.tsx b/packages/app/src/components/prompt-input.tsx index 0a18096164f0..92112c91a53a 100644 --- a/packages/app/src/components/prompt-input.tsx +++ b/packages/app/src/components/prompt-input.tsx @@ -1165,6 +1165,21 @@ export const PromptInput: Component = (props) => { } } + // Home/End move the caret to the line/document edge. contenteditable does + // not handle these reliably across the editor's mixed inline content + // (text +
+ non-editable pills), so route them through Selection.modify. + if (event.key === "Home" || event.key === "End") { + if (event.metaKey || event.altKey) return + const selection = window.getSelection() + if (!selection) return + const direction = event.key === "Home" ? "backward" : "forward" + const granularity = event.ctrlKey ? "documentboundary" : "lineboundary" + const alter = event.shiftKey ? "extend" : "move" + selection.modify(alter, direction, granularity) + event.preventDefault() + return + } + // Handle Shift+Enter BEFORE IME check - Shift+Enter is never used for IME input // and should always insert a newline regardless of composition state if (event.key === "Enter" && event.shiftKey) {