Repository navigation
fix(issue-pane): read the linked issue from the repo the item came from - #126
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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'srepoIdwith 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.resolveRepoSelectormatches onrepo.id, so the host answeredrepo_not_foundand the pane showed the unavailable message while the card never picked up issue state.After:
src/renderer/src/lib/linked-issue-repo.tsowns 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:findLinkedIssueRepofor the row,linkedIssueRepoIsOffDevicefor a distinct state.useWorktreeCardReviewDetailsderivesissueRepoand keysissueCachewith it;issueRepois threaded throughuseWorktreeCardLifecycleEffectsbesiderepo, because the PR/checks surfaces there are about this workspace's git repo, not its issue. An off-device link reportsissueRepoIsOffDevice, so the card settles as "Issue details unavailable" instead of spinning on a fetch it can never make.refreshAllGitHuband the activation sweeprefreshGitHubForWorktree) plusstale-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 budgetgithub-refresh-sweep.test.tspins.Two more things were incoherent beyond the repo choice:
IssuePaneMessagegains arepoOffDevicestate ("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):linkedIssueandlinkedWorkItemare 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 fromnplez1/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 testacrosssrc/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; fullpnpm testleft to CIManually 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
src/main/source-control/pull-request-linked-issue.tsfetcheslinkedIssuefrom the workspace'srepoPath, so a cross-repo link can put an unrelated issue title, and a wrongCloses #N, into generated text. Correcting that needs anowner/repo#Nreference, which is its own change.fetchIssueForGitHubOwnerandfindRepoOwnerstill 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
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (changed-code gates pass; full suite left to CI)