Skip to content

perf(showcase-dashboard): yield during fetch + parallelize initial pages - #4504

Merged
jpr5 merged 1 commit into
mainfrom
worktree-cheeky-knitting-graham
Apr 30, 2026
Merged

jpr5 merged 1 commit into
mainfrom
worktree-cheeky-knitting-graham

Conversation

@AlemTuzlak

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #4502. With matrix cells memoized and SSE deltas coalesced, the dashboard is much smoother — but the initial dashboard load still freezes for a few seconds because:

  1. Initial PB fetch is 10 sequential round-trips. fetchInitial walks getList(page=1, 200) → getList(page=2, 200) → … up to 10 pages, each awaiting the previous. Network wall time stacks.
  2. First commit with real data is unavoidably a full-matrix re-render. The empty-map → populated-map transition invalidates per-key memo checks on every cell — that's 720 cell renders in one synchronous React commit, blocking the main thread.

Changes

  • Parallelize the initial fetch. Pull page 1 sequentially to learn totalItems, then fire pages 2..N concurrently via Promise.all. Wall time drops from sum(rtt_per_page) to roughly max(rtt_per_page) modulo network parallelism. PocketBase reads are independent so this is safe.
  • startTransition around the initial setRows(initial). The first big commit is unavoidable, but marking it as a transition lets React 19 yield to user input mid-walk instead of blocking for the entire render. setStatus stays urgent so the "connecting → live" indicator still flips immediately.
  • startTransition around the SSE flush. Bursts that the 16ms coalescer can't fully absorb (large reconnect replays, simultaneous probe completions) still need to yield rather than block.

Test plan

  • useLiveStatus.test.tsx 15/15 pass with parallelized fetch (the mock handles arbitrary page numbers).
  • composed-cell.test.tsx 9/10 pass (1 pre-existing failure, same as perf(showcase-dashboard): memoize matrix cells + coalesce SSE deltas #4502).
  • No new TypeScript errors in useLiveStatus.ts.
  • Manual perf trace before/after on the live dashboard. Expected: initial-load wall time drops sharply (sequential → parallel pages), and any remaining heavy commit no longer blocks the main thread (transition lets React yield).
  • Functional sanity — confirm rows still arrive correctly when pages return out of order, and the "connecting → live" status transition still fires before the heavy render.

Follow-up to the matrix memoization PR. The initial dashboard load still
freezes for a few seconds because (a) the initial PB fetch is 10
sequential getList round-trips before any data arrives, and (b) when it
does arrive, the empty-map → populated-map transition forces every cell
in the matrix to re-render in one synchronous commit.

- Parallelize initial fetch: pull page 1 sequentially to learn
  totalItems, then fire pages 2..N concurrently via Promise.all. Wall
  time drops from `sum(rtt_per_page)` to roughly `max(rtt_per_page)`
  modulo network parallelism. PocketBase reads are independent so this
  is safe.
- Wrap initial setRows in startTransition. The first commit with real
  data is unavoidably a full-matrix re-render (per-key memo checks
  invalidate on every cell when the map flips from empty to populated);
  marking it as a transition lets React 19 yield to user input mid-walk
  instead of blocking the main thread for the duration. setStatus stays
  urgent so the "connecting → live" indicator still flips immediately.
- Wrap the SSE flush setRows in startTransition for the same reason —
  bursts that the 16ms coalescer can't fully absorb still need to yield.
@vercel

vercel Bot commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chat-with-your-data Ready Ready Preview, Comment Apr 30, 2026 3:21pm
docs Ready Ready Preview, Comment Apr 30, 2026 3:21pm
form-filling Ready Ready Preview, Comment Apr 30, 2026 3:21pm
research-canvas Ready Ready Preview, Comment Apr 30, 2026 3:21pm
travel Ready Ready Preview, Comment Apr 30, 2026 3:21pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📣 Social Copy Generator

Generate social media copies (Twitter/X, LinkedIn, Blog Post) for this PR using Claude.

  • Generate social media copies

@jpr5
jpr5 merged commit d17ea91 into main Apr 30, 2026
16 checks passed
@jpr5
jpr5 deleted the worktree-cheeky-knitting-graham branch April 30, 2026 23:02
jpr5 added a commit that referenced this pull request Apr 30, 2026
Reverts #4504. The parallelized fetch change broke the dashboard's live
status connection, causing all integrations to show 'offline' and the
Feature Matrix to show 'OFFLINE'.
pull Bot pushed a commit to TheRakeshPurohit/CopilotKit that referenced this pull request Apr 30, 2026
…itial pages (CopilotKit#4504)"

This reverts commit d17ea91, reversing
changes made to a0770ea.
jpr5 added a commit that referenced this pull request Jul 24, 2026
…ake servers

PR #6156 silently invalidated the dropped-tail pagination guards added by
PR #4504. Regression in test COVERAGE, not production code — which is why
CI stayed green.

The three fake PB servers in the autocancel suite ignored the `filter` query
param (and `fields`). #6156 made the supplemental `signal` fetch UNCONDITIONAL
(dropping the `commAggregateFilter === null` early return and widening the
filter to `state != "green"`), so a filter-ignoring server answered that
now-always-issued fetch with the ENTIRE dataset — and `fetchInitial`'s
leftover-append then REPAIRED whatever rows the bulk pagination dropped.
Mutating the merge to drop the entire short page kept all three tests GREEN.

The servers now answer a list request the way real PocketBase does: filter,
then sort, then the page slice, then the `fields` projection, with the
COUNT(*) envelope omitted only when `skipTotal` is set. The filter evaluator
covers exactly the grammar `useLiveStatus` emits and THROWS on anything else
(answered as 400) — a silently-unparsed clause would degrade to "match
everything", i.e. straight back into the masking bug. Real-SDK quoting is
matched (single-quoted string params, bare numbers/booleans, verified against
the installed SDK); the sibling suite's double-quoting `pb.filter` stub flaw
is deliberately NOT copied forward, and a wire assertion pins the convention.

The supplemental fetch is discriminated by the ABSENCE of a `fields`
projection — the sibling `useLiveStatus.test.tsx` convention, reused rather
than reinvented. This replaces a `filter.includes("state !=")` substring
check that the union filter had already made unreliable.

Broken assertions repaired:

- over-fetch instrumentation no longer conflates the supplemental serial walk
  with the bulk fan-out (separate page arrays), and the split is now asserted
  rather than assumed
- the FIRST-wave-element server serves POISON rows on the page after the
  short page. Real PB pagination is monotonic, so that page is empty and
  appending it changes nothing — which is exactly why deleting the merge's
  boundary logic left the test green. Poison makes a merge that runs past
  the boundary observable
- `.some(r => r.id === "f0699")` replaced with `rows.at(-1)?.id`, the LAST-row
  boundary check the comment already claimed, plus explicit poison-absence
- the mid-wave suite no longer claims a boundary property its fixture cannot
  measure (its short page is the wave's last element); name and comment now
  state what it does measure, and it gained a real tail-boundary assertion

Mutation red-green, both directions. Drop-the-entire-short-page: PASSED 3/3
before, now FAILS 3/3 (1300 to 1000, 1250 to 1000, 700 to 500).
Boundary-logic-removed: PASSED before, now FAILS on the suite that claims it
(700 to 1000). Reversed-merge-order (same row set): PASSED before, now FAILS
on both new `.at(-1)` assertions. Mutations reverted: 3/3 pass.

Test-only change — no production code touched.
zeekay pushed a commit to Dream-AI-4444/CopilotKit that referenced this pull request Sep 11, 2026
…ges (CopilotKit#4504)

## Summary

Follow-up to CopilotKit#4502. With matrix cells memoized and SSE deltas coalesced,
the dashboard is much smoother — but the **initial dashboard load**
still freezes for a few seconds because:

1. **Initial PB fetch is 10 sequential round-trips.** `fetchInitial`
walks `getList(page=1, 200) → getList(page=2, 200) → …` up to 10 pages,
each awaiting the previous. Network wall time stacks.
2. **First commit with real data is unavoidably a full-matrix
re-render.** The empty-map → populated-map transition invalidates
per-key memo checks on every cell — that's 720 cell renders in one
synchronous React commit, blocking the main thread.

## Changes

- **Parallelize the initial fetch.** Pull page 1 sequentially to learn
`totalItems`, then fire pages 2..N concurrently via `Promise.all`. Wall
time drops from `sum(rtt_per_page)` to roughly `max(rtt_per_page)`
modulo network parallelism. PocketBase reads are independent so this is
safe.
- **`startTransition` around the initial `setRows(initial)`.** The first
big commit is unavoidable, but marking it as a transition lets React 19
yield to user input mid-walk instead of blocking for the entire render.
`setStatus` stays urgent so the "connecting → live" indicator still
flips immediately.
- **`startTransition` around the SSE flush.** Bursts that the 16ms
coalescer can't fully absorb (large reconnect replays, simultaneous
probe completions) still need to yield rather than block.

## Test plan

- [x] `useLiveStatus.test.tsx` 15/15 pass with parallelized fetch (the
mock handles arbitrary page numbers).
- [x] `composed-cell.test.tsx` 9/10 pass (1 pre-existing failure, same
as CopilotKit#4502).
- [x] No new TypeScript errors in `useLiveStatus.ts`.
- [ ] **Manual perf trace before/after on the live dashboard.**
Expected: initial-load wall time drops sharply (sequential → parallel
pages), and any remaining heavy commit no longer blocks the main thread
(transition lets React yield).
- [ ] **Functional sanity** — confirm rows still arrive correctly when
pages return out of order, and the "connecting → live" status transition
still fires before the heavy render.
zeekay pushed a commit to Dream-AI-4444/CopilotKit that referenced this pull request Sep 11, 2026
…itial pages (CopilotKit#4504)"

This reverts commit d17ea91, reversing
changes made to a0770ea.
zeekay pushed a commit to Dream-AI-4444/CopilotKit that referenced this pull request Sep 11, 2026
Reverts CopilotKit#4504. The parallelized fetch change broke the dashboard's live
status connection, causing all integrations to show 'offline' and the
Feature Matrix to show 'OFFLINE'.

This branch was successfully deployed

5 active deployments
Preview – research-canvas — fa4cc06b Deployed Apr 30, 2026 by vercel[bot]
Preview – docs — fa4cc06b Deployed Apr 30, 2026 by vercel[bot]
Preview – travel — fa4cc06b Deployed Apr 30, 2026 by vercel[bot]
Preview – form-filling — fa4cc06b Deployed Apr 30, 2026 by vercel[bot]
Preview – chat-with-your-data — fa4cc06b Deployed Apr 30, 2026 by vercel[bot]
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