Skip to content

Fix remote runtime branch diffs - #6942

Merged
Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/repro-sta-974-remote-diff
Jun 30, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/repro-sta-974-remote-diff

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

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 lint
  • pnpm exec oxlint src/renderer/src/store/slices/editor.ts src/renderer/src/store/slices/editor.test.ts
  • pnpm run typecheck:web
  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/store/slices/editor.test.ts -t "openDiff|openBranchDiff"
  • git diff --check
  • Added focused regression coverage for runtime-owner derivation on openDiff and openBranchDiff
  • Electron/CDP validation against a real headless Orca runtime server repro

Manual repro/validation details:

  • Built an SSH remote-host repro first; SSH branch diff opened successfully.
  • Built a headless Orca runtime server repro with a runtime-hosted worktree and changed file.
  • Reproduced the exact visible failure before the fix from Source Control: Error invoking remote method 'git:branchDiff': Error: Access denied: unknown repository or worktree path.
  • After the fix, launched patched Orca with CDP, paired it to the runtime server, opened the runtime worktree, clicked the visible Source Control Committed on Branch row, and confirmed the branch diff rendered base line vs runtime worktree branch line without 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 getRuntimeEnvironmentIdForWorktree ownership helper instead of introducing a new remote-host rule.

Risks checked:

  • Local diffs still omit runtime ownership unless explicitly provided.
  • SSH-owned repos/worktrees continue to resolve to null runtime ownership, preserving SSH-specific behavior.
  • Runtime-owned worktrees stamp the environment id on new and reopened diff tabs.
  • Combined branch/commit/uncommitted diff tabs use the same owner derivation.
  • Cross-platform behavior was checked: path joining continues through existing 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 🐋


Open in Stage

@ghost

ghost commented Jun 30, 2026

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 4 individual chapters for you:

Title
1 Define runtime environment resolution utility
2 Apply runtime ownership to file diffs
3 Apply runtime ownership to combined diffs
4 Verify runtime owner derivation in tests
Open in Stage

Chapters generated by Stage for commit e5fd5be on Jun 30, 2026 9:35pm UTC.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This change updates the editor store slice so that diff and combined-diff tabs derive their runtimeEnvironmentId from worktree-to-host ownership mapping when not explicitly specified. A new helper, resolveDiffRuntimeEnvironmentId, is introduced and used across openDiff, openBranchDiff, openCommitDiff, openAllDiffs, openBranchAllDiffs, and openCommitAllDiffs to resolve and persist the runtime environment id on both reopened and newly created diff tab state. New tests verify that opening diffs and branch diffs for source-control worktrees correctly resolve the runtime environment from repository and worktree host mappings.

🚥 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 runtime diff fix.
Description check ✅ Passed All required sections are present and substantively filled out, including testing, AI review, security audit, and notes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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.

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 win

Include the resolved owner in branch/commit diff tab IDs.

These paths now store runtimeEnvironmentId, but id/existing lookup remain owner-agnostic. Opening the same branch or commit diff once local and once runtime-owned will reuse and mutate the same OpenFile, unlike openDiff, 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 win

Consider adding coverage for the explicit-override and reopen paths.

Both new tests only exercise the "new file, no explicit runtimeEnvironmentId" branch of resolveDiffRuntimeEnvironmentId. The explicit-override branch (caller passes options.runtimeEnvironmentId) and the "reopen existing diff tab" branch (per snippets 2/3, runtimeEnvironmentId is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2c0ac2a and e5fd5be.

📒 Files selected for processing (2)
  • src/renderer/src/store/slices/editor.test.ts
  • src/renderer/src/store/slices/editor.ts

@Jinwoo-H
Jinwoo-H merged commit 8a52bec into main Jun 30, 2026
2 checks passed
@Jinwoo-H
Jinwoo-H deleted the Jinwoo-H/repro-sta-974-remote-diff branch June 30, 2026 21:56
@AmethystLiang AmethystLiang added the orca-remote-server Remote Orca Server / orca serve / paired remote runtime label Jul 22, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

orca-remote-server Remote Orca Server / orca serve / paired remote runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants