Add Esc-Esc to clear prompt when it's not empty (#17131)

This commit is contained in:
Adib234
2026-01-20 19:32:26 -05:00
committed by GitHub
parent 3b626e7c61
commit e1fd5be429
7 changed files with 82 additions and 12 deletions

View File

@@ -11,6 +11,7 @@ import { StatusDisplay } from './StatusDisplay.js';
import { UIStateContext, type UIState } from '../contexts/UIStateContext.js';
import { ConfigContext } from '../contexts/ConfigContext.js';
import { SettingsContext } from '../contexts/SettingsContext.js';
import type { TextBuffer } from './shared/text-buffer.js';
// Mock child components to simplify testing
vi.mock('./ContextSummaryDisplay.js', () => ({
@@ -23,8 +24,13 @@ vi.mock('./HookStatusDisplay.js', () => ({
HookStatusDisplay: () => <Text>Mock Hook Status Display</Text>,
}));
// Use a type that allows partial buffer for mocking purposes
type UIStateOverrides = Partial<Omit<UIState, 'buffer'>> & {
buffer?: Partial<TextBuffer>;
};
// Create mock context providers
const createMockUIState = (overrides: Partial<UIState> = {}): UIState =>
const createMockUIState = (overrides: UIStateOverrides = {}): UIState =>
({
ctrlCPressedOnce: false,
warningMessage: null,
@@ -35,6 +41,8 @@ const createMockUIState = (overrides: Partial<UIState> = {}): UIState =>
ideContextState: null,
geminiMdFileCount: 0,
contextFileNames: [],
buffer: { text: '' },
history: [{ id: 1, type: 'user', text: 'test' }],
...overrides,
}) as UIState;
@@ -147,9 +155,22 @@ describe('StatusDisplay', () => {
expect(lastFrame()).toMatchSnapshot();
});
it('renders Escape prompt', () => {
it('renders Escape prompt when buffer is empty', () => {
const uiState = createMockUIState({
showEscapePrompt: true,
buffer: { text: '' },
});
const { lastFrame } = renderStatusDisplay(
{ hideContextSummary: false },
uiState,
);
expect(lastFrame()).toMatchSnapshot();
});
it('renders Escape prompt when buffer is NOT empty', () => {
const uiState = createMockUIState({
showEscapePrompt: true,
buffer: { text: 'some text' },
});
const { lastFrame } = renderStatusDisplay(
{ hideContextSummary: false },