PR #9657 review: refresh past PRs in a workspace's PR history
Summary
The Workspace activity panel lists every PR a workspace was ever linked to, but the host-service only refreshed the PR on the workspace's current upstream head, so a PR left behind (earlier stack layer or branch) kept its old state forever (SUPER-3429, #1512 shown open after close). The PR adds refreshPastPullRequests, which refetches still-open/draft/queued history PRs by number during each project refresh, using the existing TTL cache, availability gate and gh→Octokit fallback. The PR pane's Refresh button now also calls pullRequests.refreshByWorkspaces and invalidates historyByWorkspaces.
Verdict
Minor issues: the fix is correctly placed, bounded and well tested; the remaining points are edge cases and polish, none blocking.
Findings
packages/host-service/src/runtime/pull-requests/pull-requests.ts:1642: a dequeued history PR stays "queued" and is polled indefinitely. The by-number path passes the storedqueuedstate asisInMergeQueue, and RESTpulls/{n}has no merge-queue field. A history PR that is removed from the merge queue but stays open keeps showing "queued" and stays in the poll set until it closes. Fix: when the stored state isqueuedand GitHub says open, callgetCachedPullRequestDetails(it already returnsisInMergeQueue), or fall back toopeninstead of carryingqueuedforward.packages/host-service/src/runtime/pull-requests/pull-requests.ts:1000: number lookups run after the head lookups, not beside them. Every awaitedrefreshByWorkspaces(merge flow, stack switch inuseOpenStackLayer, and now the Refresh button) waits for one more GitHub round trip when a workspace has open history PRs. Fix (optional): exclude each workspace's currentpullRequestId(instead of the head-lookup results) and run both lookups in onePromise.all. The rare duplicate fetch is cheap and cached.apps/desktop/.../PullRequestPane/PullRequestPane.tsx:76: the Refresh spinner does not cover the new sync.isRefreshingonly tracks the detail invalidation, so the button stops spinning before the host sync (withbypassCache) finishes and the activity row updates. A sync failure is only logged withconsole.warn. Fix: passisRefreshing || syncWorkspacePullRequests.isPending.
Evidence
Host-service (the actual fix): unit/regression tests
bun test src/runtime/pull-requestsinpackages/host-service: 113 pass, 0 fail.- Regression test proven: I disabled the
refreshPastPullRequestscall locally, and the new test "a past PR closed after the workspace moved on shows as closed" failed (history diff on #101's state). With the call restored it passes. The local change was reverted; the tree is clean. - The test's last assertion (
numberLookups == [101], line 2060) is meaningful:refreshPullRequestsByWorkspacesbypasses the cache, so a closed PR being looked up again would show up there.
Desktop (Refresh button in the PR pane)
- Desktop dev app launched over CDP (port 9333, renderer
localhost:3005, this worktree). First capture was a black window while Vite was optimizing; the retry rendered the signed-in shell:
- Not verified end-to-end. The dev profile has no project or workspace. Reproducing the reported journey also needs a workspace that linked PR A, moved to a branch with PR B, and then PR A closed on GitHub. I did not create or close real GitHub PRs from a review run. The Refresh-button wiring is covered only by the PullRequestPane tests (14 pass) and by code reading.
Questions for the author
- Open PRs that were abandoned in a workspace's history are now polled every TTL window for as long as they stay open (scoped watcher syncs don't bypass the cache, so this is about one call per PR per 60 s at most). Is that acceptable, or should rows not seen on GitHub for N days age out?
- History PRs from archived workspaces are still never refreshed, because
projectWorkspacesdrops archived rows. Is it intended that the panel can show a stale state for those? - Could the PR in the activity panel come from a repo other than the project's repo (fork upstream)?
refreshPastPullRequestsfilters to the project'srepoOwner/repoName, so such rows would still go stale.
Test / CI notes
- Commit
7040e88fd96be3ff396350e4e6ae5d6638f6373c(PR head). - Local: host-service
src/runtime/pull-requests113/113 pass; desktop PullRequestPane folder 14/14 pass; regression test fails with the fix disabled. - CI: Lint, Typecheck, Test, Sherif, Version Sync, Build CLI, Boot twice and the preview deploys all pass. Deploy Marketing and the mobile EAS build were still pending at review time.
- No tRPC procedure or schema changes, so
trpc-compatdoesn't apply. No new user-facing strings, so i18n doesn't apply.