Skip to content

fix(issue-pane): read the linked issue from the repo the item came from - #126

Merged
nplez1 merged 5 commits into
nplez1/mainfrom
nplez1/Issue-Pane-Linked-Repo
Oct 17, 2026
Merged

nplez1 merged 5 commits into
nplez1/mainfrom
nplez1/Issue-Pane-Linked-Repo

Conversation

@nplez1

@nplez1 nplez1 commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

ELI5

An issue link remembers which repo the issue lives in. Orca ignored that and looked in the workspace's own repo instead. When a workspace was created from a task on a different machine, Orca asked that machine for an issue in a repo it has never heard of, so the panel said "Couldn't load this GitHub issue" even though the link was fine — and the sidebar card's issue badge stayed empty for the same reason.

What Changed

Before: everything that renders or refreshes a workspace's linked issue — the Issue pane, the sidebar card, and the two background refresh sweeps — resolved the repo from worktree.repoId, then sent the task source's repoId with the request. When a workspace is in one repo and its issue in another (a task listed on this MacBook creates the workspace on a paired M4 Mini; a folder workspace borrows a synthetic repo id), the request went to the other host asking for a repo id only this device has. resolveRepoSelector matches on repo.id, so the host answered repo_not_found and the pane showed the unavailable message while the card never picked up issue state.

After: src/renderer/src/lib/linked-issue-repo.ts owns the rule once — the repo is the one the work item came from when that item is this link, else the workspace's own repo — and every surface calls it:

  • Issue pane: findLinkedIssueRepo for the row, linkedIssueRepoIsOffDevice for a distinct state.
  • Sidebar card: useWorktreeCardReviewDetails derives issueRepo and keys issueCache with it; issueRepo is threaded through useWorktreeCardLifecycleEffects beside repo, because the PR/checks surfaces there are about this workspace's git repo, not its issue. An off-device link reports issueRepoIsOffDevice, so the card settles as "Issue details unavailable" instead of spinning on a fetch it can never make.
  • Refresh sweeps — both paths (refreshAllGitHub and the activation sweep refreshGitHubForWorktree) plus stale-worktree-refresh-actions: same key, same fetch, so an enqueued refresh lands on the entry the card reads. The resolver goes through the store's memoised repo lookup index rather than scanning the array, because a per-worktree scan re-reads every row and turns the sweep into O(N*M) identity reads — the budget github-refresh-sweep.test.ts pins.

Two more things were incoherent beyond the repo choice:

  • A creation-time source context naming a different repo. Passing it along is precisely what asked another host for a foreign repo id. The pane now forwards it only when it names the row's own repo — consistent by construction; when it agrees it is kept so the read keeps its source-scoped cache identity and host guard.
  • A link whose repo isn't on this device rendered "Couldn't load this GitHub issue" and retried a read that cannot succeed. IssuePaneMessage gains a repoOffDevice state ("The repo this GitHub issue lives in isn't set up on this device."), with no fallback to the workspace repo: the same number in another project is a different issue.

The identity guard is why the item's repo is borrowed only for a matching GitHub issue (provider === 'github' && type === 'issue' && number === linkedIssue.number): linkedIssue and linkedWorkItem are independent slots and the former wins, so a workspace created from PR #12 and later linked to issue #7 must not read #7 out of #12's repo.

The link editor stays scoped to the workspace repo, now documented at the call site: it writes a bare number, which displaces the work item, and the pane then reads that number in the workspace repo — exactly where the picker listed it. Scoping it elsewhere would offer numbers from a repo the link no longer names.

Why

The issue number belongs to the repo the task was listed from, and that repo, not the workspace's, is where the read has to go. Fixing it in one helper rather than four call sites is the difference between the pane and the card agreeing and them drifting apart again.

Alternative considered: leave the repo resolution alone and send the workspace row's id to the paired host. That works only while both machines hold the same repo; when the remote project is a different fork, the same number resolves to an unrelated issue and the pane confidently shows the wrong one — which is what happened before this branch (upstream stablyai/orca #97 is a different PR from nplez1/orca #97).

Linked Issue

Fork PR into nplez1/main; no upstream issue accompanies it.

Visual Proof

N/A — no layout or styling change. The pane and card render the same components; the difference is whether the header's issue number resolves to a body, a message, or a settled unavailable state, which needs a paired workspace plus a rebuilt app to reproduce by hand (see Testing).

Testing

  • pnpm test across src/renderer/src/{components,store,lib,hooks} — 4510 files, 40 105 tests, all pass (includes the sweep identity-read budget test).

  • New suites: linked-issue-repo.test.ts (the four identity cases, missing row, absent slice); use-worktree-card-review-details.test.tsx (card keys the item's repo, keeps the workspace repo for a PR item, reports off-device and keys nothing when the repo is missing); use-worktree-card-linked-details.test.tsx (off-device settles as unavailable, an ordinary pending fetch still reads "Loading issue..."); pane tests for the off-device copy and both source-context guards; sweep tests for the cross-repo read and the off-device skip.

  • pnpm tc:web, oxlint, oxfmt --check, check:code-quality:changed, and the localization catalog verification are clean.

  • Not manually re-tested in the running app: reproducing needs the paired M4 Mini workspace set and a rebuild, which is the step after merge.

  • Automated tests added/updated

  • pnpm tc:web + oxlint + oxfmt --check + changed-code gate pass; full pnpm test left to CI

  • Manually tested in a rebuilt app (pending: needs the paired workspace)

AI Disclosure

Claude Opus 5, via the pi coding agent. Two Opus review passes over the branch drove the second, third and fourth commits.

Review

Three Opus review passes over the branch. The first returned "needs-work" on the item-vs-link identity and the silent fallback; the second confirmed the rule, the source-context scoping and the i18n, caught the card's endless "Loading issue..." for an off-device repo, and named the generated-PR-text path as out of scope; the third pass's questions drove covering the activation sweep and keeping the resolver on the memoised index. All fixed above with tests.

Cross-platform: no path handling changed, no shell or filesystem access added; the reads use a repo row the app already holds. Remote SSH: this is the case being fixed, in both directions (a runtime-owned issue repo is fetched through getGitHubSourceTarget, which follows the row's owner). Mobile: the pane and card decoration are desktop surfaces, untouched. Security: no new IPC surface — the same lookups, now with the repo the link names. Performance: one .find() over an already-loaded repo array; one failing RPC per broken workspace removed.

Known limitations, not fixed here

  • A link stores only a number. After re-linking through the editor, a number cannot be attributed to a repo at read time; it is read in the workspace repo, which is where the editor listed it. Giving the link a stored repo would remove the ambiguity, but that is a data-model change with a migration.
  • Generated PR/commit text still reads the workspace checkout. src/main/source-control/pull-request-linked-issue.ts fetches linkedIssue from the workspace's repoPath, so a cross-repo link can put an unrelated issue title, and a wrong Closes #N, into generated text. Correcting that needs an owner/repo#N reference, which is its own change.
  • Duplicate repo ids across hosts. The helper and the sweeps now share the store's index, but fetchIssueForGitHubOwner and findRepoOwner still resolve separately and can pick a different row when an id is duplicated across hosts. Pre-existing, and out of reach of a read-only fix.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

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 (changed-code gates pass; full suite left to CI)

A workspace created from a task on another host (or in another project) lives
in that project's repo there, while the issue stays in the repo the task was
listed from. The pane read the issue out of the workspace's repo and sent the
task source's repo id with it, so a paired client asked the workspace's host
for a repo id only the client knows: the host answered "repo_not_found" and the
pane showed "Couldn't load this GitHub issue" over a link that was intact.

Resolve the repo through the linked item first and fall back to the workspace's
repo when that row is not registered on this device. Folder workspaces already
resolved this way; every other workspace now shares the rule, so the repo path,
the repo id and the routing target all describe one repo.

Considered sending the workspace row's repo id to the host instead. That works
only while both machines hold the same repo: when they do not, the issue number
resolves against the other repo and the pane reads the wrong issue.
…link

Review of the previous commit found two ways the repo choice could mislead.

`linkedIssue` and `linkedWorkItem` are separate slots and `linkedIssue` wins
(workspace-linked-issue.ts), so the number the pane renders can name an issue
while the work item is something else: a PR, a Linear task, or a different
number. The previous commit borrowed that item's repo unconditionally, so a
workspace created from PR #12 and later linked to issue #7 would have read #7
out of #12's repo. The repo is now borrowed only when the item is a GitHub
issue with the rendered number; anything else reads the workspace repo, which
is what it did before.

The silent fallback when the item's repo is not registered on this device is
gone. It restored the old read, resolving the same number in whatever project
the workspace repo happens to be — showing an unrelated issue is worse than the
unavailable state, and the failing RPC was a wasted round trip either way.

Tests: a PR, a different number and a Linear task each keep the workspace repo,
and an unregistered item repo renders unavailable without calling the lookup.

Left out of scope, noted on the PR: the workspace card still fetches
`linkedIssue` from the workspace repo (use-worktree-card-lifecycle-effects.ts),
so for these workspaces the pane loads while the card's decoration does not.
…ywhere

The Issue pane read its link out of the workspace's repo and sent the task source's repo id
with it, so a workspace created from a task on another host asked that host for a repo id only
this device has: "Couldn't load this GitHub issue" over an intact link. The pane was fixed
first; the same mistake was still live in the sidebar card's issue decoration, in both refresh
sweeps, and in how a re-linked number was read.

`linked-issue-repo.ts` now owns the rule once, and every surface calls it: the repo is the one
the work item came from when that item is this link, else the workspace's own repo. That
covers the sidebar card's cache key and fetch, the two refresh sweeps that key the same entry,
and the pane. `issueRepo` is threaded through the card lifecycle effects beside `repo` rather
than replacing it: PR and checks surfaces are about this workspace's git repo, not its issue.

Two things made the read incoherent beyond the repo choice:

- A creation-time source context can name a different repo than the row being read. Passing it
  along is what asked another host for a foreign repo id, so the pane now forwards it only when
  it names the row's own repo — consistent by construction, and still carries the account
  otherwise.
- A link that names a repo this device does not have rendered "Couldn't load this GitHub issue"
  and retried a read that cannot succeed. It now says so: `IssuePaneMessage` gains a
  `repoOffDevice` state, and there is no fallback to the workspace repo, because the same number
  in another project is a different issue.

The link editor stays scoped to the workspace repo, documented at the call site: it writes a
bare number, which displaces the work item, and the pane then reads that number in the
workspace repo — where the picker listed it.

Tests: a pure suite for the shared rule (all four identity cases, missing row, absent slice);
the card's issue cache key in three shapes; the pane's off-device copy and both source-context
guards. `pnpm tc:web`, oxlint, oxfmt, the changed-code gate and the localization catalog verify
are clean, and 1426 renderer suite files pass.
…is device

The card's issue decoration is driven by a cache entry the review details key from the link's
repo. When that repo is not registered here there is no key, so the entry is `undefined`, which
the presentation reads as "still loading" — the card spun on a fetch that can never be made,
while the pane said the repo is missing. Before the repo moved to the link's repo this case
still ended in a failed fetch that cached `null`, so at least it settled.

`useWorktreeCardReviewDetails` now reports `issueRepoIsOffDevice` beside the entry, and the
presentation settles that link as unavailable. Two tests pin the settled and loading titles,
because the absent-entry case is exactly what the old code could not distinguish.

Also from the same review: the `readSourceContext` comment claimed it preserves the read's
account, which nothing selects from a source context — it scopes the cache and the host guard,
and the comment now says that. Dropped a duplicated cross-host pane test left over from the
previous pass.
…o identity reads

The activation sweep (`refreshGitHubForWorktree`) still keyed and refetched a linked issue
through the workspace repo; only the full sweep had moved to the link's repo, so after a push
one path invalidated an entry the card never reads and refetched through the wrong repo.

Resolving the link's repo also has to stay off the O(N*M) path the sweep budget pins: an array
scan per worktree re-reads every repo row on every lookup. `findLinkedIssueRepo` now goes
through the store's memoised repo lookup index, which is what the sweep already builds, so the
pane, the card and both sweeps share one resolver and one pass.

Tests: the full sweep reads a cross-repo link from the item's repo, skips one that names a repo
this device does not have, and the existing identity-read budget test still holds.
@nplez1
nplez1 merged commit 7631f0b into nplez1/main Oct 17, 2026
@nplez1
nplez1 deleted the nplez1/Issue-Pane-Linked-Repo branch October 24, 2026 03:23
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