Skip to content

Add page-level progress indicator#281

Open
jennings wants to merge 6 commits into
mainfrom
jennings/nxwpoorotnon
Open

Add page-level progress indicator#281
jennings wants to merge 6 commits into
mainfrom
jennings/nxwpoorotnon

Conversation

@jennings

Copy link
Copy Markdown
Owner

I've noticed when loading previous versions, the page has to fetch from GitHub but there's no progress indicator.

I didn't see a good place in the UI for this, so I added a subtle progress indicator along the top of the page.

Then it felt weird that only one UI element had this progress indicator, so I made it more-or-less universal.

jennings added 6 commits June 25, 2026 09:45
…/file/diff queries

Add 8 queryOptions factories to queries.ts for the immutable (SHA-keyed)
GitHub data that currently lives in github.tsx as imperative PersistentCache
lookups:

- commitFiles
- singleCommit
- rawGitCommit
- mergeCommitFiles
- rawCompareDiff
- prFilesForRange
- commitsForHeadSha
- fileContent

Each factory checks PersistentCache (IndexedDB) first, falls back to Octokit,
persists the result, and sets staleTime: Infinity + gcTime: 5m. No callers
changed in this ticket.

Resolves #276
…chQuery

Replace the bodies of the 8 immutable (SHA-keyed) fetch methods in github.tsx
with single-line queryClient.fetchQuery() calls using the factories added in
#276. Delete the immutablePending Map — React Query dedupes concurrent
identical keys natively.

Callers are unchanged. What changes underneath:
- First access in a session: queryFn runs (IDB check → fetch → persist).
- Subsequent same-key access: served from RQ in-memory cache.
- Concurrent same-key calls: deduplicated by React Query.
- All 8 queries now appear in useIsFetching() counts.

Resolves #277
…hing

Add GlobalProgress — a null-rendering component that watches React Query for
queries that are fetching with no data yet (initial loads, not refetches) and
drives the nanobar refcount in fetch-progress.ts.

Predicate: fetchStatus === "fetching" && data === undefined
- Excludes refresh-button invalidations (data already present)
- Excludes 30s check polling (cached data present)
- Excludes persisted-query rehydration (data hydrated before mount)
- Includes first load of a PR / new SHA / new commit range

Uses a single boolean slot (active/inactive) so the bar doesn't bounce as
individual queries complete. The existing 80ms SHOW_DELAY_MS in fetch-progress
swallows fast IDB-hit loads.

Mounted inside PersistQueryClientProvider in index.tsx so it has access to
the query client.

Resolves #278
…rogress

Unwrap the five trackFetch() calls in pr-review/index.tsx:
- setSelectedHeadSha
- setSelectedCommitSha
- setSelectedParentSha
- setCompareToSha
- setCompareToCommitSha

After #277 (IDB methods route through queryClient.fetchQuery) and #278
(GlobalProgress subscribes to useIsFetching), the nanobar is driven
automatically by React Query. These wrappers were redundant.

Also remove the trackFetch import from this file.

Resolves #279
Add a reviewThreads queryOptions factory to queries.ts and route
getReviewThreads through queryClient.fetchQuery.

Before: two independent GraphQL round-trips fired on every PR open
(once from PRReviewContent mount, once from loadPRData). No cache,
no dedup.

After: React Query deduplicates concurrent calls with the same key.
The first resolution fetches from GraphQL; within the 30s staleTime,
any subsequent call returns the cached result without a network hit.

The queryKey ["pull-request", owner, repo, number, "review-threads"]
falls under the existing invalidatePR prefix, so mutations (comment
creation, review submission, etc.) continue to invalidate it correctly.

Thread resolve/unresolve use optimistic local state updates (not
re-fetches), so the staleTime does not affect their correctness.

Resolves #97
@jennings jennings requested a review from glehmann June 25, 2026 21:55
@jennings

Copy link
Copy Markdown
Owner Author

@glehmann I can't decide whether I like this or not, could you give it a try and let me know if you hate it (which is fine) or have better ideas:

@glehmann

glehmann commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

I like it! It's a lot better than the spinner I added at the bottom of the page

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.

2 participants