Skip to content

Improve worktree switching stability and explorer state persistence #55

Merged
amandal0903 merged 7 commits intomainfrom
more-stability
Apr 2, 2026
Merged

Improve worktree switching stability and explorer state persistence #55
amandal0903 merged 7 commits intomainfrom
more-stability

Conversation

@amandal0903
Copy link
Copy Markdown
Collaborator

Changes

  • Decouple explorer tree state from ExplorerView — Moves per-worktree file explorer state caching (expanded folders, scroll position, focus/selection) into a dedicated OrchestratorExplorerContribution, removing the direct IOrchestratorService
    dependency from ExplorerView. This matches the existing pattern used by OrchestratorTerminalContribution and keeps orchestrator logic out of core VS Code files.
  • Expose minimal hooks on IExplorerService — Adds getTreeViewState() and setPendingTreeViewState() to IExplorerService/IExplorerView so the contribution can save/restore tree state without reaching into view internals.
  • Harden editor auto-retry — Wraps the failed-editor retry in a try/catch to handle cases where InstantiationService has been disposed during a worktree switch, and reduces retry delay from 1500ms to 500ms for faster recovery.

Avijit Mandal added 7 commits April 2, 2026 04:41
Drop the IProgressService wrapper and hardcoded setTimeout delay from
switchTo(), making worktree switches faster. Document known desktop app
issues (editor restore, layout distortion, switch latency) in CLAUDE.md.
Simplify test mocks accordingly.
The folder swap during worktree switching triggers an extension host
restart (10ms scheduler in WorkspaceChangeExtHostRelauncher). Editors
that depend on extension-provided services (e.g. diff editors via the
git extension) can hit a "Canceled" RPC error while the host restarts,
showing an error placeholder. This adds a delayed auto-retry that
re-opens any error placeholder editors after 1.5s, with up to 3
attempts — effectively auto-clicking "Try Again".
Save and restore the explorer tree's expand/scroll/focus state per
worktree so switching back to a previously visited worktree re-opens
the same folders the user had expanded. State is cached in-memory
keyed by worktree path, saved on onDidChangeActiveWorktree, and
restored when setInput re-initialises the tree after the folder swap.
Stale entries are cleaned up on worktree removal.
…ibution

Move per-worktree file explorer state caching out of ExplorerView and
into a dedicated OrchestratorExplorerContribution, matching the pattern
used by OrchestratorTerminalContribution. This removes the direct
IOrchestratorService dependency from ExplorerView and exposes minimal
hooks (getTreeViewState/setPendingTreeViewState) through IExplorerService.

Also hardens the editor auto-retry: catch errors from disposed
InstantiationService during worktree switch and reduce retry delay to
500ms for faster recovery.
@amandal0903 amandal0903 merged commit 6574db2 into main Apr 2, 2026
amandal0903 added a commit that referenced this pull request Apr 3, 2026
)

* migration plans

* remove progress wrapper and 1500ms timeout from worktree switching

Drop the IProgressService wrapper and hardcoded setTimeout delay from
switchTo(), making worktree switches faster. Document known desktop app
issues (editor restore, layout distortion, switch latency) in CLAUDE.md.
Simplify test mocks accordingly.

* remove known issues section from root CLAUDE.md

* auto-retry failed editors after worktree switch

The folder swap during worktree switching triggers an extension host
restart (10ms scheduler in WorkspaceChangeExtHostRelauncher). Editors
that depend on extension-provided services (e.g. diff editors via the
git extension) can hit a "Canceled" RPC error while the host restarts,
showing an error placeholder. This adds a delayed auto-retry that
re-opens any error placeholder editors after 1.5s, with up to 3
attempts — effectively auto-clicking "Try Again".

* persist file explorer tree state across worktree switches

Save and restore the explorer tree's expand/scroll/focus state per
worktree so switching back to a previously visited worktree re-opens
the same folders the user had expanded. State is cached in-memory
keyed by worktree path, saved on onDidChangeActiveWorktree, and
restored when setInput re-initialises the tree after the folder swap.
Stale entries are cleaned up on worktree removal.

* decouple explorer tree state persistence from ExplorerView into contribution

Move per-worktree file explorer state caching out of ExplorerView and
into a dedicated OrchestratorExplorerContribution, matching the pattern
used by OrchestratorTerminalContribution. This removes the direct
IOrchestratorService dependency from ExplorerView and exposes minimal
hooks (getTreeViewState/setPendingTreeViewState) through IExplorerService.

Also hardens the editor auto-retry: catch errors from disposed
InstantiationService during worktree switch and reduce retry delay to
500ms for faster recovery.

* remove migration plan files
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.

1 participant