fix(cli): ctrl c/ctrl d close cli when in dialogs (#8685)

Co-authored-by: Jacob Richman <jacob314@gmail.com>
Co-authored-by: matt korwel <matt.korwel@gmail.com>
This commit is contained in:
fuyou
2025-09-19 14:52:29 +08:00
committed by GitHub
parent 938c850ed8
commit e48f61bdc7
4 changed files with 231 additions and 25 deletions
+21 -24
View File
@@ -865,14 +865,27 @@ Logging in with Google... Please restart Gemini CLI to continue.
console.log('[DEBUG] Keystroke:', JSON.stringify(key));
}
const anyDialogOpen =
isThemeDialogOpen ||
isAuthDialogOpen ||
isEditorDialogOpen ||
isSettingsDialogOpen ||
isFolderTrustDialogOpen ||
showPrivacyNotice;
if (anyDialogOpen) {
if (keyMatchers[Command.QUIT](key)) {
if (!ctrlCPressedOnce) {
cancelOngoingRequest?.();
}
if (!ctrlCPressedOnce) {
setCtrlCPressedOnce(true);
ctrlCTimerRef.current = setTimeout(() => {
setCtrlCPressedOnce(false);
ctrlCTimerRef.current = null;
}, CTRL_EXIT_PROMPT_DURATION_MS);
return;
}
handleExit(ctrlCPressedOnce, setCtrlCPressedOnce, ctrlCTimerRef);
return;
} else if (keyMatchers[Command.EXIT](key)) {
if (buffer.text.length > 0) {
return;
}
handleExit(ctrlDPressedOnce, setCtrlDPressedOnce, ctrlDTimerRef);
return;
}
@@ -898,16 +911,6 @@ Logging in with Google... Please restart Gemini CLI to continue.
ideContextState
) {
handleSlashCommand('/ide status');
} else if (keyMatchers[Command.QUIT](key)) {
if (!ctrlCPressedOnce) {
cancelOngoingRequest?.();
}
handleExit(ctrlCPressedOnce, setCtrlCPressedOnce, ctrlCTimerRef);
} else if (keyMatchers[Command.EXIT](key)) {
if (buffer.text.length > 0) {
return;
}
handleExit(ctrlDPressedOnce, setCtrlDPressedOnce, ctrlDTimerRef);
} else if (
keyMatchers[Command.SHOW_MORE_LINES](key) &&
!enteringConstrainHeightMode
@@ -937,12 +940,6 @@ Logging in with Google... Please restart Gemini CLI to continue.
ctrlDTimerRef,
handleSlashCommand,
cancelOngoingRequest,
isThemeDialogOpen,
isAuthDialogOpen,
isEditorDialogOpen,
isSettingsDialogOpen,
isFolderTrustDialogOpen,
showPrivacyNotice,
activePtyId,
shellFocused,
settings.merged.general?.debugKeystrokeLogging,