Repository navigation
Route diffs by explicit worktree owner, not focused runtime (#8484) - #8509
Conversation
Co-authored-by: Orca <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughDiff runtime resolution now uses explicit worktree ownership. Explicit runtime IDs remain prioritized, while owner-less and SSH-owned worktrees resolve locally even when another runtime is globally focused. Tests cover local fallback, SSH-owned routing, and diffs routed to an explicitly assigned runtime. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 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 |
…ined resolveDiffRuntimeEnvironmentId returned getExplicitRuntimeEnvironmentIdForWorktree(...) ?? undefined. For an owner-less/local worktree that stamps undefined, which settingsForRuntimeOwner treats as "inherit the focused runtime" — so with a remote runtime focused, a local diff still read from the wrong host and the reported bug persisted. Return null instead: settingsForRuntimeOwner(settings, null) forces a LOCAL target, routing local via IPC and SSH via connectionId. Runtime-owned worktrees are unchanged (explicit env id is truthy). Tests: owner-less/local diffs now assert null; added an SSH-owned-worktree case (stamps null while a runtime is focused). editor.test.ts 196 pass, typecheck:tsc:web + oxlint clean. Co-authored-by: Orca <[email protected]>
Adversarial hardening review — 1 must-fix found & fixedRan 3 hostile review rounds (fresh reviewer each). Round 1 found a must-fix; the original one-line change did not actually fix the reported bug. Must-fix:
|
…#8484) (stablyai#8509) Co-authored-by: Orca <[email protected]>
Summary
Opening a diff/file for a worktree routed to the global Default runtime (
settings.activeRuntimeEnvironmentId) whenever the worktree had no explicitly-populated owner, instead of using the worktree's own host and defaulting to LOCAL. When a remote/SSH runtime was focused but the diff's worktree was local (or a different owner), the diff/file-read was fetched from the wrong host. This aligns diff routing with the established #6957 owner-routing principle: route by the worktree's EXPLICIT owner, and treat "no known owner" as LOCAL — never the focused runtime.Root cause
resolveDiffRuntimeEnvironmentIdinsrc/renderer/src/store/slices/editor.ts:330resolved the owner viagetRuntimeEnvironmentIdForWorktree, whose final branch (src/renderer/src/lib/worktree-runtime-owner.ts:179) returnsstate.settings.activeRuntimeEnvironmentId. So a Source-Control caller that knows only theworktreeId— for an owner-less worktree — inherited the globally focused runtime and read the diff through that host's RPC.The fix
Swap the fallback to
getExplicitRuntimeEnvironmentIdForWorktree(already exported fromworktree-runtime-owner.ts:182, same signature/return type), which returns the runtime env id only whenworktree.hostId/ repoexecutionHostId(or a restored runtime host / project-group owner for folder workspaces) explicitly names one, andnullfor legacy/local worktrees.nullmaps toundefined(LOCAL) via the existing?? undefined.Why zero-regression:
explicitRuntimeEnvironmentIdearly-return (including explicitnull) is untouched.resolveDiffRuntimeEnvironmentIdcaller (openDiff,openBranchDiff, and the combined-diff opens).Evidence
New tests in
editor.test.tsdrive the realopenDiffaction and assert the stampedruntimeEnvironmentId. (A live UI screenshot would require multi-runtime host state that only exists at runtime — not reproducible in headless CI; the store test is authoritative.)Before (failing on old code):
After (fix applied):
(
editor.test.ts+worktree-runtime-owner.test.ts; typechecktypecheck:tsc:webclean; oxlint clean on changed files; nearby runtime-owner store tests 71 passed.)ELI5
You open a diff for a folder on your own computer, but the app was showing the diff from a remote server you happened to have "focused." We now check who actually owns the folder — if nobody remote owns it, we read it from your computer, like it should.
Trade-offs
None. If a repo/worktree is genuinely on a runtime, its host is explicitly populated and still routes there.
Relationship to existing PR
None found (
gh pr list --search "8484 in:body"empty). Written fresh following the in-repo #6957 explicit-owner pattern.Review loops
1 (fresh reviewer, returned CLEAN).
Fixes #8484
Made with Orca 🐋