Skip to content

Commit af5f8bb

Browse files
committed
refactor(tui): share the decision-gate stop path
1 parent a86b77c commit af5f8bb

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎src/tui/shell/keys.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
exitOverlayAnswerMode,
3131
handleOverlayAnswerKey,
3232
notifyOverlayClosed,
33+
stopDecisionGate,
3334
} from "./overlay-host.js";
3435
import {
3536
applyFocus,
@@ -413,9 +414,7 @@ export function createShellKeyHandlers(
413414
// way Esc does, then interrupts the turn, which drops queued gates too.
414415
if (key.ctrl && key.name === "c" && isDecisionGate(shell)) {
415416
key.preventDefault();
416-
abortOverlayHostReservations(shell);
417-
closeInsetOverlay(shell);
418-
interruptShell(shell);
417+
stopDecisionGate(shell);
419418
return;
420419
}
421420
// Checked before the filter handlers: an opener pressed again closes,

‎src/tui/shell/overlay-host.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import {
5151
relayout,
5252
setStatusFlash,
5353
} from "./chrome.js";
54+
import { interruptShell } from "./prompt.js";
5455

5556
function refreshOverlayTitle(shell: AppShell): void {
5657
const bag = shellInternals(shell);
@@ -639,6 +640,13 @@ export function abortOverlayHostReservations(shell: AppShell): void {
639640
scheduleDeferredCommandFlush(shell);
640641
}
641642

643+
/** Reject a decision gate and stop the turn, matching its Ctrl+C behavior. */
644+
export function stopDecisionGate(shell: AppShell): void {
645+
abortOverlayHostReservations(shell);
646+
closeInsetOverlay(shell);
647+
interruptShell(shell);
648+
}
649+
642650
/** One deferred command-surface slot while the host is busy. */
643651
function deferBusyCommandOpen(
644652
shell: AppShell,

0 commit comments

Comments
 (0)