Repository navigation
Fix remote runtime branch diffs - #6942
Conversation
Co-authored-by: Orca <[email protected]>
|
Ready to review this PR? Stage has broken it down into 4 individual chapters for you:
Chapters generated by Stage for commit e5fd5be on Jun 30, 2026 9:35pm UTC. |
📝 WalkthroughWalkthroughThis change updates the editor store slice so that diff and combined-diff tabs derive their 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/store/slices/editor.ts (1)
2521-2533: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winInclude the resolved owner in branch/commit diff tab IDs.
These paths now store
runtimeEnvironmentId, butid/existinglookup remain owner-agnostic. Opening the same branch or commit diff once local and once runtime-owned will reuse and mutate the sameOpenFile, unlikeopenDiff, so content can be routed through the wrong owner. Resolve the owner before building the ID and use an owner-qualified branch/commit diff ID.Also applies to: 2612-2624
🧹 Nitpick comments (1)
src/renderer/src/store/slices/editor.test.ts (1)
459-491: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider adding coverage for the explicit-override and reopen paths.
Both new tests only exercise the "new file, no explicit
runtimeEnvironmentId" branch ofresolveDiffRuntimeEnvironmentId. The explicit-override branch (caller passesoptions.runtimeEnvironmentId) and the "reopen existing diff tab" branch (per snippets 2/3,runtimeEnvironmentIdis re-stamped on the existing entry) aren't asserted here. A couple of extra cases would tighten confidence in this regression coverage given it's the fix target for STA-974.Also applies to: 2805-2844
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 55e214e0-0d92-491e-a90b-d3a89a23593c
📒 Files selected for processing (2)
src/renderer/src/store/slices/editor.test.tssrc/renderer/src/store/slices/editor.ts
Co-authored-by: Orca <[email protected]>
Summary
Fixes STA-974 by carrying the runtime environment owner onto diff tabs opened from remote runtime-hosted worktrees.
Source Control callers often only know the worktree id. For runtime worktrees, branch/commit/uncommitted diff tabs now derive the runtime owner from that worktree so diff content loads through runtime RPC instead of falling back to local git IPC.
Screenshots
No visual design change.
Validation screenshot captured locally during repro/verification:
/tmp/sta974-runtime-branch-diff-fixed.png.Testing
pnpm lintpnpm exec oxlint src/renderer/src/store/slices/editor.ts src/renderer/src/store/slices/editor.test.tspnpm run typecheck:webpnpm exec vitest run --config config/vitest.config.ts src/renderer/src/store/slices/editor.test.ts -t "openDiff|openBranchDiff"git diff --checkopenDiffandopenBranchDiffManual repro/validation details:
Error invoking remote method 'git:branchDiff': Error: Access denied: unknown repository or worktree path.Committed on Branchrow, and confirmed the branch diff renderedbase linevsruntime worktree branch linewithout the access-denied error.AI Review Report
Reviewed the diff routing path and verified the change is limited to editor diff tab metadata. The fix reuses the existing
getRuntimeEnvironmentIdForWorktreeownership helper instead of introducing a new remote-host rule.Risks checked:
nullruntime ownership, preserving SSH-specific behavior.joinPath; no shortcut, shell, path separator, or OS-specific Electron behavior was introduced.Security Audit
This change does not add command execution, dependency changes, credentials, or new IPC channels. It reduces the chance of local git IPC being invoked with a runtime-host path by preserving the runtime owner on diff editor records, so content loads through the already-established runtime RPC route and existing repository/worktree access checks.
No follow-up security work identified.
Notes
The original issue was not reproducible through SSH remote worktrees; it reproduced only through the remote runtime environment path where the branch diff tab was missing
runtimeEnvironmentId.Made with Orca 🐋