mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-14 22:02:59 -07:00
Fix shell output display (#24490)
This commit is contained in:
@@ -101,6 +101,7 @@ import {
|
||||
type GeminiClient,
|
||||
type ShellExecutionResult,
|
||||
type ShellOutputEvent,
|
||||
type AnsiOutput,
|
||||
CoreToolCallStatus,
|
||||
} from '@google/gemini-cli-core';
|
||||
import * as fs from 'node:fs';
|
||||
@@ -521,6 +522,52 @@ describe('useExecutionLifecycle', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should prepend warnings to AnsiOutput array', async () => {
|
||||
const { result } = await renderProcessorHook();
|
||||
|
||||
act(() => {
|
||||
result.current.handleShellCommand('ls', new AbortController().signal);
|
||||
});
|
||||
const execPromise = onExecMock.mock.calls[0][0];
|
||||
|
||||
const ansiOutput: AnsiOutput = [
|
||||
[
|
||||
{
|
||||
text: 'ansi line 1',
|
||||
fg: '',
|
||||
bg: '',
|
||||
bold: false,
|
||||
dim: false,
|
||||
italic: false,
|
||||
underline: false,
|
||||
inverse: false,
|
||||
},
|
||||
],
|
||||
];
|
||||
|
||||
act(() => {
|
||||
resolveExecutionPromise(
|
||||
createMockServiceResult({
|
||||
exitCode: 1,
|
||||
output: 'ansi line 1',
|
||||
ansiOutput,
|
||||
}),
|
||||
);
|
||||
});
|
||||
await act(async () => await execPromise);
|
||||
|
||||
expect(setPendingHistoryItemMock).toHaveBeenCalledWith(null);
|
||||
expect(addItemToHistoryMock).toHaveBeenCalledTimes(2);
|
||||
|
||||
const historyCall = addItemToHistoryMock.mock.calls[1][0];
|
||||
const display = historyCall.tools[0].resultDisplay;
|
||||
|
||||
expect(Array.isArray(display)).toBe(true);
|
||||
expect(display.length).toBe(3); // Error line, empty line, original output
|
||||
expect(display[0][0].text).toBe('Command exited with code 1.');
|
||||
expect(display[2][0].text).toBe('ansi line 1');
|
||||
});
|
||||
|
||||
it('should handle promise rejection and show an error', async () => {
|
||||
const { result } = await renderProcessorHook();
|
||||
const testError = new Error('Unexpected failure');
|
||||
|
||||
Reference in New Issue
Block a user