Skip to content

fix(worktree): reconcile symlinked creates by Git identity - #10266

Merged
OrcaWin merged 6 commits into
mainfrom
fix/worktree-symlink-git-authority
Jul 24, 2026
Merged

OrcaWin merged 6 commits into
mainfrom
fix/worktree-symlink-git-authority

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • fix native-local worktree registration when Git canonicalizes a requested symlink-root path
  • preserve the direct path fast path, then reconcile by the exact refs/heads/<created branch> row returned by the same Git host
  • avoid host realpath authority and filesystem probes for native, WSL, and future remote reuse
  • add real-system-Git coverage with a symlink root and an earlier broken/stale listed worktree

Fixes #10170. Supersedes the filesystem-realpath approach proposed in #10172; credit to @innocarpe for the original diagnosis and candidate.

Test plan

  • Real temporary repository: git -c maintenance.auto=false worktree add through a symlink root, followed by git worktree list --porcelain canonical-path reconciliation
  • Earlier stale/broken listed row cannot prevent the later created-branch match
  • Direct, relative, canonical, macOS case/path, Linux case-sensitive, Windows drive/slash/case, WSL-shaped, and SSH-negative authority cases
  • pnpm exec vitest run --config config/vitest.config.ts src/main/ipc/created-worktree-reconciliation.test.ts src/main/ipc/worktree-symlink-reconciliation.real.test.ts src/main/ipc/worktrees.test.ts src/main/ipc/worktrees-windows.test.ts (213 passed)
  • pnpm exec tsc --noEmit -p config/tsconfig.node.json --pretty false
  • git diff --check origin/main...HEAD

Screenshots

Not applicable; no UI change.

Security audit

The fallback trusts exact branch identity from the authoritative Git listing and performs no filesystem resolution. WSL and SSH paths are never interpreted by the desktop filesystem.

AI review report

Independent adversarial, performance/security, and Git-compatibility reviews found no blocking issue in the final replacement.

Notes

No production Git command changed; Git 2.25 compatibility and leading global -c fetch options are preserved.

innocarpe and others added 6 commits July 23, 2026 18:53
On immutable Linux, /home is often a symlink to /var/home. git worktree
list reports the realpath while Orca still holds the /home request path,
so creation failed with "Worktree created but not found in listing".

After local worktree add, fall back to realpath when string comparison
misses. Keep WSL listings on string comparison only (host realpath is not
authoritative there).

Closes #10170
@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 886d0605-9e77-4e64-80fa-4892315bcd8b

📥 Commits

Reviewing files that changed from the base of the PR and between 122372a and 45309f8.

📒 Files selected for processing (2)
  • src/main/ipc/worktree-remote.ts
  • src/main/runtime/orca-runtime.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/runtime/orca-runtime.ts
  • src/main/ipc/worktree-remote.ts

📝 Walkthrough

Walkthrough

Adds findCreatedWorktree, which first matches worktrees by platform-aware path comparison and then by exact Git branch identity. Local and runtime worktree creation now use this reconciliation. Unit tests cover path and branch matching edge cases, while an integration test validates symlinked worktree creation against real Git porcelain output.

🚥 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%. 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 is concise and accurately summarizes the main change: reconciling symlinked worktree creation by Git identity.
Description check ✅ Passed The description covers summary, tests, screenshots, security, review, and notes, with only a minor heading mismatch for Testing.
Linked Issues check ✅ Passed The PR addresses #10170 by matching the created worktree via exact Git branch identity after direct path matching fails, with regression tests for symlink cases.
Out of Scope Changes check ✅ Passed The changes stay focused on worktree reconciliation and test coverage, with no clearly unrelated features or broad refactors.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4e734012-ca2d-4627-9bec-4fa8274440df

📥 Commits

Reviewing files that changed from the base of the PR and between fd72a89 and 122372a.

📒 Files selected for processing (6)
  • src/main/ipc/created-worktree-reconciliation.test.ts
  • src/main/ipc/created-worktree-reconciliation.ts
  • src/main/ipc/worktree-logic.ts
  • src/main/ipc/worktree-remote.ts
  • src/main/ipc/worktree-symlink-reconciliation.real.test.ts
  • src/main/runtime/orca-runtime.ts

Comment thread src/main/ipc/worktree-logic.ts Outdated
type WorktreeBasePathRepo = Pick<Repo, 'path' | 'worktreeBasePath'>

export { computeBranchName, getConfiguredBranchPrefix } from './worktree-branch-name'
export { findCreatedWorktree } from './created-worktree-reconciliation'

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Register the new module in the TypeScript project.

verify fails because config/tsconfig.tc.web.json does not include src/main/ipc/created-worktree-reconciliation.ts. Add the file to its files list or broaden its include pattern so TypeScript checking passes.

🧰 Tools
🪛 GitHub Actions: PR Checks / verify

[error] 12-12: TypeScript (tsc) failed with TS6307: File '/home/runner/work/orca/orca/src/main/ipc/created-worktree-reconciliation.ts' is not listed within the file list of project 'config/tsconfig.tc.web.json'. Projects must list all files or use an 'include' pattern.

🪛 GitHub Check: verify

[failure] 12-12:
File '/home/runner/work/orca/orca/src/main/ipc/created-worktree-reconciliation.ts' is not listed within the file list of project '/home/runner/work/orca/orca/config/tsconfig.tc.web.json'. Projects must list all files or use an 'include' pattern.

Source: Linters/SAST tools

@OrcaWin
OrcaWin merged commit 1b01385 into main Jul 24, 2026
1 check passed
@OrcaWin
OrcaWin deleted the fix/worktree-symlink-git-authority branch July 24, 2026 02:12
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…10266)

* fix(worktree): match created worktrees through symlink roots

On immutable Linux, /home is often a symlink to /var/home. git worktree
list reports the realpath while Orca still holds the /home request path,
so creation failed with "Worktree created but not found in listing".

After local worktree add, fall back to realpath when string comparison
misses. Keep WSL listings on string comparison only (host realpath is not
authoritative there).

Closes stablyai#10170

* test(worktree): harden symlink reconciliation authority

* fix(worktree): reconcile creation by Git branch identity

* test(worktree): reproduce symlink-root listing with real Git

* test(worktree): cover cross-platform reconciliation

* fix(worktree): keep reconciliation main-only

---------

Co-authored-by: Wooseong Kim <[email protected]>
Co-authored-by: OrcaWin <[email protected]>
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]: Worktree creation fails on immutable Linux when /home resolves to /var/home

2 participants