From c27168840c8be347ea72e1ea56840c54cc023451 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Sun, 1 Feb 2026 01:33:28 +0100 Subject: [PATCH] test(tui): cover non-qwerty kitty base layout fallback --- packages/coding-agent/CHANGELOG.md | 1 + packages/tui/CHANGELOG.md | 4 ++++ packages/tui/test/keys.test.ts | 34 ++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 4c6440a7..fafbdd01 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -12,6 +12,7 @@ - Fixed `switchSession()` appending spurious `thinking_level_change` entry to session log on resume. `setThinkingLevel()` is now idempotent. ([#1118](https://github.com/badlogic/pi-mono/issues/1118)) - Fixed clipboard image paste on WSL2/WSLg writing invalid PNG files when clipboard provides `image/bmp` format. BMP images are now converted to PNG before saving. ([#1112](https://github.com/badlogic/pi-mono/pull/1112) by [@lightningRalf](https://github.com/lightningRalf)) +- Fixed Kitty keyboard protocol base layout fallback so non-QWERTY layouts do not trigger wrong shortcuts ([#1096](https://github.com/badlogic/pi-mono/pull/1096) by [@rytswd](https://github.com/rytswd)) ## [0.50.7] - 2026-01-31 diff --git a/packages/tui/CHANGELOG.md b/packages/tui/CHANGELOG.md index 493e0666..2532f592 100644 --- a/packages/tui/CHANGELOG.md +++ b/packages/tui/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Fixed Kitty keyboard protocol base layout fallback so non-QWERTY layouts do not trigger wrong shortcuts ([#1096](https://github.com/badlogic/pi-mono/pull/1096) by [@rytswd](https://github.com/rytswd)) + ## [0.50.7] - 2026-01-31 ## [0.50.6] - 2026-01-30 diff --git a/packages/tui/test/keys.test.ts b/packages/tui/test/keys.test.ts index 276cba7b..d307c7b9 100644 --- a/packages/tui/test/keys.test.ts +++ b/packages/tui/test/keys.test.ts @@ -83,6 +83,24 @@ describe("matchesKey", () => { setKittyProtocolActive(false); }); + it("should prefer codepoint for Latin letters even when base layout differs", () => { + setKittyProtocolActive(true); + // Dvorak Ctrl+K reports codepoint 'k' (107) and base layout 'v' (118) + const dvorakCtrlK = "\x1b[107::118;5u"; + assert.strictEqual(matchesKey(dvorakCtrlK, "ctrl+k"), true); + assert.strictEqual(matchesKey(dvorakCtrlK, "ctrl+v"), false); + setKittyProtocolActive(false); + }); + + it("should prefer codepoint for symbol keys even when base layout differs", () => { + setKittyProtocolActive(true); + // Dvorak Ctrl+/ reports codepoint '/' (47) and base layout '[' (91) + const dvorakCtrlSlash = "\x1b[47::91;5u"; + assert.strictEqual(matchesKey(dvorakCtrlSlash, "ctrl+/"), true); + assert.strictEqual(matchesKey(dvorakCtrlSlash, "ctrl+["), false); + setKittyProtocolActive(false); + }); + it("should not match wrong key even with base layout", () => { setKittyProtocolActive(true); // Cyrillic ctrl+с with base 'c' should NOT match ctrl+d @@ -254,6 +272,22 @@ describe("parseKey", () => { setKittyProtocolActive(false); }); + it("should prefer codepoint for Latin letters when base layout differs", () => { + setKittyProtocolActive(true); + // Dvorak Ctrl+K reports codepoint 'k' (107) and base layout 'v' (118) + const dvorakCtrlK = "\x1b[107::118;5u"; + assert.strictEqual(parseKey(dvorakCtrlK), "ctrl+k"); + setKittyProtocolActive(false); + }); + + it("should prefer codepoint for symbol keys when base layout differs", () => { + setKittyProtocolActive(true); + // Dvorak Ctrl+/ reports codepoint '/' (47) and base layout '[' (91) + const dvorakCtrlSlash = "\x1b[47::91;5u"; + assert.strictEqual(parseKey(dvorakCtrlSlash), "ctrl+/"); + setKittyProtocolActive(false); + }); + it("should return key name from codepoint when no base layout", () => { setKittyProtocolActive(true); const latinCtrlC = "\x1b[99;5u";