-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: auto-delete old checkpoints + add optional auto task history removal #9262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
784a70d to
67c7629
Compare
d9b68d5 to
42d73fe
Compare
84853c9 to
cc67f71
Compare
heyseth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Executive Summary
This PR introduces an auto-delete task history feature that purges old tasks on extension reload. The implementation is well-architected, type-safe, and thoroughly tested. The code demonstrates solid engineering practices with proper error handling, i18n support, and integration with existing deletion logic.
Strengths
- ✅Consistency: Excellent reuse of existing
deleteTaskWithId()logic ensures checkpoints, shadow repos, and state are cleaned up alongside files. - ✅Reliability: Sequential deletion prevents race conditions, and robust retry logic handles stubborn filesystem operations.
- ✅Quality: Full i18n support across 17 languages and type-safe schema validation with Zod.
Suggested Enhancements (Code Included)
I have included specific code snippets in the comments to address performance and user trust:
1. Performance: Non-blocking Activation (Critical)
The current implementation awaits the purge process during the activate phase. On machines with large histories or slow disks, this will block the extension startup.
- Fix: I provided a snippet to wrap the logic in a background "fire-and-forget" task (
void (async ...)), ensuring the extension activates immediately. - Optimization: Added an early return check for
retention === "never"to skip the logic entirely for the majority of users.
2. UX: Visibility & Trust
Silent deletion of user data can be alarming if a user expects to find a task.
- Fix: I added a Toast Notification logic to the background task. It only triggers if files were actually deleted and provides a direct link to Settings.
3. Testing: Edge Case Coverage
Since we are permanently deleting files, I identified a gap in testing regarding "Orphan Checkpoints" and "Legacy Mtime Fallback."
- Fix: I drafted 4 specific test cases to verify we strictly target garbage data and do not accidentally delete recent, valid tasks that lack metadata.
Conclusion
This is a high-value maintenance feature. Once the activation blocking issue is resolved (using the background task pattern I suggested), this logic is solid and ready for production!
cc67f71 to
ab6d3ab
Compare
- Remove expensive recursive getDirectorySize() that caused UI freeze with ~9000 tasks - Now only counts top-level task directories via single fs.readdir() call - Make task count on-demand (user must click refresh) instead of auto-trigger on settings load - Update types, i18n strings, and tests accordingly
This PR was never merged, so no need for backwards compatibility. Import formatBytes directly from its source file.
The formatBytes tests are not relevant since we no longer calculate size.
…ence race condition
- Add parallel metadata reads with 50 concurrent operations - Add parallel deletions with 10 concurrent operations - Batch read all metadata first, then filter, then delete - Reduce retry attempts from 3 to 1 (remove aggressive retries with sleeps) - Extract helper functions for cleaner code (readTaskMetadata, pathExists, removeDir) This significantly improves purge performance for users with many tasks (~9000+).
- Add purgeOldCheckpoints() function with hardcoded 30-day threshold - Add startBackgroundCheckpointPurge() for fire-and-forget activation - Culls only checkpoints/ subdirectory, preserves task history - Runs silently on extension activation (no user notification) - Coexists with existing taskHistoryRetention setting - Add 6 new tests for checkpoint culling functionality
- Log number of tasks being scanned - Log how many tasks have checkpoints - Log how many need culling (older than 30 days) - Log progress every 100 deletions during large culls
… popover - Add Settings gear icon in HistoryView header with popover for retention settings - Retention dropdown allows configuring auto-delete task history (never, 3-90 days) - Settings are saved immediately via vscode.postMessage updateSettings - Remove retention settings from About.tsx (Settings View) - Update About.tsx props and tests to remove taskHistoryRetention
…aging
- Add confirmation dialog before changing retention settings to prevent accidental changes
- Move task count display from About tab to History View settings popover
- Combine redundant description/warning into single, clear warning message
- Update task count display to be more human-friendly ('X tasks in history')
- Update all 18 locale files with consistent messaging
- Revert About.tsx to original state (no retention UI there)
The file was left over after size calculation was removed from task-storage-size.ts for performance reasons. Knip correctly detected it as unused.
- Improve calculateTaskStorageSize() logging to show actual error message instead of generic 'directory not found' - Serialize task deletions when using provider-backed deleteTaskById to avoid taskHistory state race conditions (parallel deletion kept for filesystem-only operations)
Summary
Adds automatic task history cleanup to help manage disk space and keep your task history tidy.
What's New
Auto-Delete Task History (User-Configurable)
You can now set Roo Code to automatically delete old tasks when VS Code starts. Access this setting from the History view via the new gear icon in the header.
Retention options: Never (default), 90 days, 60 days, 30 days, 7 days, or 3 days
Task Count Display
The settings popover shows how many tasks are in your history with a refresh button to update the count on demand.
Automatic Checkpoint Cleanup
Checkpoint data (used for restore points) from tasks not touched in 30 days is automatically removed. This runs silently in the background and preserves your conversation history - only the checkpoint files are removed to save storage space.
How to Use
Notes
Closes #10850
Important
Introduces automatic task history cleanup and checkpoint data removal with user-configurable settings and internationalization support.
global-settings.tsandvscode-extension-host.ts.task-history-retention.ts.HistoryView.tsx.TASK_HISTORY_RETENTION_OPTIONSandTaskHistoryRetentionSettinginglobal-settings.ts.ExtensionStateinvscode-extension-host.tsto includetaskHistoryRetentionandtaskHistorySize.task-history-retention.spec.tsandtask-storage-size.spec.ts.This description was created by
for 30f2aa2. You can customize this summary. It will automatically update as commits are pushed.