Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/src/ui/auth/ApiAuthDialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('ApiAuthDialog', () => {

it.each([
{
keyName: 'return',
keyName: 'enter',
sequence: '\r',
expectedCall: onSubmit,
args: ['submitted-key'],
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/ui/components/ConfigExtensionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export const ConfigExtensionDialog: React.FC<ConfigExtensionDialogProps> = ({
useKeypress(
(key: Key) => {
if (state.type === 'ASK_CONFIRMATION') {
if (key.name === 'y' || key.name === 'return') {
if (key.name === 'y' || key.name === 'enter') {
state.resolve(true);
return true;
}
Expand All @@ -220,7 +220,7 @@ export const ConfigExtensionDialog: React.FC<ConfigExtensionDialogProps> = ({
}
}
if (state.type === 'DONE' || state.type === 'ERROR') {
if (key.name === 'return' || key.name === 'escape') {
if (key.name === 'enter' || key.name === 'escape') {
onClose();
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/ui/components/InputPrompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
if (targetIndex < completion.suggestions.length) {
const suggestion = completion.suggestions[targetIndex];

const isEnterKey = key.name === 'return' && !key.ctrl;
const isEnterKey = key.name === 'enter' && !key.ctrl;

if (isEnterKey && shellModeActive) {
if (hasUserNavigatedSuggestions.current) {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/ui/components/SessionBrowser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ describe('SessionBrowser component', () => {
await waitUntilReady();

// Press Enter.
triggerKey({ name: 'return', sequence: '\r' });
triggerKey({ name: 'enter', sequence: '\r' });
await waitUntilReady();

expect(onResumeSession).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -367,7 +367,7 @@ describe('SessionBrowser component', () => {
await waitUntilReady();

// Active selection is at 0 (current session).
triggerKey({ name: 'return', sequence: '\r' });
triggerKey({ name: 'enter', sequence: '\r' });
await waitUntilReady();
expect(onResumeSession).not.toHaveBeenCalled();

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/ui/components/SessionBrowser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ export const useSessionBrowserInput = (

// Handling regardless of search mode.
if (
key.name === 'return' &&
key.name === 'enter' &&
state.filteredAndSortedSessions[state.activeIndex]
) {
const selectedSession =
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/ui/components/shared/TextInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ describe('TextInput', () => {

await act(async () => {
keypressHandler({
name: 'return',
name: 'enter',
shift: false,
alt: false,
ctrl: false,
Expand All @@ -314,7 +314,7 @@ describe('TextInput', () => {

await act(async () => {
keypressHandler({
name: 'return',
name: 'enter',
shift: false,
alt: false,
ctrl: false,
Expand All @@ -339,7 +339,7 @@ describe('TextInput', () => {

await act(async () => {
keypressHandler({
name: 'return',
name: 'enter',
shift: false,
alt: false,
ctrl: false,
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/ui/components/shared/text-buffer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,7 @@ describe('useTextBuffer', () => {
const { result } = renderHook(() => useTextBuffer({ viewport }));
act(() => {
result.current.handleInput({
name: 'return',
name: 'enter',
shift: false,
alt: false,
ctrl: false,
Expand Down Expand Up @@ -1789,7 +1789,7 @@ describe('useTextBuffer', () => {
const { result } = renderHook(() => useTextBuffer({ viewport }));
act(() => {
result.current.handleInput({
name: 'return',
name: 'enter',
shift: true,
alt: false,
ctrl: false,
Expand Down Expand Up @@ -2290,7 +2290,7 @@ Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots
);
act(() => {
result.current.handleInput({
name: 'return',
name: 'enter',
shift: false,
alt: false,
ctrl: false,
Expand Down
18 changes: 9 additions & 9 deletions packages/cli/src/ui/contexts/KeypressContext.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe('KeypressContext', () => {

expect(keyHandler).toHaveBeenCalledWith(
expect.objectContaining({
name: 'return',
name: 'enter',
shift: false,
ctrl: false,
cmd: false,
Expand All @@ -115,7 +115,7 @@ describe('KeypressContext', () => {

expect(keyHandler).toHaveBeenCalledWith(
expect.objectContaining({
name: 'return',
name: 'enter',
shift: true,
ctrl: false,
cmd: false,
Expand Down Expand Up @@ -148,7 +148,7 @@ describe('KeypressContext', () => {

expect(keyHandler).toHaveBeenCalledWith(
expect.objectContaining({
name: 'return',
name: 'enter',
...expected,
}),
);
Expand Down Expand Up @@ -177,7 +177,7 @@ describe('KeypressContext', () => {

expect(keyHandler).toHaveBeenCalledWith(
expect.objectContaining({
name: 'return',
name: 'enter',
shift: false,
alt: true,
ctrl: false,
Expand Down Expand Up @@ -216,7 +216,7 @@ describe('KeypressContext', () => {

expect(keyHandler).toHaveBeenLastCalledWith(
expect.objectContaining({
name: 'return',
name: 'enter',
sequence: '\r',
insertable: true,
shift: true,
Expand All @@ -238,7 +238,7 @@ describe('KeypressContext', () => {

expect(keyHandler).toHaveBeenLastCalledWith(
expect.objectContaining({
name: 'return',
name: 'enter',
shift: false,
alt: false,
ctrl: false,
Expand Down Expand Up @@ -638,8 +638,8 @@ describe('KeypressContext', () => {
describe('Parameterized functional keys', () => {
it.each([
// ModifyOtherKeys
{ sequence: `\x1b[27;2;13~`, expected: { name: 'return', shift: true } },
{ sequence: `\x1b[27;5;13~`, expected: { name: 'return', ctrl: true } },
{ sequence: `\x1b[27;2;13~`, expected: { name: 'enter', shift: true } },
{ sequence: `\x1b[27;5;13~`, expected: { name: 'enter', ctrl: true } },
{ sequence: `\x1b[27;5;9~`, expected: { name: 'tab', ctrl: true } },
{
sequence: `\x1b[27;6;9~`,
Expand Down Expand Up @@ -1124,7 +1124,7 @@ describe('KeypressContext', () => {
expect(keyHandler).toHaveBeenNthCalledWith(
1,
expect.objectContaining({
name: 'return',
name: 'enter',
}),
);
expect(keyHandler).toHaveBeenNthCalledWith(
Expand Down
14 changes: 7 additions & 7 deletions packages/cli/src/ui/contexts/KeypressContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ const KEY_INFO_MAP: Record<
'[[5~': { name: 'pageup' },
'[[6~': { name: 'pagedown' },
'[9u': { name: 'tab' },
'[13u': { name: 'return' },
'[13u': { name: 'enter' },
'[27u': { name: 'escape' },
'[32u': { name: 'space' },
'[127u': { name: 'backspace' },
'[57414u': { name: 'return' }, // Numpad Enter
'[57414u': { name: 'enter' }, // Numpad Enter
'[a': { name: 'up', shift: true },
'[b': { name: 'down', shift: true },
'[c': { name: 'right', shift: true },
Expand Down Expand Up @@ -186,10 +186,10 @@ function bufferFastReturn(keypressHandler: KeypressHandler): KeypressHandler {
let lastKeyTime = 0;
return (key: Key) => {
const now = Date.now();
if (key.name === 'return' && now - lastKeyTime <= FAST_RETURN_TIMEOUT) {
if (key.name === 'enter' && now - lastKeyTime <= FAST_RETURN_TIMEOUT) {
keypressHandler({
...key,
name: 'return',
name: 'enter',
shift: true, // to make it a newline, not a submission
alt: false,
ctrl: false,
Expand Down Expand Up @@ -232,7 +232,7 @@ function bufferBackslashEnter(

if (nextKey === null) {
keypressHandler(key);
} else if (nextKey.name === 'return') {
} else if (nextKey.name === 'enter') {
keypressHandler({
...nextKey,
shift: true,
Expand Down Expand Up @@ -582,11 +582,11 @@ function* emitKeys(
}
} else if (ch === '\r') {
// carriage return
name = 'return';
name = 'enter';
alt = escaped;
} else if (escaped && ch === '\n') {
// Alt+Enter (linefeed), should be consistent with carriage return
name = 'return';
name = 'enter';
alt = escaped;
} else if (ch === '\t') {
// tab
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/ui/hooks/useKeypress.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe(`useKeypress`, () => {

it('should correctly identify alt+enter (meta key)', () => {
renderKeypressHook(true);
const key = { name: 'return', sequence: '\x1B\r' };
const key = { name: 'enter', sequence: '\x1B\r' };
act(() => stdin.write(key.sequence));
expect(onKeypress).toHaveBeenCalledWith(
expect.objectContaining({
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/src/ui/hooks/useSelectionList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ describe('useSelectionList', () => {
initialIndex: 2,
onSelect: mockOnSelect,
});
pressKey('return');
pressKey('enter');
await waitUntilReady();
expect(mockOnSelect).toHaveBeenCalledTimes(1);
expect(mockOnSelect).toHaveBeenCalledWith('C');
Expand All @@ -371,7 +371,7 @@ describe('useSelectionList', () => {
act(() => result.current.setActiveIndex(1));
await waitUntilReady();

pressKey('return');
pressKey('enter');
await waitUntilReady();
expect(mockOnSelect).not.toHaveBeenCalled();
});
Expand Down Expand Up @@ -415,7 +415,7 @@ describe('useSelectionList', () => {
await waitUntilReady();
// 3. Press Enter. Should select D.
act(() => {
press('return');
press('enter');
});
await waitUntilReady();

Expand Down Expand Up @@ -459,7 +459,7 @@ describe('useSelectionList', () => {
// All presses happen in same render cycle - React batches the state updates
press('down'); // Should move 0 (A) -> 2 (C)
press('down'); // Should move 2 (C) -> 3 (D)
press('return'); // Should select D
press('enter'); // Should select D
});
await waitUntilReady();

Expand Down Expand Up @@ -759,7 +759,7 @@ describe('useSelectionList', () => {
pressNumber('1');
await waitUntilReady();

pressKey('return');
pressKey('enter');
await waitUntilReady();
expect(mockOnSelect).toHaveBeenCalledTimes(1);

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/ui/hooks/vim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ export function useVim(buffer: TextBuffer, onSubmit?: (value: string) => void) {
// In INSERT mode, let InputPrompt handle completion keys and special commands
if (
normalizedKey.name === 'tab' ||
(normalizedKey.name === 'return' && !normalizedKey.ctrl) ||
(normalizedKey.name === 'enter' && !normalizedKey.ctrl) ||
normalizedKey.name === 'up' ||
normalizedKey.name === 'down' ||
(normalizedKey.ctrl && normalizedKey.name === 'r')
Expand Down Expand Up @@ -424,7 +424,7 @@ export function useVim(buffer: TextBuffer, onSubmit?: (value: string) => void) {

// Special handling for Enter key to allow command submission (lower priority than completion)
if (
normalizedKey.name === 'return' &&
normalizedKey.name === 'enter' &&
!normalizedKey.alt &&
!normalizedKey.ctrl &&
!normalizedKey.cmd
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/ui/key/keyBindings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ describe('KeyBinding', () => {
});

it('should handle named keys with modifiers', () => {
const binding = new KeyBinding('ctrl+return');
expect(binding.key).toBe('return');
const binding = new KeyBinding('ctrl+enter');
expect(binding.key).toBe('enter');
expect(binding.ctrl).toBe(true);
});

Expand Down
25 changes: 10 additions & 15 deletions packages/cli/src/ui/key/keyBindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,9 @@ export class KeyBinding {
'numpad_subtract',
'numpad_decimal',
'numpad_divide',
// Gemini CLI legacy/internal support
'return',
]);

/** The key name (e.g., 'a', 'return', 'tab', 'escape') */
/** The key name (e.g., 'a', 'enter', 'tab', 'escape') */
readonly key: string;
readonly shift: boolean;
readonly alt: boolean;
Expand Down Expand Up @@ -238,7 +236,7 @@ export type KeyBindingConfig = {
*/
export const defaultKeyBindings: KeyBindingConfig = {
// Basic Controls
[Command.RETURN]: [new KeyBinding('return')],
[Command.RETURN]: [new KeyBinding('enter')],
[Command.ESCAPE]: [new KeyBinding('escape'), new KeyBinding('ctrl+[')],
[Command.QUIT]: [new KeyBinding('ctrl+c')],
[Command.EXIT]: [new KeyBinding('ctrl+d')],
Expand Down Expand Up @@ -308,7 +306,7 @@ export const defaultKeyBindings: KeyBindingConfig = {
[Command.HISTORY_UP]: [new KeyBinding('ctrl+p')],
[Command.HISTORY_DOWN]: [new KeyBinding('ctrl+n')],
[Command.REVERSE_SEARCH]: [new KeyBinding('ctrl+r')],
[Command.SUBMIT_REVERSE_SEARCH]: [new KeyBinding('return')],
[Command.SUBMIT_REVERSE_SEARCH]: [new KeyBinding('enter')],
[Command.ACCEPT_SUGGESTION_REVERSE_SEARCH]: [new KeyBinding('tab')],

// Navigation
Expand All @@ -325,23 +323,20 @@ export const defaultKeyBindings: KeyBindingConfig = {
[Command.DIALOG_PREV]: [new KeyBinding('shift+tab')],

// Suggestions & Completions
[Command.ACCEPT_SUGGESTION]: [
new KeyBinding('tab'),
new KeyBinding('return'),
],
[Command.ACCEPT_SUGGESTION]: [new KeyBinding('tab'), new KeyBinding('enter')],
[Command.COMPLETION_UP]: [new KeyBinding('up'), new KeyBinding('ctrl+p')],
[Command.COMPLETION_DOWN]: [new KeyBinding('down'), new KeyBinding('ctrl+n')],
[Command.EXPAND_SUGGESTION]: [new KeyBinding('right')],
[Command.COLLAPSE_SUGGESTION]: [new KeyBinding('left')],

// Text Input
// Must also exclude shift to allow shift+enter for newline
[Command.SUBMIT]: [new KeyBinding('return')],
[Command.SUBMIT]: [new KeyBinding('enter')],
[Command.NEWLINE]: [
new KeyBinding('ctrl+return'),
new KeyBinding('cmd+return'),
new KeyBinding('alt+return'),
new KeyBinding('shift+return'),
new KeyBinding('ctrl+enter'),
new KeyBinding('cmd+enter'),
new KeyBinding('alt+enter'),
new KeyBinding('shift+enter'),
new KeyBinding('ctrl+j'),
],
[Command.OPEN_EXTERNAL_EDITOR]: [new KeyBinding('ctrl+x')],
Expand All @@ -366,7 +361,7 @@ export const defaultKeyBindings: KeyBindingConfig = {
[Command.UNFOCUS_BACKGROUND_SHELL_LIST]: [new KeyBinding('tab')],
[Command.SHOW_BACKGROUND_SHELL_UNFOCUS_WARNING]: [new KeyBinding('tab')],
[Command.SHOW_SHELL_INPUT_UNFOCUS_WARNING]: [new KeyBinding('tab')],
[Command.BACKGROUND_SHELL_SELECT]: [new KeyBinding('return')],
[Command.BACKGROUND_SHELL_SELECT]: [new KeyBinding('enter')],
[Command.BACKGROUND_SHELL_ESCAPE]: [new KeyBinding('escape')],
[Command.SHOW_MORE_LINES]: [new KeyBinding('ctrl+o')],
[Command.EXPAND_PASTE]: [new KeyBinding('ctrl+o')],
Expand Down
Loading
Loading