From 205203a458b124f9d7d95f973501a0305c326212 Mon Sep 17 00:00:00 2001 From: William Valentin Date: Mon, 16 Feb 2026 11:34:05 -0800 Subject: [PATCH] fix(tui): detect escape key variants for prompt cancellation --- src/frontends/tui/minimal.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/frontends/tui/minimal.ts b/src/frontends/tui/minimal.ts index 1cc26df..4b632b0 100644 --- a/src/frontends/tui/minimal.ts +++ b/src/frontends/tui/minimal.ts @@ -80,6 +80,10 @@ export class MinimalTui { constructor(private config: MinimalTuiConfig) {} + private isEscapeKey(char: string, key: readline.Key): boolean { + return key?.name === 'escape' || key?.sequence === '\x1b' || char === '\x1b'; + } + private showHint(line: string): void { if (!line.startsWith('/')) { this.clearHint(); @@ -158,8 +162,8 @@ export class MinimalTui { } // Listen for line changes to show hints - this.keypressHandler = (_char: string, key: readline.Key) => { - if (key?.name === 'escape' && this.activePromptCancel) { + this.keypressHandler = (char: string, key: readline.Key) => { + if (this.activePromptCancel && this.isEscapeKey(char, key)) { this.activePromptCancel(); return; }