Skip to content

fix(projects/sidebar): prefer origin for project identity; prune stale project-group collapse keys - #29792

Open
rizub wants to merge 4 commits into
stablyai:mainfrom
rizub:fix/origin-project-identity-and-sidebar-collapse
Open

rizub wants to merge 4 commits into
stablyai:mainfrom
rizub:fix/origin-project-identity-and-sidebar-collapse

Conversation

@rizub

@rizub rizub commented Oct 16, 2026

Copy link
Copy Markdown

Summary

  • Prefer gitRemoteIdentity (origin) over GitHub fork-parent upstream / parent avatar when deriving project provider identity, so org remotes that are still marked as forks share one project id across Local + VPS hosts.
  • Ignore / prune persisted project-group:<uuid> entries in collapsedGroups when the group no longer exists, so the TanStack sidebar virtualizer stops measuring ghost rows after group reshuffles.

Fixes #29789
Related: #13945, #21309

Why

On multi-host setups, orca repo add of an org remote that GitHub still lists as a fork was stamped as github:<parent> locally while the VPS stayed on github:<org>/<repo>. Dual workspaces never merged, and setup-existing-folder failed with identity mismatch. Separately, deleting/reparenting project groups left stale collapsedGroups keys that corrupted sidebar layout until a manual wipe.

Test plan

  • project-host-setup-projection unit tests pass (includes new org-fork + dual-host case)
  • Add org-fork checkout with origin=org/repo and GitHub parent=user/repo on two hosts → one project with Local + remote setups
  • setup-existing-folder against the org project id succeeds for that folder
  • Create nested project groups, collapse them, delete/flatten parents, restart → sidebar headers no longer overlap
  • Existing upstream-only repos (no gitRemoteIdentity) still project as before

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Project identity resolution now checks the remote URL and canonical key before upstream or avatar metadata. The sidebar hook filters collapsed project-group keys against the current project groups before returning them or processing reveal keys. Tests cover local and SSH checkouts that share an origin identity.

Priority: ➖ Normal

Estimated code review effort:

Severity of issue fixed: Medium

Merge Risk: 🟡 Moderate · up to 7b878

Checkouts using an SSH alias can receive a different project ID from checkouts using the resolved GitHub host. Fix alias handling before merging; the stated origin-first behavior also remains incomplete for non-GitHub origins.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description explains the problem, user impact, changes, rationale, linked issue, and planned tests. However, it omits required template sections, including Visual Proof, Review, Agent skill upstre… Complete the required template sections. Add Visual Proof with screenshots or videos, or write N/A with a reason if there is no visual or interaction change. Complete or explain the Testing checklist, record the relevant review and compatib…
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly summarizes both primary changes: preferring origin-based project identity and pruning stale project-group collapse keys.
Linked Issues check Passed Issue #29789 has two coding requirements. getProjectProviderIdentity now checks gitRemoteIdentity.remoteUrl and canonicalKey before upstream and avatar metadata. This makes a valid origin iden…
Out of Scope Changes check Passed The reviewed changes stay within issue #29789. The projection change implements origin-based identity matching. The sidebar change sanitizes stale project-group collapse state. The added projection te…
Full details: Linked Issues check

Explanation

Issue #29789 has two coding requirements. getProjectProviderIdentity now checks gitRemoteIdentity.remoteUrl and canonicalKey before upstream and avatar metadata. This makes a valid origin identity primary for project projection. sanitizeCollapsedGroupsAgainstProjectGroups removes missing project-group:&lt;id&gt; keys, and useEffectiveCollapsedGroups applies it before sidebar reveal logic. The projection tests cover an org-fork origin and verify one project with two host setups.

Full details: Out of Scope Changes check

Explanation

The reviewed changes stay within issue #29789. The projection change implements origin-based identity matching. The sidebar change sanitizes stale project-group collapse state. The added projection tests support the identity requirement. No unrelated behavior or files are identified in the available whole-PR summary.

Full details: Description check

Explanation

The description explains the problem, user impact, changes, rationale, linked issue, and planned tests. However, it omits required template sections, including Visual Proof, Review, Agent skill upstream boundary, Notes, and Checklist. The test items are also unchecked.

Resolution

Complete the required template sections. Add Visual Proof with screenshots or videos, or write N/A with a reason if there is no visual or interaction change. Complete or explain the Testing checklist, record the relevant review and compatibility considerations, complete the Agent skill upstream boundary section, and complete the final Checklist.

  • Fix all pre-merge checks with AI
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 224019d8-ed01-4149-ba45-d37cf2201b2e
📥 Commits

Reviewing files that changed from the base of the PR and between 41bd7ba and 7b87869.

📒 Files selected for processing: 4
  • src/renderer/src/components/sidebar/host-section-collapse.ts
  • src/renderer/src/components/sidebar/worktree-list/listing/use-collapsed-groups.ts
  • src/shared/project-host-setup-projection.test.ts
  • src/shared/project-host-setup-projection.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment on lines +38 to +40
const fromRemote =
parseGitHubRemoteUrl(repo.gitRemoteIdentity?.remoteUrl) ??
parseGitHubCanonicalKey(repo.gitRemoteIdentity?.canonicalKey)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '35,48p;140,230p' src/shared/project-host-setup-projection.ts
sed -n '100,155p' src/shared/git-remote-identity.ts
rg -n 'github.com-work|GHES|enterprise|ssh alias|Host github' src/shared/project-host-setup-projection* src/shared/git-remote-identity* | head -100

Repository: stablyai/orca

Length of output: 6757


🏁 Script executed:

set -e
printf '%s\n' '--- projection identity selection ---'
sed -n '1,75p' src/shared/project-host-setup-projection.ts
printf '%s\n' '--- host parsing and normalization ---'
sed -n '135,235p' src/shared/project-host-setup-projection.ts
printf '%s\n' '--- remote normalization ---'
sed -n '1,180p' src/shared/git-remote-identity.ts
printf '%s\n' '--- relevant tests ---'
sed -n '150,380p' src/shared/project-host-setup-projection.test.ts
printf '%s\n' '--- base to head diff for these files ---'
git diff 42dfd813fedb9497e3df23fc100f810e5f4cdab7 7b87869d832c62ea82a0ead58b029da7f2b7a236 -- src/shared/project-host-setup-projection.ts src/shared/git-remote-identity.ts src/shared/project-host-setup-projection.test.ts

Repository: stablyai/orca

Length of output: 42625


🏁 Script executed:

set -e
printf '%s\n' '--- alias helper and references ---'
sed -n '1,260p' src/shared/git-remote-host-alias.ts
printf '%s\n' '--- alias helper tests/references ---'
rg -n -F --glob '*.{ts,tsx}' -e 'isUnresolvedSshHostAlias' -e 'normalizeGitHubRemoteHost' -e 'github.com-work' -e 'git-remote-host-alias' src || test "$?" -eq 1
printf '%s\n' '--- focused test blocks ---'
rg -n -F --glob '*.{ts,tsx}' -e 'alias' -e 'SSH' -e 'ssh' src/shared/git-remote-host-alias* src/shared/project-host-setup-projection.test.ts src/shared/git-remote-identity.test.ts || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 9451


🏁 Script executed:

set -e
printf '%s\n' '--- GitHub remote identity parsing ---'
sed -n '1,190p' src/main/github/github-remote-identity-parsing.ts
printf '%s\n' '--- parser tests around SSH aliases ---'
sed -n '80,155p' src/main/github/github-remote-identity-parsing.test.ts
printf '%s\n' '--- SSH config alias resolution implementation and callers ---'
rg -n -F --glob '*.{ts,tsx}' -e 'gitHubSshConfigHostAlias' -e 'resolveWithSsh' -e 'resolvedSshHostname' -e 'github.com-work' src/main src/shared || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 23071


🏁 Script executed:

set -e
printf '%s\n' '--- remote identity enrichment ---'
sed -n '1,190p' src/main/repo-git-remote-identity-enrichment.ts
printf '%s\n' '--- GitHub SSH alias resolution ---'
sed -n '1,220p' src/main/github/github-ssh-host-alias-resolution.ts
printf '%s\n' '--- GitHub repository identity alias handling ---'
sed -n '220,285p' src/main/github/github-enterprise-repository.ts

Repository: stablyai/orca

Length of output: 16574


Resolve SSH aliases before using remote identity.

parseGitHubRemoteUrl accepts github.com-work through the github- prefix. Therefore, [email protected]:org/repo.git can produce github:github.com-work/org/repo and override upstream or avatar metadata. canonicalKey has the same problem because it is derived from the raw remote URL.

When an SSH alias is unresolved, both provider-identity parsers must return null and allow upstream or avatar metadata to provide the fallback. Use the resolved SSH hostname when one is available. Do not reject every non-default SSH host, because direct GHES hosts such as github.acme.test are supported identities.

Comment on lines +38 to +43
const fromRemote =
parseGitHubRemoteUrl(repo.gitRemoteIdentity?.remoteUrl) ??
parseGitHubCanonicalKey(repo.gitRemoteIdentity?.canonicalKey)
if (fromRemote) {
return fromRemote
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '1,145p' src/shared/project-host-setup-projection.ts
sed -n '145,250p' src/shared/project-host-setup-projection.ts
rg -n 'gitRemoteIdentity|upstream|gitlab|bitbucket|non-GitHub' src/shared/project-host-setup-projection.test.ts | head -105

Repository: stablyai/orca

Length of output: 12000


The origin-first identity selection does not apply to non-GitHub origins.

When gitRemoteIdentity is valid but points to a non-GitHub host, both remote parsers return null. The function then selects the GitHub upstream or avatar identity. getProjectIdentityKey therefore returns github:<upstream> instead of git:<canonicalKey>, so unrelated repositories that share GitHub fork-parent metadata can collide, while the same origin without that metadata receives a different project ID.

The origin-first contract must also use the provider-neutral gitRemoteIdentity when the origin is not a recognized GitHub remote. The fix must preserve GitHub origin parsing and the existing upstream/avatar fallback only when no usable remote identity exists.

This branch has not been deployed

No deployments
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.

fix(projects/sidebar): prefer origin over fork-parent upstream for project identity; prune stale project-group collapse keys

1 participant