@devries-cameron20 / t3code Mirror · read-only / commits / 0f6de8c22c
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 12:00 UTC

fix(web): preserve Ctrl+Arrow terminal key sequences (#23480)

Utkarsh Patil committed Oct 30, 2026 at 18:10 UTC 0f6de8c22c0bc694efe0926125b60b57e6ecf8cb
3 files changed +47 -4
apps/web/src/keybindings.test.ts
+26
@@ -21,6 +21,7 @@ import {
21 resolveShortcutCommand,
22 shouldShowThreadJumpHintsForModifiers,
23 shortcutLabelForCommand,
24 + terminalNavigationShortcutData,
25 type ShortcutEventLike,
26 } from "./keybindings";
27
@@ -35,6 +36,31 @@ function event(overrides: Partial<ShortcutEventLike> = {}): ShortcutEventLike {
36 };
37 }
38
39 +describe("terminal word navigation", () => {
40 + it.each(["Win32", "Linux x86_64"])(
41 + "leaves Ctrl+Arrow to the terminal encoder on %s",
42 + (platform) => {
43 + for (const key of ["ArrowLeft", "ArrowRight"]) {
44 + assert.equal(terminalNavigationShortcutData(event({ key, ctrlKey: true }), platform), null);
45 + }
46 + },
47 + );
48 +
49 + it.each(["Win32", "Linux x86_64", "MacIntel"])(
50 + "preserves Alt+Arrow word navigation on %s",
51 + (platform) => {
52 + assert.equal(
53 + terminalNavigationShortcutData(event({ key: "ArrowLeft", altKey: true }), platform),
54 + "\u001bb",
55 + );
56 + assert.equal(
57 + terminalNavigationShortcutData(event({ key: "ArrowRight", altKey: true }), platform),
58 + "\u001bf",
59 + );
60 + },
61 + );
62 +});
63 +
64 function modShortcut(
65 key: string,
66 overrides: Partial<Omit<KeybindingShortcut, "key">> = {},
apps/web/src/keybindings.ts
-4
@@ -464,10 +464,6 @@ export function terminalNavigationShortcutData(
464 return null;
465 }
466
467 - if (event.ctrlKey && !event.metaKey && !event.altKey) {
468 - return moveWord;
469 - }
470 -
467 if (event.altKey && !event.metaKey && !event.ctrlKey) {
468 return moveWord;
469 }
apps/web/src/terminal/ghostty/core.test.ts
+21
@@ -12,6 +12,7 @@ import {
12 import { writeTerminalOutputUpdate } from "../../components/ThreadTerminalDrawer";
13 import { GHOSTTY_CELL_WIDE, GhosttyTerminalCore, ghosttyCellText } from "./core";
14 import { loadGhosttyRuntime } from "./runtime";
15 +import { terminalNavigationShortcutData } from "../../keybindings";
16
17 vi.mock("./vendor/ghostty-vt.wasm?url", async () => ({
18 default: (await import("./vendor/ghostty-vt.wasm?inline")).default,
@@ -101,6 +102,26 @@ describe("GhosttyTerminalCore snapshots", () => {
102 vi.restoreAllMocks();
103 });
104
105 + it.each([
106 + { key: "ArrowLeft", expected: "\x1b[1;5D" },
107 + { key: "ArrowRight", expected: "\x1b[1;5C" },
108 + ])("sends Ctrl+$key as a modified arrow instead of Alt+B/F", async ({ key, expected }) => {
109 + const core = await createCore();
110 + const event = {
111 + code: key,
112 + key,
113 + repeat: false,
114 + shiftKey: false,
115 + ctrlKey: true,
116 + altKey: false,
117 + metaKey: false,
118 + isComposing: false,
119 + getModifierState: () => false,
120 + } as unknown as KeyboardEvent;
121 +
122 + expect(terminalNavigationShortcutData(event, "Win32") ?? core.encodeKey(event)).toBe(expected);
123 + });
124 +
125 it.each([
126 { code: "", key: "Backspace", expected: "\x7f" },
127 { code: "Unidentified", key: "Backspace", expected: "\x7f" },