Skip to content

fix(app-kit): keep data on failed reloads and read every page of a paged operation - #4625

Open
icedevera wants to merge 3 commits into
mainfrom
fix/app-kit-query-paging
Open

icedevera wants to merge 3 commits into
mainfrom
fix/app-kit-query-paging

Conversation

@icedevera

Copy link
Copy Markdown
Member

Problem

Change

  • A failed reload keeps the last good data and revision beside error. data still clears when the operation, input, or Collection changes. If a change event arrives around a reload that fails with 429 or 503, the hook retries in the background as it already did for live refreshes.
  • New useDatasetPages<Page>(operation, input, options) in dohc/app. It sends input, then { ...input, after: nextCursor } until nextCursor is null, and returns the pages in order. It shares useDatasetQuery's scope keys, aborts, live rereads, enabled, dataset, live, and reload.
    • A page that gets a 429 waits retryAfterMs (2 s if absent) and asks for the same page again. Share links allow 30 requests in a burst, so a read of more than 30 pages would otherwise never finish.
    • If a later page's revision differs from the first page's, the read starts again from the first page, at most twice.
    • A page without nextCursor, or a cursor it already followed, fails with a 400 that names the operation. groupBy reads (nextGroupCursor) don't silently look complete, and a stuck cursor can't loop.
  • docs/reference/app-kit.md: the hook, the paging rules, and the minimal example now keep showing data beside an error.

Closes #4553
Closes #4565

Verification

  • packages/app-kit vitest on the rebased head: 42 of 42 pass. The 5 new tests failed before the fix: failed reload keeps data and clears on input change, catch-up after a failed reload (3 flows), multi-page read with live reread, input change mid-read and failed reread, and 429 retry, torn-read restart, repeated and missing cursor.
  • tsc for app-kit, oxlint over the repository, and oxfmt are clean. apps/desktop closedAppCompiler.test.ts: 34 of 34 pass.
  • Real Chromium on Windows, through the real local app launcher, broker, and dataset host, with a compiled app (temporary Playwright spec, not committed): useDatasetPages read 45 pages (135 items). A write through useDatasetMutation reread 46 pages live. A failed reload() (409 refusal) kept the old value beside the error. No console errors besides the browser's network line for that deliberate 409.
  • Not checked: macOS, Linux, and the phone app. The change is platform-independent browser code.

Council review

Design: one round, all three seats said revise. Folded in: 429 retry at the same cursor, required and non-repeating nextCursor, torn-read restart, pending live refresh after a failed reload, and the docs example.

Rounds: 3 in total (1 pre-pass, 2 council). Size: +97 product lines (budget 75 after the design council).

Seat Pre-pass Round 1 Round 2
Claude Opus 8/10 approved
GPT Sol 8/10 8/10 9/10
Gemini 4 Neon 9/10 approved

Sol's two blockers were the same bug in two forms: a live change that arrived around a manual reload() was dropped if that reload failed with 503. Both are fixed and covered by the extended catch-up test.

Follow-ups:

  • Cap the 429 wait inside a paged read (now up to retryAfterMs, at most 1 h) or show the 429 after a few tries.
  • The "Stale queries and rate limits" docs line should say useDatasetPages waits out a 429 rather than showing it.
  • A poll interval option for hosts without change events, and a quiet background reload() so polling doesn't flip loading.
  • Paging for groupBy (nextGroupCursor) and offset-paged reads.
  • Move the Lightbox and Tournament examples onto these hooks.
  • Tests for the two-restart cap and a non-object input. A clear message for the non-object input 400, and an input type that accepts interfaces.
  • The desktop verifier's read-only hint could name useDatasetPages.
  • Reading every page again on each live change costs up to 3N requests on a busy Collection. Measure before large paged apps rely on live mode.

🤖 Generated with Claude Code

icedevera and others added 3 commits November 25, 2026 16:36
…ged operation

A failed foreground reload in useDatasetQuery cleared data, so an app that
polls with reload() blanked out on one failed request. A failed reload now
keeps the last good data and revision beside the error, and a transient
failure keeps a pending live refresh.

useDatasetPages follows nextCursor with { ...input, after } and returns every
page. It shares useDatasetQuery's scope, abort, and live-update handling,
retries a rate-limited page at its cursor, restarts a read whose pages came
from different revisions, and refuses a missing or repeated nextCursor.

Closes #4553
Closes #4565

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…first read

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T08:40:26.349646Z 4ee8dec PR opened
🔒 Security Review ✅ Completed 2026-11-25T08:42:58.743009Z 4ee8dec PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant