Repository navigation
sessions: fix Worktree Cleanup safety and usability - #351264
Open
Megan Rogge (meganrogge) wants to merge 4 commits into
Open
Megan Rogge (meganrogge) wants to merge 4 commits into
Megan Rogge (meganrogge) wants to merge 4 commits into
Conversation
Protect host ownership and running sessions, retain failed cleanup for retry, and add stable rows, host filters, refresh, and background progress. Co-authored-by: Copilot <[email protected]>
Preserve upstream remote capability checks and open-session classification, and cover human machine labels, refresh, live status changes, and retry behavior. Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Switching sessions while Cleanup is active skips working-set restoration and can overwrite the destination session’s saved editors with the previous session’s editors.
3 open issues
What changed in this PR
This PR improves Worktree Cleanup safety and usability in the Agents window, with updates to the shared cleanup editor used in editor windows.
Changes:
- Require host ownership evidence, recheck running sessions before archiving, and allow two concurrent host removals.
- Keep failures visible and retryable; add machine names, filtering, refresh, stable row ordering, and clearer progress.
- Preserve docked Cleanup during session transitions and expand accessibility guidance and regression coverage.
| File | Description |
|---|---|
src/vs/workbench/contrib/sessions/test/browser/sessionInputBanners/sessionWorktreeCleanupService.test.ts |
Tests running-session protection and machine names in confirmations. |
src/vs/workbench/contrib/sessions/test/browser/sessionInputBanners/sessionWorktreeCleanupEditor.test.ts |
Covers filtering, refresh, retries, progress, stable rows, and keyboard controls. |
src/vs/workbench/contrib/sessions/browser/sessionInputBanners/sessionWorktreeCleanupService.ts |
Resolves provider machine names and rechecks live session status. |
src/vs/workbench/contrib/sessions/browser/sessionInputBanners/sessionWorktreeCleanupEditor.ts |
Adds machine controls, visible failures, stable ordering, and progress updates. |
src/vs/workbench/contrib/sessions/browser/sessionInputBanners/sessionWorktreeCleanupAccessibilityHelp.ts |
Updates instructions for filtering, refresh, retries, and cleanup progress. |
src/vs/sessions/contrib/layout/test/browser/baseSessionLayoutController.test.ts |
Tests keeping docked Cleanup open across layout-owner changes. |
src/vs/sessions/contrib/layout/browser/baseSessionLayoutController.ts |
Adds a Cleanup-specific working-set restoration guard. |
src/vs/platform/agentHost/test/node/agentHostWorktreeCleanupService.test.ts |
Tests ownership rejection, acceptance rechecks, and concurrent removal/restoration. |
src/vs/platform/agentHost/node/agentHostWorktreeCleanupService.ts |
Enforces ownership evidence and limits concurrent removals to two. |
Review effort: Balanced
Defer working-set restores while Cleanup is active without saving outgoing editors over an incoming owner's snapshot. Resume on editor activation and retain already-settled owners on return.\n\nClear remembered checkbox choices on machine changes and refresh machine cells after host renames. Co-authored-by: Copilot <[email protected]>
Apply the repository formatter to the three cleanup files rejected by hygiene. Co-authored-by: Copilot <[email protected]>
Megan Rogge (meganrogge)
marked this pull request as ready for review
November 30, 2026 19:48
Megan Rogge (meganrogge)
enabled auto-merge
November 30, 2026 19:48
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Fix Worktree Cleanup safety and usability in the Agents window, preserving the shared cleanup editor's behavior in editor windows.
Conservative product choices
Worktrees without ownership evidence in this host are not offered or accepted, even with force. This can leave older, truly ownerless leftovers for manual investigation rather than risk deleting another host's checkout. The machine filter defaults to All Machines and clears selection when changed. Refresh discards confirmed removal rows but preserves pending and failed requests. No new settings or automatic cleanup policy are introduced.
Validation
Validated after rebasing onto current main, using the Node version required by the repository.
pnpm run build-fast --client-only— passed.pnpm run typecheck-client— passed.git diff HEAD~2 --name-only -z -- '*.ts' | xargs -0 pnpm run oxlint— passed, no warnings.pnpm run valid-layers-check— passed.git diff --check— passed../scripts/test.sh \ --run src/vs/platform/agentHost/test/node/agentHostWorktreeCleanupService.test.ts \ --run src/vs/workbench/contrib/sessions/test/browser/sessionInputBanners/sessionWorktreeCleanupService.test.ts \ --run src/vs/workbench/contrib/sessions/test/browser/sessionInputBanners/sessionWorktreeCleanupEditor.test.ts \ --run src/vs/sessions/contrib/layout/test/browser/baseSessionLayoutController.test.ts \ --grep 'AgentHostWorktreeCleanupService|SessionWorktreeCleanup|BaseLayoutController' \ --reporter dotNot run: live SSH/multiple-agent-host end-to-end testing, manual screen-reader testing, or full integration/smoke suites.
Manual testing
Fixes #349800
Fixes #349801
Fixes #349803
Fixes #349799
Fixes #349940
Fixes #349985
Fixes #349966
Fixes #349983
Fixes #349984