mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-27 03:37:27 -07:00
fix(cli): filter internal session context from history during resumption (#27391)
This commit is contained in:
committed by
GitHub
parent
3cc7e5b096
commit
630ecc21b9
@@ -1111,6 +1111,28 @@ describe('convertSessionToHistoryFormats', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should filter out <session_context> from UI history', () => {
|
||||
const messages: MessageRecord[] = [
|
||||
{
|
||||
id: '1',
|
||||
timestamp: new Date().toISOString(),
|
||||
type: 'user',
|
||||
content:
|
||||
'<session_context>\nThis is the Gemini CLI\n</session_context>',
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
timestamp: new Date().toISOString(),
|
||||
type: 'user',
|
||||
content: 'Real message',
|
||||
},
|
||||
];
|
||||
|
||||
const result = convertSessionToHistoryFormats(messages);
|
||||
expect(result.uiHistory).toHaveLength(1);
|
||||
expect(result.uiHistory[0].text).toBe('Real message');
|
||||
});
|
||||
|
||||
it('should handle missing tool descriptions and displayNames', () => {
|
||||
const messages: MessageRecord[] = [
|
||||
{
|
||||
|
||||
@@ -606,7 +606,16 @@ export function convertSessionToHistoryFormats(
|
||||
const contentString = partListUnionToString(msg.content);
|
||||
const uiText = displayContentString || contentString;
|
||||
|
||||
if (uiText.trim()) {
|
||||
// Skip internal context messages in the UI history
|
||||
const trimmedText = uiText.trim();
|
||||
if (
|
||||
trimmedText.startsWith('<session_context>') ||
|
||||
trimmedText.startsWith('<hook_context>')
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (trimmedText) {
|
||||
let messageType: MessageType;
|
||||
switch (msg.type) {
|
||||
case 'user':
|
||||
|
||||
Reference in New Issue
Block a user