mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-07 20:00:37 -07:00
fix(plan): clean up session directories and plans on deletion (#20914)
This commit is contained in:
@@ -569,6 +569,13 @@ export class ChatRecordingService {
|
||||
fs.unlinkSync(sessionPath);
|
||||
}
|
||||
|
||||
// Cleanup Activity logs in the project logs directory
|
||||
const logsDir = path.join(tempDir, 'logs');
|
||||
const logPath = path.join(logsDir, `session-${sessionId}.jsonl`);
|
||||
if (fs.existsSync(logPath)) {
|
||||
fs.unlinkSync(logPath);
|
||||
}
|
||||
|
||||
// Cleanup tool outputs for this session
|
||||
const safeSessionId = sanitizeFilenamePart(sessionId);
|
||||
const toolOutputDir = path.join(
|
||||
@@ -585,6 +592,13 @@ export class ChatRecordingService {
|
||||
) {
|
||||
fs.rmSync(toolOutputDir, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
// ALSO cleanup the session-specific directory (contains plans, tasks, etc.)
|
||||
const sessionDir = path.join(tempDir, safeSessionId);
|
||||
// Robustness: Ensure the path is strictly within the temp root
|
||||
if (fs.existsSync(sessionDir) && sessionDir.startsWith(tempDir)) {
|
||||
fs.rmSync(sessionDir, { recursive: true, force: true });
|
||||
}
|
||||
} catch (error) {
|
||||
debugLogger.error('Error deleting session file.', error);
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user