From be26d362faff986551c3d507b7191992328485c0 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Fri, 16 Jan 2026 01:30:46 +0100 Subject: [PATCH] Fix alt+backspace in Kitty mode and clamp Codex effort (refs #752) --- packages/ai/src/providers/openai-codex-responses.ts | 1 + packages/tui/src/keys.ts | 6 +++--- packages/tui/test/keys.test.ts | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/ai/src/providers/openai-codex-responses.ts b/packages/ai/src/providers/openai-codex-responses.ts index 7889e23f..b05a3b81 100644 --- a/packages/ai/src/providers/openai-codex-responses.ts +++ b/packages/ai/src/providers/openai-codex-responses.ts @@ -209,6 +209,7 @@ function buildSystemPrompt(userSystemPrompt?: string): { instructions: string; d function clampReasoningEffort(modelId: string, effort: string): string { const id = modelId.includes("/") ? modelId.split("/").pop()! : modelId; + if (id.startsWith("gpt-5.2") && effort === "minimal") return "low"; if (id === "gpt-5.1" && effort === "xhigh") return "high"; if (id === "gpt-5.1-codex-mini") return effort === "high" || effort === "xhigh" ? "high" : "medium"; return effort; diff --git a/packages/tui/src/keys.ts b/packages/tui/src/keys.ts index 4c8093a5..af7653c6 100644 --- a/packages/tui/src/keys.ts +++ b/packages/tui/src/keys.ts @@ -771,8 +771,8 @@ export function matchesKey(data: string, keyId: KeyId): boolean { case "backspace": if (alt && !ctrl && !shift) { - if (!_kittyProtocolActive) { - return data === "\x1b\x7f" || data === "\x1b\b"; + if (data === "\x1b\x7f" || data === "\x1b\b") { + return true; } return matchesKittySequence(data, CODEPOINTS.backspace, MODIFIERS.alt); } @@ -1065,7 +1065,7 @@ export function parseKey(data: string): string | undefined { if (data === "\x1b[Z") return "shift+tab"; if (!_kittyProtocolActive && data === "\x1b\r") return "alt+enter"; if (!_kittyProtocolActive && data === "\x1b ") return "alt+space"; - if (!_kittyProtocolActive && (data === "\x1b\x7f" || data === "\x1b\b")) return "alt+backspace"; + if (data === "\x1b\x7f" || data === "\x1b\b") return "alt+backspace"; if (!_kittyProtocolActive && data === "\x1bB") return "alt+left"; if (!_kittyProtocolActive && data === "\x1bF") return "alt+right"; if (!_kittyProtocolActive && data.length === 2 && data[0] === "\x1b") { diff --git a/packages/tui/test/keys.test.ts b/packages/tui/test/keys.test.ts index 3f936aad..ef46bae6 100644 --- a/packages/tui/test/keys.test.ts +++ b/packages/tui/test/keys.test.ts @@ -137,7 +137,7 @@ describe("matchesKey", () => { assert.strictEqual(parseKey("\x00"), "ctrl+space"); }); - it("should parse legacy alt-prefixed sequences only when kitty inactive", () => { + it("should parse legacy alt-prefixed sequences when kitty inactive", () => { setKittyProtocolActive(false); assert.strictEqual(matchesKey("\x1b ", "alt+space"), true); assert.strictEqual(parseKey("\x1b "), "alt+space"); @@ -153,8 +153,8 @@ describe("matchesKey", () => { setKittyProtocolActive(true); assert.strictEqual(matchesKey("\x1b ", "alt+space"), false); assert.strictEqual(parseKey("\x1b "), undefined); - assert.strictEqual(matchesKey("\x1b\b", "alt+backspace"), false); - assert.strictEqual(parseKey("\x1b\b"), undefined); + assert.strictEqual(matchesKey("\x1b\b", "alt+backspace"), true); + assert.strictEqual(parseKey("\x1b\b"), "alt+backspace"); assert.strictEqual(matchesKey("\x1b\x03", "ctrl+alt+c"), false); assert.strictEqual(parseKey("\x1b\x03"), undefined); assert.strictEqual(matchesKey("\x1bB", "alt+left"), false);