Repository navigation
Reconcile existing-folder project identity from canonical remotes (#10620) - #10809
AmethystLiang wants to merge 1 commit into
Conversation
Before rejecting a mismatched existing Git folder, synchronously re-probe its current remotes on the host that owns it and decide acceptance from canonical remote keys, not from projected project ids. Persist the authoritative result on acceptance only; a rejected import leaves the store untouched. The policy applies uniformly to local, SSH, and runtime-host setup paths. A migration converges stale host-less GitHub Enterprise project IDs onto their host-qualified equivalents.
📝 WalkthroughWalkthroughThe change adds multi-remote canonical Git identity probing with timeout handling, centralized existing-folder reconciliation, rollback support, worktree metadata repair, and GitHub Enterprise project-ID migration. Local IPC and runtime setup paths now use reconciliation with execution-host validation and conditional notifications. Persistence preserves upstream hosts and restores identity fields for rejected writes. Extensive unit and integration tests cover matching, fallback, routing, rollback, migration, and isolated Git behavior. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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.
Actionable comments posted: 2
🧹 Nitpick comments (3)
DESIGN.md (1)
177-181: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueTag the fenced block to satisfy MD040.
-``` +```text projectCanonicalKeys(project) =Source: Linters/SAST tools
src/main/ipc/repos-remote.test.ts (1)
2088-2092: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPrefer the channel-counting helper over
not.toHaveBeenCalledWith('repos:changed').
toHaveBeenCalledWith('repos:changed')only matches an exact single-argument call. IfnotifyReposChangedever sends a payload alongside the channel, this assertion silently passes even when a broadcast occurred.reposChangedNotifications()(Line 1765) filters on channel only and is immune to that.♻️ Suggested tightening
- // The store never changed, so the renderer must not be told it did. - expect(mockWindow.webContents.send).not.toHaveBeenCalledWith('repos:changed') + // The store never changed, so the renderer must not be told it did. + expect(reposChangedNotifications()).toBe(0)src/main/persistence.test.ts (1)
597-626: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider asserting
getProjects()/getProjectHostSetups()survive the load-time remap too.This test only checks
worktreeMeta. The scenario the "Why" comment inpersistence.tscalls out — a host-less GHES reference losing its project row whenmergeProjectHostSetupCompatibilityStaterebuilds repo-backed rows — is only unit-tested in isolation (github-enterprise-project-id-remap.test.ts), not through the fullStore.load()pipeline. Adding a project/host-setup assertion here would cover the end-to-end path for the actual motivating bug (#10620).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9863d362-9c9e-4f0c-9cfd-f36b43bc4ec8
📒 Files selected for processing (20)
DESIGN.mdsrc/main/github-enterprise-project-id-remap.test.tssrc/main/github-enterprise-project-id-remap.tssrc/main/ipc/repos-remote.test.tssrc/main/ipc/repos.tssrc/main/persistence.test.tssrc/main/persistence.tssrc/main/project-host-existing-folder-reconciliation-fixture.tssrc/main/project-host-existing-folder-reconciliation.test.tssrc/main/project-host-existing-folder-reconciliation.tssrc/main/project-identity-repair-worktree-meta.tssrc/main/project-remote-identity-match.tssrc/main/repo-git-remote-identity-enrichment.test.tssrc/main/repo-git-remote-identity.test.tssrc/main/repo-git-remote-identity.tssrc/main/runtime/isolated-git-repo-fixture.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/shared/git-remote-identity.test.tssrc/shared/git-remote-identity.ts
| const ownedExecutionHostId = normalizeExecutionHostId(hostId) ?? LOCAL_EXECUTION_HOST_ID | ||
| if (parseExecutionHostId(ownedExecutionHostId)?.kind === 'ssh') { | ||
| throw new Error( | ||
| 'SSH hosts must be set up through the desktop projectHostSetups.setupExistingFolder IPC.' | ||
| ) | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
ast-grep run --pattern $'export function normalizeExecutionHostId($$$) { $$$ }' --lang typescript src/shared/execution-host.ts
rg -nP -C3 '\bnormalizeExecutionHostId\s*\(' src --type=tsRepository: stablyai/orca
Length of output: 30207
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "## execution host parsing helpers"
sed -n '1,180p' src/shared/execution-host.ts | cat -n
echo
echo "## orca-runtime addExistingFolder context"
sed -n '14888,14998p' src/main/runtime/orca-runtime.ts | cat -n
echo
echo "## addRepo definitions/usages"
rg -n "function addRepo|addRepo\s*\(" src/main/src src/main --type=ts | sed -n '1,120p'
# locate implementation more robustly by filename/outline
fd -e ts . src/main | xargs -r rg -n "addRepo\\s*\\(|class .*Repo|executionHostId" | sed -n '1,140p'Repository: stablyai/orca
Length of output: 23134
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "## implementation files containing addRepo"
rg -n "async .*addRepo|addRepo\s*\(" src/main/runtime src/main/persistence src/main/ipc --type=ts | sed -n '1,180p'
echo
echo "## exact orca-runtime addExistingFolder"
sed -n '14888,14998p' src/main/runtime/orca-runtime.ts | cat -n
echo
echo "## orca runtime repo methods around addRepo"
rg -n -C5 "addRepo\\s*\\(" src/main/runtime src/main --type=ts | sed -n '1,220p'Repository: stablyai/orca
Length of output: 2132
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "## orca-runtime addRepo implementation"
sed -n '15400,15495p' src/main/runtime/orca-runtime.ts | cat -n
echo
echo "## setupProjectClone host resolution context"
sed -n '15690,15820p' src/main/runtime/orca-runtime.ts | cat -n
echo
echo "## imports/constants around addExistingFolder/top"
sed -n '1,80p' src/main/runtime/orca-runtime.ts | cat -nRepository: stablyai/orca
Length of output: 13521
Stamp the repo with the canonical ownedExecutionHostId, not the raw args.hostId.
normalizeExecutionHostId can return null for unparseable values, which this code masks by treating the host as local while addRepo still stamps args.hostId on the persisted Repo. Pass ownedExecutionHostId to addRepo, and reject instead of coercing when normalization returns null.
🛡️ Proposed alignment
- const repo = await this.addRepo(
- args.path,
- args.kind === 'folder' ? 'folder' : 'git',
- args.hostId
- )
+ const repo = await this.addRepo(
+ args.path,
+ args.kind === 'folder' ? 'folder' : 'git',
+ ownedExecutionHostId
+ )| this.invalidateResolvedWorktreeCache() | ||
| // Reconciliation can move the repo between projects, and only an identity write does | ||
| // that — the setup-method stamp it always writes is already in the returned result. | ||
| if (!addRepoNotified || didReconciliationChangeRepoIdentity(repo, result.repo)) { | ||
| this.notifyReposChanged() | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
ast-grep run --pattern 'export function didReconciliationChangeRepoIdentity($$$) { $$$ }' --lang typescript src/main/project-host-existing-folder-reconciliation.ts
rg -nP -C4 'projectHostSetupMethod' src/main/project-host-existing-folder-reconciliation.tsRepository: stablyai/orca
Length of output: 1025
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate and inspect the relevant implementation and call sites without running repository code.
wc -l src/main/project-host-existing-folder-reconciliation.ts src/main/runtime/orca-runtime.ts
printf '\n--- project-host-existing-folder-reconciliation outline ---\n'
ast-grep outline src/main/project-host-existing-folder-reconciliation.ts \
--view expanded | sed -n '1,220p'
printf '\n--- reconciliation function body ---\n'
sed -n '300,385p' src/main/project-host-existing-folder-reconciliation.ts
printf '\n--- didReconciliationChangeRepoIdentity definition/usages ---\n'
rg -n "didReconciliationChangeRepoIdentity|notifyReposChanged|addRepoNotified|result.repo" \
src/main/src/main/runtime/orca-runtime.ts src/main/project-host-existing-folder-reconciliation.ts
printf '\n--- orca-runtime snippets around repo reconcile/add path ---\n'
sed -n '14960,15015p' src/main/runtime/orca-runtime.tsRepository: stablyai/orca
Length of output: 5321
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- didReconciliationChangeRepoIdentity definition ---'
sed -n '260,285p' src/main/project-host-existing-folder-reconciliation.ts
printf '%s\n' '--- setup result definition ---'
sed -n '90,145p' src/main/project-host-existing-folder-reconciliation.ts
printf '%s\n' '--- reconciliation call sites ---'
rg -n -C3 "reconcileExistingFolderProjectIdentity|didReconciliationChangeRepoIdentity" src/main
printf '%s\n' '--- orca-runtime snippet ---'
sed -n '14960,15012p' src/main/runtime/orca-runtime.ts
printf '%s\n' '--- repo identity update sites ---'
rg -n -C2 "projectHostSetupMethod|setup-method|notification" src/main/project-store src/main/src/main 2>/dev/null || trueRepository: stablyai/orca
Length of output: 14887
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- notifyReposChanged definitions/usages ---'
rg -n -C3 "notifyReposChanged|repos-changed|getRepos|listRepos|getProjectHostSetups|listProjectHostSetups" src/main src/shared | sed -n '1,260p'
printf '%s\n' '--- shared types repo/projectHostSetup references ---'
rg -n -C2 "projectHostSetupMethod|ProjectHostSetup|RepoProjectHostSetupMethod|emitRepo|repos-changed" src/shared src/main | sed -n '1,260p'Repository: stablyai/orca
Length of output: 34124
Broadcast the stale repo update from setupProjectExistingFolder when the same repo is already hosted.
Reconciliation writes updateRepo(repo.id, { projectHostSetupMethod }) after result is built, but the return gate skips notifyReposChanged() unless identity fields changed or this was the add broadcast. If the repo already existed on this host, other clients continue reading the old setup-method/link until an unrelated refresh.
|
Moving this PR to draft because it has been untouched for more than 80 days (latest recorded PR activity or commit timestamp: 2026-07-27T00:38:26Z; checked on 2026-10-27). This keeps the review queue focused on active work while preserving the proposal. Please mark it ready for review when work resumes. |
Summary
Fixes #10620 by re-probing an existing folder's git remotes on its own host before accepting or rejecting a project link. When setup identity initially mismatches, Orca now:
This handles two causes of "Imported folder does not match the selected project identity":
gitRemoteIdentityon existing records (add paths returned unchanged records, so detect never re-ran)git:, while the same repo on a credentialed host settles asgithub:)The unified policy applies to local IPC, SSH IPC, and runtime-host setup paths; a fork checkout persists the matching
originrather than the primaryupstreamremote.Testing
Platform-Specific & Security
upstream.hostin sanitization; migration (remapHostLessGitHubEnterpriseProjectIds) converges stale host-less project IDs on first loadunavailablerather than hanggit remote -v(Git 2.25+) with optional timeout on local (execFile) and SSH (provider.exec) callsNotes