Repository navigation
fix(sidebar): keep independent same-host checkouts of one repo as separate projects - #7237
Conversation
…arate projects Re-regression of stablyai#5374: PR stablyai#6320 removed the per-host-surface separation added by stablyai#5375, so independent local clones of the same repo (shared origin => same github:owner/repo identity) collapse into one sidebar project again. Restore the surface-key separation in worktree-list-groups.ts, scoped by ProjectHostSetup.setupMethod: 'provisioned' (ephemeral-VM runtime copies) still nest under the project header (preserving stablyai#6320), while real user checkouts (legacy-repo / imported-existing-folder / cloned) each get their own header when duplicated on one host surface. Revert the two tests stablyai#6320 inverted and add coverage for a provisioned copy nesting alongside a same-host user checkout.
The Cmd+J palette shares getProjectGroupingForRepo (via getProjectHeaderRevealTarget) with the sidebar, so restoring same-host checkout separation also splits independent `cloned` checkouts into per-setup palette entries. Update the multi-setup test to assert the split and add coverage that a `provisioned` runtime copy still nests under one project key.
Guard the intersection of stablyai#5374 and stablyai#6320: when a project has two real same-host user checkouts AND a provisioned copy, the real checkouts each get their own per-setup header while the provisioned copy stays under the plain project key (never a path-scoped ::setup: header). Locks the two features' combined behavior so a future change can't silently regress either half.
📝 WalkthroughWalkthroughThis PR changes project grouping in the sidebar and command palette so same-project user checkouts on the same surface are split into separate per-setup keys, while provisioned runtime copies stay under the plain project key. 🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/sidebar/worktree-list-groups.test.ts (1)
819-911: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winGood combined-scenario coverage; consider adding WSL/Windows surface-key cases too.
This test nicely covers the intersection of split + nest behavior on one host. However, none of the added tests exercise the new
getProjectSetupSurfaceKeyWSL (parseWslUncPath) or Windows drive-letter branches — all fixtures use plain POSIX paths (/tmp/orca...), landing in thedefaultsurface bucket. Given these are new, non-trivial branches (case-insensitive distro matching, drive-letter regex), a couple of targeted cases would help lock in behavior, e.g.:
- two checkouts with different WSL distros on the same host should NOT split,
- two checkouts with the same WSL distro (or a Windows-host path) duplicated should split.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 357e6040-1227-45fa-9b83-6919372e469a
📒 Files selected for processing (3)
src/renderer/src/components/cmd-j/palette-results.test.tssrc/renderer/src/components/sidebar/worktree-list-groups.test.tssrc/renderer/src/components/sidebar/worktree-list-groups.ts
…ace count Take-over polish of stablyai#7237: - Use shared isWindowsAbsolutePathLike instead of an inline drive-letter regex, deduplicating the pattern and also bucketing UNC \\server\share paths as a Windows surface instead of falling through to default. - Collapse buildProjectGroupingIndex's two passes over projectHostSetups into one, computing each surface key once and flagging ambiguous projects from the aggregated counts. - Tighten why-comments to AGENTS.md's two-line rule. No behavior change to the fix; all 123 sidebar/palette grouping tests pass. Co-authored-by: Orca <[email protected]>
Maintainer take-over summaryI took this PR over for validation, hostile-author security screening, and polish. Summary of what I did and found: Verdict: VALIDATED. The bug is real, still present on Security screen — clean. Reviewed the full diff vs merge-base with a hostile eye: no network/exfiltration, no obfuscation, no CI/workflow/script/dependency/postinstall changes, no credential/keychain/shell/path-traversal/unicode tricks. It is pure client-side, read-only sidebar grouping logic. Root cause confirmed by git archaeology. #5375 added the same-host split; #6430 refined it for WSL/Windows; #6320 ( Reproduced first, then verified. With the fix reverted to Changes I made on top of the author's work:
Checks: Not merging or approving — leaving that to a human maintainer. Also worth reopening #5374 upstream, which is currently marked completed but regressed. |
|
Thanks so much for this one, @Naxon. Independent checkouts of the same repo collapsing into each other is one of those things nobody notices until it's suddenly broken, and you pinned down exactly the right discriminator to tell them apart. Appreciate the careful work here — merged and shipped. |
|
Hey Daniel — thank you for this one 🙏 The part that impressed me was the archaeology: tracing the collapse back to the #6320 "Per-Workspace Environments" change and realizing the |
…arate projects (stablyai#7237) * fix(sidebar): keep independent same-host checkouts of one repo as separate projects Re-regression of stablyai#5374: PR stablyai#6320 removed the per-host-surface separation added by stablyai#5375, so independent local clones of the same repo (shared origin => same github:owner/repo identity) collapse into one sidebar project again. Restore the surface-key separation in worktree-list-groups.ts, scoped by ProjectHostSetup.setupMethod: 'provisioned' (ephemeral-VM runtime copies) still nest under the project header (preserving stablyai#6320), while real user checkouts (legacy-repo / imported-existing-folder / cloned) each get their own header when duplicated on one host surface. Revert the two tests stablyai#6320 inverted and add coverage for a provisioned copy nesting alongside a same-host user checkout. * test(cmd-j): update palette grouping tests for same-host checkout split The Cmd+J palette shares getProjectGroupingForRepo (via getProjectHeaderRevealTarget) with the sidebar, so restoring same-host checkout separation also splits independent `cloned` checkouts into per-setup palette entries. Update the multi-setup test to assert the split and add coverage that a `provisioned` runtime copy still nests under one project key. * test(sidebar): cover split + provisioned-nest on one host together Guard the intersection of stablyai#5374 and stablyai#6320: when a project has two real same-host user checkouts AND a provisioned copy, the real checkouts each get their own per-setup header while the provisioned copy stays under the plain project key (never a path-scoped ::setup: header). Locks the two features' combined behavior so a future change can't silently regress either half. * refactor(sidebar): reuse shared Windows-path helper, single-pass surface count Take-over polish of stablyai#7237: - Use shared isWindowsAbsolutePathLike instead of an inline drive-letter regex, deduplicating the pattern and also bucketing UNC \\server\share paths as a Windows surface instead of falling through to default. - Collapse buildProjectGroupingIndex's two passes over projectHostSetups into one, computing each surface key once and flagging ambiguous projects from the aggregated counts. - Tighten why-comments to AGENTS.md's two-line rule. No behavior change to the fix; all 123 sidebar/palette grouping tests pass. Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Neil <[email protected]> Co-authored-by: Orca <[email protected]>
Description
In the sidebar, multiple independent local checkouts of the same git repo on one host (e.g.
app,app-clone-2,app-hotfix, all cloned from onegithub.com/owner/repo) collapse into a single project header instead of appearing as separate projects. All their worktrees nest under one arbitrarily-named project.This is a re-regression of #5374. The sidebar groups checkouts by a host-independent project identity (
github:owner/repo, derived from the git remote) so the same repo on Local + SSH shows as one project — but that same identity also collapses genuinely independent checkouts on one host. #5375 (and #6430 for WSL/Windows) fixed this by splitting same-host duplicates at the grouping layer. #6320 ("Per-Workspace Environments") then deleted that split so its newprovisionedephemeral-runtime copies would nest under one header — but it had no way to tell a provisioned copy from a genuine user checkout, so it collapsed everything.This PR restores same-host checkout separation, scoped by the discriminator the data model already carries —
ProjectHostSetup.setupMethod:provisioned(recipe-created ephemeral-runtime copies) → still nest under the project header, preserving Per-Workspace Environments (on-demand disposable runtimes) + Add Project remote host setup #6320's feature.legacy-repo/imported-existing-folder/cloned(real user checkouts) → each becomes its own sidebar entry when duplicated on one host surface, fixing Regression (v1.4.68): multiple local checkouts of the same repo collapse into one sidebar project #5374.Implemented in
src/renderer/src/components/sidebar/worktree-list-groups.ts:isDistinctUserCheckout(setup)=setup.setupMethod !== 'provisioned'.getProjectSetupSurfaceKey(setup)=projectId::hostId::{wsl:<distro> | windows-host | default}, classified by the checkout's path string (not the client OS, so SSH/remote clients holding aC:\or\\wsl.localhost\path for a remote host classify correctly). A Windows checkout and its WSL checkout of one project (same runtime host, different execution surfaces) are therefore not treated as duplicates.buildProjectGroupingIndexcounts real user checkouts per surface in one pass; a project with >1 on one surface is flagged inprojectIdsRequiringSetupGroups.getProjectGroupingForReporeturns the per-setup keyproject:${id}::setup:${repoId}only for a flagged project's distinct user checkouts; provisioned copies still returnproject:${id}.The Cmd+J palette shares this grouping (via
getProjectHeaderRevealTarget), so it surfaces each independent checkout as its own jump target too. The::setup:key format is a pre-existing #5375/#6430 shape already parsed byWorktreeList.tsxreveal/drop logic (getProjectIdFromHeaderRowKey/getRepoIdsFromHeaderRowKey), so no downstream regression.Maintainer take-over notes (@nwparker)
This PR was taken over for validation and polish. On top of the original author's work:
main(no conflicts).mainwith the added tests, then verified the fix flips them green (evidence below).isWindowsAbsolutePathLikehelper (src/shared/cross-platform-path.ts) — deduplicates the pattern used in 8+ call sites and additionally buckets UNC\\server\sharepaths as a Windows surface instead ofdefault. Safe direction: coarser bucketing can only increase splitting, never wrongly merge distinct checkouts.buildProjectGroupingIndex's two passes overprojectHostSetupsinto one (each surface key computed once).Reviewed under a hostile-author security screen (pure client-side, read-only grouping; no network/IPC/shell/filesystem/auth/dependency changes) — clean.
Evidence
Reproduced-before (fix reverted to
main, PR tests kept) — 4 split assertions fail:The collapse is visible directly: same-host checkouts resolve to a single
project:github:stablyai/orcaheader instead of one header per checkout.Fixed-after (this branch) — all green:
pnpm typecheck(node + cli + web) — passoxlinton touched files — passWorktreeList.tsx(::setup:parsing already present).Provisioned-nesting coverage, the split×nest intersection, and the Windows+WSL-on-one-host case are all covered by the added unit tests.
ELI5
Imagine your sidebar is a shelf of labeled folders. If you download the same book (repo) into three different boxes on your desk, you want three folders on the shelf — one per box. A recent change meant to handle temporary "loaner" copies of a book accidentally started shoving all copies — including your three real ones — into a single folder with one box's name, hiding the other two. This change teaches the shelf to tell a real copy from a temporary loaner: real copies each get their own folder again, while temporary loaner copies still tuck neatly inside the main folder.
Trade-offs
provisionedgate is a denylist (!== 'provisioned'). A futuresetupMethodthat should also nest would default to "distinct" until this predicate is updated — kept as-is to mirror the data model's framing.