Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Nov 14, 2025

Closes #10850

Summary

image

Adds an auto-delete task history feature that purges old tasks on extension reload, helping users manage disk space and keep their task history clean.

Changes

New Setting

  • Auto-delete task history dropdown in Settings → About
  • Options: Never (default), 90 days, 60 days, 30 days, 7 days, 3 days
  • Stored in VS Code global configuration as roo-cline.taskHistoryRetention

Purge Logic (src/utils/task-history-retention.ts)

  • Runs once on extension activation
  • Deletes tasks older than the configured retention period based on task_metadata.json timestamp
  • Falls back to directory mtime for legacy tasks without metadata
  • Detects and removes orphan checkpoint-only folders (directories containing only a checkpoints/ subdirectory)
  • Uses ClineProvider.deleteTaskWithId() to ensure consistent cleanup of checkpoints, shadow repositories, and task state
  • Includes retry logic with backoff for stubborn filesystem operations

UI Updates

  • Added retention dropdown to About.tsx settings panel
  • Full i18n support across 17 languages
  • Warning text about permanent deletion

Testing

  • New test suite task-history-retention.spec.ts covering:
    • Retention periods (3, 7, 30 days)
    • Dry run mode
    • Invalid metadata handling
    • Never (disabled) setting

Technical Notes

  • Purge executes sequentially (not in parallel) to avoid race conditions when updating task state
  • Verbose logging available but disabled by default to reduce noise
  • Schema allows string enum values for UI compatibility

Important

Introduces an auto-delete task history feature with configurable retention settings, UI updates, and comprehensive testing.

  • Behavior:
    • Adds auto-delete task history feature, purging old tasks on extension reload based on retention settings.
    • New setting roo-cline.taskHistoryRetention in VS Code global configuration.
    • Purge logic in task-history-retention.ts deletes tasks older than configured retention period.
    • Handles orphan checkpoint-only folders and uses ClineProvider.deleteTaskWithId() for cleanup.
  • UI Updates:
    • Adds retention dropdown to About.tsx with i18n support for 17 languages.
    • Displays warning about permanent deletion.
  • Testing:
    • New test suite task-history-retention.spec.ts for retention periods, dry run mode, and invalid metadata handling.
  • Misc:
    • Updates to global-settings.ts and vscode-extension-host.ts for new retention setting.
    • Logging improvements in ClineProvider.ts.

This description was created by Ellipsis for 098aa38. You can customize this summary. It will automatically update as commits are pushed.

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. Enhancement New feature or request labels Nov 14, 2025
@roomote
Copy link
Contributor

roomote bot commented Nov 14, 2025

Oroocle Clock   See task on Roo Cloud

Re-reviewed latest commit(s) on this PR (098aa38). No new issues found.

  • Race condition in concurrent task state updates during purge
  • settings:taskHistoryStorage i18n added only in en (missing in other locales)
  • task-storage-size test suite mocks fs/promises but not VS Code config access via getStorageBasePath (can make tests environment-dependent)
  • settings.taskHistoryRetention.description copy says "runs on extension reload" but purge now runs on activation
  • common:taskHistoryRetention.* i18n keys exist only in src/i18n/locales/en/common.json (purge toast/actions can show missing-key strings in non-English UIs)
  • Settings save should persist normalized taskHistoryRetention value (avoid re-saving legacy/invalid values)
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Nov 14, 2025
@hannesrudolph hannesrudolph force-pushed the chore/retention-purge-checkpoint-cleanup branch from 784a70d to 67c7629 Compare November 19, 2025 08:57
@hannesrudolph hannesrudolph force-pushed the chore/retention-purge-checkpoint-cleanup branch from d9b68d5 to 42d73fe Compare November 26, 2025 19:47
@hannesrudolph hannesrudolph moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Nov 26, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Nov 26, 2025
@hannesrudolph hannesrudolph force-pushed the chore/retention-purge-checkpoint-cleanup branch from 84853c9 to cc67f71 Compare January 7, 2026 16:38
Copy link
Contributor

@heyseth heyseth left a 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!

@hannesrudolph hannesrudolph force-pushed the chore/retention-purge-checkpoint-cleanup branch from cc67f71 to ab6d3ab Compare January 20, 2026 01:43
@daniel-lxs
Copy link
Member

All mrubens review comments have been addressed in commit 2ade8a0:

  • Named type for retention: Now using TaskHistoryRetentionSetting from @roo-code/types in About.tsx and SettingsView.tsx
  • Using TASK_HISTORY_RETENTION_OPTIONS: Imported and used in both task-history-retention.ts (line 6, 314) and extension.ts (line 49, 400-404)
  • Settings navigation to About tab: Uses roo-cline.settingsButtonClicked, "about"` which correctly opens to the About tab (line 340 in task-history-retention.ts)
  • Internationalization: The startBackgroundRetentionPurge function uses t() for all user-facing strings (lines 329-335)
  • Defensive checks: Kept for safety since the value comes from global state which could theoretically be invalid from older versions, but now properly typed

The non-blocking feedback items (moving logic into tabs, using day numbers instead of strings for i18n) follow existing patterns in the codebase.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 21, 2026
hannesrudolph and others added 25 commits January 22, 2026 10:15
- Remove unused fs/promises import in extension.ts
- Fix Turkish translation: replace Cyrillic 'д' with Turkish 'd' in süreden
- Fix Catalan translation: use consistent 'extensió' terminology
- Import and use RetentionSetting type instead of 'as any' in extension.ts
- Use proper type narrowing for metadata parsing instead of 'as any'
…on flow

- Replace generic 'number' with explicit RetentionDays union type to prevent accidental misconfiguration
- Skip aggressive fs cleanup when deleteTaskById callback successfully removes the directory
- This avoids redundant filesystem work and log noise on stubborn paths
Co-authored-by: Seth Miller <sethmillerp@gmail.com>
Co-authored-by: Seth Miller <sethmillerp@gmail.com>
…plugin reload

- Updated description and warning text for aboutRetention in all 18 languages
- Changed 'plugin reload' to 'extension is activated' for clarity
- Changed 'deletes tasks' to 'deletes old tasks' to clarify it doesn't delete all tasks
- Add storage usage display showing total size and task count
- Add calculateTaskStorageSize utility to compute global storage folder sizes
- Add getTaskStorageSize message handler to communicate storage info to webview
- Update About settings section to display storage usage with refresh button
- Add taskHistoryStorage translations for all 18 supported languages
- Add non-blocking background task history purge on extension activation
- Fire-and-forget pattern prevents blocking startup
- Skip purge entirely when retention is 'never' (default)
- Remove duplicate 'settings.taskHistoryRetention.description' keys from all 18 package.nls.*.json files
- Keep consistent 'extension reload' terminology (vs 'plugin reload')
…cleaner code

- Resolved merge conflict in extension.ts, keeping extracted function approach
- startBackgroundRetentionPurge() encapsulates all purge logic in task-history-retention.ts
- Added getStorageBasePath mock to task-storage-size tests (addresses roomote review)
- Check if workspace repo directory exists before git operations in deleteTask()
- Reduce log verbosity - only log actual errors, not expected cases
- Add test case for non-existent directory handling
Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>
@daniel-lxs daniel-lxs force-pushed the chore/retention-purge-checkpoint-cleanup branch from 2ade8a0 to 098aa38 Compare January 22, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request lgtm This PR has been approved by a maintainer PR - Needs Preliminary Review size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Status: PR [Needs Prelim Review]

Development

Successfully merging this pull request may close these issues.

Auto-delete task history with configurable retention

5 participants