Skip to content

fix(projects): link cloned and existing folders for GitLab and other non-GitHub remotes - #30785

Merged
nwparker merged 1 commit into
mainfrom
nwparker/fix-project-identity-non-github-remotes
Oct 19, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/fix-project-identity-non-github-remotes

Conversation

@nwparker

@nwparker nwparker commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​178 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​178
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​68 $\color{#cf222e}{\Huge{\mathbf{−}}}$​36 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​32

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:

  • Linking a folder into a project it didn't already belong to only worked through a GitHub identity: owner and repo, recorded on the folder as upstream.
  • Projects with any other remote have an id built from the remote itself (git:gitlab.com/group/app). They had no GitHub identity, so the check refused them every time.
  • A fresh clone made it worse. Its remote is not read when the folder is registered, so it never matched that project on its own either.

After:

  • If the folder's remote has not been read yet, it is read when the folder is linked.
  • If that remote's canonical key is the project's key, the remote is recorded on the folder, and the folder then belongs to the project. SSH and HTTPS forms of one repository share a key ([email protected]:group/app.git and https://gitlab.com/group/app.git).
  • GitHub projects are linked exactly as before.
  • A remote that names a different repository is still refused, and a clone that is refused is still rolled back.

Mechanism:

  • Both link paths, desktop projectHostSetups:setupExistingFolder and the runtime controller's setupExistingFolder and setupClone, now go through a single function, resolveImportedFolderProjectLink, in shared/imported-folder-project-identity.ts.
  • It returns the repo fields to record (upstream or gitRemoteIdentity), or throws the same error as before.
  • GIT_REMOTE_PROJECT_ID_PREFIX names the git: id prefix that projection already used.

Why

  • Exact key equality, not a looser host/path match. Projection derives the project id from this same canonical key. A looser match, for example one that ignores case, could link the folder and still project it into a different id than the one requested.
  • Record the remote, rather than inventing an upstream for non-GitHub hosts. upstream means 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):

    • GitHub is still stamped as upstream.
    • GitLab over HTTPS and SSH, self-hosted ssh:// with a port, and a generic HTTPS host all link.
    • The SSH and HTTPS forms are treated as one project.
    • A different repository is refused.
    • A folder with no remote is refused.
    • A GitHub remote that names another repository is still refused.
  • Controller tests (runtime-project-host-setup-git-remote-link.test.ts):

    • A real fresh clone with a GitLab remote, in both HTTPS and SSH form, links into the git: project.
    • A clone of another repository is refused and rolled back.
  • Existing tests: the existing project-operations, controller, projection and repos IPC suites pass (205 tests). pnpm tc:node and 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Mixed versions: the clone runs on the target host, so the fix applies once that host's Orca server has it. An older server still refuses as before. No wire changes.
  • SSH and folder workspaces: folder workspaces have no remote and are unaffected. The probe reads the folder in the process that registered it, as the existing re-read for already registered folders does.

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)

…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.
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Project setup now uses a shared resolver to link imported folders through provider identity or canonical Git remote identity. Setup paths read the current Git remote when a repo has no stored remote identity. The change adds a Git-remote project ID prefix constant and tests for supported remote forms, project links, and identity mismatches.

Priority: ⬇️ Low

Merge Risk: 🟡 Moderate · up to 3f972

Some existing folders can appear linked to the selected project while remaining associated with an older project, and a reused clone can fail to link despite a matching remote. Resolve both paths before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: linking cloned and existing folders for GitLab and other non-GitHub remotes.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The pull request description follows the required template. It explains the user impact, changes, rationale, linked issue, testing, visual-proof status, compatibility notes, and checklist status. The …
Full details: Description check

Explanation

The pull request description follows the required template. It explains the user impact, changes, rationale, linked issue, testing, visual-proof status, compatibility notes, and checklist status. The manual-testing checkbox is unchecked, but automated testing is documented in sufficient detail. The empty Review section is non-critical.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • 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: 92239801-c095-452c-b1af-7c9505622098
📥 Commits

Reviewing files that changed from the base of the PR and between 5cc0f85 and 3f9721d.

📒 Files selected for processing: 6
  • src/main/ipc/repos/project-host-setup-handlers.ts
  • src/main/runtime/runtime-project-host-setup-controller.ts
  • src/main/runtime/runtime-project-host-setup-git-remote-link.test.ts
  • src/shared/imported-folder-project-identity.test.ts
  • src/shared/imported-folder-project-identity.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; 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

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:

#!/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/main

Repository: 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 500

Repository: 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/ipc

Repository: 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 500

Repository: 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.

Suggested change
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 }

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 '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.ts

Repository: 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 -120

Repository: 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.ts

Repository: 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.ts

Repository: 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.ts

Repository: 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.

@nwparker
nwparker merged commit a201eac into main Oct 19, 2026
74 of 76 checks passed
nwparker added a commit that referenced this pull request Oct 20, 2026
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).
nwparker added a commit that referenced this pull request Oct 20, 2026
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).
nwparker added a commit that referenced this pull request Oct 21, 2026
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).
nwparker added a commit that referenced this pull request Oct 21, 2026
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).
nwparker added a commit that referenced this pull request Oct 21, 2026
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).
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]: “Existing folder” fails with “Imported folder does not match the selected project identity” in Available Hosts

1 participant