Skip to content

fix(git): prioritize probed remote identity over stale avatar icon (#21515) - #21890

Closed
bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:fix/21515-stale-repo-icon-identity
Closed

bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:fix/21515-stale-repo-icon-identity

Conversation

@bbingz

@bbingz bbingz commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

ELI5

When a repository is renamed or transferred to a new organization on GitHub, Orca should group all worktrees across different computers under the updated repository name instead of keeping them split apart under old names.

What Changed

  • User experience before: If a repository was transferred or renamed (e.g. from owner-a/app to org-b/app), existing machines that had already cached the old avatar icon label would continue to group the repository under github:owner-a/app. A newly added machine would derive github:org-b/app. This caused the sidebar to show duplicate project rows split across machines for the same repository with no way to merge them.
  • User experience after: All machines resolve the repository's identity to the updated remote (github:org-b/app), unifying worktrees into a single project row across local and remote hosts.
  • Mechanism: In getProjectProviderIdentity() (src/shared/project-host-setup-projection.ts), evaluate the probed gitRemoteIdentity before falling back to cached repoIcon avatar metadata.

Why

Probed gitRemoteIdentity is the authoritative source of truth for the active repository remote and is continuously refreshed (every 6h by repo-git-remote-identity-enrichment.ts). In contrast, repoIcon.label is a static presentation artifact captured once during initial clone or import. Prioritizing the authoritative remote identity over cached avatar labels ensures that renames and transfers take effect immediately and consistently across all connected execution hosts.

Alternatives considered:

  • Updating repoIcon and upstream in the periodic identity enrichment sweep: This would require network calls or GitHub API queries in the background sweep and would not fix project grouping on hosts before the sweep runs or on offline/disconnected clients. Evaluating the already-probed gitRemoteIdentity in the projection is immediate, pure, and does not require extra network requests.

Linked Issue

Fixes #21515

Visual Proof

N/A - This fixes repository identity resolution and project grouping logic across hosts; no new UI primitives or styles were introduced.

Testing

  • Automated tests added/updated:
    • Added regression test prefers probed git remote identity over stale cached avatar icon label across renames in src/shared/project-host-setup-projection.test.ts.
    • Added isGitHubBackedRepo test covering gitRemoteIdentity in src/shared/project-host-setup-projection.test.ts.
  • Local verification:
    • node config/scripts/check-changed-code-quality.mjs (passed with 0 findings)
    • node config/scripts/check-max-lines-ratchet.mjs (passed with 0 new bypasses)
    • tsc --noEmit across CLI, Node, and Web configurations (all passed)
    • vitest run on project-host-setup-projection.test.ts and repo-git-remote-identity-enrichment.test.ts (60 passed)

AI Disclosure

Developed with Google Antigravity.

Agent skill upstream boundary

  • Not applicable

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 3e2580d1-11a3-4679-ad05-a2fa166879bb

📥 Commits

Reviewing files that changed from the base of the PR and between 7a6d100 and f09d8a4.

📒 Files selected for processing (2)
  • src/shared/project-host-setup-projection.test.ts
  • src/shared/project-host-setup-projection.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

getProjectProviderIdentity now checks gitRemoteIdentity before the cached repoIcon label. It parses the remote URL first and the canonical key second. The previous final remote-parsing fallback is replaced with return null. Tests cover renamed repositories with stale labels and GitHub detection from gitRemoteIdentity.

Priority: ➖ Normal

Severity of issue fixed: Medium

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: prioritizing probed Git remote identity over stale avatar metadata.
Description check ✅ Passed The description is complete and relevant. It explains the user impact, mechanism, rationale, alternatives, linked issue, visual proof, testing, AI disclosure, and scope. The Review and Notes sections …
Linked Issues check ✅ Passed The change satisfies #21515. getProjectProviderIdentity now checks gitRemoteIdentity.remoteUrl, then gitRemoteIdentity.canonicalKey, before the cached GitHub repoIcon label. This makes the ref…
Out of Scope Changes check ✅ Passed The diff is limited to the project identity precedence logic and related regression tests in src/shared/project-host-setup-projection.ts and its test file. These changes directly implement #21515 an…
  • Fix all pre-merge checks with AI

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.

@pullfrog pullfrog 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.

Important

The reorder makes the raw probed remote authoritative over a correctly resolved avatar, which exposes an inconsistency for dotless SSH host aliases. A repo cloned through an alias named github-* / ghe-* now keys as GHES (github:github-work/owner/repo) instead of github:owner/repo, splitting it from its github.com siblings. Details inline.

Reviewed changes

  • Precedence reorder — getProjectProviderIdentity() now evaluates the probed gitRemoteIdentity before the cached GitHub repoIcon.label, so a renamed/transferred repo (owner-a/app → org-b/app) no longer stays grouped under the stale icon on machines that cached it.
  • Rename regression test — both repos carry remote org-b/app; one keeps a stale owner-a/app icon; asserts a single project github:org-b/app. This test genuinely fails against the old ordering (two projects), so it pins the fix.
  • isGitHubBackedRepo test — covers a remote-only repo; see nitpicks.

I verified the same-name-fork parent preference (githubAvatarSlug) is not regressed: a same-name fork always carries repo.upstream, which is still evaluated first, and icon/upstream are written atomically by detectRepoIconAndUpstream. Re-keying of persisted project ids is also handled by carryProjectStateThroughIdentityChange.

ℹ️ Nitpicks

  • The deleted // Why: the remote URL retains HTTP(S) endpoint ports that the canonical key omits... comment explained a load-bearing ordering (parseGitHubRemoteUrl before parseGitHubCanonicalKey, still exercised by the preserves GHES HTTP ports test). Consider restoring it above fromRemote.
  • The new isGitHubBackedRepo test passes against the old code too — getProjectProviderIdentity already evaluated gitRemoteIdentity last, so it documents behavior but does not pin this change.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment on lines +42 to +47
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.

The reorder makes this branch authoritative over a correctly resolved avatar, but parseGitHubRemoteUrl / parseGitHubCanonicalKey keep the remote's host verbatim. For a dotless SSH alias such as github-work, isGitHubRemoteHost() matches the github- prefix, so the project keys as github:github-work/owner/repo, while the icon for the same repo was resolved through ssh -G to github.com/owner/repo. That splits alias-cloned repos from their github.com siblings — the same failure mode this PR fixes.

Technical details
# Unresolved SSH alias hosts leak into the project identity key

## Affected sites
- `src/shared/project-host-setup-projection.ts:42-47` — the newly prioritized remote branch returns a host-qualified identity for a dotless alias host.
- `src/shared/project-host-setup-projection.ts:144-155` — `isGitHubRemoteHost()` treats `github-*` / `ghe-*` hosts as GHES without consulting `isUnresolvedSshHostAlias`.
- `src/shared/git-remote-host-alias.ts:42` — `isUnresolvedSshHostAlias`: a dotless host is an OpenSSH `Host` alias, unexpandable from `git remote -v`.
- `src/shared/git-remote-identity.ts:44` — the comparison path already treats dotless hosts as `'unknown'`, so the projection path is inconsistent with it.

## Reproduction
Repo cloned as `git@github-work:org/app.git` with `HostName github.com` in `~/.ssh/config`, plus a github-sourced `repoIcon` (avatar detection resolves the alias to `github.com`). Before the reorder: icon → `github:org/app`. After: remote `canonicalKey` `github-work/org/app` → `github:github-work/org/app`.

## Required outcome
An unexpanded dotless SSH alias must not mint a host-qualified GHES project id while a resolved identity (the icon) exists; both identity paths should agree on github.com.

## Suggested approach
Either skip `fromRemote` when `fromRemote.host` is a dotless alias (fall through to the icon), or update `isGitHubRemoteHost` to return false for `isUnresolvedSshHostAlias(host)` so every identity path agrees.

@nwparker

Copy link
Copy Markdown
Contributor

Closing as superseded by merged #22421, which carries the reviewed fix and regression coverage. Thank you for the original contribution. The merged approach repairs automatic metadata at its owning host rather than changing identity precedence across mixed client/host versions.

@nwparker nwparker closed this Sep 26, 2026
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.

[Bug]: Stale repoIcon label outranks the re-probed git remote in project identity — renames and transfers permanently split one project across hosts

2 participants