Skip to content

Commit cbacdc6

Browse files
authored
feat(cli): switch to ctrl+g from ctrl-x (google-gemini#24861)
1 parent 7e1938c commit cbacdc6

13 files changed

Lines changed: 71 additions & 36 deletions

docs/reference/keyboard-shortcuts.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,22 @@ available combinations.
8686

8787
#### Text Input
8888

89-
| Command | Action | Keys |
90-
| -------------------------- | ------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
91-
| `input.submit` | Submit the current prompt. | `Enter` |
92-
| `input.queueMessage` | Queue the current prompt to be processed after the current task finishes. | `Tab` |
93-
| `input.newline` | Insert a newline without submitting. | `Ctrl+Enter`<br />`Cmd/Win+Enter`<br />`Alt+Enter`<br />`Shift+Enter`<br />`Ctrl+J` |
94-
| `input.openExternalEditor` | Open the current prompt or the plan in an external editor. | `Ctrl+X` |
95-
| `input.paste` | Paste from the clipboard. | `Ctrl+V`<br />`Cmd/Win+V`<br />`Alt+V` |
89+
| Command | Action | Keys |
90+
| ------------------------------------ | ------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
91+
| `input.submit` | Submit the current prompt. | `Enter` |
92+
| `input.queueMessage` | Queue the current prompt to be processed after the current task finishes. | `Tab` |
93+
| `input.newline` | Insert a newline without submitting. | `Ctrl+Enter`<br />`Cmd/Win+Enter`<br />`Alt+Enter`<br />`Shift+Enter`<br />`Ctrl+J` |
94+
| `input.openExternalEditor` | Open the current prompt or the plan in an external editor. | `Ctrl+G` |
95+
| `input.deprecatedOpenExternalEditor` | Deprecated command to open external editor. | `Ctrl+X` |
96+
| `input.paste` | Paste from the clipboard. | `Ctrl+V`<br />`Cmd/Win+V`<br />`Alt+V` |
9697

9798
#### App Controls
9899

99100
| Command | Action | Keys |
100101
| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
101102
| `app.showErrorDetails` | Toggle detailed error information. | `F12` |
102103
| `app.showFullTodos` | Toggle the full TODO list. | `Ctrl+T` |
103-
| `app.showIdeContextDetail` | Show IDE context details. | `Ctrl+G` |
104+
| `app.showIdeContextDetail` | Show IDE context details. | `F4` |
104105
| `app.toggleMarkdown` | Toggle Markdown rendering. | `Alt+M` |
105106
| `app.toggleCopyMode` | Toggle copy mode when in alternate buffer mode. | `F9` |
106107
| `app.toggleMouseMode` | Toggle mouse mode (scrolling and clicking). | `Ctrl+S` |

packages/cli/src/ui/components/ContextSummaryDisplay.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import type React from 'react';
88
import { Box, Text } from 'ink';
99
import { theme } from '../semantic-colors.js';
1010
import { type IdeContext, type MCPServerConfig } from '@google/gemini-cli-core';
11+
import { Command } from '../key/keyMatchers.js';
12+
import { formatCommand } from '../key/keybindingUtils.js';
1113

1214
interface ContextSummaryDisplayProps {
1315
geminiMdFileCount: number;
@@ -49,7 +51,7 @@ export const ContextSummaryDisplay: React.FC<ContextSummaryDisplayProps> = ({
4951
}
5052
return `${openFileCount} open file${
5153
openFileCount > 1 ? 's' : ''
52-
} (ctrl+g to view)`;
54+
} (${formatCommand(Command.SHOW_IDE_CONTEXT_DETAIL)} to view)`;
5355
})();
5456

5557
const geminiMdText = (() => {

packages/cli/src/ui/components/ExitPlanModeDialog.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ Implement a comprehensive authentication system with multiple providers.
587587
expect(onFeedback).not.toHaveBeenCalled();
588588
});
589589

590-
it('automatically submits feedback when Ctrl+X is used to edit the plan', async () => {
590+
it('automatically submits feedback when Ctrl+G is used to edit the plan', async () => {
591591
const { stdin, lastFrame } = await act(async () =>
592592
renderDialog({ useAlternateBuffer }),
593593
);
@@ -600,9 +600,9 @@ Implement a comprehensive authentication system with multiple providers.
600600
expect(lastFrame()).toContain('Add user authentication');
601601
});
602602

603-
// Press Ctrl+X
603+
// Press Ctrl+G
604604
await act(async () => {
605-
writeKey(stdin, '\x18'); // Ctrl+X
605+
writeKey(stdin, '\x07'); // Ctrl+G
606606
});
607607

608608
await waitFor(() => {

packages/cli/src/ui/components/ExitPlanModeDialog.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ import { useKeypress } from '../hooks/useKeypress.js';
2525
import { Command } from '../key/keyMatchers.js';
2626
import { formatCommand } from '../key/keybindingUtils.js';
2727
import { useKeyMatchers } from '../hooks/useKeyMatchers.js';
28+
import {
29+
appEvents,
30+
AppEvent,
31+
TransientMessageType,
32+
} from '../../utils/events.js';
2833

2934
export interface ExitPlanModeDialogProps {
3035
planPath: string;
@@ -173,6 +178,14 @@ export const ExitPlanModeDialog: React.FC<ExitPlanModeDialogProps> = ({
173178
void handleOpenEditor();
174179
return true;
175180
}
181+
if (keyMatchers[Command.DEPRECATED_OPEN_EXTERNAL_EDITOR](key)) {
182+
const cmdKey = formatCommand(Command.OPEN_EXTERNAL_EDITOR);
183+
appEvents.emit(AppEvent.TransientMessage, {
184+
message: `Use ${cmdKey} to open the external editor.`,
185+
type: TransientMessageType.Hint,
186+
});
187+
return true;
188+
}
176189
return false;
177190
},
178191
{ isActive: true, priority: true },

packages/cli/src/ui/components/InputPrompt.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5065,8 +5065,8 @@ describe('InputPrompt', () => {
50655065
input: '\x12',
50665066
},
50675067
{
5068-
name: 'Ctrl+X hotkey is pressed',
5069-
input: '\x18',
5068+
name: 'Ctrl+G hotkey is pressed',
5069+
input: '\x07',
50705070
},
50715071
{
50725072
name: 'F12 hotkey is pressed',

packages/cli/src/ui/components/InputPrompt.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,15 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
12721272
return true;
12731273
}
12741274

1275+
if (keyMatchers[Command.DEPRECATED_OPEN_EXTERNAL_EDITOR](key)) {
1276+
const cmdKey = formatCommand(Command.OPEN_EXTERNAL_EDITOR);
1277+
appEvents.emit(AppEvent.TransientMessage, {
1278+
message: `Use ${cmdKey} to open the external editor.`,
1279+
type: TransientMessageType.Hint,
1280+
});
1281+
return true;
1282+
}
1283+
12751284
// Ctrl+V for clipboard paste
12761285
if (keyMatchers[Command.PASTE_CLIPBOARD](key)) {
12771286
// eslint-disable-next-line @typescript-eslint/no-floating-promises
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`<ContextSummaryDisplay /> > should not render empty parts 1`] = `
4-
" 1 open file (ctrl+g to view)
4+
" 1 open file (F4 to view)
55
"
66
`;
77

88
exports[`<ContextSummaryDisplay /> > should render on a single line on a wide screen 1`] = `
9-
" 1 open file (ctrl+g to view) · 1 GEMINI.md file · 1 MCP server · 1 skill
9+
" 1 open file (F4 to view) · 1 GEMINI.md file · 1 MCP server · 1 skill
1010
"
1111
`;
1212

1313
exports[`<ContextSummaryDisplay /> > should render on multiple lines on a narrow screen 1`] = `
14-
" 1 open file (ctrl+g to view) · 1 GEMINI.md file · 1 MCP server · 1 skill
14+
" 1 open file (F4 to view) · 1 GEMINI.md file · 1 MCP server · 1 skill
1515
"
1616
`;

packages/cli/src/ui/components/__snapshots__/ExitPlanModeDialog.test.tsx.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Files to Modify
2323
Approves plan but requires confirmation for each tool
2424
3. Type your feedback...
2525
26-
Enter to select · ↑/↓ to navigate · Ctrl+X to edit plan · Esc to cancel
26+
Enter to select · ↑/↓ to navigate · Ctrl+G to edit plan · Esc to cancel
2727
"
2828
`;
2929

@@ -50,7 +50,7 @@ Files to Modify
5050
Approves plan but requires confirmation for each tool
5151
3. Type your feedback...
5252
53-
Enter to select · ↑/↓ to navigate · Ctrl+X to edit plan · Esc to cancel
53+
Enter to select · ↑/↓ to navigate · Ctrl+G to edit plan · Esc to cancel
5454
"
5555
`;
5656

@@ -82,7 +82,7 @@ Implementation Steps
8282
Approves plan but requires confirmation for each tool
8383
3. Type your feedback...
8484
85-
Enter to select · ↑/↓ to navigate · Ctrl+X to edit plan · Esc to cancel
85+
Enter to select · ↑/↓ to navigate · Ctrl+G to edit plan · Esc to cancel
8686
"
8787
`;
8888

@@ -109,7 +109,7 @@ Files to Modify
109109
Approves plan but requires confirmation for each tool
110110
3. Type your feedback...
111111
112-
Enter to select · ↑/↓ to navigate · Ctrl+X to edit plan · Esc to cancel
112+
Enter to select · ↑/↓ to navigate · Ctrl+G to edit plan · Esc to cancel
113113
"
114114
`;
115115

@@ -136,7 +136,7 @@ Files to Modify
136136
Approves plan but requires confirmation for each tool
137137
3. Type your feedback...
138138
139-
Enter to select · ↑/↓ to navigate · Ctrl+X to edit plan · Esc to cancel
139+
Enter to select · ↑/↓ to navigate · Ctrl+G to edit plan · Esc to cancel
140140
"
141141
`;
142142

@@ -163,7 +163,7 @@ Files to Modify
163163
Approves plan but requires confirmation for each tool
164164
3. Type your feedback...
165165
166-
Enter to select · ↑/↓ to navigate · Ctrl+X to edit plan · Esc to cancel
166+
Enter to select · ↑/↓ to navigate · Ctrl+G to edit plan · Esc to cancel
167167
"
168168
`;
169169

@@ -216,7 +216,7 @@ Testing Strategy
216216
Approves plan but requires confirmation for each tool
217217
3. Type your feedback...
218218
219-
Enter to select · ↑/↓ to navigate · Ctrl+X to edit plan · Esc to cancel
219+
Enter to select · ↑/↓ to navigate · Ctrl+G to edit plan · Esc to cancel
220220
"
221221
`;
222222

@@ -243,6 +243,6 @@ Files to Modify
243243
Approves plan but requires confirmation for each tool
244244
3. Type your feedback...
245245
246-
Enter to select · ↑/↓ to navigate · Ctrl+X to edit plan · Esc to cancel
246+
Enter to select · ↑/↓ to navigate · Ctrl+G to edit plan · Esc to cancel
247247
"
248248
`;

packages/cli/src/ui/components/__snapshots__/ShortcutsHelp.test.tsx.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ exports[`ShortcutsHelp > renders correctly in 'narrow' mode on 'linux' 1`] = `
1212
Ctrl+V paste images
1313
Alt+M raw markdown mode
1414
Ctrl+R reverse-search history
15-
Ctrl+X open external editor
15+
Ctrl+G open external editor
1616
"
1717
`;
1818

@@ -28,7 +28,7 @@ exports[`ShortcutsHelp > renders correctly in 'narrow' mode on 'mac' 1`] = `
2828
Ctrl+V paste images
2929
Option+M raw markdown mode
3030
Ctrl+R reverse-search history
31-
Ctrl+X open external editor
31+
Ctrl+G open external editor
3232
"
3333
`;
3434

@@ -37,7 +37,7 @@ exports[`ShortcutsHelp > renders correctly in 'wide' mode on 'linux' 1`] = `
3737
Shortcuts See /help for more
3838
! shell mode Shift+Tab cycle mode Ctrl+V paste images
3939
@ select file or folder Ctrl+Y YOLO mode Alt+M raw markdown mode
40-
Double Esc clear & rewind Ctrl+R reverse-search history Ctrl+X open external editor
40+
Double Esc clear & rewind Ctrl+R reverse-search history Ctrl+G open external editor
4141
Tab focus UI
4242
"
4343
`;
@@ -47,7 +47,7 @@ exports[`ShortcutsHelp > renders correctly in 'wide' mode on 'mac' 1`] = `
4747
Shortcuts See /help for more
4848
! shell mode Shift+Tab cycle mode Ctrl+V paste images
4949
@ select file or folder Ctrl+Y YOLO mode Option+M raw markdown mode
50-
Double Esc clear & rewind Ctrl+R reverse-search history Ctrl+X open external editor
50+
Double Esc clear & rewind Ctrl+R reverse-search history Ctrl+G open external editor
5151
Tab focus UI
5252
"
5353
`;

packages/cli/src/ui/components/__snapshots__/ToolConfirmationQueue.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ exports[`ToolConfirmationQueue > renders ExitPlanMode tool confirmation with Suc
191191
│ Approves plan but requires confirmation for each tool │
192192
│ 3. Type your feedback... │
193193
│ │
194-
│ Enter to select · ↑/↓ to navigate · Ctrl+X to edit plan · Esc to cancel │
194+
│ Enter to select · ↑/↓ to navigate · Ctrl+G to edit plan · Esc to cancel │
195195
╰──────────────────────────────────────────────────────────────────────────────╯
196196
"
197197
`;

0 commit comments

Comments
 (0)