Move the parsed-diff cache from PRReviewStore.loadedDiffs into React Query.
The problem today
useDiffLoader fetches raw diffs (via RQ), parses them, and writes the parsed form to store.loadedDiffs. Other code paths (keyboard nav, skip-block expansion) read store.getSnapshot().loadedDiffs[filename] synchronously inside effects to decide whether to re-fetch or reuse.
The change
- Introduce
useParsedDiff(filename, sha, prKey) — reads the existing immutable raw-diff query and returns the parsed form via select, or via a dedicated RQ key wrapping the parse step.
- Synchronous "do I already have this parsed?" checks switch to
queryClient.getQueryData(...).
- Delete
loadedDiffs, setLoadedDiff, setDiffLoading, loadingFiles, and the getFullDiffFromCache helper on the store.
useDiffLoader no longer writes to the store; it becomes a thin driver that ensures the RQ query is subscribed.
Files affected
src/browser/lib/queries.ts — add useParsedDiff.
src/browser/hooks/useDiffLoader.ts — rewrite to use RQ cache directly.
src/browser/contexts/pr-review/index.tsx — delete cache fields + methods.
src/browser/hooks/useSkipBlockExpansion.ts and useKeyboardNavigation.ts — retarget synchronous reads.
Tests
useParsedDiff: test with fixture raw diffs — success, error, SHA-change invalidation, cache-key stability.
useDiffLoader: existing fetch-trigger tests retargeted to RQ cache reads.
- Skip-block expansion + keyboard nav: cache reads work via
queryClient.getQueryData in a QueryClientProvider wrapper.
- End-to-end style: navigating between files re-uses parsed diffs from RQ cache; no re-parse observed.
Part of #351
Depends on #352.
Move the parsed-diff cache from
PRReviewStore.loadedDiffsinto React Query.The problem today
useDiffLoaderfetches raw diffs (via RQ), parses them, and writes the parsed form tostore.loadedDiffs. Other code paths (keyboard nav, skip-block expansion) readstore.getSnapshot().loadedDiffs[filename]synchronously inside effects to decide whether to re-fetch or reuse.The change
useParsedDiff(filename, sha, prKey)— reads the existing immutable raw-diff query and returns the parsed form viaselect, or via a dedicated RQ key wrapping the parse step.queryClient.getQueryData(...).loadedDiffs,setLoadedDiff,setDiffLoading,loadingFiles, and thegetFullDiffFromCachehelper on the store.useDiffLoaderno longer writes to the store; it becomes a thin driver that ensures the RQ query is subscribed.Files affected
src/browser/lib/queries.ts— adduseParsedDiff.src/browser/hooks/useDiffLoader.ts— rewrite to use RQ cache directly.src/browser/contexts/pr-review/index.tsx— delete cache fields + methods.src/browser/hooks/useSkipBlockExpansion.tsanduseKeyboardNavigation.ts— retarget synchronous reads.Tests
useParsedDiff: test with fixture raw diffs — success, error, SHA-change invalidation, cache-key stability.useDiffLoader: existing fetch-trigger tests retargeted to RQ cache reads.queryClient.getQueryDatain aQueryClientProviderwrapper.Part of #351
Depends on #352.