You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Legacy taskHistory blob stays in globalState after file-backed migration #1771
After task history migrated to per-task history_item.json files, the old "taskHistory" array stays in extension globalState indefinitely. VS Code weighs the total extension state on every read and write, so the large-state warning keeps appearing even though Zoo Code no longer writes new history there (#1664).
Context (who is affected and when)
Users who ran a version from before the file-backed migration and built up a large task history. The blob is never removed, so it persists across updates. Split out of #1664 (for #1542) at the maintainer's request: #1664 (comment)
Reproduction steps
Use a pre-migration version and build up a large task history.
Update to a version with file-backed history, so migration runs and sets taskHistoryMigratedToFiles.
Inspect extension globalState: taskHistory still holds the full legacy array.
Expected result
After a successful, verified migration, the legacy taskHistory blob is removed (or reduced), so it no longer counts toward extension state size.
Actual result
The blob stays in globalState indefinitely, and the large-state warning persists.
Variations tried (optional)
A first attempt cleared the blob in initializeTaskHistoryStore right after the migration marker was set (reverted from #1664 in 720f1e9). Handling old blobs needs its own design. Open questions:
When cleanup is safe: clear only after migration is verified complete. Fallbacks such as getTaskWithId and the mode/API-config update handlers still read globalState.taskHistory while the store is uninitialized or migration failed.
Partial failures: what happens if the cleanup write fails, and whether it is retried on the next startup without making stale legacy history authoritative again.
Multiple windows: coordinating with other windows or instances that may still be migrating or reading the blob.
Downgrades: older versions that still rely on the blob would lose their history view after a downgrade. Consider a delay or a backup before deleting.
Users who already migrated: they need a one-time cleanup path.
Spec-first fix opened as PR #2873 (head 01ab2855f).
Root cause: the file-backed migration sets taskHistoryMigratedToFiles but nothing ever removes the legacy globalState.taskHistory array, so every install that ever ran a pre-migration version keeps weighing the whole extension state on every read/write and the large-state warning persists.
Fix (PR #2873): a one-time sweep in initializeTaskHistoryStore once the store is initialized:
delete only when the file-backed store holds every blob entry whose task directory exists (per-entry verification; any miss keeps the blob — entries an older build appended after the marker are never deleted);
back up the full array (orphans included) to legacy-task-history.backup.json in global storage and read it back before the delete;
any failure keeps the blob and retries on the next startup (the blob's presence is the retry condition — no extra marker, idempotent, multi-window safe through update(key, undefined));
a provider whose startup failed keeps its legacy fallback: getTaskHistoryItem now also reads the sweep backup when the blob is gone, so a failed window does not report existing tasks as missing after a peer swept (the gap the previous [BUG] Legacy taskHistory blob stays in globalState after file-backed migration #1771 PR left open — it was auto-closed for author inactivity, not rejected on the approach).
SDD (per docs/architecture/tla/AGENTS.md): new spec TaskHistoryMigration.tla (+MC module, base + 4 sabotage cfgs). Base passes in 650 states; NoSweep (the pre-fix behavior) fails SweptWhenVerifiable (218 states); NoVerify fails ClearRequiresVerification (392); NoBackup fails ClearRequiresBackup (97); StaleResurrect fails PeerClearedStaysCleared (515). Each variant run violates only its named invariant.
Tests: 7 sweep cases in ClineProvider.taskHistory.spec.ts fail on the pre-fix code exactly at the sweep assertions, plus the property test legacyTaskHistoryBlob.spec.ts (seeded 500-scenario loop: clear ⇒ backup written ∧ every non-orphan entry held). Sabotage-verified: removing the orphan exclusion, the verification gate, the backup-failure handling, or the empty-blob guard fails the matching test.
UI/UX: none — after migration the webview already reads the file-backed store; the large-state warning clearing is the issue's expected outcome.
Activity
gh311 commentedon Dec 6, 2026
Spec-first fix opened as PR #2873 (head
01ab2855f).Root cause: the file-backed migration sets
taskHistoryMigratedToFilesbut nothing ever removes the legacyglobalState.taskHistoryarray, so every install that ever ran a pre-migration version keeps weighing the whole extension state on every read/write and the large-state warning persists.Fix (PR #2873): a one-time sweep in
initializeTaskHistoryStoreonce the store is initialized:legacy-task-history.backup.jsonin global storage and read it back before the delete;update(key, undefined));getTaskHistoryItemnow also reads the sweep backup when the blob is gone, so a failed window does not report existing tasks as missing after a peer swept (the gap the previous [BUG] Legacy taskHistory blob stays in globalState after file-backed migration #1771 PR left open — it was auto-closed for author inactivity, not rejected on the approach).SDD (per
docs/architecture/tla/AGENTS.md): new specTaskHistoryMigration.tla(+MC module, base + 4 sabotage cfgs). Base passes in 650 states;NoSweep(the pre-fix behavior) failsSweptWhenVerifiable(218 states);NoVerifyfailsClearRequiresVerification(392);NoBackupfailsClearRequiresBackup(97);StaleResurrectfailsPeerClearedStaysCleared(515). Each variant run violates only its named invariant.Tests: 7 sweep cases in
ClineProvider.taskHistory.spec.tsfail on the pre-fix code exactly at the sweep assertions, plus the property testlegacyTaskHistoryBlob.spec.ts(seeded 500-scenario loop: clear ⇒ backup written ∧ every non-orphan entry held). Sabotage-verified: removing the orphan exclusion, the verification gate, the backup-failure handling, or the empty-blob guard fails the matching test.UI/UX: none — after migration the webview already reads the file-backed store; the large-state warning clearing is the issue's expected outcome.
fix(webview): keep the legacy blob when the sweep window or backup is…
fix(webview): lock the backup merge and bound the sweep's cache window
fix(webview): defer on a malformed legacy backup and model the write …
fix(webview): close the round-4 CodeRabbit findings on the legacy blo…
fix(webview): close the round-5 CodeRabbit findings on the legacy blo…