Skip to content

fix(github): route PR merges through repo owner - #7590

Merged
Jinwoo-H merged 3 commits into
stablyai:mainfrom
siddqamar:issue-6957-debug
Jul 7, 2026
Merged

Jinwoo-H merged 3 commits into
stablyai:mainfrom
siddqamar:issue-6957-debug

Conversation

@siddqamar

@siddqamar siddqamar commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes PR merge and auto-merge routing for headless/runtime-owned GitHub repositories. These actions now use the repository owner's runtime settings before applying source-context overrides, ensuring runtime repository paths stay on runtime RPC instead of incorrectly falling back to local gh:mergePR. Fixes #6957

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Added focused regression coverage for GitHub item dialog merge routing.

AI Review Report

AI review traced the failure from GitHubItemDialog PR actions through local IPC and runtime RPC. It identified that merge routing relied on sourceContext alone, which could incorrectly route runtime-owned repositories to local IPC and trigger Access denied: unknown repository path.

The routing now prefers the repository owner's runtime settings before applying GitHub source-context overrides. Cross-platform review covered macOS, Linux, and Windows. This PR does not modify shortcuts, labels, shell behavior, paths, or platform-specific Electron APIs.

Security Audit

Reviewed IPC, path handling, command execution, authentication, dependencies, and runtime-routing risks.

  • Preserves local IPC repository authorization
  • Prevents headless/runtime repository paths from being sent to local GitHub IPC
  • Introduces no new command execution, path parsing, secrets handling, or dependencies

No additional security follow-up identified.

Notes

This is a non-visual routing fix. Local and SSH behavior remain unchanged, while runtime-owned repositories now correctly stay on runtime RPC.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

PRActionsPanel now derives sourceSettings from repo-owner runtime settings and only merges GitHub source runtime settings when an active runtime environment id is present. The test updates align assertions with the new settings lookup and add coverage for merge routing outcomes across local and runtime cases.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: routing PR merges through the repo owner.
Description check ✅ Passed The description follows the template and includes all required sections, with testing, AI review, security, screenshots, and notes covered.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/renderer/src/components/github-item-dialog-source-boundary.test.ts (1)

193-194: 🎯 Functional Correctness | 🔵 Trivial | 🏗️ Heavy lift

Substring assertions don't verify merge precedence.

These checks only confirm that getSettingsForRepoRuntimeOwner(...) and ...repoOwnerSettings appear somewhere in the actions section — they don't assert that repoOwnerSettings is spread after getTaskSourceRuntimeSettings(sourceContext). This means the precedence bug flagged in GitHubItemDialog.tsx (source-context settings unconditionally overriding repo-owner settings) would pass these assertions unnoticed.

Consider a behavioral test (rendering PRActionsPanel with a mocked store where repo-owner settings resolve to a runtime environment but sourceContext.hostId is non-runtime) that asserts the merge/mergePR call routes to runtime RPC, not local gh:mergePR.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ebd3cb3d-0ba0-40a0-847f-7dc8e04c5520

📥 Commits

Reviewing files that changed from the base of the PR and between d8ed41f and b199dfb.

📒 Files selected for processing (2)
  • src/renderer/src/components/GitHubItemDialog.tsx
  • src/renderer/src/components/github-item-dialog-source-boundary.test.ts

@Jinwoo-H Jinwoo-H 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.

Thanks @siddqamar — this is a clean, well-scoped fix.

Verified the repro and the fix end to end: on main, PRActionsPanel routed merges using only the source context, so a runtime-owned (headless) repo whose source view resolved local fell back to local gh:mergePR → Access denied: unknown repository path (#6957). Routing repo-owner-first, with the guard that only lets a source override when it actually points at a runtime, fixes that and brings the merge panel in line with the sibling read-path panels already on main.

Notes:

  • The activeRuntimeEnvironmentId truthiness guard is the right call — it avoids clobbering a runtime-owned repo's routing with a null local source (the unconditional-spread siblings have that latent gap on their read RPCs; tracking separately).
  • No GitLab impact (GitLab uses a separate dialog); SSH-owned repos still route to local IPC as before.
  • I pushed one extra commit: a behavioral regression test that exercises the routing decision through the real helpers and fails if the fix is reverted.

Rebased onto current main; typecheck + lint + targeted tests green.

@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.

🧹 Nitpick comments (1)
src/renderer/src/components/github-item-dialog-merge-routing.test.ts (1)

14-30: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Consider extracting the routing decision into a shared, importable helper.

resolveMergeTarget re-implements the exact merge/source-override decision that presumably lives inline in PRActionsPanel (per the stack summary). Since this test's entire purpose is to guard against a regression to source-only routing, if the real component's logic changes independently, this mirrored copy won't catch the drift — defeating the regression guard.

Consider extracting this decision (lines 19-29) into an exported helper in a shared module (e.g., alongside repo-runtime-owner.ts) that both PRActionsPanel and this test import, so the test always exercises the real code path.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1bc85f3c-9278-4d0a-a35a-3ad16078311b

📥 Commits

Reviewing files that changed from the base of the PR and between 7f025d1 and 44f1a59.

📒 Files selected for processing (1)
  • src/renderer/src/components/github-item-dialog-merge-routing.test.ts

siddqamar and others added 3 commits July 7, 2026 01:03
- Use repo-owner runtime settings before source-context overrides in PR actions
- Keep headless/runtime repos on runtime RPC instead of local gh:mergePR
- Add source-boundary coverage for merge routing and Windows-safe newline matching
- Apply task-source runtime overrides only when they resolve to a runtime host
- Keep runtime-owned repos from being downgraded to local gh:mergePR
- Guard the routing contract with source-boundary coverage
- Important because non-runtime source contexts could recreate the issue stablyai#6957 access-denied path
…ting

Mirrors PRActionsPanel's merge-routing decision through the real
repo-runtime-owner/task-source helpers so a revert to source-only
routing (issue stablyai#6957) fails here. Covers the runtime-owned repo with a
local GitHub source view and the local-repo-while-runtime-focused case.

Co-authored-by: Orca <[email protected]>
@brennanb2025

Copy link
Copy Markdown
Contributor

Thanks @siddqamar — right root cause, and owner-first precedence was the correct call. While reviewing this we found the same source-only routing on the standalone PR page (PullRequestPage's actions panel) and in both close/reopen paths, plus an edge where a repo without an explicit owner could route its mutations to the globally focused runtime. #7739 extends this fix to those seams via a shared resolver.

@siddqamar
siddqamar deleted the issue-6957-debug branch August 9, 2026 14:54
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix(github): route PR merges through repo owner

- Use repo-owner runtime settings before source-context overrides in PR actions
- Keep headless/runtime repos on runtime RPC instead of local gh:mergePR
- Add source-boundary coverage for merge routing and Windows-safe newline matching

* fix(github): preserve repo-owner merge routing

- Apply task-source runtime overrides only when they resolve to a runtime host
- Keep runtime-owned repos from being downgraded to local gh:mergePR
- Guard the routing contract with source-boundary coverage
- Important because non-runtime source contexts could recreate the issue stablyai#6957 access-denied path

* test(github): add behavioral regression test for repo-owner merge routing

Mirrors PRActionsPanel's merge-routing decision through the real
repo-runtime-owner/task-source helpers so a revert to source-only
routing (issue stablyai#6957) fails here. Covers the runtime-owned repo with a
local GitHub source view and the local-repo-while-runtime-focused case.

Co-authored-by: Orca <[email protected]>

---------

Co-authored-by: Jinwoo-H <[email protected]>
Co-authored-by: Orca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Merging PR on headless orca server errors

3 participants