fix(core): ensure tool output cleanup on session deletion for legacy files#26263
fix(core): ensure tool output cleanup on session deletion for legacy files#26263cocosheng-g merged 2 commits intomainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where tool output directories were not being properly cleaned up when deleting legacy pretty-printed JSON session files. By introducing a more resilient parsing strategy that falls back to full-file reading when necessary, the system can now reliably extract session identifiers from older file formats. Additionally, the cleanup process has been improved to guarantee that session files are removed regardless of potential errors encountered during artifact deletion, improving overall system hygiene. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request enhances the session cleanup logic to support both JSONL and legacy pretty-printed JSON formats. It introduces a more robust deletion mechanism that ensures session files are unlinked even if artifact removal encounters errors, and adds corresponding test cases. Feedback was provided regarding the efficiency of file reading in sessionCleanup.ts, suggesting a chunked read approach similar to the one implemented in ChatRecordingService.ts to avoid loading large files entirely into memory.
8cd3c68 to
0d0970d
Compare
|
Size Change: +1.8 kB (+0.01%) Total Size: 33.9 MB
ℹ️ View Unchanged
|
09b90bb to
55514de
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the session cleanup and recording services to support both .json and .jsonl file formats. It introduces a more robust session ID extraction process that attempts to read the first line of a file (optimized for JSONL) before falling back to a full file read for legacy pretty-printed JSON. Additionally, the ChatRecordingService was updated to ensure session files are unlinked even if artifact deletion fails, and new tests were added to verify handling of legacy and corrupted files. I have no feedback to provide.
…files Fixes #21568. Robustly parse session files during deletion to extract sessionId and clean up artifacts, even for legacy pretty-printed JSON files.
55514de to
d6efef2
Compare
Summary
Fixes an issue where
deleteSession()failed to clean up tool output directories when deleting legacy pretty-printed JSON session files.Details
ChatRecordingService.deleteSessionAndArtifactsin@google/gemini-cli-coreto fall back to a full-file parse if the efficient first-line parse (used for JSONL) fails. This ensures thefullSessionId(UUID) is correctly extracted from legacy pretty-printed JSON files.cleanupExpiredSessionsin@google/gemini-cliwith the same robust parsing logic to ensure associated artifacts (logs, tool outputs) are removed during automatic cleanup of "corrupted" or expired sessions.ChatRecordingService.test.tscovering legacy format deletion and corrupted file handling.Related Issues
Fixes #21568
How to Validate
session-2026-01-01T00-00-12345678.json) in the project'schatsdirectory.tool-outputs/session-<UUID>.gemini --delete-session 1.npm test -w @google/gemini-cli-core -- src/services/chatRecordingService.test.tsandnpm test -w @google/gemini-cli -- src/utils/sessionCleanup.test.ts.Pre-Merge Checklist