Skip to content

Commit 254426d

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 eccc200 commit 254426d

9 files changed

Lines changed: 534 additions & 15 deletions

File tree

docs/cli/keyboard-shortcuts.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ available combinations.
3939
| Delete the next word. | `Ctrl + Delete`<br />`Alt + Delete` |
4040
| Delete the character to the left. | `Backspace`<br />`Ctrl + H` |
4141
| Delete the character to the right. | `Delete`<br />`Ctrl + D` |
42-
| Undo the most recent text edit. | `Ctrl + Z (no Shift)` |
43-
| Redo the most recent undone text edit. | `Shift + Ctrl + Z` |
42+
| Undo the most recent text edit. | `Alt + Z (no Shift)` |
43+
| Redo the most recent undone text edit. | `Shift + Alt + Z` |
4444

4545
#### Scrolling
4646

@@ -108,6 +108,7 @@ available combinations.
108108
| Focus the Gemini input from the shell input. | `Tab` |
109109
| Clear the terminal screen and redraw the UI. | `Ctrl + L` |
110110
| Restart the application. | `R` |
111+
| Suspend the CLI and move it to the background. | `Ctrl + Z` |
111112

112113
<!-- KEYBINDINGS-AUTOGEN:END -->
113114

packages/cli/src/config/keyBindings.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export enum Command {
8383
UNFOCUS_SHELL_INPUT = 'app.unfocusShellInput',
8484
CLEAR_SCREEN = 'app.clearScreen',
8585
RESTART_APP = 'app.restart',
86+
SUSPEND = 'app.suspend',
8687
}
8788

8889
/**
@@ -168,8 +169,8 @@ export const defaultKeyBindings: KeyBindingConfig = {
168169
],
169170
[Command.DELETE_CHAR_LEFT]: [{ key: 'backspace' }, { key: 'h', ctrl: true }],
170171
[Command.DELETE_CHAR_RIGHT]: [{ key: 'delete' }, { key: 'd', ctrl: true }],
171-
[Command.UNDO]: [{ key: 'z', shift: false, ctrl: true }],
172-
[Command.REDO]: [{ key: 'z', shift: true, ctrl: true }],
172+
[Command.UNDO]: [{ key: 'z', alt: true, shift: false }],
173+
[Command.REDO]: [{ key: 'z', alt: true, shift: true }],
173174

174175
// Scrolling
175176
[Command.SCROLL_UP]: [{ key: 'up', shift: true }],
@@ -253,6 +254,7 @@ export const defaultKeyBindings: KeyBindingConfig = {
253254
[Command.TOGGLE_COPY_MODE]: [{ key: 's', ctrl: true }],
254255
[Command.TOGGLE_YOLO]: [{ key: 'y', ctrl: true }],
255256
[Command.CYCLE_APPROVAL_MODE]: [{ key: 'tab', shift: true }],
257+
[Command.SUSPEND]: [{ key: 'z', ctrl: true }],
256258
[Command.SHOW_MORE_LINES]: [
257259
{ key: 'o', ctrl: true },
258260
{ key: 's', ctrl: true },
@@ -368,6 +370,7 @@ export const commandCategories: readonly CommandCategory[] = [
368370
Command.UNFOCUS_SHELL_INPUT,
369371
Command.CLEAR_SCREEN,
370372
Command.RESTART_APP,
373+
Command.SUSPEND,
371374
],
372375
},
373376
];
@@ -450,6 +453,7 @@ export const commandDescriptions: Readonly<Record<Command, string>> = {
450453
[Command.TOGGLE_YOLO]: 'Toggle YOLO (auto-approval) mode for tool calls.',
451454
[Command.CYCLE_APPROVAL_MODE]:
452455
'Cycle through approval modes: default (prompt), auto_edit (auto-approve edits), and plan (read-only).',
456+
[Command.SUSPEND]: 'Suspend the CLI and move it to the background.',
453457
[Command.SHOW_MORE_LINES]:
454458
'Expand a height-constrained response to show additional lines when not in alternate buffer mode.',
455459
[Command.FOCUS_SHELL_INPUT]: 'Focus the shell input from the gemini input.',

0 commit comments

Comments
 (0)