@devries-cameron20 / t3code-1 / commits / b859a575d1
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

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

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Guilherme Vieira committed Jul 18, 2026 at 12:23 UTC b859a575d19cc0ff060b11a94a0f8aa92cb38c3f
1 file changed +51 -1
apps/web/src/components/ComposerPromptEditor.tsx
+51 -1
@@ -9,6 +9,7 @@ import { type ServerProviderSkill } from "@t3tools/contracts";
9 import { serializeComposerFileLink } from "@t3tools/shared/composerTrigger";
10 import {
11 $applyNodeReplacement,
12 + $createRangeSelectionFromDom,
13 $createRangeSelection,
14 $getSelection,
15 $setSelection,
@@ -23,6 +24,7 @@ import {
24 KEY_ARROW_LEFT_COMMAND,
25 KEY_ARROW_RIGHT_COMMAND,
26 KEY_ARROW_UP_COMMAND,
27 + KEY_DOWN_COMMAND,
28 KEY_ENTER_COMMAND,
29 KEY_TAB_COMMAND,
30 COMMAND_PRIORITY_HIGH,
@@ -63,7 +65,7 @@ import {
65 INLINE_TERMINAL_CONTEXT_PLACEHOLDER,
66 type TerminalContextDraft,
67 } from "~/lib/terminalContext";
66 -import { cn } from "~/lib/utils";
68 +import { cn, isMacPlatform } from "~/lib/utils";
69 import { basenameOfPath } from "~/pierre-icons";
70 import {
71 COMPOSER_INLINE_CHIP_ICON_CLASS_NAME,
@@ -1023,6 +1025,53 @@ function ComposerInlineTokenArrowPlugin() {
1025 return null;
1026 }
1027
1028 +function ComposerHomeEndKeyPlugin() {
1029 + const [editor] = useLexicalComposerContext();
1030 +
1031 + useEffect(() => {
1032 + return editor.registerCommand(
1033 + KEY_DOWN_COMMAND,
1034 + (event) => {
1035 + if (!isMacPlatform(navigator.platform)) {
1036 + return false;
1037 + }
1038 + if (event.key !== "Home" && event.key !== "End") {
1039 + return false;
1040 + }
1041 + if (event.altKey || event.metaKey || event.ctrlKey || event.isComposing) {
1042 + return false;
1043 + }
1044 +
1045 + const rootElement = editor.getRootElement();
1046 + const selection = window.getSelection();
1047 + const anchorNode = selection?.anchorNode;
1048 + if (!rootElement || !selection || !anchorNode || !rootElement.contains(anchorNode)) {
1049 + return false;
1050 + }
1051 + if (selection.rangeCount === 0 || typeof selection.modify !== "function") {
1052 + return false;
1053 + }
1054 +
1055 + event.preventDefault();
1056 + event.stopPropagation();
1057 +
1058 + selection.modify(
1059 + event.shiftKey ? "extend" : "move",
1060 + event.key === "Home" ? "backward" : "forward",
1061 + "lineboundary",
1062 + );
1063 + editor.update(() => {
1064 + $setSelection($createRangeSelectionFromDom(selection, editor));
1065 + });
1066 + return true;
1067 + },
1068 + COMMAND_PRIORITY_HIGH,
1069 + );
1070 + }, [editor]);
1071 +
1072 + return null;
1073 +}
1074 +
1075 function ComposerInlineTokenSelectionNormalizePlugin() {
1076 const [editor] = useLexicalComposerContext();
1077
@@ -1647,6 +1696,7 @@ function ComposerPromptEditorInner({
1696 <OnChangePlugin onChange={handleEditorChange} />
1697 <ComposerCommandKeyPlugin {...(onCommandKeyDown ? { onCommandKeyDown } : {})} />
1698 <ComposerSurroundSelectionPlugin terminalContexts={terminalContexts} skills={skills} />
1699 + <ComposerHomeEndKeyPlugin />
1700 <ComposerInlineTokenArrowPlugin />
1701 <ComposerInlineTokenSelectionNormalizePlugin />
1702 <ComposerInlineTokenBackspacePlugin />