Repository navigation
fix(projects): link cloned and existing folders for GitLab and other non-GitHub remotes - #30785
Conversation
…ric-remote project Setting a project up on another host (a cloned or imported folder) only knew how to link the folder through a GitHub identity. A project keyed by its Git remote (GitLab, Bitbucket, a self-hosted host) was always refused with "Imported folder does not match the selected project identity". A fresh clone's remote is not probed when it is registered, so it never projected into that project by itself. The link now probes an unprobed folder's remote. If the canonical key of that remote is the project's, the remote is recorded on the repo, so the folder projects into the project. SSH and HTTPS forms share a key. A GitHub project is still linked by stamping upstream, and a remote that names another repository is still refused.
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
92239801-c095-452c-b1af-7c9505622098
📒 Files selected for processing: 6
src/main/ipc/repos/project-host-setup-handlers.tssrc/main/runtime/runtime-project-host-setup-controller.tssrc/main/runtime/runtime-project-host-setup-git-remote-link.test.tssrc/shared/imported-folder-project-identity.test.tssrc/shared/imported-folder-project-identity.tssrc/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; 3 remain after this review.
| !knownRepoIds.has(repo.id), | ||
| repo | ||
| // Why: a fresh clone's remote is not probed yet, and a Git-remote project links through it. | ||
| repo.gitRemoteIdentity === undefined ? await readCurrentGitRemoteIdentity(repo) : repo |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect registration implementations and their immediate remote-identity values.
rg -n -C 5 --type ts 'gitRemoteIdentity\s*:\s*null|cloneRepo\s*[:=(]|addRepo\s*[:=(]' src/mainRepository: stablyai/orca
Length of output: 45664
🏁 Script executed:
set -e
printf '%s\n' '--- controller ---'
nl -ba src/main/runtime/runtime-project-host-setup-controller.ts | sed -n '110,185p'
printf '%s\n' '--- local registration ---'
nl -ba src/main/ipc/repos/local-repo-registration.ts | sed -n '1,155p'
printf '%s\n' '--- clone lifecycle ---'
nl -ba src/main/ipc/repos/repo-clone-lifecycle.ts | sed -n '245,325p'
printf '%s\n' '--- relevant type and constructors ---'
rg -n -C 6 --type ts 'interface Repo|type Repo|gitRemoteIdentity' src/main src/shared | head -n 500Repository: stablyai/orca
Length of output: 41919
🏁 Script executed:
set -e
printf '%s\n' '--- clone conversion definitions and callers ---'
rg -n -C 12 --type ts 'resolveClonedFolderConversion|cloneRepo\s*[:=]|cloneRepo\(' src/main/ipc src/main/runtime src/main
printf '%s\n' '--- clone conversion source ---'
rg -l --type ts 'function resolveClonedFolderConversion|const resolveClonedFolderConversion|export .*resolveClonedFolderConversion' src/main | while read -r f; do
echo "FILE: $f"
nl -ba "$f" | sed -n '1,220p'
done
printf '%s\n' '--- remote detection source ---'
nl -ba src/main/repo-git-remote-identity.ts | sed -n '55,95p'
nl -ba src/main/repo-icon-autodetect.ts | sed -n '135,162p'Repository: stablyai/orca
Length of output: 41858
🏁 Script executed:
set -e
printf '%s\n' '--- controller completion and resolver ---'
rg -n -C 10 --type ts 'completeSetup|resolveImportedFolderProjectLink' src/main/runtime src/main
printf '%s\n' '--- addRepo binding ---'
rg -n -C 12 --type ts 'setupProjectExistingFolder|addLocalRepoFromPath|addRepo:\s*async|addRepo\s*=' src/main/runtime src/main/ipcRepository: stablyai/orca
Length of output: 42602
🏁 Script executed:
set -e
printf '%s\n' '--- imported-folder resolver ---'
nl -ba src/shared/imported-folder-project-identity.ts | sed -n '1,220p'
printf '%s\n' '--- completion and rollback ---'
nl -ba src/main/runtime/runtime-project-host-setup-controller.ts | sed -n '259,320p'Repository: stablyai/orca
Length of output: 6401
🏁 Script executed:
set -e
printf '%s\n' '--- runtime addRepo implementations ---'
rg -n -C 14 --type ts 'async addRepo|addRepo\(|addRepo\s*:' src/main/runtime src/main | rg -v 'test|addLocalRepoFromPath' | head -n 500
printf '%s\n' '--- runtime service declarations ---'
rg -n -C 12 --type ts 'class OrcaRuntimeService|addRepo' src/main/runtime/runtime* src/main/runtime | head -n 500Repository: stablyai/orca
Length of output: 41981
🏁 Script executed:
set -e
nl -ba src/main/runtime/runtime-repository-clone-controller.ts | sed -n '1,225p'Repository: stablyai/orca
Length of output: 9525
Probe a reused folder clone when its stored remote is null.
A clone that reuses a saved folder can convert that row to kind: 'git' while preserving gitRemoteIdentity: null. setupClone then skips readCurrentGitRemoteIdentity, and the resolver rejects the row for a project identified by its Git remote.
Change the clone guard to a nullish check. The reused row is already known, so this path does not roll it back.
🐛 Suggested fix
--- "a/src/main/runtime/runtime-project-host-setup-controller.ts"
+++ "b/src/main/runtime/runtime-project-host-setup-controller.ts"
@@ -158,7 +158,7 @@
repo,
!knownRepoIds.has(repo.id),
// Why: a fresh clone's remote is not probed yet, and a Git-remote project links through it.
- repo.gitRemoteIdentity === undefined ? await readCurrentGitRemoteIdentity(repo) : repo
+ repo.gitRemoteIdentity == null ? await readCurrentGitRemoteIdentity(repo) : repo
)
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| repo.gitRemoteIdentity === undefined ? await readCurrentGitRemoteIdentity(repo) : repo | |
| repo.gitRemoteIdentity == null ? await readCurrentGitRemoteIdentity(repo) : repo |
| // Why exact: SSH and HTTPS forms already share a canonical key, and projection keys on it. | ||
| `${GIT_REMOTE_PROJECT_ID_PREFIX}${remote.canonicalKey}` === projectId | ||
| ) { | ||
| return { gitRemoteIdentity: remote } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '105,205p' src/shared/project-host-setup-projection.ts
sed -n '30,95p' src/shared/imported-folder-project-identity.ts
sed -n '275,330p' src/main/runtime/runtime-project-host-setup-controller.ts
sed -n '45,85p' src/main/ipc/repos/project-host-setup-handlers.tsRepository: stablyai/orca
Length of output: 8836
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- provider projection and setup definitions ---'
rg -n -F --glob '*.ts' -e 'function getProjectProviderIdentity' -e 'export function getProjectProviderIdentity' -e 'function getProjectHostSetupForRepo' -e 'export function getProjectHostSetupForRepo' -e 'updateRepo(' src/shared src/main | head -80
printf '%s\n' '--- relevant projection source ---'
sed -n '1,125p' src/shared/project-host-setup-projection.ts
printf '%s\n' '--- setup projection callers/definition ---'
rg -n -F --glob '*.ts' 'getProjectHostSetupForRepo' src
printf '%s\n' '--- updateRepo declarations and implementation ---'
rg -n -F --glob '*.ts' -e 'updateRepo' src/main src/shared | head -120Repository: stablyai/orca
Length of output: 32841
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- setup lookup ---'
sed -n '1,90p' src/shared/project-host-setup-lookup.ts
printf '%s\n' '--- update operation ---'
sed -n '1,235p' src/main/persistence/tracking-repos/repo-update-operations.ts
printf '%s\n' '--- lifecycle update wrapper ---'
sed -n '130,215p' src/main/persistence/loading-store/repo-lifecycle-operations.ts
printf '%s\n' '--- focused persistence tests ---'
sed -n '530,625p' src/main/persistence-update-repo.test.tsRepository: stablyai/orca
Length of output: 16910
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- remainder of update operation ---'
sed -n '220,380p' src/main/persistence/tracking-repos/repo-update-operations.ts
printf '%s\n' '--- project host setup update ---'
sed -n '1,130p' src/main/persistence/tracking-repos/project-host-setup-update.ts
printf '%s\n' '--- projection implementation ---'
rg -n -F --glob '*.ts' -e 'projectHostSetupProjectionFromRepos' -e 'syncProjectHostSetupCompatibilityState' src/main src/shared
sed -n '125,285p' src/shared/project-host-setup-projection.tsRepository: stablyai/orca
Length of output: 26133
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- compatibility synchronization ---'
sed -n '1,150p' src/main/persistence/tracking-repos/project-host-compatibility.ts
printf '%s\n' '--- setup/project projection construction ---'
sed -n '285,470p' src/shared/project-host-setup-projection.tsRepository: stablyai/orca
Length of output: 7224
Clear stale provider metadata before linking by Git remote.
When a Git-remote project matches, resolveImportedFolderProjectLink returns only gitRemoteIdentity. updateRepo merges this partial update, so existing upstream or GitHub repoIcon remains. The project projection gives that metadata precedence over gitRemoteIdentity, and compatibility synchronization rebuilds the setup from that projection. The link gate only decides whether to enter the update path; it does not validate the resulting project.
Clear upstream and repoIcon when linking by remote, or reject the link unless the resulting getProjectHostSetupForRepo has the requested projectId.
Create a Temporary machine from the composer's Run-on picker and wait for its stages; the project clones onto it for real. Sleep it from the worktree's machine menu, reload, and open the worktree. Wake-on-open brings the same terminal tab back and it answers. Then delete the machine through the Delete dialog: its container and worktree go. Each fixture machine seeds a bare origin once and serves it with git daemon on its loopback; the project's remote is git://127.0.0.1/orca-e2e-origin.git, so the clone needs no network. That is a generic, non-GitHub remote, so the project links into the machine through its Git remote alone (#30785).
Create a Temporary machine from the composer's Run-on picker and wait for its stages; the project clones onto it for real. Sleep it from the worktree's machine menu, reload, and open the worktree. Wake-on-open brings the same terminal tab back and it answers. Then delete the machine through the Delete dialog: its container and worktree go. Each fixture machine seeds a bare origin once and serves it with git daemon on its loopback; the project's remote is git://127.0.0.1/orca-e2e-origin.git, so the clone needs no network. That is a generic, non-GitHub remote, so the project links into the machine through its Git remote alone (#30785).
Create a Temporary machine from the composer's Run-on picker and wait for its stages; the project clones onto it for real. Sleep it from the worktree's machine menu, reload, and open the worktree. Wake-on-open brings the same terminal tab back and it answers. Then delete the machine through the Delete dialog: its container and worktree go. Each fixture machine seeds a bare origin once and serves it with git daemon on its loopback; the project's remote is git://127.0.0.1/orca-e2e-origin.git, so the clone needs no network. That is a generic, non-GitHub remote, so the project links into the machine through its Git remote alone (#30785).
Create a Temporary machine from the composer's Run-on picker and wait for its stages; the project clones onto it for real. Sleep it from the worktree's machine menu, reload, and open the worktree. Wake-on-open brings the same terminal tab back and it answers. Then delete the machine through the Delete dialog: its container and worktree go. Each fixture machine seeds a bare origin once and serves it with git daemon on its loopback; the project's remote is git://127.0.0.1/orca-e2e-origin.git, so the clone needs no network. That is a generic, non-GitHub remote, so the project links into the machine through its Git remote alone (#30785).
Create a Temporary machine from the composer's Run-on picker and wait for its stages; the project clones onto it for real. Sleep it from the worktree's machine menu, reload, and open the worktree. Wake-on-open brings the same terminal tab back and it answers. Then delete the machine through the Delete dialog: its container and worktree go. Each fixture machine seeds a bare origin once and serves it with git daemon on its loopback; the project's remote is git://127.0.0.1/orca-e2e-origin.git, so the clone needs no network. That is a generic, non-GitHub remote, so the project links into the machine through its Git remote alone (#30785).
ELI5
Orca lets you set up a project on another host by cloning it there or by pointing at a folder already on that host. If the project's code lives on GitHub, that works. If it lives on GitLab, Bitbucket or a company's own Git server, Orca always refused with "Imported folder does not match the selected project identity", even when the folder was a clone of exactly that repository. This fixes that.
What Changed
Before:
upstream.git:gitlab.com/group/app). They had no GitHub identity, so the check refused them every time.After:
[email protected]:group/app.gitandhttps://gitlab.com/group/app.git).Mechanism:
projectHostSetups:setupExistingFolderand the runtime controller'ssetupExistingFolderandsetupClone, now go through a single function,resolveImportedFolderProjectLink, inshared/imported-folder-project-identity.ts.upstreamorgitRemoteIdentity), or throws the same error as before.GIT_REMOTE_PROJECT_ID_PREFIXnames thegit:id prefix that projection already used.Why
upstreamfor non-GitHub hosts.upstreammeans a GitHub repository to the rest of Orca, including the gh CLI, avatars and PR features.Linked Issue
Fixes #10620
Related: #30717 (same identity check, GitHub case), #23528 (identity-mismatch error wording), #29789 (origin vs fork-parent identity).
Visual Proof
N/A. The change is in project-setup logic, not in UI.
Testing
Unit tests (
imported-folder-project-identity.test.ts):ssh://with a port, and a generic HTTPS host all link.Controller tests (
runtime-project-host-setup-git-remote-link.test.ts):git:project.Existing tests: the existing project-operations, controller, projection and repos IPC suites pass (205 tests).
pnpm tc:nodeand the changed-code quality gate are clean.Found by: the Machines UI e2e journey, which clones a project onto a new machine.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)