Skip to content

SCM repository visibility is not persisted across restarts #301028

@kno

Description

@kno

Bug Description

When hiding repositories in the Source Control Repositories view, the visibility state is lost on restart — all repositories are shown again.

Steps to Reproduce

  1. Open a workspace with multiple git repositories
  2. In the Source Control Repositories view, deselect (hide) one or more repositories
  3. Close and reopen VS Code
  4. All repositories are visible again, ignoring the previous visibility selection

Expected Behavior

Repositories that were hidden before closing VS Code should remain hidden after restart.

Root Cause

The persistence mechanism exists (scm:view:visibleRepositories in workspace storage), but the restoration logic in SCMViewService.onDidAddRepository has two bugs:

  1. isHidden repositories (e.g., Copilot worktrees) are not included in the saved all array (because the repositories getter filters them out). When they register on restart, they hit the index === -1 code path which makes ALL repos visible and resets the didSelectRepository flag, destroying the entire restoration state.

  2. Genuinely new repositories (not present in the previous session) also trigger the index === -1 path, which makes all existing repos visible instead of only adding the new repo as visible.

Fix

  • Skip the restoration logic for isHidden repos — they should be tracked internally but not affect visibility restoration
  • For new repos not in previous state, add them as visible without changing existing repos' visibility

VS Code Version

main branch (1.112.0-dev)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions