mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-13 23:01:09 -07:00
feat(ui): dynamically generate all keybinding hints (#21346)
This commit is contained in:
committed by
GitHub
parent
4669148a4c
commit
6d607a5953
@@ -29,6 +29,8 @@ import {
|
||||
cleanupTerminalOnExit,
|
||||
terminalCapabilityManager,
|
||||
} from '../utils/terminalCapabilityManager.js';
|
||||
import { formatCommand } from '../utils/keybindingUtils.js';
|
||||
import { Command } from '../../config/keyBindings.js';
|
||||
|
||||
vi.mock('@google/gemini-cli-core', async () => {
|
||||
const actual = await vi.importActual('@google/gemini-cli-core');
|
||||
@@ -99,8 +101,12 @@ describe('useSuspend', () => {
|
||||
act(() => {
|
||||
result.current.handleSuspend();
|
||||
});
|
||||
|
||||
const suspendKey = formatCommand(Command.SUSPEND_APP);
|
||||
const undoKey = formatCommand(Command.UNDO);
|
||||
|
||||
expect(handleWarning).toHaveBeenCalledWith(
|
||||
'Press Ctrl+Z again to suspend. Undo has moved to Cmd + Z or Alt/Opt + Z.',
|
||||
`Press ${suspendKey} again to suspend. Undo has moved to ${undoKey}.`,
|
||||
);
|
||||
|
||||
act(() => {
|
||||
@@ -190,8 +196,9 @@ describe('useSuspend', () => {
|
||||
result.current.handleSuspend();
|
||||
});
|
||||
|
||||
const suspendKey = formatCommand(Command.SUSPEND_APP);
|
||||
expect(handleWarning).toHaveBeenCalledWith(
|
||||
'Ctrl+Z suspend is not supported on Windows.',
|
||||
`${suspendKey} suspend is not supported on Windows.`,
|
||||
);
|
||||
expect(killSpy).not.toHaveBeenCalled();
|
||||
expect(cleanupTerminalOnExit).not.toHaveBeenCalled();
|
||||
|
||||
@@ -20,6 +20,8 @@ import {
|
||||
terminalCapabilityManager,
|
||||
} from '../utils/terminalCapabilityManager.js';
|
||||
import { WARNING_PROMPT_DURATION_MS } from '../constants.js';
|
||||
import { formatCommand } from '../utils/keybindingUtils.js';
|
||||
import { Command } from '../../config/keyBindings.js';
|
||||
|
||||
interface UseSuspendProps {
|
||||
handleWarning: (message: string) => void;
|
||||
@@ -59,10 +61,11 @@ export function useSuspend({
|
||||
clearTimeout(ctrlZTimerRef.current);
|
||||
ctrlZTimerRef.current = null;
|
||||
}
|
||||
const suspendKey = formatCommand(Command.SUSPEND_APP);
|
||||
if (ctrlZPressCount > 1) {
|
||||
setCtrlZPressCount(0);
|
||||
if (process.platform === 'win32') {
|
||||
handleWarning('Ctrl+Z suspend is not supported on Windows.');
|
||||
handleWarning(`${suspendKey} suspend is not supported on Windows.`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -130,8 +133,9 @@ export function useSuspend({
|
||||
|
||||
process.kill(0, 'SIGTSTP');
|
||||
} else if (ctrlZPressCount > 0) {
|
||||
const undoKey = formatCommand(Command.UNDO);
|
||||
handleWarning(
|
||||
'Press Ctrl+Z again to suspend. Undo has moved to Cmd + Z or Alt/Opt + Z.',
|
||||
`Press ${suspendKey} again to suspend. Undo has moved to ${undoKey}.`,
|
||||
);
|
||||
ctrlZTimerRef.current = setTimeout(() => {
|
||||
setCtrlZPressCount(0);
|
||||
|
||||
Reference in New Issue
Block a user