Repository navigation
fix(worktrees): route unstamped local worktrees local in the two states #16841 still fails closed - #16829
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change routes known unstamped local worktrees locally when repository identity exists, even when unrelated runtime environments are saved. It uses Priority: ⚪ Not assessed Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The change adds local routing for known unstamped worktrees while retaining fail-closed behavior for unknown or conflicting ownership states. No current merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
7e19356 to
b14857c
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: aafebe0e-457e-4ee8-843c-688002030969
📥 Commits
Reviewing files that changed from the base of the PR and between 1d1b73c and b14857c66b52d7eceb8c9ebca900173c2a11f083.
📒 Files selected for processing (3)
src/renderer/src/lib/terminal-worktree-route.test.tssrc/renderer/src/lib/worktree-operation-route.test.tssrc/renderer/src/lib/worktree-operation-route.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/renderer/src/lib/worktree-operation-route.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
dbe57f9 to
80934b9
Compare
…es (stablyai#16733) A local git worktree whose rows carry no host stamp fails every owner-routed operation closed as soon as any runtime environment is saved, however unrelated. resolveWorktreeOperationRouteResult establishes positive identity from the worktree/repo catalogs, then discards it: with no runtime active the only exit is the legacy-local gate, which demands an empty saved-runtime list. One saved environment makes that false and the call returns { kind: 'missing' }. These tests state the contract before the fix, so the claim that the fix is purely additive can be checked rather than asserted. Committed red on purpose. Observed at 5631aa0 (vitest run, both files): Tests 7 failed | 52 passed (59) The 7 failing are exactly the states that must become local, plus their two consumers: - an unrelated runtime is saved (the reported bug) - several unrelated runtimes are saved - the repo is known before its worktree row is listed - the saved-runtime catalog has not hydrated - an unrelated runtime was removed - resolveTerminalWorktreeRoute on such a worktree (the gate in front of the "Terminal creation is unavailable" reply) - the folder/worktree parity state: identical store, folder local, worktree missing The other 52 pass now and must keep passing: connection-owned and runtime-stamped repos never route local, a stamped worktree row still outranks its repo, contradictory repo rows stay ambiguous, an ambiguous or hydrating runtime focus still fails closed, and a genuinely unknown id still fails closed. That set is the additive-only guarantee.
…ners (stablyai#16733) Two cases in src/renderer/src/lib/worktree-operation-route.test.ts assert the behaviour stablyai#16733 reports as the bug, so they have to move: - :158 'fails a paired-client ownerless stale publication closed instead of routing it locally' - :171 'fails ownerless rows closed until the saved-runtime catalog is hydrated' Both arrived with stablyai#9994 (41751dd, route HUB-owned SSH worktrees through their owning runtime), whose stated goal was to fail closed for missing or stale owners. That goal is right and is kept. The premise being rebutted is narrower: neither fixture describes a missing or stale owner. Each carries a present repo row that is merely unstamped -- repos: [{ id: 'repo-1' }] -- and three places in this codebase already read exactly that row as locally owned: - shared/execution-host.ts getRepoExecutionHostId returns LOCAL_EXECUTION_HOST_ID - main/ipc/worktrees/listing/worktree-host-ownership.ts resolveRepoOwnershipEvidence falls back to LOCAL_EXECUTION_HOST_ID, and the listing and removal paths trust it - shared/repo-types.ts documents executionHostId as the field runtime-host repos need precisely because they otherwise look identical to local repos attribute. It swept in the legacy-local case because at the time nothing in this resolver consulted the repo index for an unstamped row. So each case is re-aimed at the state it was actually defending, and neither is deleted -- the fail-closed coverage is not reduced, it is pointed at a real missing owner: - the first becomes 'fails a paired-client publication closed when no repo row can own it': same runtime state, repos: []. A worktree row alone is not host evidence, so this still returns missing, before and after the fix. - the second becomes 'fails ownerless rows closed mid-hydration while a saved runtime could own them': an active runtime with an ambiguous saved catalog during hydration. This returns missing from the active-runtime branch and is untouched by the fix. It is worded to stay distinct from the neighbouring case at :185, which already covers focus-is-not-ownership with an empty catalog, rather than duplicating it. The states these two cases vacate are re-asserted with their corrected expected result in the stablyai#16733 block added by the previous commit. Suite unchanged at 7 failed | 52 passed (59): the rewrites pass, the 7 reds are still the 7 states the fix must convert.
… are saved (stablyai#16733) resolveWorktreeOperationRouteResult establishes positive identity from the worktree and repo catalogs, then discards it. With no runtime active the only exit is the legacy-local gate, which requires an empty saved-runtime list, so one saved runtime environment -- connected or not, related or not -- made it false and the call returned { kind: 'missing' }. Every owner-routed operation on a genuinely local git worktree then failed closed, and because resolveTerminalWorktreeRoute is the sole gate in front of terminal-request-ipc-bridge.ts, the user saw "Terminal creation is unavailable because the worktree owner could not be resolved". Folder workspaces hit the same gate and were carved out in stablyai#10251/stablyai#10269, whose comment in this file states the principle and names this exact failure mode: a found record is positive identity evidence, and the worktree legacy hydration gates "would fail local folders closed whenever unrelated runtimes exist". Git worktrees never got the equivalent. This adds it, in the same shape and the same function. The rule is not new. An unstamped repo row is read as locally owned by getRepoExecutionHostId, by main's resolveRepoOwnershipEvidence, and by Repo.executionHostId's own documentation; and the repo write path (repoWithFetchedOwner) stamps runtime: and ssh: owners at fetch time, so an unstamped row is a legacy row that predates owner projection -- local by construction. The router now consults that evidence instead of contradicting it. The sidebar already rendered these worktrees as Local; this removes the disagreement rather than adding a heuristic. Four properties this change holds to: 1. The branch sits after the active-runtime block, so an unambiguous active runtime still wins (routes runtime:<id>, not local) and an ambiguous or mid-hydration focus still returns missing. That ordering is structural, not incidental. 2. mayBeLegacyLocal is left byte-identical (verified: both 7-line hunks hash to f0ed1b4287c646cb). The new branch does take over the two states where a local repo row exists and no runtime is saved, but returns the identical local route, so no input changes its answer -- only which branch produced it. 3. The helper returns null on anything but unanimous local, so the branch can only ever convert missing into local. It never returns ambiguous: a contradiction between repo rows is already decided upstream by resolveExplicitWorktreeOperationRouteResult, and answering it here would be a second, divergent authority. 4. It reads neither runtimeEnvironmentCatalogHydrated nor removedRuntimeEnvironmentIds. That is sound rather than merely convenient, because it consults host evidence rather than runtime-environment inference: a runtime-owned repo row is stamped runtime:<id> at fetch time, so neither an unhydrated runtime catalog nor a removed environment can turn an unstamped row into a remote one. Control only reaches this point after the explicit catalog resolver returned missing, which means every worktree row and every repo row for this id is unstamped -- any stamped row routes ssh: or runtime: earlier, and two disagreeing rows return ambiguous earlier. There is no remote-owned state left here to leak. Out of scope, deliberately: who wins when a runtime is focused (stablyai#11512), and back-filling Worktree.hostId at creation time, which is a persistence migration over worktreeMeta and does nothing for the users already carrying unstamped rows. The 7 cases red in the two preceding commits now pass; the 52 that guard the fail-closed contract are unchanged. Test Files 2 passed (2) Tests 59 passed (59)
…-closed rule (stablyai#16733) Upstream stablyai#16841 (merged d347595) landed its own fix for stablyai#16733 and drew the positive-identity line one notch tighter than this branch did: its 'does not treat a repo row alone as positive local identity' case asserts that a worktree id no row has ever listed stays `missing`, even when the repo row for its repoId is local. This branch's 'routes a known local repo before its worktree row has been listed' asserted the opposite result for that identical state, so the two cannot both hold. Main's rule is the safer reading — a repo row is repo identity, not worktree identity — so the reconciled code gates resolveUnstampedLocalWorktreeRoute on hasKnownWorktree and this case is dropped rather than re-pinned. Every state that actually reproduces stablyai#16733 keeps a worktree row (listed or detected), so the reported bug and both extra fail-closed edge cases this branch fixes are unaffected.
80934b9 to
c8bf96b
Compare
|
@coderabbitai resume |
✅ Action performedReviews resumed and review finished. |
…eUnstampedLocalWorktreeRoute resolveWorktreeOperationRouteResult only calls resolveUnstampedLocalWorktreeRoute after resolveExplicitWorktreeOperationRouteResult has already returned 'missing' for this repoId. That function (worktree-operation-catalog-route.ts) indexes every repo row carrying a non-empty executionHostId or connectionId and resolves/ambiguous-es on any of them, so by construction every row resolveUnstampedLocalWorktreeRoute ever sees is unstamped -- and getRepoExecutionHostId's own fallback (shared/execution-host.ts) always resolves an unstamped row to local. The per-row disagreement check could never actually return null; it was dead defensive code describing a state the caller's short-circuit already rules out. Reduced to an existence check with identical behavior (verified: same 66/66 tests, same mutation-proof property -- reverting only this file still fails exactly the same 6 tests it did before). Also harmonized a same-function 'local' string literal to the LOCAL_EXECUTION_HOST_ID constant already in use one branch above it, and dropped a dangling getWorktreeExecutionHostId doc reference the shipped code never actually calls.
LesleyMurfin
left a comment
There was a problem hiding this comment.
Verdict: SAFE TO MERGE.
Reviewed at head d00e599e47ac against base d0506bf5de0d (main). Verified independently — not taken from the PR description: live gh pr view metadata, full diff read, source read of resolveWorktreeOperationRouteResult / resolveUnstampedLocalWorktreeRoute and the upstream functions they compose with, and direct test execution including a red/green mutation proof (source reverted to the merge-base with the branch's own tests → 6/66 fail exactly as claimed; restored → 66/66; git diff HEAD empty both times). Typecheck (tsc --noEmit, all three pnpm tc projects) and lint (oxlint, all four configured passes plus the changed-code-quality gate) both pass clean on the 3 changed files, each confirmed genuine via a negative control. No CI ever reported on this branch (statusCheckRollup empty) — the above is a from-scratch reproduction, not a rubber stamp of a badge.
What's good
src/renderer/src/lib/worktree-operation-route.ts:180-183,232-239 — both new comment blocks name the exact invariant and cite the three call sites that already treat an unstamped repo row as local (getRepoExecutionHostId, resolveRepoOwnershipEvidence, repo-types.ts). I re-derived the same argument independently from worktree-operation-catalog-route.ts before reading the comment, and it holds: resolveIndexedRepoOperationRoute skips any row where both executionHostId and connectionId are blank, so a stamped row — including one that disagrees with an unstamped sibling — is always caught upstream and returns resolved/ambiguous before resolveUnstampedLocalWorktreeRoute is reached. Reaching it therefore guarantees every row for the id is unstamped, and getRepoExecutionHostId's own fallback resolves an unstamped row to local unconditionally — so the plain .some() existence check is behaviorally equivalent to a per-row check, just enforced by control flow. Confirmed against this repo's own docs/reference/ssh-execution-boundary.md Rule 1 (no silent substitution): the guard tests for connection-owned and runtime-stamped rows pass, so no SSH-owned repo is ever routed local by this change.
Commit 7306a818d9's message is a good model of "teach the why": it names the exact invariant, cites the same three call sites, and states the suite's pass count before and after the rename.
Findings (informational, non-blocking)
PR body: diff-size claim is off. “+52 / -1 in the source file” vs. actual +49 / -2 (gh api, git apply --stat). Cosmetic.
PR body: rebase-base SHA is stale. 1d1b73c408 is a real ancestor of HEAD and does contain #16841, but the true merge-base with current upstream/main is the newer 6a47d2831f. Worth a rebase before merge given mergeStateStatus: UNSTABLE.
Docstring coverage: 75% vs. the configured 80% threshold (CodeRabbit pre-merge check, 4 functions across 3 files). Everything else in that automated check passed.
Checked and cleared
- Test-rename accounting — exactly one test was renamed on this branch (
fails ownerless rows closed until the saved-runtime catalog is hydrated→fails ownerless rows closed mid-hydration while a saved runtime could own them), matching the PR body's disclosure. A second suspected rename (fails a paired-client ownerless stale publication closed instead of routing it locally) traced to a no-op: upstream#16841already made the equivalent fixture edit before this branch rebased onto it: the test is byte-identical between base and HEAD. - Review threads — the one CodeRabbit thread on this PR is resolved and outdated (anchored to a pre-rebase commit); the later pass against the current head reported zero actionable comments.
- Scope — exactly 3 files touched (source + 2 test files), no drive-by changes.
- Issue/PR references —
#16733closed,#16841merged, both as claimed.
No code-correctness objection. This is a written verdict only — no approval, merge, or push taken beyond posting this review.
|
Heads-up rather than a request: this PR is ready from my side — the change is verified locally and the description has been corrected. CI hasn't run yet. Both required workflow runs on Happy to rebase or adjust anything if it would help. |
|
Fresh behavioral verification (2026-09-11), exact head Hidden Windows Electron desktop paired with an isolated real Linux server:
Wrong-host negative: production beginHostQualifiedRemoval called in the renderer with same-ID local/remote competing rows refused with “Workspace identity is ambiguous across hosts. Refresh projects and try again.” This was a production-guard fixture, not an actual UI/filesystem delete. Unknown missing identities and remote routes remained protected. Current routing tests 66/66 and destructive guards 29/29 pass. Merge risk LOW for the tested change; no proven negative user regression. Native WSL and destructive filesystem operations were not exercised in this loop. Five owned test tabs closed and owned app/server/display shut down. No merge performed. |
stablyai#16841 still fails closed (stablyai#16829) * test(worktrees): cover local worktree owner routing with saved runtimes (stablyai#16733) A local git worktree whose rows carry no host stamp fails every owner-routed operation closed as soon as any runtime environment is saved, however unrelated. resolveWorktreeOperationRouteResult establishes positive identity from the worktree/repo catalogs, then discards it: with no runtime active the only exit is the legacy-local gate, which demands an empty saved-runtime list. One saved environment makes that false and the call returns { kind: 'missing' }. These tests state the contract before the fix, so the claim that the fix is purely additive can be checked rather than asserted. Committed red on purpose. Observed at 5631aa0 (vitest run, both files): Tests 7 failed | 52 passed (59) The 7 failing are exactly the states that must become local, plus their two consumers: - an unrelated runtime is saved (the reported bug) - several unrelated runtimes are saved - the repo is known before its worktree row is listed - the saved-runtime catalog has not hydrated - an unrelated runtime was removed - resolveTerminalWorktreeRoute on such a worktree (the gate in front of the "Terminal creation is unavailable" reply) - the folder/worktree parity state: identical store, folder local, worktree missing The other 52 pass now and must keep passing: connection-owned and runtime-stamped repos never route local, a stamped worktree row still outranks its repo, contradictory repo rows stay ambiguous, an ambiguous or hydrating runtime focus still fails closed, and a genuinely unknown id still fails closed. That set is the additive-only guarantee. * test(worktrees): re-aim two fail-closed cases at genuinely missing owners (stablyai#16733) Two cases in src/renderer/src/lib/worktree-operation-route.test.ts assert the behaviour stablyai#16733 reports as the bug, so they have to move: - :158 'fails a paired-client ownerless stale publication closed instead of routing it locally' - :171 'fails ownerless rows closed until the saved-runtime catalog is hydrated' Both arrived with stablyai#9994 (41751dd, route HUB-owned SSH worktrees through their owning runtime), whose stated goal was to fail closed for missing or stale owners. That goal is right and is kept. The premise being rebutted is narrower: neither fixture describes a missing or stale owner. Each carries a present repo row that is merely unstamped -- repos: [{ id: 'repo-1' }] -- and three places in this codebase already read exactly that row as locally owned: - shared/execution-host.ts getRepoExecutionHostId returns LOCAL_EXECUTION_HOST_ID - main/ipc/worktrees/listing/worktree-host-ownership.ts resolveRepoOwnershipEvidence falls back to LOCAL_EXECUTION_HOST_ID, and the listing and removal paths trust it - shared/repo-types.ts documents executionHostId as the field runtime-host repos need precisely because they otherwise look identical to local repos attribute. It swept in the legacy-local case because at the time nothing in this resolver consulted the repo index for an unstamped row. So each case is re-aimed at the state it was actually defending, and neither is deleted -- the fail-closed coverage is not reduced, it is pointed at a real missing owner: - the first becomes 'fails a paired-client publication closed when no repo row can own it': same runtime state, repos: []. A worktree row alone is not host evidence, so this still returns missing, before and after the fix. - the second becomes 'fails ownerless rows closed mid-hydration while a saved runtime could own them': an active runtime with an ambiguous saved catalog during hydration. This returns missing from the active-runtime branch and is untouched by the fix. It is worded to stay distinct from the neighbouring case at :185, which already covers focus-is-not-ownership with an empty catalog, rather than duplicating it. The states these two cases vacate are re-asserted with their corrected expected result in the stablyai#16733 block added by the previous commit. Suite unchanged at 7 failed | 52 passed (59): the rewrites pass, the 7 reds are still the 7 states the fix must convert. * fix(worktrees): keep unstamped local worktrees routable when runtimes are saved (stablyai#16733) resolveWorktreeOperationRouteResult establishes positive identity from the worktree and repo catalogs, then discards it. With no runtime active the only exit is the legacy-local gate, which requires an empty saved-runtime list, so one saved runtime environment -- connected or not, related or not -- made it false and the call returned { kind: 'missing' }. Every owner-routed operation on a genuinely local git worktree then failed closed, and because resolveTerminalWorktreeRoute is the sole gate in front of terminal-request-ipc-bridge.ts, the user saw "Terminal creation is unavailable because the worktree owner could not be resolved". Folder workspaces hit the same gate and were carved out in stablyai#10251/stablyai#10269, whose comment in this file states the principle and names this exact failure mode: a found record is positive identity evidence, and the worktree legacy hydration gates "would fail local folders closed whenever unrelated runtimes exist". Git worktrees never got the equivalent. This adds it, in the same shape and the same function. The rule is not new. An unstamped repo row is read as locally owned by getRepoExecutionHostId, by main's resolveRepoOwnershipEvidence, and by Repo.executionHostId's own documentation; and the repo write path (repoWithFetchedOwner) stamps runtime: and ssh: owners at fetch time, so an unstamped row is a legacy row that predates owner projection -- local by construction. The router now consults that evidence instead of contradicting it. The sidebar already rendered these worktrees as Local; this removes the disagreement rather than adding a heuristic. Four properties this change holds to: 1. The branch sits after the active-runtime block, so an unambiguous active runtime still wins (routes runtime:<id>, not local) and an ambiguous or mid-hydration focus still returns missing. That ordering is structural, not incidental. 2. mayBeLegacyLocal is left byte-identical (verified: both 7-line hunks hash to f0ed1b4287c646cb). The new branch does take over the two states where a local repo row exists and no runtime is saved, but returns the identical local route, so no input changes its answer -- only which branch produced it. 3. The helper returns null on anything but unanimous local, so the branch can only ever convert missing into local. It never returns ambiguous: a contradiction between repo rows is already decided upstream by resolveExplicitWorktreeOperationRouteResult, and answering it here would be a second, divergent authority. 4. It reads neither runtimeEnvironmentCatalogHydrated nor removedRuntimeEnvironmentIds. That is sound rather than merely convenient, because it consults host evidence rather than runtime-environment inference: a runtime-owned repo row is stamped runtime:<id> at fetch time, so neither an unhydrated runtime catalog nor a removed environment can turn an unstamped row into a remote one. Control only reaches this point after the explicit catalog resolver returned missing, which means every worktree row and every repo row for this id is unstamped -- any stamped row routes ssh: or runtime: earlier, and two disagreeing rows return ambiguous earlier. There is no remote-owned state left here to leak. Out of scope, deliberately: who wins when a runtime is focused (stablyai#11512), and back-filling Worktree.hostId at creation time, which is a persistence migration over worktreeMeta and does nothing for the users already carrying unstamped rows. The 7 cases red in the two preceding commits now pass; the 52 that guard the fail-closed contract are unchanged. Test Files 2 passed (2) Tests 59 passed (59) * test(worktrees): defer repo-row-only routing to stablyai#16841's fail-closed rule (stablyai#16733) Upstream stablyai#16841 (merged d347595) landed its own fix for stablyai#16733 and drew the positive-identity line one notch tighter than this branch did: its 'does not treat a repo row alone as positive local identity' case asserts that a worktree id no row has ever listed stays `missing`, even when the repo row for its repoId is local. This branch's 'routes a known local repo before its worktree row has been listed' asserted the opposite result for that identical state, so the two cannot both hold. Main's rule is the safer reading — a repo row is repo identity, not worktree identity — so the reconciled code gates resolveUnstampedLocalWorktreeRoute on hasKnownWorktree and this case is dropped rather than re-pinned. Every state that actually reproduces stablyai#16733 keeps a worktree row (listed or detected), so the reported bug and both extra fail-closed edge cases this branch fixes are unaffected. * refactor(worktrees): drop the unreachable disagreement loop in resolveUnstampedLocalWorktreeRoute resolveWorktreeOperationRouteResult only calls resolveUnstampedLocalWorktreeRoute after resolveExplicitWorktreeOperationRouteResult has already returned 'missing' for this repoId. That function (worktree-operation-catalog-route.ts) indexes every repo row carrying a non-empty executionHostId or connectionId and resolves/ambiguous-es on any of them, so by construction every row resolveUnstampedLocalWorktreeRoute ever sees is unstamped -- and getRepoExecutionHostId's own fallback (shared/execution-host.ts) always resolves an unstamped row to local. The per-row disagreement check could never actually return null; it was dead defensive code describing a state the caller's short-circuit already rules out. Reduced to an existence check with identical behavior (verified: same 66/66 tests, same mutation-proof property -- reverting only this file still fails exactly the same 6 tests it did before). Also harmonized a same-function 'local' string literal to the LOCAL_EXECUTION_HOST_ID constant already in use one branch above it, and dropped a dangling getWorktreeExecutionHostId doc reference the shipped code never actually calls. * docs(routing): document the undocumented worktree operation route helpers
Status — scope reduced, and the headline fix is no longer mine
#16733 is already closed. It was fixed by #16841 ("fix(routing): resolve unstamped local
worktrees to the local host (STA-5683)"), merged 2026-08-27, and the issue closed with it. This
branch predates that merge and originally claimed the whole fix. It no longer does, and nothing
here asks to close #16733 — that credit is #16841's.
This branch was rebased onto
upstream/mainat1d1b73c408(which contains #16841) andreconciled with it. Correcting that reference: this branch's true merge-base with
mainis6a47d2831f("fix(native-chat): scope composer file drops to the pane that received them(#19328)"), which is a descendant of
1d1b73c408and therefore also contains #16841;mainhasadvanced since and its tip is now
12f2c6b991.What survives is the part #16841 does not cover: two states that still
fail a genuinely local git worktree closed. Both fixes now coexist inside
resolveWorktreeOperationRouteResult— #16841's stricter identity rule is kept intact, and thisbranch narrows itself to fit inside it rather than around it.
Measured against the rebase base (#16841 alone), 6 of the 66 targeted tests still fail; with
this branch, 66/66 pass. Those 6 are the two families below.
The two residual fail-closed states
The relevant base tail is
hydrated && (no saved runtimes || hasDetectedWorktree). It is false inexactly two shapes that are nonetheless local:
The worktree is present in
worktreesByRepobut absent fromdetectedWorktreesByRepo, so thetail is false and the row fails closed.
worktree-operation-route.test.ts›keeps a local worktree local when an unrelated runtime is savedruntimeEnvironmentCatalogHydrated: false,so the tail is false regardless of how unambiguous the rows are.
worktree-operation-route.test.ts›keeps a local worktree local while the saved-runtime catalog is still hydratingChecked directly, not assumed: with the source file reverted to the base and the tests left as they
are on this branch, both cases return
{ kind: 'missing' }(
AssertionError: expected { kind: 'missing' } to deeply equal { kind: 'resolved', … }). With thebranch's source, both return the
localroute.Conceded to #16841 on purpose — please do not read this as reopening it
The original branch also routed repo-row-only identity (a known repo, no worktree row at all)
to local. #16841 deliberately fails that closed — a repo row is repo identity, not worktree
identity — and its test
fails a paired-client ownerless stale publication closed instead of routing it locallyassertsexactly that. That case is given up, not re-argued. The new branch is gated behind
hasKnownWorktree, and #16841's test passes here unmodified.ELI5
Saving a remote environment should not stop an ordinary local workspace from opening a terminal. This follow-up fixes two remaining cases: Orca knows the local worktree but has not detected it on this scan, or the saved environment list is still loading. Known SSH and remote owners keep their routes, and unknown worktrees still fail closed.
What Changed
One new branch in
resolveWorktreeOperationRouteResult(
src/renderer/src/lib/worktree-operation-route.ts), plus the small helper it delegates to.+73 / -2in the source file.hasKnownWorktreegate — the branch is only reachable when a worktree row is known, listedor currently detected. This is the reconciliation with fix(routing): resolve unstamped local worktrees to the local host (STA-5683) #16841: a repo row alone is repo identity,
not worktree identity, so it no longer routes anything local.
resolveUnstampedLocalWorktreeRoute(state, repoId)— returns alocalroute only when a reporow for the id exists and every matching row resolves to
LOCAL_EXECUTION_HOST_IDviagetRepoExecutionHostId. No repo row →null. Any row disagreeing →null, so contradictionsstay a refusal rather than becoming a default.
mayBeLegacyLocaltail — the code fix(routing): resolve unstamped local worktrees to the local host (STA-5683) #16841 amended — is left intact and stillhandles everything that reaches it.
'local'is the existingLOCAL_EXECUTION_HOST_IDsentinel — no new vocabulary.One pre-existing test was re-aimed, and I want that called out rather than buried, because it
asserted one of the states above. (The original version of this PR re-aimed two; the second is the
repo-row-only case now conceded to #16841, so that test is back to untouched.)
fails ownerless rows closed until the saved-runtime catalog is hydrated—runtimeEnvironments: [], unhydratedfails ownerless rows closed mid-hydration while a saved runtime could own them— no repo row or active runtime, two saved runtimes, a detected worktree row, unhydratedIt arrived with #9994 (
41751dd90d), whose goal — fail closed for missing or stale owners — iskept, and #16841 did not touch it. Its fixture did not describe a missing owner though: it carried a
present-but-unstamped
repos: [{ id: 'repo-1' }]with no saved runtime at all, a state threeplaces in this codebase already read as locally owned (
getRepoExecutionHostId,resolveRepoOwnershipEvidenceinmain/ipc/worktrees/listing/worktree-host-ownership.ts, andRepo.executionHostId's documented contract inshared/repo-types.ts). It is re-pointed at thestate it was actually defending — mid-hydration where a saved runtime genuinely could own the row
— so fail-closed coverage is not reduced, and the state it vacates is re-asserted with its corrected
expected result in the
#16733block. Reviewer's call if you would rather I keep it verbatim andgate differently; I think the re-aim is the honest reading, but it is the one judgement call left in
here.
Why
savedRuntimeIds.length === 0was the original defect, and #16841 already removed most of itssting. What remains is the same category error in two narrower places: the count of saved
environments, and the hydration status of that list, say nothing about who owns this worktree.
An unrelated runtime existing in settings is not evidence of ambiguity, and neither is a list that
has not finished loading — yet either one still flips a recognised worktree to
{ kind: 'missing' }.The approach is not new reasoning — it is the reasoning already written into
resolveFolderWorkspaceOperationRoutein the same file, whose comment describes this bug for theother workspace kind:
Why this is safe rather than a loosening. Every row that carries host provenance routes above
the new branch and never reaches it:
resolveIndexedRepoOperationRoute, which only skips rowswhere both
executionHostIdandconnectionIdare empty (worktree-operation-catalog-route.ts:94);resolveIndexedWorktreeOwner/exactRoutes, so itstill outranks its unstamped repo;
So the branch is reachable only for rows that carry no host evidence and have a known worktree —
precisely the legacy pre-owner-projection shape, local by construction.
Scale. Not a corner case in an aged store: on the reporting deployment, 181 of 569 worktree rows
under live repos carry no host stamp and every repo row lacks both fields. An earlier stamping pass
fixed the rows that existed then; the create path does not write the stamp, so everything created
since is unstamped again. Hand-stamping rows is therefore a treadmill, not a fix.
Deliberate behavioural note: the new branch resolves local even when
removedRuntimeEnvironmentIdsis non-empty. That is intentional and symmetric with the foldercarve-out — an unstamped row is not evidence of having belonged to a deleted runtime either.
Covered by
keeps a local worktree local after an unrelated runtime has been removed. Flag it ifyou disagree; it is easy to gate.
Linked Issue
Relates to #16733 — already closed by #16841 (merged 2026-08-27). Intentionally not
Fixes #16733: this PR must not close an issue it did not fix. It is the residual follow-updescribed at the top.
Visual Proof
Independent review at c8bf96b exercised New tab → New Terminal in a hidden macOS Electron renderer using a real disposable Git repo and a synthetic legacy catalog (unstamped repo/worktree, no detected rows, no selected host, one unrelated saved environment).
Before: the baseline routing source returns missing and clicking New Terminal creates no tab.
After: the exact PR head opens a real local terminal; printf ORCA_LOCAL_PR16829_OK executes successfully.
This proves the local renderer/PTY flow. It is not a reproduction of the original Windows-desktop-paired-to-headless-Linux deployment.
Independent validation — 2026-09-07
Contributor testing (original report)
Gates on this branch, rebased onto
upstream/main@1d1b73c408(contains #16841), on Node24.19.0 (the version
enginespins — worth stating, because a stale Node 22 on PATH produceswidespread unrelated reds):
pnpm run typecheck(all projects)pnpm run lint(full chain incl. reliability/ratchet/localization gates)66 passed (66)6 failed,60 passedof 66 — the residual statespnpm vitest run src/renderer/src/lib(scoped)5182 passed, 1 skippedpnpm run test(full)maineither; see belowThe 6 that fail on the base and pass here, i.e. exactly what this PR still buys:
Reproduce the comparison:
Coverage — the negative cases are the point, not the happy path:
unrelated runtime removed; no runtime saved; adapters with no runtime catalog at all.
local; a host-stamped worktree row stays authoritative over its unstamped repo; a second
connection-owned repo row for the id refuses; contradictory repo rows report
ambiguous, notlocal; unknown id with neither repo nor worktree row still
missing; ambiguous active runtimestill fails closed; unambiguous active runtime stays authoritative over the local fallback; and
fix(routing): resolve unstamped local worktrees to the local host (STA-5683) #16841's repo-row-only refusal, unmodified.
Platforms actually run: Linux (this is renderer-side pure routing logic with no platform branch;
I have not run the desktop client on Windows or macOS). The reported environment is Windows-desktop
paired to a headless Linux
orca serve, which I could not reproduce end-to-end — noted plainlyrather than implied.
Being straight about the full suite. I will not tick
pnpm testas clean, because it is not. Onthe pre-rebase run I diffed the failing-file lists against a pristine
upstream/mainworktree in theidentical environment: 69 failing files on baseline, 74 on the branch, none only-in-baseline, and
each of the 5 differing files accounted for — 3
terminal-paneremote-runtime transport tests thatpass in isolation (30s-timeout tests under parallel load) and 2
src/main/runtime/orchestration-*files that are skipped unless
out/build artifacts exist and fail identically on baseline oncebuilt. The load-bearing point: none of the files this change touches or reads
(
worktree-operation-route,terminal-worktree-route,worktree-owner-route,worktree-operation-catalog-route) appears in any failing list, in any run.Deliberately left unticked: I did not run the desktop client by hand. I do not have the
reporter's Windows-desktop-paired-to-headless-Linux-
orca serverig, and ticking a manual-test boxon the strength of unit tests would be exactly the kind of claim this template is trying to stop.
What I verified is stated above, no more than that.
AI Disclosure
AI-assisted. Claude (Anthropic, Opus-class) driving an agent harness on my machine, under my
direction: it did the code reading, wrote the tests and the fix, ran the gates, and performed the
rebase and reconciliation against #16841; I set the approach, reviewed every diff and commit
message, and I'm the one accountable for what's here. Flagging it because the template asks and
because you should weigh the diff knowing it — not as a disclaimer on its correctness.
One meta note in the spirit of the same honesty: issue #16733 itself was filed by my
svc-orca[bot]account, which is an automation account of mine, not a third-party reporter. Thedeployment numbers in it are from my own store. Same person, both ends — no independent
corroboration is being implied.
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.Not applicable — nothing here touches skill-installer source, tests, fixtures, registry entries,
path tables, or docs.
Notes
Destructive paths — the one thing I most want a reviewer to check.
resolveWorktreeOperationRoutealso feeds worktree removal, somissing→localmeans anunqualified removal on an unstamped row now proceeds locally where it previously refused with
a toast. I believe that is correct and is the same bug in another costume — the row carries no
remote evidence, so there is no remote thing that could be destroyed, and refusing to delete a
local worktree is not a safety property, just the same fail-closed defect. Two guards that are
safety properties are untouched and I verified both by reading, not assuming:
resolveWorktreeOperationRouteResultForHost→resolveSelectedHostRoute, neither of whichcalls the modified function at all;
getWorktreeOperationOwnerHostIds, also unmodified.host-qualified-removal-refusal.test.tspasses unchanged. Still — this is the judgement worth asecond pair of eyes, more than the terminal case in the title.
Security: grants nothing new. The branch can only return the
localsentinel, and only whenno row carries host provenance. It cannot synthesise a
runtime:orssh:route, so it cannotcause an operation to be sent to a remote host that would not already have received it.
Cross-platform: pure renderer routing logic, no platform branch, no path handling.
Remote SSH: connection-owned and runtime-stamped rows route above the new branch and are
covered by explicit negative tests;
ssh:/HUB precedence from fix: route server project adds to selected runtime #11346 and fix(runtime): route HUB-owned SSH worktrees through owning runtime #9994 is untouched.Mobile: not on this path.
Backwards compatibility: additive. The only behaviour that changes is
missing→localforrows that have a known worktree and carry no host evidence; fix(routing): resolve unstamped local worktrees to the local host (STA-5683) #16841's tail is preserved for
everything that reaches it, including the repo-row-only refusal.
Performance: one
Array.prototype.filteroverstate.repos, on the fall-through path only —reached after the cached catalog index has already missed, and now only when a worktree row is
already known. No new allocation on the hot resolved paths.
Not fixed here, on purpose: the create path still does not write a host stamp, which is why
unstamped rows keep appearing. This PR makes the router correct for rows in that state rather than
chasing both; say the word if you would rather see the stamp-on-create in the same change.
If you would rather not carry this at all: that is a legitimate call now that fix(routing): resolve unstamped local worktrees to the local host (STA-5683) #16841 has
shipped the main fix. The two residual states are real and reproducible, but they are narrower
than what this PR originally proposed, and I would rather it be closed knowingly than merged on
the strength of a stale description.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)lintandtypecheckpass locally on the rebased branch.pnpm testdoes not fully pass — nordoes it on
mainin the same environment — so I have left that unticked rather than tick it on atechnicality. The measured diff, the isolation results, and the reason each differing file differs
are all in Testing; none of them touch this change's files.