Open
Conversation
When a user deletes a sidebar group linked to a tracked repository, ReconcileOrganization would immediately recreate it because it enforces 'every tracked repo must have a sidebar group'. This caused the deleted group to reappear in the sidebar. Root cause: Three code paths in ReconcileOrganization call GetOrCreateRepoGroup which recreates the group if the repo is still tracked by RepoManager. Fix: - Add DeletedRepoGroupRepoIds to OrganizationState (persisted to JSON) to track repos whose groups were explicitly deleted by the user - GetOrCreateRepoGroup now accepts an 'explicitly' parameter: implicit calls (from ReconcileOrganization) return null for deleted repos; explicit calls (from repo-add operations) clear the deleted flag - DeleteGroup clears WorktreeId on moved sessions to prevent ReconcileOrganization from reassigning them via the worktree path - Null-coalesce guard in LoadOrganization for backward compatibility with old organization.json files Includes 13 new tests covering all scenarios. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Problem
When a user deletes a sidebar group that is linked to a tracked repository, the group reappears ("resurrects") on the next UI state refresh. This happens because
ReconcileOrganization()enforces the invariant "every tracked repo must have a sidebar group" — but this conflicts with the user's explicit deletion.Root Cause
Three code paths in
ReconcileOrganizationcallGetOrCreateRepoGroup, which recreates the group if the repo is still tracked by RepoManager:_defaultgroup → creates repo groupFix
DeletedRepoGroupRepoIds— newHashSet<string>onOrganizationState(persisted toorganization.json) that tracks repo IDs whose groups were explicitly deleted by the userGetOrCreateRepoGroup(repoId, name, explicitly)— newexplicitlyparameter:nullfor deleted reposDeleteGroup— now clearsWorktreeIdon moved sessions for repo groups, preventing ReconcileOrganization from reassigning them via the worktree pathLoadOrganizationhandles oldorganization.jsonfiles without the new fieldTests
13 new tests in
DeletedRepoGroupResurrectionTestscovering:All 1157 existing tests pass (1 pre-existing locale-dependent failure unrelated).