Skip to content

sessions: reuse worktree cleanup measurements - #341814

Merged
Megan Rogge (meganrogge) merged 1 commit into
mainfrom
agents/fix-agents-window-worktree-cleanup
Oct 15, 2026
Merged

Megan Rogge (meganrogge) merged 1 commit into
mainfrom
agents/fix-agents-window-worktree-cleanup

Conversation

@meganrogge

@meganrogge Megan Rogge (meganrogge) commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes Agents Window worktree cleanup measurement reuse:

  • preserves valid disk-usage measurements when cleanup archives sessions, while recomputing cleanup state so archived sessions disappear immediately
  • keeps automatic cleanup suggestion scans invalidated after archive and cleanup
  • shares one foreground progress operation and one provider measurement across concurrent or reopened cleanup editor loads
  • adds focused regressions for post-cleanup reload and concurrent editor loads

When measurement occurs

Completed disk-usage results are cached in memory for one hour and keyed by the sorted set of session IDs and worktree URIs. Eligibility state (archived, active, running, pinned, recent, and the selected inactivity period) is recomputed whenever results are consumed; changing eligibility does not by itself require another disk measurement.

Manually opening Worktree Cleanup

  • The first open measures all currently known session worktrees when there is no valid completed measurement.
  • Reopening the editor while that measurement is still running joins the same in-flight measurement and foreground progress operation. It does not start another provider call or another measurement notification.
  • Reopening within one hour reuses completed results when the session/worktree signature is unchanged, without showing measurement progress or calling the provider again.
  • Changing the Untouched For period reuses the measured sizes and only recomputes eligibility.
  • After confirmed cleanup, the editor reload reuses the measured sizes, recomputes state, and filters out newly archived sessions. It does not remeasure unchanged remaining worktrees.
  • A new measurement starts after the one-hour cache expires or when the session/worktree signature changes.

Automatic cleanup suggestion scan

  • When suggestions are enabled, service activation (including a new application/window service lifetime) runs an automatic scan unless an automatic scan completed within the last hour.
  • The automatic scan uses the same measurement cache and in-flight measurement as the editor. Opening Worktree Cleanup during an automatic measurement joins that provider work rather than duplicating it.
  • Session changes, archive events, explicit refresh, and cleanup invalidate the automatic suggestion scan so the threshold and suggestion are reevaluated.
  • Invalidating the suggestion scan does not discard valid disk measurements. The reevaluation reuses them unless the session/worktree signature changed or the one-hour measurement cache expired.
  • Because the cache is in memory, a full application/window reload creates a new service and therefore performs a fresh measurement when the automatic scan or editor first needs results. Merely closing and reopening the editor does not.

Validation

  • npm run build-fast -- --client-only — passed
  • ./scripts/test.sh --run src/vs/sessions/contrib/sessionInputBanners/test/browser/sessionWorktreeCleanupService.test.ts — passed (24 tests)
  • ./node_modules/.bin/eslint src/vs/sessions/contrib/sessionInputBanners/browser/sessionWorktreeCleanupService.ts src/vs/sessions/contrib/sessionInputBanners/test/browser/sessionWorktreeCleanupService.test.ts — passed
  • npm run typecheck-client — passed
  • git diff --check — passed

Fixes #341816

Keep valid disk-usage results when cleanup archives sessions, and share the foreground measurement progress across concurrent editor loads.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 15, 2026 16:23
@meganrogge
Megan Rogge (meganrogge) enabled auto-merge (squash) October 15, 2026 16:26
@meganrogge Megan Rogge (meganrogge) added this to the 1.143.0 milestone Oct 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 922ce6a4 Current: a1a41638

Changed (1)

sessions/chatCompositeBar/OverflowingTabs/Light
Before After
before after

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No actionable defects remain; focused regression coverage supports the changes, though tests were not rerun during this review.

0 open findings

What changed in this PR

Improves Agents Window worktree cleanup by reusing disk measurements while recomputing session eligibility.

Changes:

  • Preserves cached measurements after archive and cleanup.
  • Shares foreground progress across concurrent editor loads.
  • Adds regression coverage for measurement reuse and shared progress.
File Description
src/​vs/​sessions/​contrib/​sessionInputBanners/​test/​browser/​sessionWorktreeCleanupService.test.ts Tests post-cleanup reuse and concurrent loads.
src/​vs/​sessions/​contrib/​sessionInputBanners/​browser/​sessionWorktreeCleanupService.ts Preserves measurements and coalesces foreground progress.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reuse Agents Window worktree cleanup measurements

3 participants