mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-09 04:41:19 -07:00
- fix(ui): implement border stitching in history pushing to eliminate gaps
- test(ui): update snapshots and test assertions for new layout
- style(ui): wrap dense tool payloads with vertical margins
- Adds margins above and below dense payload content to allow compact output to consume a single line until expanded.
- fix(ui): unify spacing logic and border handling for tool groups
- Corrects transitions between compact and standard tools to not add redundant empty lines and ensures history stitching respects boundaries.
- fix(ui): ensure top border is rendered within completed history for standard tool output when following compact tool output
- Addresses an issue where non-compact tools pushed to history at the end of a batch (via onComplete) were missing their top border and proper margin if they followed compact tools already pushed to history.
- The fix updates the onComplete callback in useGeminiStream.ts to be transition-aware. It now explicitly detects when a final push starts with a non-compact tool following a compact tool from the same batch, forcing borderTop: true in that case.
- Previously, the logic relied solely on isFirstToolInGroupRef, which would be false if any earlier tools in the batch had already been pushed, causing the final non-compact tools to incorrectly inherit a borderless state from the preceding compact tools.
----------------------
Note: ToolGroupMessage.tsx and ToolGroupMessage.compact.test.tsx contain 'any' usage/unsafe assertions to be addressed before PR.
136 lines
3.6 KiB
TypeScript
136 lines
3.6 KiB
TypeScript
|
|
import { renderWithProviders } from '../../../test-utils/render.js';
|
|
import { ToolGroupMessage } from './ToolGroupMessage.js';
|
|
import {
|
|
CoreToolCallStatus,
|
|
LS_DISPLAY_NAME,
|
|
READ_FILE_DISPLAY_NAME,
|
|
} from '@google/gemini-cli-core';
|
|
import { expect, it, describe } from 'vitest';
|
|
|
|
describe('ToolGroupMessage Compact Rendering', () => {
|
|
const defaultProps = {
|
|
item: {
|
|
id: '1',
|
|
role: 'assistant',
|
|
content: '',
|
|
timestamp: new Date(),
|
|
type: 'help' as const, // Adding type property to satisfy HistoryItem type
|
|
},
|
|
terminalWidth: 80,
|
|
};
|
|
|
|
const compactSettings = {
|
|
merged: {
|
|
ui: {
|
|
compactToolOutput: true,
|
|
},
|
|
},
|
|
};
|
|
|
|
it('renders consecutive compact tools without empty lines between them', async () => {
|
|
const toolCalls = [
|
|
{
|
|
callId: 'call1',
|
|
name: LS_DISPLAY_NAME,
|
|
status: CoreToolCallStatus.Success,
|
|
resultDisplay: 'file1.txt\nfile2.txt',
|
|
},
|
|
{
|
|
callId: 'call2',
|
|
name: LS_DISPLAY_NAME,
|
|
status: CoreToolCallStatus.Success,
|
|
resultDisplay: 'file3.txt',
|
|
},
|
|
];
|
|
|
|
const { lastFrame, waitUntilReady } = renderWithProviders(
|
|
<ToolGroupMessage {...defaultProps} toolCalls={toolCalls as any} />,
|
|
{ settings: compactSettings as any }
|
|
);
|
|
|
|
await waitUntilReady();
|
|
const output = lastFrame();
|
|
|
|
expect(output).toMatchSnapshot();
|
|
});
|
|
|
|
it('does not add an extra empty line between a compact tool and a standard tool', async () => {
|
|
const toolCalls = [
|
|
{
|
|
callId: 'call1',
|
|
name: LS_DISPLAY_NAME,
|
|
status: CoreToolCallStatus.Success,
|
|
resultDisplay: 'file1.txt',
|
|
},
|
|
{
|
|
callId: 'call2',
|
|
name: 'non-compact-tool',
|
|
status: CoreToolCallStatus.Success,
|
|
resultDisplay: 'some large output',
|
|
},
|
|
];
|
|
|
|
const { lastFrame, waitUntilReady } = renderWithProviders(
|
|
<ToolGroupMessage {...defaultProps} toolCalls={toolCalls as any} />,
|
|
{ settings: compactSettings as any }
|
|
);
|
|
|
|
await waitUntilReady();
|
|
const output = lastFrame();
|
|
expect(output).toMatchSnapshot();
|
|
});
|
|
|
|
it('does not add an extra empty line if a compact tool has a dense payload', async () => {
|
|
const toolCalls = [
|
|
{
|
|
callId: 'call1',
|
|
name: LS_DISPLAY_NAME,
|
|
status: CoreToolCallStatus.Success,
|
|
resultDisplay: 'file1.txt',
|
|
},
|
|
{
|
|
callId: 'call2',
|
|
name: READ_FILE_DISPLAY_NAME,
|
|
status: CoreToolCallStatus.Success,
|
|
resultDisplay: { summary: 'read file', payload: 'file content' }, // Dense payload
|
|
},
|
|
];
|
|
|
|
const { lastFrame, waitUntilReady } = renderWithProviders(
|
|
<ToolGroupMessage {...defaultProps} toolCalls={toolCalls as any} />,
|
|
{ settings: compactSettings as any }
|
|
);
|
|
|
|
await waitUntilReady();
|
|
const output = lastFrame();
|
|
expect(output).toMatchSnapshot();
|
|
});
|
|
|
|
it('does not add an extra empty line between a standard tool and a compact tool', async () => {
|
|
const toolCalls = [
|
|
{
|
|
callId: 'call1',
|
|
name: 'non-compact-tool',
|
|
status: CoreToolCallStatus.Success,
|
|
resultDisplay: 'some large output',
|
|
},
|
|
{
|
|
callId: 'call2',
|
|
name: LS_DISPLAY_NAME,
|
|
status: CoreToolCallStatus.Success,
|
|
resultDisplay: 'file1.txt',
|
|
},
|
|
];
|
|
|
|
const { lastFrame, waitUntilReady } = renderWithProviders(
|
|
<ToolGroupMessage {...defaultProps} toolCalls={toolCalls as any} />,
|
|
{ settings: compactSettings as any }
|
|
);
|
|
|
|
await waitUntilReady();
|
|
const output = lastFrame();
|
|
expect(output).toMatchSnapshot();
|
|
});
|
|
});
|