refactor(cli): keyboard handling and AskUserDialog (#17414)

This commit is contained in:
Jacob Richman
2026-01-27 14:26:00 -08:00
committed by GitHub
parent 3103697ea7
commit b51323b40c
46 changed files with 1220 additions and 385 deletions
+14 -7
View File
@@ -1401,7 +1401,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
setCopyModeEnabled(false);
enableMouseEvents();
// We don't want to process any other keys if we're in copy mode.
return;
return true;
}
// Debug log keystrokes if enabled
@@ -1412,7 +1412,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
if (isAlternateBuffer && keyMatchers[Command.TOGGLE_COPY_MODE](key)) {
setCopyModeEnabled(true);
disableMouseEvents();
return;
return true;
}
if (keyMatchers[Command.QUIT](key)) {
@@ -1425,13 +1425,13 @@ Logging in with Google... Restarting Gemini CLI to continue.
cancelOngoingRequest?.();
setCtrlCPressCount((prev) => prev + 1);
return;
return true;
} else if (keyMatchers[Command.EXIT](key)) {
if (buffer.text.length > 0) {
return;
return false;
}
setCtrlDPressCount((prev) => prev + 1);
return;
return true;
}
let enteringConstrainHeightMode = false;
@@ -1442,8 +1442,10 @@ Logging in with Google... Restarting Gemini CLI to continue.
if (keyMatchers[Command.SHOW_ERROR_DETAILS](key)) {
setShowErrorDetails((prev) => !prev);
return true;
} else if (keyMatchers[Command.SHOW_FULL_TODOS](key)) {
setShowFullTodos((prev) => !prev);
return true;
} else if (keyMatchers[Command.TOGGLE_MARKDOWN](key)) {
setRenderMarkdown((prev) => {
const newValue = !prev;
@@ -1451,6 +1453,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
refreshStatic();
return newValue;
});
return true;
} else if (
keyMatchers[Command.SHOW_IDE_CONTEXT_DETAIL](key) &&
config.getIdeMode() &&
@@ -1458,11 +1461,13 @@ Logging in with Google... Restarting Gemini CLI to continue.
) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
handleSlashCommand('/ide status');
return true;
} else if (
keyMatchers[Command.SHOW_MORE_LINES](key) &&
!enteringConstrainHeightMode
) {
setConstrainHeight(false);
return true;
} else if (
keyMatchers[Command.UNFOCUS_SHELL_INPUT](key) &&
activePtyId &&
@@ -1471,7 +1476,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
if (key.name === 'tab' && key.shift) {
// Always change focus
setEmbeddedShellFocused(false);
return;
return true;
}
const now = Date.now();
@@ -1491,10 +1496,12 @@ Logging in with Google... Restarting Gemini CLI to continue.
}
setEmbeddedShellFocused(false);
}, 100);
return;
return true;
}
handleWarning('Press Shift+Tab to focus out.');
return true;
}
return false;
},
[
constrainHeight,