diff --git a/ui-opentui/src/view/agentsTray.tsx b/ui-opentui/src/view/agentsTray.tsx index a63dc251dd4..ea66be51bab 100644 --- a/ui-opentui/src/view/agentsTray.tsx +++ b/ui-opentui/src/view/agentsTray.tsx @@ -133,6 +133,10 @@ export function AgentsTray(props: { boxRef?.blur() setFocused(false) props.onExit?.() + // A tray-exit Esc is CONSUMED — without this, a composer remount can + // register its handler after ours and the same keystroke would arm the + // Esc+Esc prompt-history double-press (Epic 5 review caveat). + key.preventDefault() } }) diff --git a/ui-opentui/src/view/composer.tsx b/ui-opentui/src/view/composer.tsx index 569734c084a..fc5b2cc4dbd 100644 --- a/ui-opentui/src/view/composer.tsx +++ b/ui-opentui/src/view/composer.tsx @@ -322,7 +322,7 @@ export function Composer(props: { // With text in the buffer the Esc is just an intervening key (disarms); // unfocused (e.g. the agents tray owns the keys) it never counts. if (key.name === 'escape' && key.eventType !== 'release' && !key.ctrl && !key.meta && !key.option) { - if (ta?.focused === true && ta.plainText === '') { + if (ta?.focused === true && ta.plainText === '' && !key.defaultPrevented) { if (doubleEsc.press()) props.onDoubleEsc?.() } else { doubleEsc.reset()