Skip to content

fix(github): route all PR mutations through the repo's owner host - #7739

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/headless-merge-error
Jul 7, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/headless-merge-error

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Completes the headless-server PR-mutation routing fix started in #7590 (thanks @siddqamar for the root-cause direction). #7590 covered merge/auto-merge in GitHubItemDialog only; the same source-only routing is still on main in PullRequestPage's actions panel and in both close/reopen paths, so merging or closing a PR on a headless-server project from those surfaces still fails with Access denied: unknown repository path (#6957).

  • Extracts the routing rule into a shared resolver, getGitHubMutationRoutingSettings (github-source-runtime-context.ts), matching the Checks panel's existing getGitHubActionTarget precedent: a GitHub source that explicitly names a runtime host wins; otherwise the repo's explicit owner host; otherwise local.
  • Wires it at all four PR-mutation seams: PRActionsPanel in both GitHubItemDialog and PullRequestPage, plus both duplicated runPullRequestStateUpdate close/reopen runners. Both panels are rendered with repoId={item.repoId}, so merge and close/reopen always resolve to the same host — no divergence.
  • Never consults the globally focused runtime: with the routing shipped in #7590, a repo with no explicit executionHostId/connectionId would send its PR mutations to whatever runtime happens to be focused. The new getExplicitRuntimeOwnerEnvironmentId guards that, with regression tests. This also removes the no-owner→global-focus fallback that #7590 left live in the dialog.
  • Replaces the logic-mirror regression test from #7590 with unit tests of the real exported resolver (the mirror existed because bare pnpm vitest doesn't resolve the @/ alias; --config config/vitest.config.ts does).

Addresses the first (HIGH) item of #7623; the read-path sibling seams listed there (plus TaskPage row-merge and GitLab parity) remain follow-ups.

No visual change.

Testing

  • pnpm typecheck (web + node)
  • pnpm lint (changed files clean; main has a pre-existing switch-exhaustiveness failure in source-control-manual-review-url.ts)
  • pnpm test — resolver + boundary suites green (49 tests across github-source-runtime-context, repo-runtime-owner, and both component boundary suites); the only full-suite failures are the two already red on main at the merge-base (worktrees.test.ts purge cases, serve-sim-state-watcher.test.ts)
  • Regression tests added: runtime-owned repo + local/absent source → owner runtime (#6957); explicitly-local repo stays local even with a runtime globally focused; no-owner repo never routes to the focused runtime; runtime source overrides owner; direct contract tests for getExplicitRuntimeOwnerEnvironmentId

End-to-end validation against a real headless runtime

Validated against a real headless orca serve runtime (paired desktop, serve store seeded so the scratch repo is runtime-owned):

  • Reproduce: the old source-only routing hits the verbatim #6957 failure — Access denied: unknown repository path — when merging the runtime-owned repo's PR from a local source view.
  • Fix: with this change the same merge routes over runtime RPC and merges the PR end-to-end on the owner host.
  • No-owner safety: a repo without an explicit owner stays on local IPC even with a runtime globally focused.

Made with Orca 🐋

brennanb2025 and others added 4 commits July 6, 2026 22:45
Extends the owner-first routing from the original fix into the shared
github-source-runtime-context module and applies it to every PR action
seam hit by #6957: both PRActionsPanel copies (GitHubItemDialog and
PullRequestPage) and both runPullRequestStateUpdate runners, so merge,
auto-merge, close, and reopen all run on the owner runtime instead of
falling back to local gh IPC. Replaces the logic-mirror regression test
with unit coverage of the real resolver.

Co-authored-by: Orca <[email protected]>
Review finding: getSettingsForRepoRuntimeOwner falls back to the global
activeRuntimeEnvironmentId for repos without an explicit owner, so a plain
local repo's merge/close/reopen would follow a focused runtime. Resolve PR
mutation routing from the repo's explicit owner only (source-runtime
override preserved), matching the Checks panel's getGitHubActionTarget
precedent, and add the no-owner regression tests.

Co-authored-by: Orca <[email protected]>
getGitHubMutationRoutingSettings returned a spread of all GlobalSettings
while its type and only consumers (getActiveRuntimeTarget) read solely
activeRuntimeEnvironmentId; under useShallow the spread widened the PR
actions panel's re-render trigger to every settings field. Return only
the routing field. Also pin getExplicitRuntimeOwnerEnvironmentId's
contract with direct unit tests (no-owner/SSH/duplicate-id cases) and
restore an unrelated exact-string test pin loosened in this branch.

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

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This change introduces repo-owner-based runtime routing for GitHub pull request mutations. Two new exported helpers are added: getExplicitRuntimeOwnerEnvironmentId (repo-runtime-owner.ts), which resolves a runtime environment ID only for repos with an explicit owner, and getGitHubMutationRoutingSettings (github-source-runtime-context.ts), which combines source-context host info with the explicit-owner fallback. Both GitHubItemDialog.tsx and PullRequestPage.tsx are updated to derive PR action routing (merge, close/reopen, edit) via these helpers instead of prior getTaskSourceRuntimeSettings/getGitHubSourceRuntimeHost logic. Corresponding unit and boundary tests are added or updated, and one obsolete test file is removed.

Changes

Cohort / File Summary
Routing helpers repo-runtime-owner.ts, github-source-runtime-context.ts Added getExplicitRuntimeOwnerEnvironmentId and getGitHubMutationRoutingSettings; added corresponding unit tests
GitHubItemDialog.tsx Reworked sourceSettings derivation and runPullRequestStateUpdate close/reopen routing to use new helper
PullRequestPage.tsx Same routing rework applied for close/reopen mutations and PRActionsPanel
Boundary/host tests Updated assertions to expect getGitHubMutationRoutingSettings calls; removed github-item-dialog-merge-routing.test.ts

Sequence Diagram(s)

See hidden artifact for detailed sequence diagram of PR state update routing.

Related PRs: None specified.

Suggested labels: routing, github-integration, tests

Suggested reviewers: None specified.

Poem

A rabbit hops through routing lanes,
From owner hosts to runtime domains,
No more fallback to focus astray,
Explicit owners now lead the way,
Merge, close, reopen—all routed right today. 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers Summary and Testing, but it omits the required Screenshots, AI Review Report, Security Audit, and Notes sections. Add the missing template sections, including screenshots or 'No visual change', an AI review report, a security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely summarizes the main change: routing PR mutations through the repo owner host.
✨ 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.

@brennanb2025
brennanb2025 merged commit d9225c5 into main Jul 7, 2026
2 checks passed
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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant