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, 13:15 UTC
fix(mobile): apply terminal toolbar modifiers to arrow keys (#22161)
Co-authored-by: GPT-6.1 Sol <noreply@openai.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Victor Vogel committed
Oct 29, 2026 at 12:46 UTC
e0f972e3759c628b8c202930d5d38a53d4569b72
2 files changed
+40
apps/mobile/src/features/terminal/terminalInput.test.ts
+32
@@ -12,6 +12,38 @@ const ESC = byte(0x1b);
12
const CTRL_V = byte(0x16);
13
14
describe("resolveModifiedTerminalInput", () => {
15
+ it.each(["A", "B", "C", "D"])("encodes ctrl+arrow %s with the cursor modifier", (arrow) => {
16
+ expect(
17
+ resolveModifiedTerminalInput({
18
+ data: `${ESC}[${arrow}`,
19
+ modifier: "ctrl",
20
+ hostPlatform: "linux",
21
+ }),
22
+ ).toEqual({ kind: "write", data: `${ESC}[1;5${arrow}` });
23
+ });
24
+
25
+ it.each(["A", "B", "C", "D"])("encodes meta+arrow %s with the cursor modifier", (arrow) => {
26
+ expect(
27
+ resolveModifiedTerminalInput({
28
+ data: `${ESC}[${arrow}`,
29
+ modifier: "meta",
30
+ hostPlatform: "linux",
31
+ }),
32
+ ).toEqual({ kind: "write", data: `${ESC}[1;3${arrow}` });
33
+ });
34
+
35
+ it.each(["a", "", ESC, `${ESC}[H`, `${ESC}[1;5D`, `${ESC}[D\n`])(
36
+ "preserves non-arrow modifier handling for %j",
37
+ (data) => {
38
+ expect(
39
+ resolveModifiedTerminalInput({ data, modifier: "meta", hostPlatform: "linux" }),
40
+ ).toEqual({
41
+ kind: "write",
42
+ data: `${ESC}${data}`,
43
+ });
44
+ },
45
+ );
46
+
47
it("pastes on ctrl+v for windows, linux, and unknown hosts", () => {
48
for (const hostPlatform of ["windows", "linux", "unknown"] as const) {
49
expect(resolveModifiedTerminalInput({ data: "v", modifier: "ctrl", hostPlatform })).toEqual({
apps/mobile/src/features/terminal/terminalInput.ts
+8
@@ -45,6 +45,14 @@ export function resolveModifiedTerminalInput(input: {
45
return { kind: "paste" };
46
}
47
48
+ if (
49
+ input.data.length === 3 &&
50
+ input.data.startsWith("\u001b[") &&
51
+ /[ABCD]/.test(input.data.charAt(2))
52
+ ) {
53
+ return { kind: "write", data: `\u001b[1;${input.modifier === "ctrl" ? 5 : 3}${input.data[2]}` };
54
+ }
55
+
56
return {
57
kind: "write",
58
data: input.modifier === "ctrl" ? applyCtrlModifier(input.data) : `\u001b${input.data}`,