Skip to content

perf(app): install @tanstack/react-query and add QueryClientProvider (closes #345 phase A) - #455

Merged
Xhristin3 merged 2 commits into
XStreamRollz:mainfrom
shadrackmanfred:perf/app/react-query-provider-345-a
Jul 25, 2026
Merged

perf(app): install @tanstack/react-query and add QueryClientProvider (closes #345 phase A)#455
Xhristin3 merged 2 commits into
XStreamRollz:mainfrom
shadrackmanfred:perf/app/react-query-provider-345-a

Conversation

@shadrackmanfred

@shadrackmanfred shadrackmanfred commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Installs @tanstack/react-query and wires QueryClientProvider into the app layout. This is Phase A of the react-query migration for the dashboard (closes #345 phase A). Phase B (PR #456) adds the consumer hooks and optimistic mutations.

Changes

  • app/package.json — added @tanstack/react-query (^5.62.0) dependency.
  • app/src/app/providers.tsx (NEW) — lazy QueryClient initializer in a "use client" component:
    • 30s staleTime matching lib/cache/cache-config.ts#streamList.
    • 5-minute gcTime for background cache retention.
    • refetchOnWindowFocus: true so the dashboard refreshes when the user returns to the tab.
    • retry: 1 for queries (transient blips), retry: 0 for mutations.
    • SSR-safe: per-request client on the server, singleton on the browser.
  • app/layout.tsx — wraps {children} in <AppProviders> inside <AuthProvider>.
  • app/src/app/providers.test.tsx (NEW) — verifies the client is shared across consumers and that useQuery resolves through the provider.

CI fix

  • Fixed the lets useQuery return data after a successful fetch test by replacing act + Promise.resolve() with waitFor — React Query requires multiple async ticks to resolve, and waitFor properly retries until the assertion passes.

Behaviour

Quality bar

  • TypeScript clean (tsc --noEmit).
  • All 204 tests pass across 17 suites.
  • Lint clean (13 warnings — all pre-existing, none in the new/changed files).

…loses XStreamRollz#345 phase A)

Foundation for the new client-side cache layer. Phase A only wires the
provider; consumers come in phase B.

- app/package.json: add @tanstack/react-query ^5.62.0.
- app/src/app/providers.tsx (NEW): AppProviders wraps children in a
  QueryClientProvider. Browser singleton vs per-request SSR client
  (no leak across users). Defaults: staleTime 30s (matches
  lib/cache/cache-config.ts), refetchOnWindowFocus true, retry 1,
  mutations retry 0.
- app/src/app/providers.test.tsx (NEW): verifies client is exposed,
  shared across nested consumers, and useQuery resolves end-to-end.
- app/layout.tsx: wrap children with AppProviders inside AuthProvider.
shadrackmanfred added a commit to shadrackmanfred/XStreamRoll that referenced this pull request Jul 24, 2026
…lz#345 phase B)

Three issues were causing the quality CI check to fail:

1. Added @tanstack/react-query to app/package.json (dependency was only in PR XStreamRollz#455)

2. Added Tag type and tags field on Stream in @xstreamroll/types (was only in PR XStreamRollz#454)

3. Updated lockfiles for npm ci reproducibility
…llz#455 CI fix)

The test for useQuery resolution used act + Promise.resolve() which
only flushes a single microtask. React Query requires multiple async
ticks to resolve. Using waitFor retries until the assertion passes.
@Xhristin3
Xhristin3 merged commit 73b8c22 into XStreamRollz:main Jul 25, 2026
2 checks passed

Copy link
Copy Markdown
Contributor

Thanks @shadrackmanfred for laying the foundation. Merged.

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.

perf: React frontend has no data-fetching cache — every navigation refetches all streams

2 participants