Fix cluster of bugs in the settings dialog. (#17628)

This commit is contained in:
Jacob Richman
2026-01-27 08:55:35 -08:00
committed by GitHub
parent e5145ab60d
commit 6be42be575
3 changed files with 185 additions and 69 deletions

View File

@@ -307,6 +307,26 @@ describe('SettingsDialog', () => {
// Use snapshot to capture visual layout including indicators
expect(output).toMatchSnapshot();
});
it('should use almost full height of the window but no more when the window height is 25 rows', async () => {
const settings = createMockSettings();
const onSelect = vi.fn();
// Render with a fixed height of 25 rows
const { lastFrame } = renderDialog(settings, onSelect, {
availableTerminalHeight: 25,
});
// Wait for the dialog to render
await waitFor(() => {
const output = lastFrame();
expect(output).toBeDefined();
const lines = output!.split('\n');
expect(lines.length).toBeGreaterThanOrEqual(24);
expect(lines.length).toBeLessThanOrEqual(25);
});
});
});
describe('Setting Descriptions', () => {
@@ -1072,6 +1092,87 @@ describe('SettingsDialog', () => {
});
});
describe('Restart and Search Conflict Regression', () => {
it('should prioritize restart request over search text box when showRestartPrompt is true', async () => {
vi.mocked(getSettingsSchema).mockReturnValue(TOOLS_SHELL_FAKE_SCHEMA);
const settings = createMockSettings();
const onRestartRequest = vi.fn();
const { stdin, lastFrame, unmount } = renderDialog(settings, vi.fn(), {
onRestartRequest,
});
// Wait for initial render
await waitFor(() => expect(lastFrame()).toContain('Show Color'));
// Navigate to "Enable Interactive Shell" (second item in TOOLS_SHELL_FAKE_SCHEMA)
act(() => {
stdin.write(TerminalKeys.DOWN_ARROW);
});
// Wait for navigation to complete
await waitFor(() =>
expect(lastFrame()).toContain('● Enable Interactive Shell'),
);
// Toggle it to trigger restart required
act(() => {
stdin.write(TerminalKeys.ENTER);
});
await waitFor(() => {
expect(lastFrame()).toContain(
'To see changes, Gemini CLI must be restarted',
);
});
// Press 'r' - it should call onRestartRequest, NOT be handled by search
act(() => {
stdin.write('r');
});
await waitFor(() => {
expect(onRestartRequest).toHaveBeenCalled();
});
unmount();
});
it('should hide search box when showRestartPrompt is true', async () => {
vi.mocked(getSettingsSchema).mockReturnValue(TOOLS_SHELL_FAKE_SCHEMA);
const settings = createMockSettings();
const { stdin, lastFrame, unmount } = renderDialog(settings, vi.fn());
// Search box should be visible initially (searchPlaceholder)
expect(lastFrame()).toContain('Search to filter');
// Navigate to "Enable Interactive Shell" and toggle it
act(() => {
stdin.write(TerminalKeys.DOWN_ARROW);
});
await waitFor(() =>
expect(lastFrame()).toContain('● Enable Interactive Shell'),
);
act(() => {
stdin.write(TerminalKeys.ENTER);
});
await waitFor(() => {
expect(lastFrame()).toContain(
'To see changes, Gemini CLI must be restarted',
);
});
// Search box should now be hidden
expect(lastFrame()).not.toContain('Search to filter');
unmount();
});
});
describe('String Settings Editing', () => {
it('should allow editing and committing a string setting', async () => {
let settings = createMockSettings({ 'a.string.setting': 'initial' });