Skip to content

Commit fedb3ae

Browse files
committed
feat(cli): support Ctrl-Z suspension
- Implement Ctrl+Z suspension with robust terminal state handling. - Rebind Undo/Redo to Alt+Z / Alt+Shift+Z to avoid conflicts. - Fix macOS Option key character mapping for Undo/Redo. - Improve type safety for app.rerender() in AppContainer. - Add comprehensive suspension test suite. - Fix environment leakage in core tests. - Update keyboard shortcut documentation. Fixes google-gemini#5018
1 parent c5d0fc2 commit fedb3ae

9 files changed

Lines changed: 600 additions & 23 deletions

File tree

docs/cli/keyboard-shortcuts.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ available combinations.
118118
| Focus the Gemini input from the shell input. | `Tab` |
119119
| Clear the terminal screen and redraw the UI. | `Ctrl + L` |
120120
| Restart the application. | `R` |
121-
| Suspend the application (not yet implemented). | `Ctrl + Z` |
121+
| Suspend the CLI and move it to the background. | `Ctrl + Z` |
122122

123123
<!-- KEYBINDINGS-AUTOGEN:END -->
124124

@@ -137,4 +137,4 @@ available combinations.
137137
the numbered radio option and confirm when the full number is entered.
138138
- `Double-click` on a paste placeholder (`[Pasted Text: X lines]`) in alternate
139139
buffer mode: Expand to view full content inline. Double-click again to
140-
collapse.
140+
collapse.

packages/cli/src/config/keyBindings.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export enum Command {
9494
UNFOCUS_SHELL_INPUT = 'app.unfocusShellInput',
9595
CLEAR_SCREEN = 'app.clearScreen',
9696
RESTART_APP = 'app.restart',
97-
SUSPEND_APP = 'app.suspend',
97+
SUSPEND = 'app.suspend',
9898
}
9999

100100
/**
@@ -283,6 +283,7 @@ export const defaultKeyBindings: KeyBindingConfig = {
283283
],
284284
[Command.BACKGROUND_SHELL_SELECT]: [{ key: 'return' }],
285285
[Command.BACKGROUND_SHELL_ESCAPE]: [{ key: 'escape' }],
286+
[Command.SUSPEND]: [{ key: 'z', ctrl: true }],
286287
[Command.SHOW_MORE_LINES]: [
287288
{ key: 'o', ctrl: true },
288289
{ key: 's', ctrl: true },
@@ -291,7 +292,6 @@ export const defaultKeyBindings: KeyBindingConfig = {
291292
[Command.UNFOCUS_SHELL_INPUT]: [{ key: 'tab' }],
292293
[Command.CLEAR_SCREEN]: [{ key: 'l', ctrl: true }],
293294
[Command.RESTART_APP]: [{ key: 'r' }],
294-
[Command.SUSPEND_APP]: [{ key: 'z', ctrl: true }],
295295
};
296296

297297
interface CommandCategory {
@@ -409,7 +409,7 @@ export const commandCategories: readonly CommandCategory[] = [
409409
Command.UNFOCUS_SHELL_INPUT,
410410
Command.CLEAR_SCREEN,
411411
Command.RESTART_APP,
412-
Command.SUSPEND_APP,
412+
Command.SUSPEND,
413413
],
414414
},
415415
];
@@ -494,6 +494,7 @@ export const commandDescriptions: Readonly<Record<Command, string>> = {
494494
[Command.TOGGLE_YOLO]: 'Toggle YOLO (auto-approval) mode for tool calls.',
495495
[Command.CYCLE_APPROVAL_MODE]:
496496
'Cycle through approval modes: default (prompt), auto_edit (auto-approve edits), and plan (read-only).',
497+
[Command.SUSPEND]: 'Suspend the CLI and move it to the background.',
497498
[Command.SHOW_MORE_LINES]:
498499
'Expand a height-constrained response to show additional lines when not in alternate buffer mode.',
499500
[Command.BACKGROUND_SHELL_SELECT]: 'Enter',
@@ -508,5 +509,4 @@ export const commandDescriptions: Readonly<Record<Command, string>> = {
508509
[Command.UNFOCUS_SHELL_INPUT]: 'Focus the Gemini input from the shell input.',
509510
[Command.CLEAR_SCREEN]: 'Clear the terminal screen and redraw the UI.',
510511
[Command.RESTART_APP]: 'Restart the application.',
511-
[Command.SUSPEND_APP]: 'Suspend the application (not yet implemented).',
512-
};
512+
};

0 commit comments

Comments
 (0)