Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
fix(web): handle macOS Home and End in composer (#2508)
Guilherme Vieirab859a575d19c
diff --git a/apps/web/src/components/ComposerPromptEditor.tsx b/apps/web/src/components/ComposerPromptEditor.tsxindex 67c3505d3..585d46150 100644--- a/apps/web/src/components/ComposerPromptEditor.tsx+++ b/apps/web/src/components/ComposerPromptEditor.tsx@@ -9,6 +9,7 @@ import { type ServerProviderSkill } from "@t3tools/contracts";import { serializeComposerFileLink } from "@t3tools/shared/composerTrigger";import {$applyNodeReplacement,+ $createRangeSelectionFromDom,$createRangeSelection,$getSelection,$setSelection,@@ -23,6 +24,7 @@ import {KEY_ARROW_LEFT_COMMAND,KEY_ARROW_RIGHT_COMMAND,KEY_ARROW_UP_COMMAND,+ KEY_DOWN_COMMAND,KEY_ENTER_COMMAND,KEY_TAB_COMMAND,COMMAND_PRIORITY_HIGH,@@ -63,7 +65,7 @@ import {INLINE_TERMINAL_CONTEXT_PLACEHOLDER,type TerminalContextDraft,} from "~/lib/terminalContext";-import { cn } from "~/lib/utils";+import { cn, isMacPlatform } from "~/lib/utils";import { basenameOfPath } from "~/pierre-icons";import {COMPOSER_INLINE_CHIP_ICON_CLASS_NAME,@@ -1023,6 +1025,53 @@ function ComposerInlineTokenArrowPlugin() {return null;}+function ComposerHomeEndKeyPlugin() {+ const [editor] = useLexicalComposerContext();++ useEffect(() => {+ return editor.registerCommand(+ KEY_DOWN_COMMAND,+ (event) => {+ if (!isMacPlatform(navigator.platform)) {+ return false;+ }+ if (event.key !== "Home" && event.key !== "End") {+ return false;+ }+ if (event.altKey || event.metaKey || event.ctrlKey || event.isComposing) {+ return false;+ }++ const rootElement = editor.getRootElement();+ const selection = window.getSelection();+ const anchorNode = selection?.anchorNode;+ if (!rootElement || !selection || !anchorNode || !rootElement.contains(anchorNode)) {+ return false;+ }+ if (selection.rangeCount === 0 || typeof selection.modify !== "function") {+ return false;+ }++ event.preventDefault();+ event.stopPropagation();++ selection.modify(+ event.shiftKey ? "extend" : "move",+ event.key === "Home" ? "backward" : "forward",+ "lineboundary",+ );+ editor.update(() => {+ $setSelection($createRangeSelectionFromDom(selection, editor));+ });+ return true;+ },+ COMMAND_PRIORITY_HIGH,+ );+ }, [editor]);++ return null;+}+function ComposerInlineTokenSelectionNormalizePlugin() {const [editor] = useLexicalComposerContext();@@ -1647,6 +1696,7 @@ function ComposerPromptEditorInner({<OnChangePlugin onChange={handleEditorChange} /><ComposerCommandKeyPlugin {...(onCommandKeyDown ? { onCommandKeyDown } : {})} /><ComposerSurroundSelectionPlugin terminalContexts={terminalContexts} skills={skills} />+ <ComposerHomeEndKeyPlugin /><ComposerInlineTokenArrowPlugin /><ComposerInlineTokenSelectionNormalizePlugin /><ComposerInlineTokenBackspacePlugin />