mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-14 07:10:34 -07:00
fix(ui): make tool confirmations take up entire terminal height (#22366)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -232,7 +232,7 @@ describe('ToolConfirmationMessage', () => {
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should render multiline shell scripts with correct newlines and syntax highlighting (SVG snapshot)', async () => {
|
||||
it('should render multiline shell scripts with correct newlines and syntax highlighting', async () => {
|
||||
const confirmationDetails: SerializableConfirmationDetails = {
|
||||
type: 'exec',
|
||||
title: 'Confirm Multiline Script',
|
||||
@@ -628,6 +628,83 @@ describe('ToolConfirmationMessage', () => {
|
||||
unmount();
|
||||
});
|
||||
|
||||
describe('height allocation and layout', () => {
|
||||
it('should expand to available height for large exec commands', async () => {
|
||||
let largeCommand = '';
|
||||
for (let i = 1; i <= 50; i++) {
|
||||
largeCommand += `echo "Line ${i}"\n`;
|
||||
}
|
||||
|
||||
const confirmationDetails: SerializableConfirmationDetails = {
|
||||
type: 'exec',
|
||||
title: 'Confirm Execution',
|
||||
command: largeCommand.trimEnd(),
|
||||
rootCommand: 'echo',
|
||||
rootCommands: ['echo'],
|
||||
};
|
||||
|
||||
const { waitUntilReady, lastFrame, generateSvg, unmount } =
|
||||
await renderWithProviders(
|
||||
<ToolConfirmationMessage
|
||||
callId="test-call-id"
|
||||
confirmationDetails={confirmationDetails}
|
||||
config={mockConfig}
|
||||
getPreferredEditor={vi.fn()}
|
||||
availableTerminalHeight={40}
|
||||
terminalWidth={80}
|
||||
/>,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
const outputLines = lastFrame().split('\n');
|
||||
// Should use the entire terminal height minus 1 line for the "Press Ctrl+O to show more lines" hint
|
||||
expect(outputLines.length).toBe(39);
|
||||
|
||||
await expect({ lastFrame, generateSvg }).toMatchSvgSnapshot();
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should expand to available height for large edit diffs', async () => {
|
||||
// Create a large diff string
|
||||
let largeDiff = '--- a/file.ts\n+++ b/file.ts\n@@ -1,10 +1,15 @@\n';
|
||||
for (let i = 1; i <= 20; i++) {
|
||||
largeDiff += `-const oldLine${i} = true;\n`;
|
||||
largeDiff += `+const newLine${i} = true;\n`;
|
||||
}
|
||||
|
||||
const confirmationDetails: SerializableConfirmationDetails = {
|
||||
type: 'edit',
|
||||
title: 'Confirm Edit',
|
||||
fileName: 'file.ts',
|
||||
filePath: '/file.ts',
|
||||
fileDiff: largeDiff,
|
||||
originalContent: 'old',
|
||||
newContent: 'new',
|
||||
isModifying: false,
|
||||
};
|
||||
|
||||
const { waitUntilReady, lastFrame, generateSvg, unmount } =
|
||||
await renderWithProviders(
|
||||
<ToolConfirmationMessage
|
||||
callId="test-call-id"
|
||||
confirmationDetails={confirmationDetails}
|
||||
config={mockConfig}
|
||||
getPreferredEditor={vi.fn()}
|
||||
availableTerminalHeight={40}
|
||||
terminalWidth={80}
|
||||
/>,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
const outputLines = lastFrame().split('\n');
|
||||
// Should use the entire terminal height minus 1 line for the "Press Ctrl+O to show more lines" hint
|
||||
expect(outputLines.length).toBe(39);
|
||||
|
||||
await expect({ lastFrame, generateSvg }).toMatchSvgSnapshot();
|
||||
unmount();
|
||||
});
|
||||
});
|
||||
|
||||
describe('ESCAPE key behavior', () => {
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers();
|
||||
|
||||
Reference in New Issue
Block a user