Skip to content

Commit 880cf12

Browse files
scidominoDavidAPierce
authored andcommitted
refactor(ui): unify keybinding infrastructure and support string initialization (#21776)
1 parent 5a1227a commit 880cf12

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+523
-410
lines changed

.gemini/commands/strict-development-rules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Gemini CLI project.
107107
set.
108108
- **Logging**: Use `debugLogger` for rethrown errors to avoid duplicate logging.
109109
- **Keyboard Shortcuts**: Define all new keyboard shortcuts in
110-
`packages/cli/src/config/keyBindings.ts` and document them in
110+
`packages/cli/src/ui/key/keyBindings.ts` and document them in
111111
`docs/cli/keyboard-shortcuts.md`. Be careful of keybindings that require the
112112
`Meta` key, as only certain meta key shortcuts are supported on Mac. Avoid
113113
function keys and shortcuts commonly bound in VSCode.

docs/reference/keyboard-shortcuts.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,13 @@ available combinations.
5555

5656
#### History & Search
5757

58-
| Action | Keys |
59-
| -------------------------------------------- | ------------ |
60-
| Show the previous entry in history. | `Ctrl+P` |
61-
| Show the next entry in history. | `Ctrl+N` |
62-
| Start reverse search through history. | `Ctrl+R` |
63-
| Submit the selected reverse-search match. | `Enter` |
64-
| Accept a suggestion while reverse searching. | `Tab` |
65-
| Browse and rewind previous interactions. | `Double Esc` |
58+
| Action | Keys |
59+
| -------------------------------------------- | -------- |
60+
| Show the previous entry in history. | `Ctrl+P` |
61+
| Show the next entry in history. | `Ctrl+N` |
62+
| Start reverse search through history. | `Ctrl+R` |
63+
| Submit the selected reverse-search match. | `Enter` |
64+
| Accept a suggestion while reverse searching. | `Tab` |
6665

6766
#### Navigation
6867

packages/cli/src/config/keyBindings.test.ts

Lines changed: 0 additions & 93 deletions
This file was deleted.

packages/cli/src/ui/AppContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ import { type InitializationResult } from '../core/initializer.js';
119119
import { useFocus } from './hooks/useFocus.js';
120120
import { useKeypress, type Key } from './hooks/useKeypress.js';
121121
import { KeypressPriority } from './contexts/KeypressContext.js';
122-
import { Command } from './keyMatchers.js';
122+
import { Command } from './key/keyMatchers.js';
123123
import { useLoadingIndicator } from './hooks/useLoadingIndicator.js';
124124
import { useShellInactivityStatus } from './hooks/useShellInactivityStatus.js';
125125
import { useFolderTrust } from './hooks/useFolderTrust.js';

packages/cli/src/ui/auth/ApiAuthDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { useTextBuffer } from '../components/shared/text-buffer.js';
1313
import { useUIState } from '../contexts/UIStateContext.js';
1414
import { clearApiKey, debugLogger } from '@google/gemini-cli-core';
1515
import { useKeypress } from '../hooks/useKeypress.js';
16-
import { Command } from '../keyMatchers.js';
16+
import { Command } from '../key/keyMatchers.js';
1717
import { useKeyMatchers } from '../hooks/useKeyMatchers.js';
1818

1919
interface ApiAuthDialogProps {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Box, Text } from 'ink';
88
import { theme } from '../semantic-colors.js';
99
import { useKeypress } from '../hooks/useKeypress.js';
1010
import { useUIActions } from '../contexts/UIActionsContext.js';
11-
import { Command } from '../keyMatchers.js';
11+
import { Command } from '../key/keyMatchers.js';
1212
import { useKeyMatchers } from '../hooks/useKeyMatchers.js';
1313

1414
export const AdminSettingsChangedDialog = () => {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import type React from 'react';
88
import { Box, Text } from 'ink';
99
import { theme } from '../semantic-colors.js';
1010
import { ApprovalMode } from '@google/gemini-cli-core';
11-
import { formatCommand } from '../utils/keybindingUtils.js';
12-
import { Command } from '../../config/keyBindings.js';
11+
import { formatCommand } from '../key/keybindingUtils.js';
12+
import { Command } from '../key/keyBindings.js';
1313

1414
interface ApprovalModeIndicatorProps {
1515
approvalMode: ApprovalMode;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import { BaseSelectionList } from './shared/BaseSelectionList.js';
2020
import type { SelectionListItem } from '../hooks/useSelectionList.js';
2121
import { TabHeader, type Tab } from './shared/TabHeader.js';
2222
import { useKeypress, type Key } from '../hooks/useKeypress.js';
23-
import { Command } from '../keyMatchers.js';
23+
import { Command } from '../key/keyMatchers.js';
2424
import { checkExhaustive } from '@google/gemini-cli-core';
2525
import { TextInput } from './shared/TextInput.js';
26-
import { formatCommand } from '../utils/keybindingUtils.js';
26+
import { formatCommand } from '../key/keybindingUtils.js';
2727
import {
2828
useTextBuffer,
2929
expandPastePlaceholders,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import {
1616
} from '@google/gemini-cli-core';
1717
import { cpLen, cpSlice, getCachedStringWidth } from '../utils/textUtils.js';
1818
import { type BackgroundShell } from '../hooks/shellCommandProcessor.js';
19-
import { Command } from '../keyMatchers.js';
19+
import { Command } from '../key/keyMatchers.js';
2020
import { useKeypress } from '../hooks/useKeypress.js';
21-
import { formatCommand } from '../utils/keybindingUtils.js';
21+
import { formatCommand } from '../key/keybindingUtils.js';
2222
import {
2323
ScrollableList,
2424
type ScrollableListRef,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { renderWithProviders } from '../../test-utils/render.js';
1010
import { waitFor } from '../../test-utils/async.js';
1111
import { ExitPlanModeDialog } from './ExitPlanModeDialog.js';
1212
import { useKeypress } from '../hooks/useKeypress.js';
13-
import { Command } from '../keyMatchers.js';
13+
import { Command } from '../key/keyMatchers.js';
1414
import {
1515
ApprovalMode,
1616
validatePlanContent,

0 commit comments

Comments
 (0)