Skip to content

feat: add @octanejs/tanstack-db binding - #689

Merged
trueadm merged 8 commits into
octanejs:mainfrom
jherr:feat/tanstack-db
Aug 15, 2026
Merged

trueadm merged 8 commits into
octanejs:mainfrom
jherr:feat/tanstack-db

Conversation

@jherr

@jherr jherr commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds @octanejs/tanstack-db — Octane live-query bindings for @tanstack/db, rebound onto TanStack DB 0.7.0's new adapter architecture. Re-exports @tanstack/[email protected] unchanged and ports the React live-query surface of @tanstack/[email protected] — useLiveQuery, useLiveInfiniteQuery, useLiveSuspenseQuery, useLiveQueryEffect, usePacedMutations — onto Octane hooks.

Why

A review of the initial revision found 7 P1 correctness blockers and flagged that the port predated DB's 0.7.0 shared-observer / window-lease architecture, was missing binding-port artifacts, and conflicted with main. This revision moves to 0.7.0, fixes every finding at the source (per CLAUDE.md — no app/test workarounds), and adds the artifacts.

Changes

Review remediation (all 7 P1 findings fixed at source):

  1. Async Suspense — useLiveSuspenseQuery now suspends via Octane use(thenable) instead of throw promise (Octane Suspense only recognizes the use() sentinel; a raw throw hits the error path). Pinned by a new async-fallback regression test.
  2. Status-only changes — useLiveQuery/useLiveSuspenseQuery rebuilt on DB's shared createLiveQueryObserver (db #1642) so error/cleaned-up transitions with no row delta update status/isError/isCleanedUp.
  3. Shared window coordination — useLiveInfiniteQuery rebuilt on the coordinated createLiveQueryWindowController (db #1675): window leases stop two hooks on one collection truncating each other. New two-hook regression test.
  4. Failed-page rollback — a rejected page load now rolls back loadedPageCount, surfaces snapshot.error on the result, and allows a clean retry (via the shared controller), instead of fire-and-forget console.error.
  5. Effect slot — useLiveQueryEffect parses deps + the compiler-injected trailing slot together from ...rest, so the common no-deps call useLiveQueryEffect(config) keeps its call-site slot.
  6. Order contract + version — bumped @tanstack/db ^0.6.17 → ^0.7.0; dropped order-only-move from the conformance suite's universal expected-fail set (db #1669 fixed the republish contract).
  7. Committed-test gate — the missing-orderBy test is now an active it (error surfaced synchronously during render via getWindow()); the StrictMode double-invoke case is recorded as not applicable (Octane has no dev double-invoke) rather than committed with .skip. node scripts/check-test-markers.mjs passes.

Post-review follow-up (Cursor Bugbot on the 0.7.0 commit):

  • useLiveSuspenseQuery now calls use() unconditionally (once per render). Octane keys use(thenable) by dynamic call-order index, not slot, so skipping it once ready shifted a sibling suspense query onto the resolved slot and surfaced a still-loading collection as ready. Regression test drives two independently gated collections. ([High], fixed)
  • useLiveInfiniteQuery now creates query-function collections with startSync: false, matching upstream: synchronization begins from the committed window-controller subscription after its lease is acquired. Regression coverage proves an abandoned render issues no loadSubset requests. ([Medium], fixed) A third finding (“stale pages after deps change”) was against the pre-remediation commit and no longer applies.

Binding-port artifacts:

  • UPSTREAM.md — immutable pin (@tanstack/[email protected] adapter over @tanstack/[email protected] core, MIT, npm archive SHA-256), full public-surface crosswalk, and upstream-suite disposition.
  • upstream/react-db/** — the adapter source vendored byte-exact with SHA256SUMS, .prettierignored and excluded from published files (dev evidence only).
  • status.json/README.md updated to 0.7.0 and the documented divergences.

Octane adaptation note: the useLiveQuery/useLiveInfiniteQuery subscribe wrappers defer an initial onStoreChange to a microtask, because Octane's useSyncExternalStore re-checks the store snapshot before (not after) subscribe(). Pinned by the eager-onstorechange test.

Validation

Targeted runs (record which gates ran):

  • pnpm format:check — ran pnpm format:files:check packages/tanstack-db ✅ (repo-wide not run)
  • pnpm typecheck — ran pnpm typecheck:files packages/tanstack-db (22 files, both tsconfigs) ✅ (full script not run)
  • pnpm test — ran pnpm vitest run --project tanstack-db ✅ 119 passed, 0 expected-fail, 0 skipped (full suite not run)
  • targeted tests: --project tanstack-db; node scripts/check-test-markers.mjs ✅; pnpm react-parity:validate ✅
  • Rebased onto origin/main (8a62ed6b); pnpm sync clean; the 73 audit/react-parity.json lockfile hashes regenerated for the DB 0.7.0 lockfile change.

Risk / follow-ups

  • audit/react-parity.json for tanstack-db is intentionally not added. A verified manifest requires a pristine-upstream oracle lane running @tanstack/react-db's own suite, which the npm artifact does not ship — so an honest manifest cannot reach verified yet. Documented as an open gap in status.json, consistent with the recorded-unverified posture of every other binding. The parity validator does not flag its absence.
  • SSR/hydration for the live-query hooks is not yet exercised (noted in status.json).
  • The vendored tests/db-fixtures/db-internal/* and upstream/react-db/** are pinned and would be re-vendored on a DB upgrade (the diff is the work list).

Provenance

  • An agent produced this diff (agent-authored)

Co-authored by Claude (Claude Code, Opus 4.8) and @jherr.

🤖 Generated with Claude Code


Note

Medium Risk
New binding with non-trivial Suspense and infinite-query coordination divergences from React; live-query SSR is not yet covered by tests.

Overview
Introduces @octanejs/tanstack-db, a new framework binding that re-exports @tanstack/[email protected] and ports @tanstack/react-db’s live-query hooks (useLiveQuery, useLiveInfiniteQuery, useLiveSuspenseQuery, useLiveQueryEffect, usePacedMutations) onto Octane.

TanStack DB 0.7.0 architecture: useLiveQuery / useLiveSuspenseQuery use the shared createLiveQueryObserver so status-only updates propagate; useLiveInfiniteQuery uses createLiveQueryWindowController for coordinated infinite windows, failed-page rollback, and startSync: false for query-function collections until the window subscription is active.

Octane-specific behavior: Suspense goes through use(thenable) (unconditional per render for stable use() indexing), not thrown promises. Subscribe wrappers nudge onStoreChange on a microtask to match Octane’s useSyncExternalStore ordering. Missing orderBy on pre-created infinite-query collections throws synchronously during render.

Repo inventory, binding status docs, CLI/MCP package maps, root typecheck for tanstack-db, and widespread audit/react-parity.json lockfile hash updates accompany the package. Octane client runtime adds module-local process typing so browser consumers can compile without Node ambient types while keeping literal NODE_ENV guards for bundler substitution.

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

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent feat PR: new feature or capability labels Aug 10, 2026
@jherr jherr closed this Aug 13, 2026
@jherr jherr reopened this Aug 13, 2026
jherr and others added 2 commits August 13, 2026 12:13
Port the Octane live-query bindings for @tanstack/db (TanStack/db PR octanejs#1699,
`packages/octane-db`, still open) into the monorepo as `@octanejs/tanstack-db`.

- Re-exports @tanstack/[email protected] unchanged; adapts the live-query surface
  (useLiveQuery, useLiveInfiniteQuery, useLiveSuspenseQuery, useLiveQueryEffect,
  usePacedMutations) onto Octane hooks. Source imports only public @tanstack/db.
- Package shape matches sibling bindings: exports point at src/ (no dist build),
  self-contained tsconfig (jsxImportSource octane), status.json.
- Tests decoupled from the db monorepo: internal src imports rewritten to
  @tanstack/db; test helpers, the conformance suite, and db's expression
  evaluator vendored under tests/db-fixtures/ (pinned to 0.6.17, test-only) so
  the infinite-query tests can interpret the where/cursor IR db generates.
- Wired into vitest.config.js and the root typecheck script; registered in
  website/src/content/bindings.json; changeset added.

Generated inventories (docs/packages.md, docs/bindings-status.md, CLI data,
react-parity lockfile hashes) are intentionally omitted from this diff and
should be regenerated with `pnpm sync` at merge time.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… fix live-query blockers

Rebinds the binding to the TanStack DB 0.7.0 adapter architecture and fixes the
PR review's P1 blockers at the source:

- Suspense suspends via Octane `use(thenable)` instead of `throw promise`
  (Octane Suspense only recognizes the use() sentinel). Proven by an async
  fallback regression test.
- useLiveQuery/useLiveSuspenseQuery rebuilt on db's shared createLiveQueryObserver
  (db octanejs#1642) so status-only transitions (error/cleaned-up) update isError/
  isCleanedUp.
- useLiveInfiniteQuery rebuilt on the coordinated createLiveQueryWindowController
  (db octanejs#1675): window leases stop two hooks on one collection truncating each
  other (regression test), and a failed page load rolls back and surfaces
  snapshot.error with a clean retry.
- useLiveQueryEffect parses deps + the compiler slot together from ...rest, so
  no-deps usage keeps its call-site slot.
- Conformance suite: drop order-only-move from universal expected-fail (db octanejs#1669
  fixed the contract); un-skip the missing-orderBy test (surfaced synchronously
  during render via getWindow()); record StrictMode double-invoke as
  not-applicable. Committed-test-marker gate passes.
- Bump @tanstack/db ^0.6.17 -> ^0.7.0; re-pin vendored db-internal fixtures;
  vendor the @tanstack/[email protected] adapter source under upstream/ with
  SHA256SUMS; add UPSTREAM.md pin + crosswalk; refresh status.json/README.

Octane-adaptation: the subscribe wrappers defer an initial onStoreChange to a
microtask because Octane's useSyncExternalStore re-checks the snapshot before
(not after) subscribe; pinned by the eager-onstorechange test.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@jherr
jherr force-pushed the feat/tanstack-db branch from c317774 to 7c608ad Compare August 13, 2026 16:14
… document startSync divergence

Addresses two Cursor Bugbot findings on the 0.7.0 remediation commit.

- [High] useLiveSuspenseQuery called use() only on the loading/idle path and
  skipped it once ready. Octane keys use(thenable) by dynamic call-order index
  (runtime __thenableIdx), not by compiler slot, so a ready hook that skips its
  use() shifts the thenable index of a sibling use()/second useLiveSuspenseQuery
  in the same component. On the replay after the first query resolves, the
  second hook read the first's fulfilled thenable (resume-replay leniency path)
  and stopped suspending, surfacing its still-loading collection as ready. Fix:
  call use() unconditionally — exactly once per render — handing it an
  already-resolved sentinel on the ready/stale paths so the call-order index
  stays stable and no suspend occurs. New regression test drives two
  independently gated collections and asserts the later sibling stays suspended
  while the earlier one is ready (fails pre-fix with `a:3|b:0`).

- [Medium] Documented the useLiveInfiniteQuery `startSync: true` divergence in
  status.json. The query-function collection is created with the first-page
  window already applied (.limit(pageSize + 1).offset(0)), so eager sync fetches
  exactly the first page — never a wider subset — before the window controller
  grows it; only the fetch-start timing differs from upstream's post-commit
  start. (Bugbot's third finding, "stale pages after deps change", was against
  the pre-remediation commit and no longer applies: the controller rewrite
  computes page count synchronously during render.)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit bfb6a35. Configure here.

jherr and others added 3 commits August 13, 2026 15:21
…l as fulfilled

Follow-up to the unconditional-use() change. The shared `SETTLED` thenable handed
to `use()` on the non-loading paths was a bare `Promise.resolve()`. Octane's
`use()` tags an untagged thenable `'pending'` synchronously (its fulfillment
callback runs a microtask later), so the first `use(SETTLED)` on the ready path
suspended and flashed the Suspense fallback even though data was already ready.

Give `SETTLED` the React 19 `cache()` settled shape (`status: 'fulfilled'`) so
`trackThenable` leaves it untouched and `use()` returns synchronously without
suspending. New regression test preloads a collection to `ready` before mount so
the first render takes the ready path, and asserts the fallback never renders
(fails pre-fix: first commit shows `Loading...` instead of `ready:3`).

Reported by Cursor Bugbot on the previous commit.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@trueadm
trueadm marked this pull request as ready for review August 15, 2026 19:34
@trueadm
trueadm merged commit 0fc84da into octanejs:main Aug 15, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent feat PR: new feature or capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants