Skip to content

fix(github): load issue details and mutations from the selected issue source - #24379

Closed
Katsuma-Takehisa wants to merge 2 commits into
stablyai:mainfrom
Katsuma-Takehisa:fix/issue-details-honor-issue-source
Closed

Katsuma-Takehisa wants to merge 2 commits into
stablyai:mainfrom
Katsuma-Takehisa:fix/issue-details-honor-issue-source

Conversation

@Katsuma-Takehisa

Copy link
Copy Markdown
Contributor

ELI5

On a fork, the Tasks page lets you pick whether issues come from Upstream or Origin. When you pick Origin and open issue #N, Orca showed origin's title but loaded the comments and assignees from upstream's #N — and any comment you wrote went to upstream's #N too. This makes the issue dialog read and write the same repo the selector points at.

What Changed

Before: with Origin selected, opening origin#N showed origin#N's title with upstream#N's body, comments, assignees and timeline. Commenting, editing the body/title/labels/assignees or closing from Orca wrote to upstream#N.

After: details, comments and edits for an issue all target the repo the issue source selector resolves to (origin, upstream, or the existing upstream-first default when nothing is picked). PR comments are unchanged.

Mechanism:

  • getWorkItemDetails already fetched the item with getWorkItem(..., preference), but then loaded the issue's body/comments/assignees/participants via getIssueGitHubApiRepository() (upstream-first, preference-blind). It now uses resolveIssueGitHubApiRepositorySource(repoPath, preference, ...) — the same resolver getWorkItem and listWorkItems use — so both halves of the dialog come from one repo.
  • updateIssue and addIssueComment take an optional trailing preference and resolve through the same resolver. An explicit ownerRepoOverride (prRepo) on addIssueComment still wins.
  • gh:updateIssue / gh:addIssueComment IPC and the runtime updateRepoIssue / addRepoIssueComment commands pass repo.issueSourcePreference. Comments with type: 'pr' pass no preference, since the selector only scopes issues. The github.addIssueComment RPC forwards type when set, and the renderer's runtime path now sends it.

Not changed: getIssue (linked-issue lookups by the number stored on a worktree) stays on the heuristic, because that number is persisted without a repo identity. That needs its own design.

Why

getWorkItem was already moved onto the selector ("open-by-number must share that preference so origin/upstream toggles cannot disagree"), but the details/mutation paths kept the older "mutations stay on the heuristic" rule. The result is the exact disagreement that comment warns about, inside a single dialog. Once the dialog's reads follow the selector, writes have to follow it too. Otherwise a reply typed under origin#N silently posts to upstream#N, which on a fork of a public repo means commenting on an unrelated upstream issue.

The details cache is already keyed by issueSourcePreference, so toggling the selector refetches the dialog. Reads and writes stay consistent across toggles.

Alternative considered: deriving the target repo from each item's URL in the renderer and passing it as an override. That touches many renderer call sites (dialog, edit mutations, Status/Assignees cells) and duplicates the resolution the main process already owns, so I reused resolveIssueGitHubApiRepositorySource instead.

Linked Issue

Fixes #24378

Related: #8726

Visual Proof

Not attached. This is a main-process data-source fix with no layout change. Before: origin title + upstream comments/assignees. After: origin title + origin comments/assignees. I have not yet captured a before/after recording in a running build (see Testing).

Testing

  • New src/main/github/work-item-details-issue-source.test.ts: with origin = fork and upstream = parent, getWorkItemDetails(..., 'origin') must query GraphQL/timeline for the fork. It fails on main (owner=upstream-owner) and passes with this change. A second case pins the upstream-first default when no preference is set.

  • New src/main/github/issue-mutation-source.test.ts: addIssueComment / updateIssue with 'origin' hit the fork (REST comment endpoint, PATCH, gh issue edit --repo fork/...); an explicit owner/repo override still wins; no preference keeps the default.

  • src/main/ipc/github-issue-source-preference.test.ts: IPC passes 'origin' to updateIssue / addIssueComment for issues and no preference for type: 'pr' comments.

  • Updated exact-argument expectations in github-wsl-runtime-routing.test.ts, hooks-and-hosted-review.spec.ts, and rpc/methods/github.test.ts.

  • Ran on Linux (WSL): vitest over src/main/github, src/main/ipc, src/main/runtime, src/renderer/src/components/github, src/renderer/src/web: 15,704 passed. The only failures are two real-PTY integration suites (orchestration-codex-real-pty, tui-idle-name-only-real-pty), which fail identically on main in my environment because pty.node is not built. tsc for tsconfig.node.json and tsconfig.tc.web.json passes; oxlint (both configs) and oxfmt --check pass on changed files.

  • Not yet exercised end to end in a running Orca build.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Investigation, fix, tests and this description were produced with Claude (claude-opus-5.5) via Kiro CLI, and reviewed by me.

Review

Self-review against the CONTRIBUTING checklist:

  • Cross-platform: no platform-specific code; only repository resolution changed.
  • SSH / remote / WSL: connectionId and localGitOptions are threaded unchanged into the same resolver used by list/open, so SSH and WSL projects resolve exactly as listWorkItems does. The runtime RPC path forwards the preference via the resolved Repo.
  • Backwards compatibility: the new parameters are trailing and optional. With no preference, every path behaves as before (upstream-first). The github.addIssueComment RPC calls addRepoIssueComment with the old 4-argument shape unless type is sent.
  • Security: writes are still limited to the repo's configured origin/upstream remotes (or the existing explicit override). An explicit Origin pick with no resolvable origin fails closed ("Could not resolve GitHub owner/repo") instead of falling back to ambient gh.
  • Performance: one remote resolution per call, same as before (cached probes).

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Behavior change to call out: issue edits/comments now follow the selector. Previously they deliberately stayed on the heuristic (see the removed doc comments in issue-update.ts / issue-comment.ts). That rule predates getWorkItem honoring the selector and now produces split reads/writes within one dialog.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred). Ran typecheck, targeted lint/format and the affected test suites locally (see Testing); full pnpm lint / pnpm build left to CI.

@coderabbitai

coderabbitai Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor
🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 1ce6690c-fb46-4311-a12a-f1219c9010c5

📥 Commits

Reviewing files that changed from the base of the PR and between 744e772 and b69781b.

📒 Files selected for processing (13)
  • src/main/github/issue-comment.ts
  • src/main/github/issue-mutation-source.test.ts
  • src/main/github/issue-update.ts
  • src/main/github/work-item-details-issue-source.test.ts
  • src/main/github/work-item-details.ts
  • src/main/ipc/github-issue-mutation-handlers.ts
  • src/main/ipc/github-issue-source-preference.test.ts
  • src/main/ipc/github-wsl-runtime-routing.test.ts
  • src/main/runtime/orca-runtime-tests/hooks-and-hosted-review.spec.ts
  • src/main/runtime/rpc/methods/github-issue-methods.ts
  • src/main/runtime/rpc/methods/github.test.ts
  • src/main/runtime/runtime-github-issue-comment-commands.ts
  • src/renderer/src/components/github/github-work-item-comment-mutations.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Issue detail reads, issue updates, and issue comments now resolve the GitHub repository using the configured issue source preference. An explicit repository override remains in effect for comments. Runtime and IPC routes pass the preference to issue mutations, while pull request comments omit it. Tests cover origin selection, default upstream selection, repository overrides, and comment type routing.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to b6978

Issue details, edits, and comments now follow the selected Upstream or Origin source, and the default upstream-first behavior is unchanged. No merge-blocking risk was found.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 13 files. 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 clearly and concisely describes the primary change: issue details and mutations now use the selected issue source.
Description check ✅ Passed The description is comprehensive and covers the required user impact, implementation, rationale, linked issue, testing, compatibility, and checklist items. It explains why visual proof is not attached…
Linked Issues check ✅ Passed #24378 requires Origin to control issue details, comments, and edits, while Upstream and unset preference retain upstream-first behavior. getWorkItemDetails now uses `resolveIssueGitHubApiRepository…
Out of Scope Changes check ✅ Passed The changed production paths and tests support #24378. The runtime and IPC changes propagate the selector to issue mutations and preserve explicit comment repository overrides. PR comment routing rema…
  • Fix all pre-merge checks with AI
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 3/5

[Medium risk] Routes issue mutations through the user-selected repository source.

The PR is not ready to merge until Project-row details and open-dialog edits remain bound to the issue the user selected.

Findings

  1. P1 Project issue details can mismatch ▶
  2. P1 Open issue edits can redirect ▶

Summary

The PR routes GitHub issue details and mutations through the selected origin/upstream source, while forwarding comment type so PR comments retain their existing routing.

  • Ordinary issue reads and edits now use the repository preference.
  • Project-row details and edits can disagree about the issue repository, and an open edit can be redirected by a preference change in another window.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Project row or opened issue] --> B[Dialog displays item identity]
  B --> C[Detail request by repo ID and number]
  C --> D[Current issue source preference]
  D --> E[Detail repository]
  B --> F[Edit request by repo ID and number]
  F --> G[Preference at submission]
  G --> H[Edit repository]
Loading

Reviews (1) · Last reviewed commit: "fix(github): forward issue comment type ..."

Comment thread src/main/github/work-item-details.ts Resolved

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

✅ No new issues found.

Reviewed changes

Data-routing fix so the issue-source selector (origin / upstream / auto) governs issue details reads and issue mutations, not just list/open.

  • Issue details follow the selector — getWorkItemDetails resolves the issue's body/comments/assignees/timeline repo through resolveIssueGitHubApiRepositorySource(preference) instead of the upstream-first getIssueGitHubApiRepository, matching what getWorkItem already used.
  • Issue mutations follow the selector — addIssueComment / updateIssue take a trailing optional preference and resolve through the same resolver; an explicit ownerRepoOverride (prRepo) on addIssueComment still wins.
  • IPC + runtime threading — gh:updateIssue / gh:addIssueComment and the runtime updateRepoIssue / addRepoIssueComment forward repo.issueSourcePreference; addRepoIssueComment gains an optional type and skips preference for type: 'pr' so PR comments keep their own resolution.
  • RPC + renderer type forwarding — github.addIssueComment forwards params.type when set, and the renderer runtime path now sends type; the local IPC path already did.

What I verified

  • The two new suites are genuine: reverted work-item-details.ts, issue-update.ts, issue-comment.ts to base 744e772 locally and both fail there (details asserts owner=upstream-owner; the mutation suite gets { ok: false } and the resolver is never called). Restored afterward.
  • Ran the targeted suites plus all of src/main/github (775 tests) — all pass.
  • Consistency across a selector toggle holds: the details cache key includes issueSourcePreference, and setIssueSourcePreference evicts the repo's workItemsCache entries and bumps the invalidation nonce, so both list and dialog refetch.
  • Fail-closed is preserved: explicit origin with no resolvable origin makes getWorkItem return null (issue branch), so getWorkItemDetails returns null and mutations return "Could not resolve GitHub owner/repo…" rather than falling back to ambient gh.
  • Remote wire compatibility is safe: type already existed on the IssueComment schema, the added field is optional, and the host owns the preference resolution, so both skew directions behave as before — no opcode or capability negotiation needed.

The remaining asymmetry — getIssue (linked-issue lookups by worktree-persisted number) stays on the heuristic while mutations now follow the selector — is called out in the PR description and needs the number's own repo identity; I found no mutation affordance on that read-only surface.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

nwparker added a commit that referenced this pull request Oct 4, 2026
Keeps a fork issue’s details, metadata and edits bound to the repository the user opened, including same-number issues in fork and upstream. Repairs selected-assignee leakage and delayed failed edits repainting another issue.

Fixes #24378

Incorporates and cross-reviews contributor PR #24379, including its source-resolver correction and regression material. Covers the contributor PR’s Project-row identity and retained-dialog mutation findings. The final published head passes focused tests, hidden macOS rendering and current CI; the callback-timing bot thread has an evidence-based response.

Co-authored-by: Katsuma Takehisa <[email protected]>
@nwparker

nwparker commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Superseded by merged #24729 (ce0778626618bb9a5197209f5189190f2d51545c). Thank you for the source-resolver correction and regression tests; Katsuma Takehisa receives Co-authored-by credit in that merge commit.

The final review compared this PR at b69781b with #24729 at 23d82d3. The original issue-source fix, reproduction material and PR-comment type handling are incorporated there. The follow-up also addresses both remaining bot findings:

  • Project-row details use the row’s explicit repository, even when the Tasks selector points elsewhere.
  • Retained-dialog edits use the opened issue’s captured repository, so a later selector change cannot redirect the write.

The merged implementation has the source/mounted controls, hidden macOS before/after proof and current green CI recorded in #24729. Closing this duplicate after the credited implementation has merged. The original branch is retained.

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]: Issue details show upstream#N's comments/assignees when Origin is selected, and replies post to upstream#N

2 participants