mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 18:44:30 -07:00
fix(cli): filter subagent sessions from resume history (#19698)
This commit is contained in:
@@ -86,6 +86,21 @@ describe('ChatRecordingService', () => {
|
||||
expect(files[0]).toMatch(/^session-.*-test-ses\.json$/);
|
||||
});
|
||||
|
||||
it('should include the conversation kind when specified', () => {
|
||||
chatRecordingService.initialize(undefined, 'subagent');
|
||||
chatRecordingService.recordMessage({
|
||||
type: 'user',
|
||||
content: 'ping',
|
||||
model: 'm',
|
||||
});
|
||||
|
||||
const sessionFile = chatRecordingService.getConversationFilePath()!;
|
||||
const conversation = JSON.parse(
|
||||
fs.readFileSync(sessionFile, 'utf8'),
|
||||
) as ConversationRecord;
|
||||
expect(conversation.kind).toBe('subagent');
|
||||
});
|
||||
|
||||
it('should resume from an existing session if provided', () => {
|
||||
const chatsDir = path.join(testTempDir, 'chats');
|
||||
fs.mkdirSync(chatsDir, { recursive: true });
|
||||
|
||||
@@ -102,6 +102,8 @@ export interface ConversationRecord {
|
||||
summary?: string;
|
||||
/** Workspace directories added during the session via /dir add */
|
||||
directories?: string[];
|
||||
/** The kind of conversation (main agent or subagent) */
|
||||
kind?: 'main' | 'subagent';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,6 +130,7 @@ export class ChatRecordingService {
|
||||
private cachedLastConvData: string | null = null;
|
||||
private sessionId: string;
|
||||
private projectHash: string;
|
||||
private kind?: 'main' | 'subagent';
|
||||
private queuedThoughts: Array<ThoughtSummary & { timestamp: string }> = [];
|
||||
private queuedTokens: TokensSummary | null = null;
|
||||
private config: Config;
|
||||
@@ -141,13 +144,21 @@ export class ChatRecordingService {
|
||||
/**
|
||||
* Initializes the chat recording service: creates a new conversation file and associates it with
|
||||
* this service instance, or resumes from an existing session if resumedSessionData is provided.
|
||||
*
|
||||
* @param resumedSessionData Data from a previous session to resume from.
|
||||
* @param kind The kind of conversation (main or subagent).
|
||||
*/
|
||||
initialize(resumedSessionData?: ResumedSessionData): void {
|
||||
initialize(
|
||||
resumedSessionData?: ResumedSessionData,
|
||||
kind?: 'main' | 'subagent',
|
||||
): void {
|
||||
try {
|
||||
this.kind = kind;
|
||||
if (resumedSessionData) {
|
||||
// Resume from existing session
|
||||
this.conversationFile = resumedSessionData.filePath;
|
||||
this.sessionId = resumedSessionData.conversation.sessionId;
|
||||
this.kind = resumedSessionData.conversation.kind;
|
||||
|
||||
// Update the session ID in the existing file
|
||||
this.updateConversation((conversation) => {
|
||||
@@ -180,6 +191,7 @@ export class ChatRecordingService {
|
||||
startTime: new Date().toISOString(),
|
||||
lastUpdated: new Date().toISOString(),
|
||||
messages: [],
|
||||
kind: this.kind,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -435,6 +447,7 @@ export class ChatRecordingService {
|
||||
startTime: new Date().toISOString(),
|
||||
lastUpdated: new Date().toISOString(),
|
||||
messages: [],
|
||||
kind: this.kind,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user