Add page-level progress indicator#281
Open
jennings wants to merge 6 commits into
Open
Conversation
…/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
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: |
Collaborator
|
I like it! It's a lot better than the spinner I added at the bottom of the page |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.