Skip to content

fix(github): keep linked pull request details across restarts - #749

Merged
nixuuu merged 3 commits into
devfrom
fix/github-pr-persistence
Nov 14, 2026
Merged

nixuuu merged 3 commits into
devfrom
fix/github-pr-persistence

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Problem

After an app restart, the thread summary card showed some linked pull requests as unknown: a ? icon, the repository name in place of the title, and a ! checks icon.

Root cause

The linked pull request list read title, state and checks only from github_pr_cache at the account's current access revision. A token refresh (every 8 h) moves that revision, and retention prunes the old rows. Nothing refreshes a linked pull request unless its panel is open (the poller only covers watched pull requests). So after a restart, every linked pull request that wasn't open fell back to the unavailable placeholder, with no reason given.

Fix

  • Last known summary persisted (migration 0146): github_pull_requests.summary plus summary_account_id, so a summary is only shown when the repository's current connected account read it. It is written after every complete read. The list and the thread's newest_pull_request projection fall back to it, marked stale.
  • Background refresh: listing a thread's pull requests refreshes stale links in the background, at most once per pull request per 5 min across gateway processes (SQL claim). It does not run in the read path and never moves pull_request_revision, which fences link and unlink. While a refresh is pending (stale with no detail), clients re-read every 3 s instead of every 60 s.
  • Specific reason: a failed refresh stores a user-facing reason in a new PullRequestLink.detail field (proto change, additive). Lost access (403/404) reads No access to <repo>. Check the GitHub App installation. Rate limits and network errors keep their existing messages.
  • Privacy rules unchanged: lost access, account disconnect and an account switch drop the last known summaries that account read, just as they invalidate its cache. Transient failures keep the summary.
  • Smaller invalidation: a repository that leaves the installation now invalidates only that repository's cache and summaries, not the whole account.
  • UI (web/desktop and mobile parity): a new LinkedPullRequestRow on both. A known pull request shows its state, title and checks. Without details, the row shows Loading pull request… with a spinner, or Pull request unavailable with a warning icon plus the reason and Retry. The checks slot keeps its space but stays empty, so nothing shifts and no misleading ! appears.

Tests

  • New tests/integration/github-pr-last-known.test.ts (gateway + fake GitHub over loopback):
    • restart with an orphaned access revision: details are available while GitHub is blocked, then refresh in the background without moving the link revision, and unlink with the listed revision still works;
    • transient failure (429): the summary stays, the reason is shown, polling makes no extra GitHub calls, and Retry recovers;
    • lost access (404): the private summary is dropped and the reason names the repository;
    • owner scoping: a foreign owner can't list, remember, fail or claim, and disconnect removes the summaries.
  • Checks:
    • pass: bun install, gen:check, typecheck, lint, format:check, every github-* integration suite (one file at a time), the web build, and the mobile Android and iOS exports;
    • check:tmp: 3136 pass, 1 fail. The failure is apps/worker/src/providers/codex/connections.test.ts, which also fails on its own. The locally installed Codex CLI rejects a model provider change on resume. This PR doesn't touch the worker.
  • Not done: I didn't check the UI in a real browser or on a device.

Copy audit (docs/copy.md §8)

Before After Why
repository name as the row title, ? "Unavailable" icon Loading pull request… (spinner) §4.6 -ing + ellipsis for an ongoing action; no fake title
repository name as the row title, ? icon, ! "Checks unavailable" Pull request unavailable (warning icon), no checks icon says what happened; icon is not the only cue
(none) No access to itsoltech/wrk-ai. Check the GitHub App installation. + Retry what happened, then what to do; button starts with a verb
(none) … Last verified <time>. after a reason when a last known summary is shown one fact, not repeated elsewhere

Glossary: no new terms. Text checked for long repository names (wraps under the row).

Related: #501

The linked pull request list read titles, states and checks only from the
GitHub cache row of the account's current access revision. Token rotation
moves that revision, so after a restart every linked pull request that was
not open in a panel fell back to an unknown state with the repository name,
and nothing refreshed it.

Persist the last known summary per owner and pull request, bound to the
account that read it, and serve it immediately. Stale links refresh in the
background once per interval; a failed refresh keeps a specific reason that
web, desktop and mobile show with Retry. A repository leaving the
installation now invalidates only that repository's cached reads.

Related: #501
@nixuuu
nixuuu force-pushed the fix/github-pr-persistence branch from e09412b to 581f373 Compare November 14, 2026 19:26
@nixuuu
nixuuu merged commit 9dbe255 into dev Nov 14, 2026
11 checks passed
@nixuuu
nixuuu deleted the fix/github-pr-persistence branch November 14, 2026 19:39
nixuuu added a commit that referenced this pull request Nov 14, 2026
nixuuu added a commit that referenced this pull request Nov 14, 2026
Show four linked pull requests by default, with a total count and a
motion-token disclosure. Larger lists use pages of at most 20 rows and a
bounded scroll area, keeping 500 links cheap to render and animate
without changing the summary card's height rules.

The gateway caps every list response at 20 summaries, orders open/draft
PRs first and then by update time, and returns list-wide branch
presence. Background refresh only considers the requested page, combines
four PRs per GraphQL request, shares the existing durable
budget/backoff, and skips terminal PRs. Thread sync continues to carry
only the count, revision and one summary.

Validation:

- `bun install`, `bun run gen:check`, `bun run typecheck`, `bun run
lint`, `bun run format:check`, and the web build pass. The final
mobile-only adjustment also passes its typecheck.
- `TMPDIR=/var/tmp nice -n 10 bun run check:tmp` with the eight affected
GitHub integration files: 34 pass, no temp leftovers. After adding the
rate-limit scenario, all three large-list tests pass, also with no
leftovers. These cover 500-link ordering/paging, owner isolation,
restart behavior, linked gateways, detection, watch polling, bounded
batching and backoff. No UI tests added.
- Real browser review on a disposable remote stack: 0, 1, 4, 5, 50 and
500 links, short/typical/long titles, light/dark, desktop and phone
widths. The UI fixture substitutes list responses; gateway tests
exercise the actual database and gRPC path. At 500 links, the DOM stays
at 20 PR rows. Sampled expansion/collapse heights progress smoothly over
the motion token's 250 ms. The reduced-motion CSS guard disables the
transition; OS preference emulation was not available.
- Before PNGs preserve the supplied references. After PNGs and a short
expand/collapse MP4 are saved outside the repository in the review
artifacts directory. The disposable stack, database and tunnel are
removed after review.

Copy audit (§8): “Pull requests” → the same heading with a numeric
total, making the full list size visible. “Show N more” / “Show less”
remain unchanged; the threshold moves from one to four. New “Previous” /
“Next” actions navigate bounded pages, with “1–20 of 500” identifying
the range. These use sentence case, short verb-led labels, existing
terminology and no new errors or confirmations. Short, typical and long
titles retain truncation and full title text on desktop and phone
widths. No text depends on color alone.

No migration is needed. The card's layout and max-height rules are
untouched. Closed/merged PRs refresh only on explicit refresh or opening
their full details; list-wide branch presence prevents paging from
offering a duplicate create action.

Related: #749
nixuuu added a commit that referenced this pull request Nov 26, 2026
nixuuu added a commit that referenced this pull request Nov 26, 2026
## Changes

- Run twelve duration-balanced Linux shards in full PR and Push CI.
Verify that all twelve reports cover every discovered test file exactly
once. Refresh weights from two complete #1296 runs.
- Skip dependency lifecycle scripts for Windows native test
installation. The optional SSH CPU feature build took 104–106 seconds in
two baseline jobs. The Electron test still downloads its pinned binary
and the same native checks run.
- Subscribe to the real linked-update overview stream in the integration
fixture. Batch rejected diagnostic writes while checking the same limits
and recovery.
- Prevent a GitHub batch response obtained before permission
invalidation from repopulating individual pull request summaries.
Persist the last-known summary only while its matching cache row still
exists. Serialize cache fills with account- and repository-level
invalidation.

- Make the proxy usage test share the initial refresh and open later
read leases with the existing per-gateway clock. The test still requires
exactly one vendor request for the initial read and cache hit.

## Verification

- The first twelve-shard run finished in 5m22s and exposed the GitHub
race. Windows dependency installation took 41 seconds, down from 168
seconds in the baseline. Full PR and Push CI timings will be measured on
green runs. The additional four Linux runners repeat setup and
PostgreSQL startup.
- The existing integration test now pauses the cached response, triggers
permission denial over gRPC, resumes the batch and checks that neither
the batch nor a delayed last-known write can restore the old titles. The
original code reproduced the stale titles at that barrier.
- Twenty-five linked-update and diagnostics cases passed on Bun 1.4.5
and isolated PostgreSQL 18. The shard verifier accepted the complete
twelve-report set and rejected eight reports.

- The final GitHub change passed 51 integration cases. The proxy change
passed all 16 cases in its two adjacent suites.

Fixes: #752
Fixes: #749

Related: #1296
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