mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-16 00:51:25 -07:00
fix(cli): replace hardcoded keybinding strings with dynamic formatters (#21159)
This commit is contained in:
committed by
GitHub
parent
f20e45175e
commit
1c3c7a343f
@@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
import {
|
||||
ApprovalMode,
|
||||
PolicyDecision,
|
||||
@@ -29,6 +29,10 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
|
||||
});
|
||||
|
||||
describe('Policy Engine Integration Tests', () => {
|
||||
beforeEach(() => vi.stubEnv('GEMINI_SYSTEM_MD', ''));
|
||||
|
||||
afterEach(() => vi.unstubAllEnvs());
|
||||
|
||||
describe('Policy configuration produces valid PolicyEngine config', () => {
|
||||
it('should create a working PolicyEngine from basic settings', async () => {
|
||||
const settings: Settings = {
|
||||
|
||||
@@ -37,6 +37,7 @@ import {
|
||||
import type { Key } from '../hooks/useKeypress.js';
|
||||
import { useKeypress } from '../hooks/useKeypress.js';
|
||||
import { keyMatchers, Command } from '../keyMatchers.js';
|
||||
import { formatCommand } from '../utils/keybindingUtils.js';
|
||||
import type { CommandContext, SlashCommand } from '../commands/types.js';
|
||||
import type { Config } from '@google/gemini-cli-core';
|
||||
import { ApprovalMode, coreEvents, debugLogger } from '@google/gemini-cli-core';
|
||||
@@ -494,7 +495,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
||||
buffer.insert(textToInsert, { paste: true });
|
||||
if (isLargePaste(textToInsert)) {
|
||||
appEvents.emit(AppEvent.TransientMessage, {
|
||||
message: 'Press Ctrl+O to expand pasted text',
|
||||
message: `Press ${formatCommand(Command.EXPAND_PASTE)} to expand pasted text`,
|
||||
type: TransientMessageType.Hint,
|
||||
});
|
||||
}
|
||||
@@ -730,7 +731,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
||||
buffer.handleInput(key);
|
||||
if (key.sequence && isLargePaste(key.sequence)) {
|
||||
appEvents.emit(AppEvent.TransientMessage, {
|
||||
message: 'Press Ctrl+O to expand pasted text',
|
||||
message: `Press ${formatCommand(Command.EXPAND_PASTE)} to expand pasted text`,
|
||||
type: TransientMessageType.Hint,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
} from '../../utils/textUtils.js';
|
||||
import { useKeypress, type Key } from '../../hooks/useKeypress.js';
|
||||
import { keyMatchers, Command } from '../../keyMatchers.js';
|
||||
import { formatCommand } from '../../utils/keybindingUtils.js';
|
||||
|
||||
/**
|
||||
* Represents a single item in the settings dialog.
|
||||
@@ -625,7 +626,7 @@ export function BaseSettingsDialog({
|
||||
{/* Help text */}
|
||||
<Box marginX={1}>
|
||||
<Text color={theme.text.secondary}>
|
||||
(Use Enter to select, Ctrl+L to reset
|
||||
(Use Enter to select, {formatCommand(Command.CLEAR_SCREEN)} to reset
|
||||
{showScopeSelector ? ', Tab to change focus' : ''}, Esc to close)
|
||||
</Text>
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user