From eb15f326c11d421423fd00f887e67091318c5f88 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Sun, 11 Jan 2026 04:51:44 +0300 Subject: [PATCH] fix(tui): skip key release/repeat check for bracketed paste content Pasted content containing Kitty key release patterns (e.g., :3F in bluetooth MAC addresses) was incorrectly detected as a key release event and dropped. The fix checks for bracketed paste markers before running pattern checks. Also applied to isKeyRepeat() for consistency. Closes #623 --- packages/tui/CHANGELOG.md | 1 + packages/tui/src/keys.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/packages/tui/CHANGELOG.md b/packages/tui/CHANGELOG.md index 269e4b93..da366a9b 100644 --- a/packages/tui/CHANGELOG.md +++ b/packages/tui/CHANGELOG.md @@ -7,6 +7,7 @@ - Reduced flicker by only re-rendering changed lines ([#617](https://github.com/badlogic/pi-mono/pull/617) by [@ogulcancelik](https://github.com/ogulcancelik)) - Cursor position tracking when content shrinks with unchanged remaining lines - TUI renders with wrong dimensions after suspend/resume if terminal was resized while suspended ([#599](https://github.com/badlogic/pi-mono/issues/599)) +- Pasted content containing Kitty key release patterns (e.g., `:3F` in MAC addresses) was incorrectly filtered out ([#623](https://github.com/badlogic/pi-mono/pull/623) by [@ogulcancelik](https://github.com/ogulcancelik)) ## [0.42.4] - 2026-01-10 diff --git a/packages/tui/src/keys.ts b/packages/tui/src/keys.ts index b013da36..21c96508 100644 --- a/packages/tui/src/keys.ts +++ b/packages/tui/src/keys.ts @@ -314,6 +314,14 @@ let _lastEventType: KeyEventType = "press"; * Only meaningful when Kitty keyboard protocol with flag 2 is active. */ export function isKeyRelease(data: string): boolean { + // Don't treat bracketed paste content as key release, even if it contains + // patterns like ":3F" (e.g., bluetooth MAC addresses like "90:62:3F:A5"). + // Terminal.ts re-wraps paste content with bracketed paste markers before + // passing to TUI, so pasted data will always contain \x1b[200~. + if (data.includes("\x1b[200~")) { + return false; + } + // Quick check: release events with flag 2 contain ":3" // Format: \x1b[;:3u if ( @@ -336,6 +344,12 @@ export function isKeyRelease(data: string): boolean { * Only meaningful when Kitty keyboard protocol with flag 2 is active. */ export function isKeyRepeat(data: string): boolean { + // Don't treat bracketed paste content as key repeat, even if it contains + // patterns like ":2F". See isKeyRelease() for details. + if (data.includes("\x1b[200~")) { + return false; + } + if ( data.includes(":2u") || data.includes(":2~") ||