Skip to content

feat(github): link pull requests to threads and show their summary - #501

Merged
nixuuu merged 2 commits into
feat/github-1-accountfrom
feat/github-2-manual-pr
Nov 11, 2026
Merged

nixuuu merged 2 commits into
feat/github-1-accountfrom
feat/github-2-manual-pr

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Adds stage 2 of docs/github.md: choose a repository account, link or unlink PRs from threads, and read their Summary on web/desktop and mobile. Links are many-to-many; unlink leaves a durable tombstone.

Rebase update (2026-11-11): the complete stack was rebased bottom-up onto origin/dev 48cd5e9c3ce07b7a46873ac40d92819ca847f85a, preserving #522, #526 and #527. This layer's current CI is green; implementation layers passed typecheck, lint and formatting after conflict resolution. The migration maximum at this layer is 0114; this supersedes historical numbering below. Proto generation was repeated in each affected layer (worker git-context fields use 227, preserving dev's file API fields). Final cross-stack security, parity, performance and verification evidence is in #534. Earlier results below describe the pre-rebase implementation. All layers remain draft; native device UI remains unverified.

Behaviour and UI

  • Desktop opens the PR in the thread’s existing right-hand column. The conversation and composer stay mounted; a browser check confirmed that the same composer node and its draft survive opening/closing the panel. Narrow/phone web uses the existing sheet/dialog; native mobile uses a pushed screen.
  • Compact header: linked repo/number, two-line title, author avatar fallback/login, relative updated time, mono refs, files/±, icon/state badge, checkout copy chip and overflow actions. Refresh, Open on GitHub, Copy link, Copy PR number and Unlink live in the menu.
  • Summary uses the existing segmented control. Timeline and Code stay hidden until their stages land. Small components own people, labels, checks and metadata; web and RN share status ordering, wording and label contrast calculations.
  • Checks are dense linked rows with icon, name, app and right-aligned status. Failures sort first; the summary counts failing/running checks, and long lists collapse after five. Reviewers have avatars/login/state icons; labels retain GitHub colours, choose black/white text by WCAG luminance and cap at four with +N.
  • Description uses normal message Markdown. Raw HTML stays escaped, unsafe links are rejected, and description images remain explicit links with no automatic image requests. Thread PR rows use the existing compact panel row with state/title/number/checks icon.

Data and security

Shared gateway REST/GraphQL client provides conditional REST ETags, SQL single-flight across processes, per-identity/global concurrency, durable rate accounting/backoff, and bounded shared caches. Cache keys include owner/account/access revision; SQL validates memory-cache reads. Tokens stay encrypted in the home gateway. Linked computers receive only routed DTOs and the small offline mirror; confirmed access loss purges content and clients reject late responses from the previous context.

Additive RPCs and thread projections, migration 0113, regenerated contracts. This revision adds additive coloured-label details while retaining the original string labels for older clients. The frozen update contract is unchanged. Migration numbering was rechecked against dev (highest 0111) and stage 1 (0112); no renumbering is needed.

Scope and decisions

Summary reads the first 100 items per source and marks incomplete results. Full pagination, watches/polling and detailed metrics remain stage 4. Manual links sort by upstream creation time; branch highlighting remains stage 3. docs/github.md records desktop panel/phone sheet placement, the pr URL parameter, two-line titles and hidden future tabs. No external PR mutations or automatic discovery.

Validation

  • Passed: bun install, bun run gen:check, full bun run typecheck, bun run lint, bun run format:check, web build and git diff --check. The final native feedback change also passed mobile typecheck.
  • Fresh full TMPDIR=/var/tmp bun run check:tmp --max-concurrency 1 was attempted once. It ended with SIGTERM (exit 143) before its final summary/cleanup check; the signal source is not recorded. Before interruption: 851 passing cases, 85 skipped cases, one failure across 148 encountered files. This is not a clean full local run.
  • The only recorded failure was config-sync-intent.test.ts, “choosing an alternative preserves its transitive observations across three computers”: the conflict notice did not arrive within 20 seconds (line 42). Neither that test/helper nor configuration-sync implementation differs from stage 1. A fresh, isolated check:tmp rerun passed all 3 cases, including the original case in 3.55 seconds, with no temp leftovers. The timeout was not reproduced; its cause remains unconfirmed.
  • The interrupted process never emitted its cleanup verdict. Its private directory held 20 canopy-instance-switch-* directories and 6 empty directories from skipped live suites, plus tool runtime directories. These use deferred scope/process cleanup; interruption prevents a reliable normal-exit leak verdict. The evidence was moved to /var/tmp/canopy-github-2/interrupted-full-run-temp; the run’s own Postgres container was identified by its private port descriptor and removed. Other runs were untouched.
  • Fresh isolated check:tmp runs passed github-pull-requests.test.ts (5 cases), github-pr-linked.test.ts (2), and github-pr-owner.test.ts (1), each with no temp leftovers. The file active at interruption, linked-routes-status.test.ts, also passed all 5 cases in isolation (127.84 seconds), with no temp leftovers.
  • CI is green on efd5c79a7915000e1ac9618b7efda77768701047: static checks, all four test shards, web/Linux builds, commitlint and the aggregate “Typecheck, tests, builds” check. CI run. The aggregate also verifies every test file ran exactly once; each shard includes temp cleanup. No review has been submitted. The PR remains draft.
  • Controlled local GitHub HTTP/GraphQL fixture covers tombstone/restart races, owner/account/cache isolation, offline/revoke, two gateways, ETag 304 and durable backoff. No anonymous production API or live GitHub test was used.

Manual browser QA: desktop 1440×1000, narrow 900×900, phone 390×844; light/dark; Open/Merged/Closed/Draft; long titles/refs, 12 labels and 16 varied checks; expanded labels/checks; long Markdown/code/blocked image/raw HTML/unsafe link; compact thread list; menu refresh/copy feedback/unlink; empty list and inline Connect GitHub after disconnecting the fixture account. No horizontal overflow. Clipboard writes show feedback; the browser denied permission to read the clipboard back. Native UI was checked through source/typecheck and fingerprints, not on a device.

Screenshots are outside the repository in /var/tmp/canopy-github-2/:

  • desktop-light.png, desktop-dark.png — thread visible beside the PR.
  • {desktop,narrow,phone}-{light,dark}-{open,merged,closed,draft}.png — complete state/width/theme matrix.
  • desktop-light-list.png, desktop-light-after-unlink.png, desktop-light-unlinked.png, phone-light-unlinked.png.
  • phone-light-checks.png, phone-dark-checks.png, phone-light-markdown.png.
  • {desktop,phone}-{light,dark}-connect.png.

Mobile changes are JS only. bunx [email protected] fingerprint:generate --platform <ios|android> --build-profile production --json --non-interactive matches stage 1: iOS 6ddec9ef559ee0095ac33e94ff9418a942053b17, Android 5f6eae3ab278f1cd543e9ed763f923a319b65ec9.

Copy audit — docs/copy.md §8

Raw lowercase check enums → “Passed”, “Failed”, “Running”, “Timed out”, etc., with icons so meaning never depends on colour. Repeated check metadata → one compact row and an aggregate “4 failing · 4 running”. Three bordered actions → verb-led overflow actions; checkout copy uses a small mono chip and toast feedback that does not move content. “Back to thread” → “Close pull request” on the panel. Description heading is quiet; author/title text truncates with full text available. English sentence case, explicit actionable errors, no new glossary synonyms or novelty copy. Long names checked at all three widths.

Maintainer live check

The opt-in test was added and not run by the agent. From the repository root:

CANOPY_LIVE=1 bun test tests/integration/github-pull-requests.live.test.ts

Enter the printed device-flow code on GitHub with an account whose Canopy installation includes itsoltech/canopy. The local test gateway reads PR #485 by default; set CANOPY_LIVE_GITHUB_PR=<number> to choose another. It creates only a local thread/link, reads GitHub, and disconnects the local test account during cleanup. It performs no PR writes and never prints credentials.

Stack: documentation #485 → account stage #487 → this stage. All layers remain draft until stages 1–9 are complete and verified; do not merge separately.

@nixuuu
nixuuu force-pushed the feat/github-2-manual-pr branch from 6cc122b to a47a380 Compare November 10, 2026 23:37
@nixuuu
nixuuu marked this pull request as ready for review November 11, 2026 00:57
@nixuuu
nixuuu merged commit c332123 into dev Nov 11, 2026
11 checks passed
@nixuuu
nixuuu deleted the feat/github-2-manual-pr branch November 11, 2026 00:58
nixuuu added a commit that referenced this pull request Nov 11, 2026
Adds stage 3 of the accepted GitHub integration design. Threads discover
open and closed pull requests from their checkout's head repository,
remote ref and full SHA. Completed successful tool output supplies
verified PR URL hints for stacks with different head refs. Unlink keeps
its tombstone across discovery and replay.

**Rebase update (2026-11-11):** the complete stack was rebased bottom-up
onto `origin/dev` `48cd5e9c3ce07b7a46873ac40d92819ca847f85a`, preserving
#522, #526 and #527. This layer's current CI is green; implementation
layers passed typecheck, lint and formatting after conflict resolution.
The migration maximum at this layer is **0115**; this supersedes
historical numbering below. Proto generation was repeated in each
affected layer (worker git-context fields use 227, preserving dev's file
API fields). Final cross-stack security, parity, performance and
verification evidence is in #534. Earlier results below describe the
pre-rebase implementation. All layers remain draft; native device UI
remains unverified.

The worker returns normalized read-only git context through the process
governor and the additive `git_pr_context_v1` capability;
`WORKER_LINK_PROTOCOL` stays at 1. Credentials stay in the gateway.
Durable jobs, leases, event watermarks and pagination cursors share the
existing account-scoped cache and rate budget. Web/desktop and mobile
show Auto/Manual and Current branch/History.

Validation:
- Local HTTP fixture and real Gateway↔WorkerHost git/worktree tests:
detection 6/6, security/replay/cleanup 5/5, existing manual PR tests
5/5; files run individually.
- `bun install`, generation check, full typecheck, lint, format check
and web build passed. Full `bun run check:tmp` ran exactly once in a
fresh process: 2169 pass, 165 skip, 0 fail across 396 files (1101 s),
exit 0. It reported no Canopy temp directories left; excluded tool-owned
runtime files were reported separately by the runner.
- Web browser QA with local fixtures covers light/dark at 1280, 820 and
390 px, short/typical/long titles, branch highlight, Auto/Manual and
unlink. Reopening the panel kept the unlinked PR absent. Screenshots
remain outside the repository:
`/var/tmp/canopy-github-3/desktop-light.png`, `desktop-dark.png`,
`narrow-light.png`, `narrow-dark.png`, `phone-light.png`,
`phone-dark.png`, `phone-unlinked-dark.png`.
- EAS CLI 27.4.1 production fingerprints are unchanged for both iOS and
Android. No live GitHub tests were run.
- CI is green on `58f8d5ee4d9b41224f09816fdf03b9b4f979cb2e`: all four
test shards, static checks, web/Linux builds and the aggregate gate
passed.

Copy audit (§8): source absent → Auto/Manual identifies how a PR was
linked; implicit row grouping → Current branch/History explains the
highlight without relying on color. Existing Link pull request and
Unlink actions stay verb-first. Discovery messages name the missing
match and the manual action. Short, typical and long titles were checked
on desktop and phone; no new decorative copy.

Design clarifications recorded in `docs/github.md`: cleanup proof from
the new client requires a selected PAT with the existing worker grant;
device sign-in alone grants no cleanup authority. Tool-output evidence
uses a persisted checkout snapshot from before completion and suggests
manual linking when that proof is missing. Candidate verification is
bounded to ten per batch, with a durable within-page cursor.

Stack: based on #501; stage 3 of 9. Keep this PR draft until the whole
stack is complete and verified.
nixuuu added a commit that referenced this pull request Nov 11, 2026
## Change

**Rebase update (2026-11-11):** the complete stack was rebased bottom-up
onto `origin/dev` `48cd5e9c3ce07b7a46873ac40d92819ca847f85a`, preserving
#522, #526 and #527. This layer's current CI is green; implementation
layers passed typecheck, lint and formatting after conflict resolution.
The migration maximum at this layer is **0116**; this supersedes
historical numbering below. Proto generation was repeated in each
affected layer (worker git-context fields use 227, preserving dev's file
API fields). Final cross-stack security, parity, performance and
verification evidence is in #534. Earlier results below describe the
pre-rebase implementation. All layers remain draft; native device UI
remains unverified.

Stage 4 enables Summary, Timeline and Code on web/desktop and mobile.
PRs now have paginated timeline/review threads and replies, checks/jobs
with lazy in-app redacted logs, and a paginated file list with commit
filtering and lazy unified/split diffs. Binary, renamed, truncated and
stale-SHA files have explicit fallback states. Viewed remains hidden
until stage 5; this stage makes no GitHub mutations.

Visible PRs share a watch producer and durable fetch leases; hidden
clients stop their streams, reconnect gaps invalidate pages, and active
background threads fetch bounded header batches. Linked homes retain
verified offline snapshots without mirroring logs. Cache retention,
owner quotas and fixed-label metrics cover the new resources. Composer
actions prepare bounded, quoted, untrusted attachments through the
existing attachment/harness path and never send a message automatically.

The release catalog stays CDN-first and can use an administrator's own
connected GitHub account for its authenticated API fallback. The visible
setting defaults on; missing, expired, disconnected or disabled accounts
retain the public update path. Credentials stay in the gateway and are
stripped from storage/CDN redirects.

Individual check/review states use Tabler outline glyphs with tooltips
and accessible labels, including mobile accessibility labels. The PR's
primary state stays readable as a compact icon-and-text badge. Aggregate
check counts remain text. Thread PR links use quiet source captions and
panel rows. Summary/Timeline/Code, checks, logs and the file-list
scrollport follow #512's `scroll-stable` helper and balanced padding.

The design pass gives Code one compact toolbar for commit filtering,
file count, layout, wrap, whitespace and tree view. File rows expand
their diff directly below a sticky file header; paths truncate in the
middle, renames retain both paths, and binary/large patches have inline
recovery actions. Timeline uses a compact event menu and sort toggle, an
avatar rail, grouped commits with short SHAs, relative timestamps with
absolute-time tooltips, markdown cards and inline review threads with
indented replies. Checks and review replies use progressive loading.
Shared activity/file presentation and focused components keep
web/desktop and mobile aligned; existing thread diff controls retain
their defaults.

## Stack and migrations

Rebased #485 → #487 → #501 → #508 with `gh stack` onto `origin/dev` at
`26f61cce`, including #486's static release index and #512's scrollbar
helper. Resolved conflicts, regenerated contracts where needed, checked
typecheck/lint/format at each layer, and force-pushed the rewritten
layers with explicit leases. All PRs remain drafts and their bases still
chain. Dev subsequently advanced with #510, #513 and #515; those changes
are outside this completed prerequisite rebase.

Renumbered the stack migrations above dev's 0112 in layer order: 0113
accounts, 0114 manual links, 0115 detection, then 0116 full read.
Updated the expected schema list and migration registration. Frozen
`update/v1` is unchanged; generated additive contracts are committed. No
material design deviations.

## Verification

- Passed `bun install`, `bun run gen:check`, root `bun run typecheck`,
`bun run lint`, `bun run format:check`, and the web build, including
final typecheck/build after the sticky-padding correction and mobile
typecheck/lint/format after the final mobile reset correction. The build
reports the existing chunk-size advisory. Final head
`429c46af353546c433e87293dd128910e524c04e`: CI is green. All five layers
#485/#487/#501/#508/#518 have SUCCESS check rollups, remain draft, and
retain the correct chained bases. No GitHub reviews have been submitted
for this stage.
- Sequential local fixture files passed: full-read pagination (5 tests),
security/composer (5), lifecycle/retention (4), release fallback (4),
linked-home offline/cache scope (3), and paired mobile transport (1).
Coverage includes >100 timeline/check/thread/reply/job items,
304/429/403, GraphQL partial errors, independent-client single-flight,
stream gaps/restart, 300 files/SHA races, log
SSRF/redaction/download/page limits, concurrent owner log quota,
retention, and authenticated/public release paths. Composer attachments
reached the scripted worker blob path. No live tests or anonymous
production API calls were used.
- Fresh-process full `bun run check:tmp` after the design pass: **2242
passed, 165 skipped, 0 failed**, **25397 assertions**, 2407 tests across
413 files, **1120.32 seconds**; exit 0 and **no Canopy temp entries
remained**. Harness-owned runtime entries were listed separately by the
runner and removed with its private directory. This rerun includes the
earlier cache-eviction correction and linked-home regression coverage.
The historical run was 2236 passed / 165 skipped / 6 failed; it is
superseded by this clean full run, not relabelled as passing. The final
two-file mobile state-reset correction additionally passed focused
ESLint, mobile typecheck, root lint/format and native JS exports.
- Browser fixture QA: light/dark, desktop 1440×1000, narrow 768×1000,
phone 390×844, with 18 new screenshots. Verified grouped commits, inline
review threads/replies (3→50→100), event filter/sort, relative-time
accessible labels containing absolute dates, folder collapse, long
paths, binary notices, long inline diffs and global
layout/wrap/whitespace controls. Checks progress 5→50→100→137 using one
control. Sticky toolbar/file-header bounds remain flush while scrolling;
phone panel has no horizontal overflow. Prior stage-4 fixture QA also
covered failing-job logs, huge/truncated/renamed patches, commit
filtering and all three composer attachments, including preserving an
existing draft when adding a second context.
- Mobile JS only: `bunx [email protected] fingerprint:generate --platform
ios --build-profile production --json --non-interactive` and the Android
equivalent passed. Fingerprints unchanged from stage 3: iOS
`6ddec9ef559ee0095ac33e94ff9418a942053b17`, Android
`5f6eae3ab278f1cd543e9ed763f923a319b65ec9`. Expo Doctor passed 20/20;
prebuild passed in a scratch checkout with no package changes; iOS and
Android Hermes exports passed, both limited to one bundler worker.
Additional mobile ESLint found existing app-wide findings; two findings
in the new reset effects were corrected and focused ESLint on those
files now passes. Mobile typecheck, canonical repository lint and format
checks passed again after that correction. App-wide mobile ESLint still
reports 40 errors / 5 warnings in unchanged code and is not claimed
green.

Native simulator visual QA is unverified: device tools returned “Device
list failed: Could not communicate with device support. Try refreshing
devices.” Refreshing once produced the same error; no alternate device
control was used. Mobile RPC parity is covered over the real pinned,
paired and revocable mobile transport. Live GitHub tests remain
optional.

### Performance

Real gRPC/Postgres fixture benchmark, same scripted GitHub 503 load,
stage-3 baseline versus stage 4. 10 warmups and 80 samples per read/ACK
operation, 40 dispatch samples. ACK measures committed ACK enqueue, not
network round trip.

| Existing operation | Baseline p95 ms | Stage 4 p95 ms |
| --- | ---: | ---: |
| GetOverview | 3.705 | 3.453 |
| GetThread | 1.094 | 0.893 |
| Send → worker input | 13.466 | 8.095 |
| Ingest → ACK enqueue | 2.294 | 2.309 |

No material regression observed; ACK's +0.015 ms (+0.6%) is within
shared-machine noise. This is a local sample comparison, not a
confidence-interval study. Candidate measurements precede the final
cache-write byte-accounting and access-error eviction corrections; those
change cache misses and GitHub access-error paths, not the measured
existing operations or warm-read paths. Warm-read p95: PR 3.091,
Timeline 5.392, Checks 4.412, Files 15.145, Diff 14.059, Log 6.460 ms,
all below the 50 ms target. Browser/native rendering p95, cold upstream
latency and an unavailable-partner performance comparison were not
measured; the offline partner behavior has integration coverage.

### Copy audit (§8)

Reviewed new/changed labels, settings, errors and empty states against
`docs/copy.md`: sentence case, active verbs, glossary, actionable
recovery, no decorative prose or duplicate facts. Long check names,
branches and paths were inspected at desktop and phone widths.

| Before → after | Reason |
| --- | --- |
| Author login input and separate review section → compact activity
menu, inline threads and relative times | Reduce filter weight and
preserve chronological context |
| Per-file display controls → one shared icon toolbar | Keep file rows
focused on paths and changes |
| “Show 45 more checks” plus “Next page” → progressive “Show more
checks” | One paging pattern transparently loads further pages |
| Bare SHA → “on aaaaaaa”; primary state glyph → icon plus
“Open”/“Merged”/“Draft”/“Closed” | Clarify the revision and keep the
PR's primary fact readable |
| Individual “Failed”/“Requested” status text → labelled glyphs and
tooltips | More room for names; state remains available to assistive
technology |
| “Auto”/“Manual” chips → quiet source captions | Reduce visual weight
without hiding provenance |
| Bordered “Link pull request”/“Show less” → “+ Link pull request” and
quiet “Show N more”/“Show less” rows | Match panel row actions |
| Generic missing patch → “Binary file”, “File renamed with no text
changes”, or explicit size-limit guidance | Explain the actual
limitation and recovery |

No new glossary term or “soul” sentence. Empty/error text keeps the
necessary status words; aggregate counts remain readable text. Icons
have distinct shapes and labels rather than relying on colour.

### Screenshot evidence (uncommitted)

New design matrix under `/var/tmp/canopy-github-4/`:
`{desktop,narrow,phone}-{summary,timeline,code}-{light,dark}.png` (18
files), plus `desktop-code-sticky-dark.png`. Desktop is 1440×1000,
narrow 768×1000 and phone 390×844. Phone Code light shows stacked and
dark shows split. Existing logs/composer screenshots remain in the same
uncommitted directory.

Related: #485, #486, #487, #501, #503, #508, #512.
nixuuu added a commit that referenced this pull request Nov 11, 2026
Stage 5 of the accepted GitHub design adds explicit user comments and
GitHub-synced Viewed to web/desktop and mobile. Users can post, reply in
existing review threads, edit/delete their own comments, preview
Markdown, and see X/N viewed and “Changed since you viewed”.

**Rebase update (2026-11-11):** the complete stack was rebased bottom-up
onto `origin/dev` `48cd5e9c3ce07b7a46873ac40d92819ca847f85a`, preserving
#522, #526 and #527. This layer's current CI is green; implementation
layers passed typecheck, lint and formatting after conflict resolution.
The migration maximum at this layer is **0117**; this supersedes
historical numbering below. Proto generation was repeated in each
affected layer (worker git-context fields use 227, preserving dev's file
API fields). Final cross-stack security, parity, performance and
verification evidence is in #534. Earlier results below describe the
pre-rebase implementation. All layers remain draft; native device UI
remains unverified.

The gateway revalidates owner/account/repository permissions, PR
SHA/state and target membership before writing. Durable receipts and
audit records bind each request to its authenticated client and
parameters; duplicate requests return the receipt. Lost responses become
“Couldn't confirm. Check on GitHub” and never replay on reconnect or
token refresh. Delete confirmations expire after 60 seconds. Workers and
bots are denied.

Validation:
- Local GitHub HTTP/GraphQL fixture, sequential files: mutation
durability (7 tests/48 assertions), security (5/26), paired mobile
transports (1/9), linked-home routing (1/7), existing full read (5/35);
PostgreSQL schema (23/85).
- `bun install`, `bun run gen:check`, typecheck, lint, formatting and
web build passed. No live GitHub test or feature API call was used.
- Full `bun run check:tmp` ran exactly once in a fresh process: **2255
pass, 165 skip, 1 fail**, 27128 assertions across 417 files. Temp
cleanup passed. The failure was a 5-second timeout in the unchanged
release dispatch SHA test (`scripts/release.test.ts:175`). That file
subsequently passed in isolation: **14 pass, 0 fail**, with the
timed-out case taking 984 ms. The full suite was not repeated.
- Real-browser fixture QA: post/edit/delete/reply, uncertain result
retained across tabs, error rollback, VIEWED/UNVIEWED/DISMISSED,
offline-disabled Viewed, long Markdown and sticky scrolling; light/dark,
desktop/narrow/phone widths. Screenshots remain outside the repository
in `/var/tmp/canopy-github-5/`. Browser evidence covers the web UI used
by desktop; native mobile screens and the Electron binary were not
visually exercised. Paired pinned iOS/Android transports were tested
through gRPC.
- Mobile JS only. Production iOS fingerprint remains
`6ddec9ef559ee0095ac33e94ff9418a942053b17`; Android remains
`5f6eae3ab278f1cd543e9ed763f923a319b65ec9`. Both exact fingerprint JSON
files match their baseline.

CI: lower stack layers #485/#487/#501/#508/#518 are green. On this head,
static checks, web/Linux builds and shards 1/3/4 passed. Shard 2 failed
in the unchanged updater test “a confirmed update can apply the next
one”: `readUpdateRecord` encountered an unexpected EOF while reading
JSON. The updater test file passed in isolation locally (6 tests, 26
assertions). Failed CI jobs have been rerun; their result is pending.

Copy audit (§8): no comment controls → “Post comment”, “Reply”, “Save
comment” and “Delete comment”; actions name their effect and delete
repeats its verb in the confirmation. Unknown write outcome → “Couldn't
confirm. Check on GitHub”, with an explicit source link. “Start a new
comment”/“Start a new reply”/“Edit again” explicitly opens an empty
editor, without resending the old body. Viewed invalidation → “Changed
since you viewed”, with text beyond checkbox colour. Error/offline copy
tells users to refresh/check access and preserves the draft.
Short/typical/long names and Markdown checked at desktop/narrow/phone
widths. No new glossary term or decorative copy.

Implementation decisions recorded in `docs/github.md`: advertise the
narrower `github_pr_comments_v1` capability until all v1 writes exist;
client drafts/uncertain editor state remain in bounded client memory
across tab/remounts, while receipts are durable in the gateway.
Migration 0118 avoids the in-flight diagnostics migration 0117 and must
be rechecked/renumbered against the merge base before merging. Proto
changes are additive and `update/v1` is unchanged.

Related: #485, #518. Keep draft with the remaining stack stages.
nixuuu added a commit that referenced this pull request Nov 11, 2026
Implements stage 6 of the accepted GitHub integration: users can select
LEFT/RIGHT diff lines and ranges, post a single inline comment or
collect a pending review, then submit Comment, Approve or Request
changes with a summary. Review conversations support resolve/unresolve
and editing/deleting the user's own comments on web/desktop and native
mobile.

**Rebase update (2026-11-11):** the complete stack was rebased bottom-up
onto `origin/dev` `48cd5e9c3ce07b7a46873ac40d92819ca847f85a`, preserving
#522, #526 and #527. This layer's current CI is green; implementation
layers passed typecheck, lint and formatting after conflict resolution.
The migration maximum at this layer is **0118**; this supersedes
historical numbering below. Proto generation was repeated in each
affected layer (worker git-context fields use 227, preserving dev's file
API fields). Final cross-stack security, parity, performance and
verification evidence is in #534. Earlier results below describe the
pre-rebase implementation. All layers remain draft; native device UI
remains unverified.

- Reuses stage 5's owner-scoped preflight, durable receipts, audit,
confirmation and uncertain/no-replay behavior. The gateway verifies
original diff/SHA anchors, the selected account, review/thread ownership
and fresh GitHub rights; workers and bots cannot mutate reviews.
- Pending comments are paginated and checked against fresh page digests
and head SHA before submit/discard. Other-device changes require
refresh; outdated comments require acknowledgment. The PR author sees
why only Comment is available.
- Adds additive generated contracts and the narrow `github_pr_review_v1`
capability. Migration `0119_github_reviews.sql` follows stage 5's 0118;
diagnostics reserves 0117. Recheck numbering before merging the whole
stack.
- Keeps the Code diff open across unchanged refreshes, reserves the
Viewed icon slot, removes repeated Viewed text, and uses an auto-growing
composer without a native resize grip.

Validation: dependency install, generated-contract check, monorepo
typecheck, lint, formatting and web build pass. Focused local
GitHub-fixture integration files pass individually: review 6 tests/77
assertions, security 5/39, mobile 1/15, linked 1/12. The full
fresh-process `check:tmp` ran once and passed: 2267 pass, 165 skip, 0
fail, 27016 assertions across 419 files, with no test-owned temporary
entries left (tools' runtime cache entries are excluded by the checker).
No live GitHub integration API was used.

Manual browser checks completed using only the local fixture: desktop,
narrow and phone widths; light/dark; exact LEFT/RIGHT range endpoints in
unified/split views; all verdicts; pending edits/deletion/discard; push
refusal/outdated acknowledgment; author restrictions; conversation
resolution; other-device changes; 55-comment pagination; rejected
submission with retained summary; and lost-response uncertainty without
replay. Browser JavaScript errors were empty. Screenshots are kept
outside the repository in `/var/tmp/canopy-github-6/`. Phone
verification used browser viewport emulation; native device UI was not
exercised.

Mobile: Expo Doctor passes 20/20, CNG prebuild succeeds, and both
iOS/Android JS/Hermes exports succeed. Production fingerprints are
unchanged: iOS `6ddec9ef559ee0095ac33e94ff9418a942053b17`, Android
`5f6eae3ab278f1cd543e9ed763f923a319b65ec9`. Supplemental Expo ESLint for
all new review files passes. The app-wide Expo ESLint command still
reports 41 existing errors and 7 warnings in older files; the touched
shared `usePages.ts` findings were reproduced from the parent branch.
Root repository lint passes.

Copy audit (§8): repeated “Viewed” labels → accessible checkbox
label/tooltip, because the toolbar already supplies the count; “Changed
since you viewed” as a second line → icon with tooltip, to keep rows
aligned. New actions use explicit verbs (“Add to review”, “Submit
review”, “Resolve conversation”); refusal text explains the next action.
Account/repository/PR/SHA appear at the mutation boundary. No new
glossary terms or decorative slogans. Short, typical and long fixture
content checked at desktop and phone widths.

CI is green on this head and every preceding implementation layer (#487,
#501, #508, #518, #523); the stage 5 updater rerun passed. No review
decision has been recorded.

Related: #485, #523. Linked in [stack
#488](Stack #488), on top of #523.
This PR stays draft until the complete nine-stage stack is verified.
nixuuu added a commit that referenced this pull request Nov 11, 2026
Stage 9 adds explicit GitHub Actions controls to pull request checks and
job/log views on web/desktop and mobile: re-run failed jobs, one job
(including dependent jobs), the whole workflow run, and cancel with
confirmation. The dialog identifies repository/PR, run, attempt and SHA
and explains deployment effects. External CI and missing App/user
permissions disable controls with a reason. There is no workflow
dispatch, debug logging or force-cancel.

All writes reuse fresh preflight inside the shared mutation queue,
durable client-bound receipts, owner scoping, structural audit and
uncertainty without replay. An Actions 201/202 means **accepted**, while
stage 4 watch/polling supplies queued/in-progress/completed states. No
network response is treated as workflow completion. Linked CI
prepare/write requires `github_pr_write_v1` at both ends; only the home
stores the receipt and holds credentials.

Successful empty responses are accepted only for POST to the three fixed
rerun endpoints with 201, or cancel with 202. The local fixture now
sends both null and zero-length bodies. An unexpected empty 200 remains
uncertain, and repeating its request ID never replays the write.

The reviewer picker now has one pre-checked list. Apply computes
removals and additions with separate receipts and verification between
writes; uncertainty stops the diff. Re-request is a separate icon on
completed reviews in Summary and picker rows. Search placeholders match
each picker; teams use the team icon.

`docs/github.md` and API/mobile/architecture docs describe the
implemented v1 and its limits, available after the whole stack merges.
The jobs API exposes no DAG: dependent-job semantics are explained
without fabricating edges. Fine-grained PAT permissions cannot be fully
introspected; upstream refusal becomes an explicit receipt.

Rebased bottom-up onto `origin/dev`
**48cd5e9c3ce07b7a46873ac40d92819ca847f85a**, preserving #522/#526/#527,
including feed/message optimizations, clone behavior and linked
workspace-copy scope. No merge of dev into stage 9. All conflicted
layers received typecheck/lint/format; affected proto layers were
regenerated in their originating commits. All pushes used
force-with-lease. The verified chain is #485 → #487 → #501 → #508 → #518
→ #523 → #525 → #528 → #532 → #534; every PR remains draft. Stack:
Stack #488.

Dev's highest migration is 0112. Unapplied stack migrations are now
**0113 accounts, 0114 PR links, 0115 detection, 0116 full read, 0117
mutations, 0118 reviews, 0119 lifecycle**, with the schema
registry/tests updated in the originating layers. Stage 9 adds no
migration. Diagnostics 0117 is still in flight: renumber affected stack
migrations again if it lands first. Worker git-context fields use
additive number 227, preserving dev file API 222–226. Frozen update/v1
is unchanged.

One dialog host per run survives job-row refresh/reordering and retains
the selected job identity after acceptance. Mobile log actions wait for
the existing native overlay dismissal callback before opening that
shared confirmation. Explicit page refresh waits for an expired Summary,
including between reviewer diff writes and before receipt inspection.

Validation (draft):

- **All ten PRs have green CI, including final #534 head
`04c09aa4bf17307ce25b9377638a1c8ae13f9710`** (all four test shards,
static checks, web/binaries and aggregate gate). Every PR remains draft;
no review decision is recorded. Final-head CI passed without a retry.
- `bun install`, generated-code check, full typecheck (Svelte zero
errors/warnings), lint, formatting and web build passed. Dialog/refresh
changes: **28 fixture integration tests, 234 assertions, zero
failures**. Final empty-response/security/linked/pinned-mobile/account
integration: **35 tests, 300 assertions, zero failures**. Includes real
gRPC and client-bound receipts, not only HTTP mocks.
- Final fresh-process `check:tmp` on
**04c09aa4bf17307ce25b9377638a1c8ae13f9710** passed: **2,351 pass, 165
skip, 0 fail; 28,245 assertions across 437 files**, exit 0 in 1,340.14
seconds. No source changes occurred during this run; the temp-directory
check reported nothing left. No production GitHub feature API or live
provider tests were used.
- Mobile: Expo Doctor 20/20; changed GitHub files pass Expo ESLint and
full mobile typecheck. Production Hermes exports pass on iOS and
Android. EAS CLI **27.4.1**, production profile, unchanged fingerprints:
iOS `6ddec9ef559ee0095ac33e94ff9418a942053b17`, Android
`5f6eae3ab278f1cd543e9ed763f923a319b65ec9`. Full Expo lint has 40
pre-existing errors/5 warnings outside this change.
- Native device QA is blocked: device discovery on MacStudio twice
returned “Device list failed: Could not communicate with device support.
Try refreshing devices.” Local iOS/Android runtimes are unavailable.
Pinned transport coverage is distinct from native UI interaction.

Security and linked routing review:

| Mutation RPCs | Owner/binding/preflight | Linked capability and
destination |
| --- | --- | --- |
| BeginGitHubDeviceAuth, GetGitHubDeviceAuth, CancelGitHubDeviceAuth |
Owner/home/client-bound attempt, TTL, one durable poller |
`github_accounts_v1`, explicit home, direct only |
| UseGitHubPat, DisconnectGitHubAccount | Owned connector/account;
immediate revocation and cache invalidation | `github_accounts_v1`,
account home, credentials never forwarded |
| GetGitHubUpdateAccount, SetGitHubUpdateAccount | Owner preference and
owned selected account; both RPCs are linked-capable |
`github_accounts_v1`, explicit home, no relay |
| SetGitHubRepositoryAccount | Owner account/repo identity/install or
explicit PAT, expected mapping revision | `github_pr_v1`,
repository/account home |
| LinkThreadPullRequest, UnlinkThreadPullRequest | Owner thread/PR,
verified identity, revision/tombstone | `github_pr_v1`, thread home |
| PreparePullRequestContext, GetPullRequestCreateContext,
PreparePullRequestDraftContext | Owner thread/PR/account/current SHA/git
context; bounded untrusted attachment, no upstream write/model
publication | PR read or lifecycle capability as applicable, thread home
|
| PreparePullRequestMutation, GetPullRequestMutation | Owner PR/account
and authenticated browser/device/peer; fingerprint/TTL; receipt lookup
binds client | comments capability for shared receipt; CI prepare
additionally requires full write; qualified PR/account/confirmation IDs
route home |
| CreatePullRequestComment, ReplyPullRequestReviewThread,
UpdatePullRequestComment, DeletePullRequestComment,
SetPullRequestFileViewed | Shared
owner/account/access/mapping/head/state preflight; comment ownership,
PR-bound thread or file; delete confirmation | `github_pr_comments_v1`;
home only, no offline queue |
| AddPullRequestReviewComment, SubmitPullRequestReview,
DiscardPullRequestReview, SetPullRequestReviewThreadResolved | Shared
preflight plus complete pending-review digest, anchor/SHA and upstream
viewer permissions; discard confirmation | `github_pr_review_v1`; home
only, private review DTOs |
| CreatePullRequest | Owner thread, current git context and
repository/account; client receipt, confirmation, head/base; uncertain
reconciliation only reads | `github_pr_lifecycle_v1`; thread home |
| SetPullRequestDraft, MergePullRequest, SetPullRequestQueue,
SetPullRequestAutoMerge, UpdatePullRequestBranch, SetPullRequestOpen |
Shared preflight plus lifecycle rights, branch/head/base/method/rules
and confirmation | `github_pr_lifecycle_v1`; PR home |
| UpdatePullRequestDetails, RequestPullRequestReviewers,
SetPullRequestAssignees, SetPullRequestLabels | Shared preflight plus
current metadata revision; user/team/repo/label ownership; Issues write
where needed | `github_pr_metadata_v1`; PR home |
| RerunPullRequestChecks, CancelPullRequestCheckRun | Shared preflight
plus fresh run/job/repo/PR/SHA/attempt and Actions write/user push;
client-bound cancel confirmation | `github_pr_write_v1`; PR home;
numeric run/job IDs stay upstream IDs |

All mutation handlers deny worker/bot credentials. Writes never use
`authorized()` retry; a response loss or abandoned in-flight intent
becomes uncertain. Direct-link sender and receiver enforce negotiated
capabilities. Relays advertise read-only GitHub capability, so writes
fail closed; no offline mutation queue. Credentials and receipts remain
at the home. Qualified object IDs are translated at link boundaries;
numeric GitHub IDs stay upstream IDs. Reviewed UI handlers, client
binding/preflight, routed-home dispatcher, remote policy/IDs, receiver
and relay policy. Integration covers foreign owner/run/job/attempt/SHA,
stale account/mapping/head, confirmation, old/offline link capabilities,
fixed endpoint allowlist and secret-free structural audit. Actions write
and Checks read are separate.

Whole-stack action parity matrix:

**W/D** = web/shared desktop renderer implementation and browser
evidence in the named stage PR; no fresh packaged Electron run claimed.
**M** = mobile implementation plus pinned transport/security integration
where applicable. **B9** = fixture browser QA during this stage,
including after rebase. Prior-stage browser evidence is historical, not
a claim that every action was rerun post-rebase. Phone-width web is not
native mobile.

| Actions | Web / desktop renderer | Mobile implementation / transport |
Browser evidence |
| --- | --- | --- | --- |
| Connect, Copy code, Open GitHub, cancel device flow, reconnect | W/D
#487 | M, client binding | Historical #487 |
| Explicit PAT fallback, disconnect,
installation/repository/update-account selection | W/D #487 | M, owned
accounts/preferences | Historical #487 |
| Link URL, choose repository account, unlink, history/relink | W/D #501
| M, thread/owner/revision | Historical #501 |
| Branch/fork detection, refresh, dismiss/tombstone, old/linked worker |
W/D #508 | M, negotiation | Historical #508 |
| Summary, expand description/people/labels, copy checkout, open GitHub
| W/D #501/#518 | M, bounded read DTOs | B9 long title/branch/labels |
| Timeline pagination, review threads, refresh, Code unified/split,
file/hunk navigation | W/D #518 | M, pagination/security | Historical
#518 |
| Expand checks/jobs, View logs, log pagination/truncated/unavailable,
external provider | W/D #518 | M, bounded logs | B9 jobs/logs |
| Ask a question, Explain this PR, Fix findings; attach context and
explicitly send | W/D #518 | M, attachment/turn transport | Historical
#518 |
| Post general comment, reply, edit own comment, confirmed delete | W/D
#523 | M, receipts/security | Historical #523 |
| Mark/unmark Viewed | W/D #523 | M, file/SHA binding | Historical #523
|
| Inline LEFT/RIGHT/multiline; add pending comment | W/D #525 | M,
blob/anchor/digest | Historical #525 |
| Submit Comment/Approve/Request changes, discard pending review | W/D
#525 | M, each verdict/confirmation | Historical #525 |
| Resolve/unresolve; edit/delete own review comment | W/D #525 | M,
viewer/ownership | Historical #525 |
| Create, Draft with agent, review draft, explicit publish, existing PR
suggestion | W/D #528 | M, git/context/receipt | Historical #528 |
| Ready for review / Convert to draft | W/D #528 | M, lifecycle
preflight | Historical #528 |
| Merge/Squash/Rebase; join/leave queue; enable/disable auto-merge | W/D
#528 | M, rules/head/method | Historical #528 |
| Update branch; confirmed close / explicit reopen | W/D #528 | M,
lifecycle confirmation | Historical #528 |
| Edit title / description | W/D #532 | M, revision/receipt | Historical
#532 |
| Request/remove user/team with one checked diff; Summary/picker
re-request | W/D | M, diff/uncertain integration | B9 desktop
light/phone dark, prechecks, user→team diff, Summary re-request |
| Set/remove assignees and existing labels; per-picker search | W/D #532
| M, Issues/owned choices | Historical #532; B9 copy/layout |
| Re-run failed/all/single job and dependents | W/D | M, shared
controller + pinned iOS/Android RPC | B9 confirmation, single write,
accepted, queued/running |
| Cancel, Keep run, confirmed cancellation; inspect accepted/uncertain
without replay | W/D | M, client confirmation/restart | B9 Keep run
sends nothing; confirm produces accepted receipt |
| External-CI/missing-permission disabled reasons; stale/offline
controls | W/D | M, accessible hints/security | B9 external
tooltip/permissions; transport failures covered |

**Native gap applies to every row:** unavailable runtimes prevent native
interaction/visual/p95 verification. Hermes export, RPC integration and
phone-width screenshots do not close that gap. No claim of complete
native parity QA or merge readiness.

Performance vs dev `48cd5e9c`, Ryzen 5 5600X (6 cores/12 threads), Bun
1.4.4. Final-head serial real UI gRPC fixture measurements: **two runs ×
250 samples per side**, 5 warmups each, 20 seeded turns; order dev/head
then head/dev, with local browser/servers/exports/tests stopped. The
table pools 500 observations per side; dispatch ends when both the send
RPC and worker startTurn delivery complete, ACK waits for durable
EventAck. No providers/production GitHub. Earlier degraded runs
pair/close a peer and await one failed GitHub watch attempt before
timing; not a sustained active-watch benchmark.

| Existing operation, p95 ms | dev | candidate |
| --- | ---: | ---: |
| Overview RPC | 2.188 | 2.186 |
| Thread RPC | 1.018 | 1.020 |
| Send RPC + worker startTurn | 8.964 | 8.097 |
| Durable-event ACK | 4.265 | 4.410 |
| Browser long-thread delta (1,000 turns / 5,005 rows) | 2.3 | 1.9 |
| Decode + reducer / 200 deltas, Bun proxy | 14.742 | 14.777 |
| Mobile visible slice, Bun proxy | 1.323 | 1.353 |
| Markdown, Bun proxy | 4.811 | 6.129 |

Browser: 297 DOM nodes both sides, zero gaps/long frames, scroll average
16.67 ms/max 16.8 ms. Preserving #522 corrected the pre-rebase renderer
p95/gap regression. Client-JS dataset: 1,000 turns, 7,099 items,
14,085,915 serialized bytes; 999/1,000 unchanged groups retained on both
sides.

**No-regression gate is not proven.** Final RPC p95 run ranges
dev/candidate: dispatch 8.125–9.319 / 7.395–8.419 ms; ACK 4.237–4.299 /
4.165–4.925 ms. Pooled ACK increased 0.145 ms (median 3.384/3.404 ms);
Thread increased 0.003 ms. These are descriptive results, not confidence
intervals. Final client-JS repeat improved grouping (1.961/1.277 ms),
typical turn (0.0369/0.0280 ms) and 5,000 siblings (3.308/3.299 ms), but
unchanged-feed p95 (0.893/1.263 ms), markdown (table), new-array cache
(30.008/32.702 ms) and cold cache (22.711/24.844 ms) were higher.
Cache/sibling metrics have only ten samples (p95 is their maximum);
other JS metrics use thirty. Feed/cache source is identical to dev, but
that does not establish measured parity. Earlier pairs varied
substantially, including markdown 7.128/7.057 ms. No native Hermes
timing, cold native TTI or 30-minute soak. These remain explicit wrap-up
limitations.

Screenshots are local/uncommitted under `/var/tmp/canopy-github-9/`:
desktop light checks/re-run-failed/accepted/queued/cancel, desktop dark
running jobs/job confirmation, narrow dark checks, phone light
logs/re-run-failed/cancel, phone dark job confirmation/accepted/queued,
reviewer picker/diff. Final examples:
`phone-dark-job-accepted-empty-response-final.png`,
`phone-dark-queued-final.png`,
`narrow-dark-rerun-all-confirm-final.png`,
`desktop-light-cancel-accepted-final.png`,
`phone-light-permissions-tooltip-final.png`,
`desktop-light-external-tooltip-final.png`,
`desktop-light-reviewers-final.png`,
`phone-dark-reviewers-after-diff-final.png`,
`phone-dark-reviewer-picker-final.png`. Light/dark,
desktop/narrow/phone, long repository/branch/reviewer/label text
checked. Native gap remains. Browser QA exercised all four CI endpoints;
Keep run sent no write. After the HTTP contract fix, single-job
acceptance was retested with an empty 201 body. Owned servers and
browser tabs were closed after QA.

Copy audit (§8): Request/Re-request/Remove modes → one checked selection
plus explicit Re-request review; makes current requests visible. Search
people, teams or labels → per-picker Search people or teams / Search
labels / Search people. Team badge → accessible team icon. Re-run/cancel
copy names dependent-job/deployment/whole-run effects; acceptance says
waiting for GitHub. English sentence case, direct verbs and existing
glossary; no repeated warnings or personality metaphors.
Error/stale/offline/empty/uncertain states give a next action without
promising retry/success. Text/icons supplement color. One tooltip host;
compact overlays and long names remain readable at checked
widths/themes.

Related: #485, #532

Draft stage 9 of 9. Keep all layers draft. The maintainer merges the
complete stack together; native QA and p95 uncertainty above remain
open.
nixuuu added a commit that referenced this pull request Nov 13, 2026
Overview thread updates cleared every cached PR snapshot with
`forget()`. A panel that had already loaded consequently unmounted its
header and sections, showed first-load skeletons, and lost scroll and
expansion state. Reconnection after an overview gap did the same.

Use stale-while-revalidate invalidation for these two refresh paths in
the shared web/mobile cache event mapper. The existing panel, standalone
PR page, checks, timeline/reviews, files, commits and pending review
reads keep their mounted content. Account/access-revision boundaries,
authoritative home snapshots, computer removal, pairing changes and
denied-read handling retain their existing private-data protections.

Fixes: #501

Validation:
- Reproduced in Chromium on the review machine with a disposable
gateway/BFF reading the real `itsoltech/canopy` PR #592. Delayed the
summary response by 300 ms and sampled animation frames after loaded
Timeline content. Before: 21/119 frames showed skeletons, the original
row detached, scroll 132 → 0. After: 0/121 skeleton frames, original
timeline/row retained, scroll stayed at 132.
- Added cache-layer coverage for delayed revalidation with concurrent
consumers, overview gaps, refresh failure, unchanged thread revisions
and a separate uncached PR. Existing revocation/late-response coverage
passes. No UI tests added.
- Final browser matrix: 760 animation-frame samples across Summary with
all 11 checks visible, expanded Code/diff, standalone PR page, desktop
thread panel and 390 px sheet, light/dark. Triggered thread revision
updates, overview gaps, a watch-style snapshot/page invalidation, and
manual refresh. Zero skeleton frames or section detachments; scroll and
the expanded file/check-list state remained unchanged. Review browser,
processes, containers and checkout were cleaned up.
- Audited web/mobile section cache keys, pagination invalidations and
retained visited tabs. Native mobile uses the same changed
`OverviewInvalidation`; mobile typecheck passes, but no native UI/device
run was performed. Live job-detail reads and avatar requests returned
existing errors in the disposable setup; successful job/log refresh is
not claimed by the browser evidence.
- All requested handover checks passed with `nice -n 10`: dependency
installation, `gen:check`, full typecheck (including mobile), lint,
formatting, format check, full `check:tmp` and web build. Full tests:
**2678 passed, 166 opt-in/skipped, zero failed**, 34,947 assertions
across 501 files; nothing left in the tests' private temp directory.
Final-head CI static checks, all four test shards, web/Linux builds and
commitlint are green.

Copy audit (§8): no user-facing text changes. The existing loading,
error and Retry wording remains in use.
nixuuu added a commit that referenced this pull request Nov 14, 2026
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 added a commit that referenced this pull request Nov 14, 2026
## 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
nixuuu added a commit that referenced this pull request Nov 19, 2026
## Change

A cached pull request read could publish thread and overview updates for
every linked thread in its repository. Selecting another active thread
could also restart the shared overview twice and fetch two full
snapshots. A slow overview subscriber could then reach its 256-frame
limit while little data was queued.

- Scope PR updates to active links for that owner and PR. Repair stale
projections on cache hits. Re-read under the thread row lock so a
concurrent unlink cannot restore a removed link in the sidebar. Refresh
open lists when an older PR changes.
- Send changed bot summaries and preserve pending approvals and
execution state across partial bot replies. Limit the project updates
generated by worker status reports while keeping workspace origin and
scratch placement discovery.
- Keep the upstream overview open for a 500 ms renderer handover and
replay authorized head cursors to the new subscriber.
- Compact a slow overview queue only at its existing item or byte limit.
Keep ordering around state transitions and controls. An irreducible
queue still reports DataLoss and can recover from a new snapshot.

Migration 0177 initializes a per-link summary fingerprint for current
active links. It keeps concurrent readers of the same PR from increasing
a thread’s list revision repeatedly.

## Verification

An isolated repository with 439 linked threads, including five linked to
the measured PR, reproduced the fan-out. One warm GetPullRequest made
439 projection calls, read 439 thread rows and produced 878 hub
publications before the change. Each count fell to zero, with the same
PR returned and no GitHub HTTP request in either run. One local RPC took
247.7 ms before and 6.7 ms after.

On the original gateway a two-thread burst of 300 worker events
terminated the stalled overview with DataLoss. The fixed gateway
delivered both final states, persisted all 300 events in order and
replayed both completed responses from pre-burst checkpoints. Separate
cases exercise item and byte overflow with nonreplaceable frames, and
delivery to a healthy observer.

Five renderer handovers with the same subscriptions produced ten
additional snapshots before and zero after. Real PostgreSQL and gRPC
integration coverage exercises independent PRs in the same repository,
shared links, concurrent unlink, older PRs, cache repair, account
changes, bot feeds, disconnection, worker replay and lost
acknowledgements.

With five projects and 16 status reports, the original gateway published
80 project frames. The fixed gateway published zero, issued zero project
list queries and delivered all 16 worker updates. The same suite
verifies changed Git origins, retry after a failed read and a new
worker’s scratch placement.

Production renderer in Chromium, isolated gateway, BFF and PostgreSQL.
Seven bot conversation switches opened no additional overview SSE. A
pending approval survived navigation and reload and sent exactly one
worker response. Checked light and dark at desktop and phone widths.

Fixes: #501
Fixes: #847
Fixes: #458
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