Skip to content

Commit 7d6a721

Browse files
committed
refactor(tui): share the decision-gate stop path
1 parent 6ad6c68 commit 7d6a721

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
@@ -27,6 +27,7 @@ import {
2727
exitOverlayAnswerMode,
2828
handleOverlayAnswerKey,
2929
notifyOverlayClosed,
30+
stopDecisionGate,
3031
} from "./overlay-host.js";
3132
import {
3233
applyFocus,
@@ -356,9 +357,7 @@ export function createShellKeyHandlers(
356357
// way Esc does, then interrupts the turn, which drops queued gates too.
357358
if (key.ctrl && key.name === "c" && isDecisionGate(shell)) {
358359
key.preventDefault();
359-
abortOverlayHostReservations(shell);
360-
closeInsetOverlay(shell);
361-
interruptShell(shell);
360+
stopDecisionGate(shell);
362361
return;
363362
}
364363
// Checked ahead of the filter handlers: an opener chord pressed again is

‎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);
@@ -682,6 +683,13 @@ export function abortOverlayHostReservations(shell: AppShell): void {
682683
scheduleDeferredCommandFlush(shell);
683684
}
684685

686+
/** Reject a decision gate and stop the turn, matching its Ctrl+C behavior. */
687+
export function stopDecisionGate(shell: AppShell): void {
688+
abortOverlayHostReservations(shell);
689+
closeInsetOverlay(shell);
690+
interruptShell(shell);
691+
}
692+
685693
/** One deferred command-surface slot while the host is busy. */
686694
function deferBusyCommandOpen(
687695
shell: AppShell,

0 commit comments

Comments
 (0)