mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-30 06:54:15 -07:00
bug(core): Strip thoughts when loading history. (#7167)
This commit is contained in:
@@ -417,6 +417,44 @@ describe('useSlashCommandProcessor', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should strip thoughts when handling "load_history" action', async () => {
|
||||||
|
const mockSetHistory = vi.fn();
|
||||||
|
const mockGeminiClient = {
|
||||||
|
setHistory: mockSetHistory,
|
||||||
|
};
|
||||||
|
vi.spyOn(mockConfig, 'getGeminiClient').mockReturnValue(
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
mockGeminiClient as any,
|
||||||
|
);
|
||||||
|
|
||||||
|
const historyWithThoughts = [
|
||||||
|
{
|
||||||
|
role: 'model',
|
||||||
|
parts: [{ text: 'response', thoughtSignature: 'CikB...' }],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const command = createTestCommand({
|
||||||
|
name: 'loadwiththoughts',
|
||||||
|
action: vi.fn().mockResolvedValue({
|
||||||
|
type: 'load_history',
|
||||||
|
history: [{ type: MessageType.MODEL, text: 'response' }],
|
||||||
|
clientHistory: historyWithThoughts,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = setupProcessorHook([command]);
|
||||||
|
await waitFor(() => expect(result.current.slashCommands).toHaveLength(1));
|
||||||
|
|
||||||
|
await act(async () => {
|
||||||
|
await result.current.handleSlashCommand('/loadwiththoughts');
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(mockSetHistory).toHaveBeenCalledTimes(1);
|
||||||
|
expect(mockSetHistory).toHaveBeenCalledWith(historyWithThoughts, {
|
||||||
|
stripThoughts: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('with fake timers', () => {
|
describe('with fake timers', () => {
|
||||||
// This test needs to let the async `waitFor` complete with REAL timers
|
// This test needs to let the async `waitFor` complete with REAL timers
|
||||||
// before switching to FAKE timers to test setTimeout.
|
// before switching to FAKE timers to test setTimeout.
|
||||||
|
|||||||
@@ -393,9 +393,9 @@ export const useSlashCommandProcessor = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 'load_history': {
|
case 'load_history': {
|
||||||
await config
|
config
|
||||||
?.getGeminiClient()
|
?.getGeminiClient()
|
||||||
?.setHistory(result.clientHistory);
|
?.setHistory(result.clientHistory, { stripThoughts: true });
|
||||||
fullCommandContext.ui.clear();
|
fullCommandContext.ui.clear();
|
||||||
result.history.forEach((item, index) => {
|
result.history.forEach((item, index) => {
|
||||||
fullCommandContext.ui.addItem(item, index);
|
fullCommandContext.ui.addItem(item, index);
|
||||||
|
|||||||
Reference in New Issue
Block a user