Skip to content

feat(github): cache and polish pull request loading - #555

Merged
nixuuu merged 1 commit into
devfrom
feat/pr-panel-loading
Nov 12, 2026
Merged

nixuuu merged 1 commit into
devfrom
feat/pr-panel-loading

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Opening or refreshing a pull request could replace content with loaders, lose the current reading state, and repeatedly fetch unchanged resources. Bot actors also lost their identity/avatar, while every check showed three permanent icon actions.

Reuse the existing owner/account/access-scoped durable GitHub cache, real REST ETags and SQL single-flight leases. Serve expired pages while revalidating, keep client pages and presentation state across panel reopen, preserve keyed rows and expanded replies, and show skeletons only before the first result. Visible completed/open PRs share one conditional REST request slot every 60 seconds across metadata, check-runs and legacy commit statuses. With one page per resource each endpoint is revisited about every three minutes; this deliberately meets the aggregate five-request budget rather than polling all three every minute. Only resources with running checks get the faster 15-second schedule. Respect upstream x-poll-interval. Merged/closed PRs and hidden panels/windows do not poll. Stream renewals and the maintenance sweep share deadlines and single-flight; hiding the last observer aborts its in-flight probe. Timeline/reviews refresh on metadata changes, files/commits on SHA changes, or through explicit refresh/mutations. Unchanged signals never trigger periodic GraphQL reads. Check changes update the check summary without fetching PR metadata.

Preserve payload avatar URLs and bot logins including [bot]. Fetch raster avatars through an authorized gateway RPC and the durable cache, with a fixed CDN allowlist, no credentials or cookies, no redirects, bounded size and timeout. Initials are an opaque fallback. Read-only markdown task boxes keep normal contrast. Replace check icons with a compact labeled action menu, reserved row space, and applicable actions. Apply equivalent loading, avatar and action changes on mobile using TypeScript only; native configuration and dependencies are unchanged.

Based directly on dev after #551 was squash-merged and #559 added the remote thread panel. This PR contains only the loading/cache/avatar/check-action changes; the merged resize, diff/commit-picker and timeline layout fixes remain in dev. Rebase resolution preserves the repository account-access controls, Link pull request picker route and all remote connector/schedule RPCs from #559.

Validation:

  • Static implementation and copy review completed; additive protobuf contracts regenerated.
  • Mobile screen lint correction: extracted the summary/error/retry/account-access notices into PullRequestNotices, preserving sibling layout and copy. The complete repository bun run lint passes with the 120-line function limit enabled. Local nightly fingerprints before/after the extraction are identical on both iOS (6ddec9ef559ee0095ac33e94ff9418a942053b17) and Android (5f6eae3ab278f1cd543e9ed763f923a319b65ec9). No native configuration or dependencies changed.
  • CI Static checks log identified two TS2769 errors at the fixture Request constructors. Explicitly branch between Request and string inputs before calling the overloaded constructor; forward the normalized URL with the original request options to the loopback fixture transport. Regenerated protobuf outputs after resolving the rebase against the merged picker and remote-panel contracts. Extracted the mobile change statistics/checkout row to keep the combined header under the 120-line function limit; rendering and copy remain unchanged.
  • Added fixture integration coverage for conditional 304 reuse, durable cache after gateway service restart, concurrent single-flight, owner boundaries, bot identity, avatar transport restrictions and no hidden polling.
  • Added an accelerated-clock fixture measurement for first open, reopen and five visible idle minutes.
  • bun install and gen:check passed during stack verification. Freshness correction adds fixture coverage for request budgets across 90-second lease renewals plus the maintenance sweep, legacy pending statuses, server poll intervals, completed/terminal transitions, changes-only page invalidation and abort-on-hide. After rebasing directly onto dev: focused gateway/cache/mobile-transport/timeline checks 19 passed, zero failed, 117 assertions. Changed-file lint and formatting pass. Full tests/typecheck/builds run remotely in CI; no local check:tmp, per maintainer instruction.
  • Real-browser review used the actual fixture-backed gateway/BFF/web, with one gateway, one web server and one browser. Verified Summary/header including Merge at 320/1200 px, long commits, 2001-row diff, horizontal scroll/wrap, keyboard/reset/persistence, narrow 0/60, mixed timeline with noise removed and claude[bot] using gateway-fetched payload avatars, opaque read-only task boxes, check menus with Re-run / Re-run failed jobs / Cancel according to state, and light/dark desktop plus 390 px phone sheets. No browser requests went directly to GitHub or its avatar CDN. Avatars used opaque red fixture images, not real account images.
  • Delayed background refresh (1.5 seconds upstream latency) retained 2001 diff rows, expanded state and scrollTop=900 throughout 132 samples: zero diff subtree mutations, no Loading text, no detected layout shifts. Close/reopen retained Code, rows and scrollTop=2300. A new commit resource showed one first-load skeleton region and no visible Loading text. A mocked 503 retained Summary and checks with a compact stale-data message. Added Retry beside stale-data errors in web/mobile; cache expiry alone no longer inserts an offline warning or Retry during background revalidation.
  • EAS fingerprint engine (@expo/fingerprint, nightly, same project path): iOS 6ddec9ef559ee0095ac33e94ff9418a942053b17, Android 5f6eae3ab278f1cd543e9ed763f923a319b65ec9, both identical to the feat(github): resize the pull request panel #551 baseline. Mobile changes are JS/TS only; no native configuration or dependencies changed. Native app UI was not exercised; phone coverage above is the web sheet.

Request measurements (mock transport, five simulated minutes, fixed +5% jitter):

The previously reported 27 → 27 was an open PR with running checks, not completed/idle CI. Replaying that exact continuous-stream harness against the previous #555 head (5683f91) produces 19 CanopyChecks + 4 CanopyPullRequest + 4 CanopyTimeline = 27 POST /graphql requests; 27 HTTP 200, zero conditional requests, zero 304. The old cache avoided reopen work but did not reduce this periodic GraphQL traffic. That was insufficient for the intended freshness policy.

The following apples-to-apples comparison includes 90-second stream renewals and a maintenance sweep on every simulated wait, for both versions. Before = previous #555 head, after = this correction. Metadata was already verified during PR linking. Counts cover the visible PR watch, excluding authentication/discovery, avatars and user-triggered tab/file/page loads. Cold validator setup is deliberately counted on first open; unchanged idle traffic after the fix is entirely conditional (If-None-Match).

PR state First open before → after Second open before → after Five minutes idle before → after Idle before: 200 / 304 Idle after: 200 / 304
Open, running checks 2 → 3 0 → 0 23 → 23 23 / 0 0 / 23
Open, completed checks 2 → 3 0 → 0 12 → 4 12 / 0 0 / 4
Merged 2 → 0 0 → 0 1 → 0 1 / 0 0 / 0
Closed 2 → 0 0 → 0 1 → 0 1 / 0 0 / 0
Hidden panel/window, any state — — 0 → 0 0 / 0 0 / 0

Endpoint breakdown for that comparison:

State Before: POST /graphql operations (all 200) After: conditional REST GETs (all 304)
Running CanopyChecks ×16, CanopyPullRequest ×4, CanopyTimeline ×3 /repos/itsoltech/canopy/commits//check-runs ×19; /repos/itsoltech/canopy/pulls/42 ×2; /repos/itsoltech/canopy/commits//status ×2
Completed CanopyChecks ×6, CanopyPullRequest ×3, CanopyTimeline ×3 /repos/itsoltech/canopy/pulls/42 ×2; /repos/itsoltech/canopy/commits//check-runs ×1; /repos/itsoltech/canopy/commits//status ×1
Merged / closed CanopyPullRequest ×1 each None
Hidden None None

REST check/status pages use per_page=100&page=1 in this fixture. First-open requests before were one GraphQL Checks and one Timeline; after they are three REST 200s priming metadata/check-runs/status validators (none for terminal PRs). The new watch does not eagerly load Timeline or Checks pages. The renewal-aware baseline differs from the original continuous-stream 27 because the old scheduler/cache deadlines reset on reconnect; both ledgers are reported separately rather than conflated. Targets are met: completed 4 ≤ 5, merged/closed 0, hidden 0; fast running polling is restricted to check resources. Tests also exercise legacy pending statuses, the upstream minimum interval, concurrent sweeps, metadata/check invalidation and last-observer cancellation. No real GitHub product API was contacted.

Copy audit (§8):

  • Repeated “Loading…” messages → first-load skeletons and one reserved header refresh control, so background updates keep content readable.
  • Three icon-only check controls → “Check actions” menu with “Re-run”, “Re-run failed jobs” and “Cancel”; actions are named and only applicable choices appear.
  • Ambiguous fallback identity → payload login such as “claude[bot]”; initials remain a visual fallback.
  • Read failures keep prior content and provide Retry. New wording uses sentence case, short active sentences and existing terminology; no new glossary terms, humour or destructive operations.
  • Short, typical and long labels reviewed statically and visually at desktop, narrow and phone widths, light and dark. Retry reuses the existing action label. No new glossary terms, humour or destructive confirmations.

@nixuuu
nixuuu force-pushed the feat/pr-panel-resize branch from 4c2915b to e016583 Compare November 12, 2026 08:28
@nixuuu
nixuuu force-pushed the feat/pr-panel-loading branch 3 times, most recently from 1151642 to c171012 Compare November 12, 2026 09:10
@nixuuu
nixuuu force-pushed the feat/pr-panel-resize branch from e016583 to c52008e Compare November 12, 2026 09:10
@nixuuu
nixuuu force-pushed the feat/pr-panel-loading branch from c171012 to 409c725 Compare November 12, 2026 09:31
@nixuuu
nixuuu force-pushed the feat/pr-panel-resize branch from c52008e to f778e39 Compare November 12, 2026 10:30
@nixuuu
nixuuu force-pushed the feat/pr-panel-loading branch from 409c725 to ac895a1 Compare November 12, 2026 10:30
@nixuuu
nixuuu force-pushed the feat/pr-panel-resize branch from f778e39 to a7d8db2 Compare November 12, 2026 11:16
@nixuuu
nixuuu force-pushed the feat/pr-panel-loading branch 2 times, most recently from ff463e2 to da3a9a1 Compare November 12, 2026 12:21
@nixuuu
nixuuu force-pushed the feat/pr-panel-resize branch from a7d8db2 to 7f6102d Compare November 12, 2026 12:21
@nixuuu
nixuuu force-pushed the feat/pr-panel-loading branch from da3a9a1 to b30acb1 Compare November 12, 2026 12:30
@nixuuu
nixuuu force-pushed the feat/pr-panel-resize branch from 7f6102d to 8c55259 Compare November 12, 2026 12:30
@nixuuu
nixuuu force-pushed the feat/pr-panel-loading branch 2 times, most recently from 59b7fcf to 5683f91 Compare November 12, 2026 12:37
@nixuuu
nixuuu marked this pull request as ready for review November 12, 2026 12:39
@nixuuu
nixuuu force-pushed the feat/pr-panel-loading branch from 5683f91 to f6e9408 Compare November 12, 2026 12:56
nixuuu added a commit that referenced this pull request Nov 12, 2026
The PR panel was fixed at one width, diff rows included blank bands, and
long commit subjects could stretch the picker over the thread. Reuse the
sidebar's accessible ResizeHandle on the panel's left edge, with
device-local persistence, a 320–1200 px preferred range, a 576 px reset,
and a 384 px minimum thread column. During a drag, requestAnimationFrame
updates a CSS variable; state and storage change on release.

Keep diff whitespace on code cells so rows remain compact and files
scroll horizontally when wrapping is off. Bound the commit menu,
preserve the viewed numbers at narrow widths, show event descriptions,
and omit missing relative times. Preserve PR numbers and long Summary
content at narrow widths.

Hide MentionedEvent, SubscribedEvent and UnsubscribedEvent regardless of
whether they contain actor/time fields. Share this filter between
gateway projection and web/mobile activity so previously cached entries
are hidden too. Unsupported union members with no date/content remain
hidden. Actor and time come from the payload's actor/author and
createdAt fields. Add fixtures for type-only and metadata-bearing noise,
plus a gateway integration scenario that preserves pagination past a
noise-only page and verifies payload identity/time and an undated
comment.

Stack: layer 1, targets dev. Layer 2 is #555, based on this branch, and
adds payload avatars, loading/cache polish, check action menus and
mobile parity. Both layers are submitted together for the maintainer to
merge after CI passes.

Validation:
- Rebased both layers onto dev with gh stack and pushed. bun install and
gen:check pass. Focused gateway cache/polling/timeline integration
tests: 8 pass, 0 fail, 38 assertions. The timeline case verifies noise
filtering, pagination past a noise-only page, payload actor/time and an
undated comment. Changed-file lint and formatting pass. Full suite,
typecheck and builds run in CI; no local check:tmp, per maintainer
instruction.
- Reviewed the actual gateway/BFF/web in one real browser using mocked
GitHub transports: 320–1200 px drag, 576 px double-click reset,
arrow/Shift-arrow resizing, persistence on reopen, separator ARIA
values, 2001-row diff with 20 px rows, horizontal scrolling and
wrapping, bounded 448 px commit menu with 902-character subjects, SHA,
ellipsis, full-text tooltip and keyboard navigation, and visible 0/60 at
320 px.
- Reviewed Summary/header, mixed Timeline, desktop and 390 px phone
sheet in light/dark. Mention/subscription noise is absent; payload
actor/time remain, with no empty GitHub/ago rows. No browser requests to
GitHub or its avatar CDN.
- During an automated long-diff drag, the diff subtree had zero DOM
mutations. Shared-host frame samples included 83–100 ms stalls on large
width jumps; this is functional browser verification, not a dedicated
smoothness benchmark.

Copy audit (§8): new “Resize pull request panel” names the control and
keeps keyboard/ARIA values; narrow “X/N viewed” → “X/N” preserves the
numbers and an accessible label; empty “GitHub / ago” → omit
mention/subscription noise, unsupported blank entries and missing times,
including cached data; event type names → sentence-case actions
(“Requested a review”, “Changed the title”, “Added a label”,
branch/assignee equivalents). Existing Glossary terms retained; no new
errors, destructive confirmations or humour. The explicit noise filter
adds no UI labels. Short, typical and long text reviewed statically and
visually at desktop, narrow and phone widths, light and dark.
@nixuuu
nixuuu deleted the branch feat/pr-panel-resize November 12, 2026 12:59
@nixuuu nixuuu closed this Nov 12, 2026
@nixuuu nixuuu reopened this Nov 12, 2026
@nixuuu
nixuuu changed the base branch from feat/pr-panel-resize to dev November 12, 2026 12:59
@nixuuu
nixuuu force-pushed the feat/pr-panel-loading branch 2 times, most recently from f921377 to 79af354 Compare November 12, 2026 13:20
@nixuuu
nixuuu force-pushed the feat/pr-panel-loading branch from 79af354 to a0d9d0a Compare November 12, 2026 13:37
@nixuuu
nixuuu merged commit 579a81a into dev Nov 12, 2026
11 of 12 checks passed
@nixuuu
nixuuu deleted the feat/pr-panel-loading branch November 12, 2026 13:50
nixuuu added a commit that referenced this pull request Nov 12, 2026
nixuuu added a commit that referenced this pull request Nov 12, 2026
Concurrent avatar reads could fetch the same image twice. The shared
cache client checked its in-flight map after asynchronous cache I/O, and
a second service could reacquire a released SQL lease without reusing a
fresh result if the first fill completed before its generation sample.

Register the shared promise before cache I/O and recheck freshness after
acquiring the SQL lease. Keep forced refreshes separate from ordinary
cache reads, and remove promises and controllers on either success or
failure. This common client also handles cached PR resources;
owner/account/access-revision boundaries and credential-free image
requests remain intact.

The avatar integration fixture now gates upstream responses. A
regression holds an independent service's cache miss until the first
service has completed its fill, then verifies that both responses share
one upstream image fetch. It matches the canonical avatar URL, including
the proxy's `s=64` parameter. The initial regression test used the raw
URL's hash, so its gate never matched and it deadlocked; the production
fill was waiting for the test to release upstream.

Each shared fill has a 55-second deadline. Timeout aborts it, clears its
flight entry, and releases the fenced SQL cache lease even if an
upstream transport ignores cancellation. A waiter can attempt one
replacement fill; another timeout surfaces an error. Gated integration
cases cover a successful replacement, a stalled replacement, and
subsequent cache recovery. Existing coverage checks concurrent callers,
persisted reuse, bot identity, owner scoping, absent credentials and
retry after image rejection.

Validation: the specifically authorized `nice -n 19 bun test
tests/integration/github-panel-cache.test.ts` passes all 9 tests.
Changed files pass spacing autofix, oxlint, oxfmt and `git diff
--check`. No full local test suite, typecheck, builds or install ran
while the host performance measurement is active. CI verification is
pending, including a full workflow rerun after the first clean run on
the final head.

Copy audit: new timeout error, `Loading GitHub data timed out. Try
again.` It states the outcome and the next action in two short
sentences, uses sentence case and plain words, and does not depend on
names, icons or color. No controls or layout changed.

Fixes: #555
nixuuu added a commit that referenced this pull request Nov 12, 2026
## Change

The pull request panel now scrolls its header, tabs and content
together. After the full header scrolls away, a compact sticky bar
retains the PR state, repository and number, truncated title with
tooltip, check status, primary lifecycle action, menu and close button.
The tabs, Timeline filter and Code controls stack below it with opaque
backgrounds.

The full header keeps its flow height, so switching to the compact bar
changes neither the content offset nor scroll position.
IntersectionObserver supplies a 16 px hysteresis band; ResizeObserver
updates dimensions on resize. The transition uses existing motion tokens
and becomes instant with reduced motion. Each tab retains its own
session scroll position. The compact primary action shares the original
lifecycle controller and confirmation dialog. Long action labels
truncate within the compact button without covering the menu.

This applies to web/desktop and the phone-width web sheet. Native mobile
has a separate virtualized-list layout whose headers already scroll with
their lists; its code is unchanged. Rebased onto dev after #589.

Related: #551, #555

## Verification

- Dependency installation, `bun run gen:check`, full typecheck, lint,
format check and web build passed on the review machine. The final build
used `nice -n 10`. Final-head CI static checks and web/Linux builds
passed; the full test suite with temp-directory checks is running in
GitHub CI at the maintainer's request. No web UI tests added.
- Fixture-only Chromium review covered a 200-comment timeline, 90-file
Code tab with a 1,500-line expanded diff, short PR, long
names/title/branches, 320/576/1056 px panel widths, 390 px phone width,
light/dark, reduced motion, menu, title tooltip, close and
primary-action confirmation. No application errors. No live GitHub calls
from the fixture app. Review processes, containers and scratch checkout
were cleaned up.
- Slow threshold crossings retained the compact state across the 16 px
deadband. Content flow position stayed at 300 px through compaction;
requested scroll positions did not change. Timeline 1600 px and Code 900
px positions restored on tab switches. Diff scrolling remained
horizontal per file; no nested vertical viewport. Reduced-motion
transition duration was 0s. Sticky surfaces had no visible gaps or
see-through seams.
- Chromium 155 Performance traces on the final source: 180
animation-frame samples each. Timeline: 3 layout events totaling 1.038
ms; expanded diff: 0 layout events. Both: 0 long tasks, maximum frame
interval 16.8 ms, 0 intervals above 25 ms. Evidence remains outside the
repository.
- EAS fingerprints before/after, generated locally with `nice -n 19`,
are unchanged: iOS `74705db3a68907bc28379bb9b1080a227bc0755b`; Android
`7d38be8f5c9bf842d62060c75820a206f99c87e3`.

Copy audit (§8): compact controls reuse existing state, check and
lifecycle labels. Refresh remains available in the compact menu
(`Refresh pull request`, reused wording). Icons retain accessible
labels. Truncation retains the full title in a verified tooltip, the PR
number stays visible, and primary actions retain their full accessible
labels and tooltips. Short and long text was checked at narrow, wide and
phone widths. No new errors, empty states, glossary terms or humorous
copy.
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