fix(frontend): seed limit-book prefetch as InfiniteData (#354) #851

Merged
PlasticDigits merged 1 commit from local1/354-impl-prefetch-infinite into main 2026-06-10 05:31:19 +00:00
PlasticDigits commented 2026-06-10 03:26:58 +00:00 (Migrated from gitlab.com)

Summary

Fixes #354 — click pair-switch on /trade crashed to ErrorBoundary because prefetchTradePairWorkspace seeded a flat limit-book page via prefetchQuery under the same key consumed by useLimitBookInfinite (useInfiniteQuery).

Changes

  • Switch limit-book prefetch to prefetchInfiniteQuery with matching initialPageParam / getNextPageParam
  • Add regression tests (tradePairPrefetch.infiniteSeed.test.tsx, cache-shape assertion in tradePairPrefetch.test.ts)
  • Document invariant in skills/AGENTS_FRONTEND_DEEP_ORDER_BOOK.md, skills/AGENTS_FRONTEND_TRADE_PAIR_SWITCH.md, docs/frontend.md

Verification checklist

  • On /trade, click a different pair in the pair search — workspace loads without "Something went wrong"
  • Order book panel renders bids/asks for the new pair
  • make test-frontend — prefetch + infinite seed tests pass

Note

Low Risk
Localized React Query prefetch fix plus tests and docs; no API or on-chain behavior changes.

Overview
Fixes #354: switching pairs on /trade could hit the ErrorBoundary because prefetchTradePairWorkspace warmed the limit book with prefetchQuery (a flat page) under the same React Query key that useLimitBookInfinite uses for useInfiniteQuery.

tradePairPrefetch.ts now calls prefetchInfiniteQuery for bid/ask with the same initialPageParam, getNextPageParam, and page fetch shape as the hook so the cache holds InfiniteData (pages / pageParams).

Regression coverage adds a cache-shape assertion in tradePairPrefetch.test.ts and tradePairPrefetch.infiniteSeed.test.tsx (prefetch then useLimitBookInfinite succeeds). Docs/skills (docs/frontend.md, deep order book + pair-switch playbooks) record the invariant: never seed a flat object on the infinite book key.

Reviewed by Cursor Bugbot for commit 35e38e54b2. Bugbot is set up for automated code reviews on this repo. Configure here.

## Summary Fixes #354 — click pair-switch on `/trade` crashed to ErrorBoundary because `prefetchTradePairWorkspace` seeded a flat limit-book page via `prefetchQuery` under the same key consumed by `useLimitBookInfinite` (`useInfiniteQuery`). ## Changes - Switch limit-book prefetch to `prefetchInfiniteQuery` with matching `initialPageParam` / `getNextPageParam` - Add regression tests (`tradePairPrefetch.infiniteSeed.test.tsx`, cache-shape assertion in `tradePairPrefetch.test.ts`) - Document invariant in `skills/AGENTS_FRONTEND_DEEP_ORDER_BOOK.md`, `skills/AGENTS_FRONTEND_TRADE_PAIR_SWITCH.md`, `docs/frontend.md` ## Verification checklist - [ ] On `/trade`, click a different pair in the pair search — workspace loads without "Something went wrong" - [ ] Order book panel renders bids/asks for the new pair - [ ] `make test-frontend` — prefetch + infinite seed tests pass <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Localized React Query prefetch fix plus tests and docs; no API or on-chain behavior changes. > > **Overview** > Fixes **#354**: switching pairs on `/trade` could hit the **ErrorBoundary** because `prefetchTradePairWorkspace` warmed the limit book with **`prefetchQuery`** (a flat page) under the same React Query key that **`useLimitBookInfinite`** uses for **`useInfiniteQuery`**. > > **`tradePairPrefetch.ts`** now calls **`prefetchInfiniteQuery`** for bid/ask with the same **`initialPageParam`**, **`getNextPageParam`**, and page fetch shape as the hook so the cache holds **`InfiniteData`** (`pages` / `pageParams`). > > Regression coverage adds a cache-shape assertion in **`tradePairPrefetch.test.ts`** and **`tradePairPrefetch.infiniteSeed.test.tsx`** (prefetch then **`useLimitBookInfinite`** succeeds). Docs/skills (**`docs/frontend.md`**, deep order book + pair-switch playbooks) record the invariant: never seed a flat object on the infinite book key. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 35e38e54b2937344bc6573a67619a8e6efd43c53. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
PlasticDigits commented 2026-06-10 03:27:04 +00:00 (Migrated from gitlab.com)

mentioned in issue #354

mentioned in issue #354
ghost1 commented 2026-06-10 03:27:04 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
ghost1 commented 2026-06-10 03:27:10 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
PlasticDigits (Migrated from gitlab.com) merged commit 76072064a0 into main 2026-06-10 05:31:19 +00:00
PlasticDigits commented 2026-06-10 05:31:23 +00:00 (Migrated from gitlab.com)

mentioned in commit 76072064a0

mentioned in commit 76072064a078f08b495d2e8e4c8826b74e2f5334
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic!851
No description provided.