migrate yolo/auto-edit keybindings (#16457)

This commit is contained in:
Tommaso Sciortino
2026-01-12 14:50:32 -08:00
committed by GitHub
parent b8cc414d5b
commit 95d9a33996
4 changed files with 34 additions and 13 deletions
@@ -7,6 +7,7 @@
import { useState, useEffect } from 'react';
import { ApprovalMode, type Config } from '@google/gemini-cli-core';
import { useKeypress } from './useKeypress.js';
import { keyMatchers, Command } from '../keyMatchers.js';
import type { HistoryItemWithoutId } from '../types.js';
import { MessageType } from '../types.js';
@@ -33,7 +34,7 @@ export function useAutoAcceptIndicator({
(key) => {
let nextApprovalMode: ApprovalMode | undefined;
if (key.ctrl && key.name === 'y') {
if (keyMatchers[Command.TOGGLE_YOLO](key)) {
if (
config.isYoloModeDisabled() &&
config.getApprovalMode() !== ApprovalMode.YOLO
@@ -53,7 +54,7 @@ export function useAutoAcceptIndicator({
config.getApprovalMode() === ApprovalMode.YOLO
? ApprovalMode.DEFAULT
: ApprovalMode.YOLO;
} else if (key.shift && key.name === 'tab') {
} else if (keyMatchers[Command.TOGGLE_AUTO_EDIT](key)) {
nextApprovalMode =
config.getApprovalMode() === ApprovalMode.AUTO_EDIT
? ApprovalMode.DEFAULT
+12
View File
@@ -77,6 +77,8 @@ describe('keyMatchers', () => {
key.name === 'tab',
[Command.TOGGLE_SHELL_INPUT_FOCUS]: (key: Key) =>
key.ctrl && key.name === 'f',
[Command.TOGGLE_YOLO]: (key: Key) => key.ctrl && key.name === 'y',
[Command.TOGGLE_AUTO_EDIT]: (key: Key) => key.shift && key.name === 'tab',
[Command.EXPAND_SUGGESTION]: (key: Key) => key.name === 'right',
[Command.COLLAPSE_SUGGESTION]: (key: Key) => key.name === 'left',
};
@@ -336,6 +338,16 @@ describe('keyMatchers', () => {
positive: [createKey('f', { ctrl: true })],
negative: [createKey('f')],
},
{
command: Command.TOGGLE_YOLO,
positive: [createKey('y', { ctrl: true })],
negative: [createKey('y'), createKey('y', { meta: true })],
},
{
command: Command.TOGGLE_AUTO_EDIT,
positive: [createKey('tab', { shift: true })],
negative: [createKey('tab')],
},
];
describe('Data-driven key binding matches original logic', () => {