fix: persist worktree state across reload and polish desktop UX#95
Merged
amandal0903 merged 16 commits intomainfrom Apr 10, 2026
Merged
fix: persist worktree state across reload and polish desktop UX#95amandal0903 merged 16 commits intomainfrom
amandal0903 merged 16 commits intomainfrom
Conversation
Persists the worktree path→editor working set mapping to StorageScope.WORKSPACE so editor layouts survive window close/reopen. - Add WORKING_SET_MAP_KEY storage key - Add _persistWorkingSetMap() called after every switchTo() save - Delete stale working set before creating a new snapshot (prevents unbounded accumulation across sessions) - Restore map in restoreState() with id validation against editorGroupsService.getWorkingSets() to guard against storage drift
When removeWorktree() fires, delete the worktree's snapshot from both editorGroupsService and _workingSetMap, then persist the updated map. Prevents orphaned working set entries from accumulating after worktrees are deleted.
On reload, restoreState() was calling switchTo() which ran the full
switch flow (applyWorkingSet('empty') → folder swap → restore), wiping
VS Code's own editor restoration. Fix by setting _activeWorktree
directly and only firing the event — no destructive editor ops.
Additionally, backgrounded worktree terminals were killed on reload
because forcePersist was never set and the ownership map was in-memory.
Now set forcePersist=true when backgrounding so pty processes survive,
and persist/restore the ownership map (keyed by persistentProcessId)
to workspace storage so terminals can be reclaimed after reconnect.
Seed _activeKey from the already-restored active worktree during contribution init so the first worktree switch correctly claims terminals. Remove the now-redundant _restoreOwnership call from _onActiveWorktreeChanging and the duplicate fire during service restoration. Fix deleteWorktreeModal test teardown to click cancel buttons instead of removing DOM elements, ensuring DisposableStores are properly disposed. Remove unused mcpStdioStateHandler test.
On macOS, clicking the red close button now hides the window instead of destroying it, preserving all terminals, editors, and cursor positions. Clicking the dock icon shows the hidden window. Cmd+Q still fully quits. Also removes debug console.warn from hookNotificationServer.
…clean up styles Extract shared _buildWorktreeEntries() to eliminate duplicated logic between addRepository and restoreState. Merge _findGroupIndex and _findTabIndex into single-pass _findGroupPosition. Move inline styles to CSS and flatten nested try/catch in getRemoteUrl.
Prevents worktree repositories inside .workstreams/ from appearing in the Source Control panel by filtering them in both directory traversal and the openRepository catch-all path.
The previous filter was too aggressive — it blocked SCM for worktrees opened as their own workspace. Now checks relative path from workspace folder so the filter only applies to sub-repo discovery, not when the workspace root itself is inside .workstreams/.
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