Skip to content

fix: persist SCM repository visibility state across restarts#301029

Open
kno wants to merge 1 commit intomicrosoft:mainfrom
kno:fix/scm-repo-visibility-persistence
Open

fix: persist SCM repository visibility state across restarts#301029
kno wants to merge 1 commit intomicrosoft:mainfrom
kno:fix/scm-repo-visibility-persistence

Conversation

@kno
Copy link

@kno kno commented Mar 12, 2026

Summary

Fixes #301028

  • isHidden repos (e.g., Copilot worktrees) no longer corrupt the visibility restoration on startup. They are skipped in the previousState logic since they were never part of the saved state.
  • New repos (not in previous state) are added as visible without resetting the visibility of existing repos or the didSelectRepository flag.

Changes

  • scmViewService.ts: Fixed onDidAddRepository to properly handle isHidden repos and new repos during state restoration
  • scmViewService.test.ts: Added 4 tests covering visibility persistence scenarios

Test plan

  • Open a multi-repo workspace, hide a repo in the SCM Repositories view, restart VS Code → hidden repo should remain hidden
  • Same scenario but with a Copilot worktree present → hidden repo should remain hidden
  • Add a new git repo to the workspace after hiding one, restart → new repo visible, previously hidden repo still hidden
  • Hidden repo registers before visible repos on startup → visibility correctly restored regardless of order

@vs-code-engineering
Copy link

vs-code-engineering bot commented Mar 12, 2026

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@lszomoru

Matched files:

  • src/vs/workbench/contrib/scm/browser/scmViewService.ts
  • src/vs/workbench/contrib/scm/test/browser/scmViewService.test.ts

SCM repository visibility was not properly restored on restart due to
two issues in the onDidAddRepository restoration logic:

1. Repositories with isHidden (e.g., Copilot worktrees) were not in the
   saved state but triggered the index === -1 path, which made ALL repos
   visible and reset the didSelectRepository flag.

2. Genuinely new repos (not in previous state) also triggered the same
   path, making all existing repos visible instead of only adding the
   new repo.

The fix:
- Skip the restoration logic for isHidden repos (they are still tracked
  internally but don't affect visibility restoration)
- New repos are added as visible without changing existing repos'
  visibility state
@kno kno force-pushed the fix/scm-repo-visibility-persistence branch from 18fff29 to 1864f58 Compare March 12, 2026 06:23
@kno
Copy link
Author

kno commented Mar 12, 2026

@kno please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

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.

SCM repository visibility is not persisted across restarts

2 participants