Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: reintroduce automatic task cleanup for old task history - #14054

Open
vkeerthivikram wants to merge 6 commits into
Kilo-Org:mainfrom
vkeerthivikram:feat/auto-cleanup
Open

feat: reintroduce automatic task cleanup for old task history#14054
vkeerthivikram wants to merge 6 commits into
Kilo-Org:mainfrom
vkeerthivikram:feat/auto-cleanup

Conversation

@vkeerthivikram

@vkeerthivikram vkeerthivikram commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Closes #14053

The old extension had an Auto-Cleanup setting under Settings → Checkpoints that deleted old task history on a schedule. It never made it into the rebuilt extension, so task history just grows forever now. This puts the feature back.

What it does

A daily pass (plus a Run Cleanup Now button with a last-run summary in Settings → Checkpoints) that deletes expired sessions through the backend. The toggle is off by default.

Two knobs: how long to keep regular tasks (30 days default) and how long to keep abandoned ones (7 days). "Abandoned" means the session never really got used — created and last touched within the same minute. The legacy feature also had separate buckets for completed and favorited tasks, but the new session model doesn't track completion or favorites, so those buckets have nothing to key off. Dropped them rather than guess.

Safety rules:

  • a task that is currently running never gets deleted
  • if the backend status check fails for a directory, that whole group is skipped (fail closed)
  • an old task with a fresh fork survives until the fork ages out, because deleting a task takes its forks with it

Only expired roots get delete calls. The backend cascades children with the parent, so calling delete on them just produces 404s that pollute the last-run stats.

Checkpoint data is left alone on purpose. Snapshot storage already runs an hourly GC that drops unreachable objects older than 7 days, so checkpoints of deleted tasks disappear on their own.

Testing

  • bun run typecheck (host + webview), lint, knip, compile, check-kilocode-change — all pass
  • bun run test:unit: 5542 pass, includes 14 new tests for retention math, fork protection and root selection
  • Manually: built a VSIX, installed it, created six sample sessions backdated in storage (regular, abandoned, fresh, parent+fork pair), hit Run Cleanup Now. The three expired ones got deleted, the fresh task and the fork pair survived, and the summary line rendered right.

Ownership

I've reviewed the full diff, ran everything above, and tested the feature end to end in VS Code. Happy to explain any part of it.
Screenshot_2026-09-11_15-36-16

The legacy extension shipped an auto-cleanup setting that pruned old
task history; it was never ported when the extension was rebuilt on the
CLI backend. This brings it back as a TaskCleanupService in the VS Code
extension: a daily pass (plus a manual Run Cleanup Now button in
Settings > Checkpoints) deletes expired sessions through the backend,
with retention buckets for regular and abandoned tasks.

Safety rules: running sessions are never deleted, a failed status check
skips the whole directory group (fail closed), and parents with fresh
forks stay alive until the fork ages out, since the backend cascades
child deletion. Snapshot storage keeps pruning itself via its hourly GC,
so checkpoints of deleted tasks age out within the existing 7-day
window.

Includes settings keys (kilo-code.new.autoCleanup.*), a Checkpoints-tab
settings card with last-run summary, webview message contracts,
translations for all 21 locales, and unit tests for the retention and
root-selection logic.
Comment thread packages/kilo-vscode/src/services/task-cleanup/service.ts Outdated
Comment thread packages/kilo-vscode/webview-ui/src/i18n/bs.ts Outdated
Comment thread packages/kilo-vscode/src/KiloProvider.ts
@kilo-code-bot

kilo-code-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • packages/kilo-vscode/src/services/task-cleanup/service.ts
  • packages/kilo-vscode/src/KiloProvider.ts
  • packages/kilo-vscode/webview-ui/src/i18n/bs.ts
Previous Review Summaries (2 snapshots, latest commit 75b0230)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 75b0230)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • packages/kilo-vscode/src/services/task-cleanup/service.ts
  • packages/kilo-vscode/src/KiloProvider.ts
  • packages/kilo-vscode/webview-ui/src/i18n/bs.ts

Previous review (commit daccee9)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 2
Issue Details (click to expand)

WARNING

File Line Issue
packages/kilo-vscode/src/services/task-cleanup/service.ts 61 tick() reschedules in finally even after dispose(), so an in-flight pass creates a new timer post-disposal.

SUGGESTION

File Line Issue
packages/kilo-vscode/webview-ui/src/i18n/bs.ts 1118 Bosnian typo zadake should be zadatke (also line 1121).
packages/kilo-vscode/src/KiloProvider.ts 3334 runAutoCleanupNow returns without sendAutoCleanupState() when the service is unavailable, leaving the webview button stuck disabled.
Files Reviewed (33 files)
  • packages/kilo-vscode/src/services/task-cleanup/service.ts - 1 issue
  • packages/kilo-vscode/src/services/task-cleanup/classify.ts
  • packages/kilo-vscode/src/services/task-cleanup/settings.ts
  • packages/kilo-vscode/src/KiloProvider.ts - 1 issue
  • packages/kilo-vscode/src/extension.ts
  • packages/kilo-vscode/webview-ui/src/components/settings/CheckpointsTab.tsx
  • packages/kilo-vscode/webview-ui/src/i18n/bs.ts - 1 issue
  • packages/kilo-vscode/webview-ui/src/i18n/*.ts (20 other locales)
  • packages/kilo-vscode/webview-ui/src/types/messages/extension-messages.ts
  • packages/kilo-vscode/webview-ui/src/types/messages/webview-messages.ts
  • packages/kilo-vscode/tests/unit/task-cleanup.test.ts
  • packages/kilo-vscode/package.json
  • packages/kilo-docs/pages/code-with-ai/features/checkpoints.md
  • .changeset/auto-cleanup-reintroduce.md

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0

Review guidance: REVIEW.md from base branch main

- Stop the cleanup scheduler from re-arming after dispose(): an in-flight
  pass rescheduled in its finally block, leaving a live timer on a
  disposed service.
- Reset the webview Run Cleanup Now button when the cleanup service is
  unavailable by always posting the state message.
- Fix Bosnian typo zadake -> zadatke in two retention labels.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reintroduce automatic task cleanup for old task history

1 participant