Repository navigation
fix(worktrees): when the host can't fetch a remote base, create from the local branch and say so - #26009
Conversation
…acking ref, and say so, on the host's create The host's create (agent.launch, worktree.create, the phone and the CLI) asked for a remote base like origin/main with no tracking ref yet fetched it, and threw offline, even when the local branch existed; it also never reported a base it fell back to. Like the desktop create, it now uses the local branch without fetching and returns baseFallback, which the desktop window already turns into a notice.
…l branch only when the fetch fails The host's create skipped the fetch whenever a local branch matched a remote base with no tracking ref, so online phone/CLI/agent.launch creates silently built on a possibly stale local branch, every time. Fetch first, as main does; only when that fetch fails use the local branch the remote names and report it with baseFallback. With no local branch the existing error is unchanged. Decide the base before naming so branch reuse and conflict checks, the add and the persisted baseRef all see the base actually used, and return baseFallback as its own field of the create result instead of riding on the git add result.
…name, as the desktop create does The tracking ref is still missing there; only the fetch is skipped, as before.
…etch settles Also pins the existing not-found-after-fetching error, now owned by the base decision.
… asked for; keep the exact-name ref silent Scheduled automations, orchestration workers and federation keep main's "Check your network" error offline: nobody is watching to be told the workspace was built on a possibly stale local branch. The fallback is a host-side create option (allowLocalBaseFallback, default off, not on the wire) that the worktree.create RPC and agent.launch set unless the request carries automation provenance. A local ref of the exact requested name goes back to silent, as on main's host: reporting it showed "may not include the latest remote changes" online for plain local branches.
…sence for an automation's worktree.create
Resolves the conflict with #26006 in runtime-local-worktree-create.test.ts by keeping both describe blocks. runtime-local-worktree-create.ts auto-merged: the setup check stays before any base resolution, and the local-base decision stays after the !baseBranch check.
Review summary (head 81f4193)The problem. The host's workspace create (used by the phone, the CLI, What changes for users.
What review changed (the PR as first opened copied the desktop rule as-is):
Deferred (follow-ups, not in this PR):
Verified:
Not verified:
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (11)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughManaged worktree requests without automation provenance now allow local-base fallback. Runtime creation resolves the requested base before branch selection and worktree creation. If a remote refresh fails, the resolver uses the corresponding local branch only when fallback is allowed and that branch exists. The runtime result reports fallback details when present. Tests cover request policy, refresh behavior, fallback selection, and failure cases. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The fallback behavior is ready for normal merge checks; some interfaces do not yet display the fallback notice. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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 |
Rebuild the base-fetch overlap on #26009's base decision: the base is still decided before naming, and its deferred refresh (the existing tracking ref, or `fetch origin` for a plain base not local yet) now starts right after that decision and is awaited before the add, so naming's first-name PR lookup overlaps it. A remote base with no tracking ref still fetches before naming, since the base (and any local fallback) depends on that fetch.
ELI5
You ask the host (from the phone, the CLI, a paired desktop or the web client) for a workspace on
origin/mainin a repo that has norefs/remotes/origin/mainyet, while you're offline. Today that fails with "Check your network", even though localmainis right there. Now Orca still tries the network first. Only when that fails does it create from localmain, and it reports that in the result. Online, the base is the same as before. Unattended runs (automations, orchestration) on a repo the host creates in locally still fail loudly offline, as today.What Changed
The problem.
orca worktree create),agent.launch, theworktree.createRPC (which a paired desktop and the web client also use), automation runs (scheduled or Run now), orchestration workers and federation.origin/Xand the repo has no tracking refrefs/remotes/origin/Xyet, the host's path fetches it.Could not refresh base ref "origin/X" from "origin". Check your network and try again.It does so even when localXis there to build from.For users:
worktree.createRPC used by the phone, the CLI, a paired desktop and the web client, andagent.launch): offline, or when the remote lacks the branch, a create fromorigin/Xwith only a localXnow succeeds from localXinstead of failing. The workspace's base isX, and the result carriesbaseFallback(requestedRef: origin/X,localRef: X).--jsonoutput includes it.agent.launch. They drop the field.origin/Xfirst and builds on it.X: the error is the same as before.origin/X(for example a local branchteam/featurewhileteamis also a remote): unchanged. The create uses it without fetching and reports nothing.The change:
runtime-local-worktree-create-base.tsdecides the base once, before naming:Xexists, useXand report it. Otherwise throw the existing error.allowLocalBaseFallback. It isn't a wire field and it defaults to off.buildManagedWorktreeCreateArgssets it for theworktree.createRPC andagent.launchunless the request carries automation provenance.runtime-local-worktree-create.tsruns that decision before branch-name resolution. Naming, the add and the persistedbaseRefall use the same decided base.runtime-local-git-worktree-create.tstakes the decided base instead of re-resolving it.baseFallbackis its own typed field on the create result.orca-runtime-create-managed-worktree.tscopies it onto the managed create result.Why
agent.launch, automations and orchestration never fetch the base ahead of time. Skipping the fetch whenever a local branch exists would therefore build on a possibly stale branch every time.Differences from the desktop create:
team/feature), and main's host shows nothing there.worktree-remote.ts:2321-2337).worktree-create-base-prefetch.ts), whenever the named ref isn't local. So online, desktop users already end up on the fetched base.worktree.prefetchCreateBase). The other host callers listed above don't prefetch, so the create itself has to fetch.Known edges (follow-ups, not fixed here):
git-process-env.ts:50-80).git-exec-file.ts:71-94).orca worktree createwaits 60 seconds and sends no request id for deduplication. So the CLI can report a timeout while the host goes on to create the workspace, and a retry makes a second one (-2).worktree.create.Linked Issue
None.
Visual Proof
Electron QA screenshots from the dev app on an M4 MacBook Air, at e8d477e (the same production code as the current head).
Offline CLI create from
origin/main: it created from localmainand returnedbaseFallback.Online create: it fetched
origin/mainand returned no fallback.Not captured: the base-fallback dialog on a paired desktop or the web client. No paired environment was available. That dialog is existing UI, driven by the existing
baseFallbackfield.Testing
runtime-local-worktree-create.test.ts(baseorigin/mainwith no tracking ref, only localmain):origin/main, reports nobaseFallback, andbaseRefisrefs/remotes/origin/main. Naming runs only after the fetch has settled and seesorigin/main.main,baseFallbackis{origin/main, main}, and the persistedbaseRefismain. Naming seesmain.mainexists.main: the same "Check your network" error; nothing is named or created.baseFallback.worktree-create-args.test.ts: a person's request getsallowLocalBaseFallback; one carrying automation provenance doesn't.worktree.test.tspins that the RPC handler passes it.orca-runtime-tests/local-worktree-creation.spec.ts: the full managed create offline with only localmain.main, carriesbaseFallback, and persistsbaseRef: main.Re-broken and watched fail:
mainexists;baseFallbackfrom the create result or the managed result.Scripted CLI QA on an M4 MacBook Air, this PR vs main: the offline, online, no-local-
mainand tracking-ref-present rows all behaved as expected. An unattended offline create (an orchestration worker) fails with the same network error on both and creates nothing, while a person's offline create on this PR still falls back.tc:nodepasses. The test files around the host's create, theworktree.createRPC andagent.launchpass. oxlint and oxfmt are clean on the changed files.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Author: @BrennanKB5.
origin/X's tip can then be reused instead of getting a-2suffix.baseFallbackis an existing optional field of the create result. Older clients ignore it.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)