fix: prevent duplicate URL group for local-only repos#613
Merged
Conversation
GetOrCreateRepoGroup created a duplicate URL-based group for repos that only exist as local folder repos (e.g., dotnet-maui-local-*). This caused two 'maui' groups to appear in the sidebar — the local folder group and a newly created URL-based group with the same name. The fix: when a local folder group already covers a repo with a '-local-' ID suffix, GetOrCreateRepoGroup returns null instead of creating a redundant URL-based group. Repos with managed bare clones (same repoId for both local and URL groups) still allow URL group creation for the heal-stranded-sessions scenario. Adds regression test verifying that local-only repos don't get duplicate URL-based groups during ReconcileOrganization. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Owner
Author
🔍 Multi-Model Code Review — PR #613 (v3 Re-Review)Reviewed by: 3 independent reviewers with adversarial consensus All Findings — Final Status
v3 Changes (commit
|
- Fix test repo ID to use real '-local-' format ('dotnet-maui-local-a1b2c3d4')
so the guard code is actually exercised (was 'local-repo-abc123' which
doesn't contain '-local-' substring)
- Set IsInitialized + allowPruning:false in integration test so
ReconcileOrganization doesn't early-exit before reaching heal loop
- Remove unnecessary localRepo != null check — repoId.Contains('-local-')
alone is sufficient, avoids silent failure when repo missing from state
- Simplify guard: check '-local-' first, then verify local folder group
exists (clearer intent, fewer LINQ scans on non-local repos)
- Add direct GetOrCreateRepoGroup unit test for local-only repos (null)
- Add direct GetOrCreateRepoGroup unit test for non-local repos (allowed)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add RepoManager.LocalRepoIdInfix constant ("-local-") and
IsLocalOnlyRepoId() helper method
- Replace all 5 inline "-local-" usages across RepoManager.cs and
CopilotService.Organization.cs with the constant/helper
- Add diagnostic Debug log when heal-stranded-sessions is intentionally
blocked for local-only repos (aids troubleshooting)
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
After PR #607 fixed group name destruction during promotion, a second duplicate group issue appeared:
GetOrCreateRepoGroupcreated a URL-based group for repos that only exist as local folder repos (e.g.,dotnet-maui-local-66cccd41). This caused two "maui" groups in the sidebar — the local folder group (maui3) and a newly auto-created URL group (maui).Root Cause
The "heal stranded sessions" loop in
ReconcileOrganizationcallsGetOrCreateRepoGroupfor sessions in local folder groups whose worktree paths are outside the group'sLocalPath. For local-only repos (IDs containing-local-), this created a redundant URL-based group with the same name as the local folder group's repo name.GetOrCreateRepoGroupskipsIsLocalFoldergroups when searching for existing groups (by design — they coexist). But for repos that only exist as local folder repos, this creates a duplicate.Fix
Add a guard in
GetOrCreateRepoGroup: when a local folder group already covers a repo with a-local-ID suffix, returnnullinstead of creating a redundant URL-based group. Repos without the-local-suffix (i.e., repos with both URL and local entries) still allow URL group creation for the heal-stranded-sessions scenario.Testing
LocalOnlyRepo_DoesNotCreateUrlGroup_ForCentralizedWorktreeHealsStrandedSessionstests still pass (URL repos with both local + managed worktrees)