Add framework DB adapter package #1699
main fromfeat/framework-db-adapter·opened Summary#
- Add a new framework integration package for TanStack DB with live query hooks (useLiveQuery, useLiveSuspenseQuery, useLiveInfiniteQuery, usePacedMutations, useLiveQueryEffect)
- Port test coverage and shared conformance driver from the React adapter
- Register docs, installation, skill tree, and doc generation for the new package
Test plan#
- pnpm --filter @tanstack/octane-db build
- pnpm --filter @tanstack/octane-db test
Made with Cursor
Summary by CodeRabbit#
- New Features
- Released the Octane framework adapter for TanStack DB as a new package.
- Added live query hooks, Suspense-enabled live queries, infinite live queries, live query effects, and paced mutations for Octane.
- Enabled Octane compiler integration and supports incremental adoption alongside React.
- Documentation
- Added Octane installation guidance, expanded overview and API reference pages, and created detailed hook/skill documentation for the new adapter.
- Tests
- Added conformance coverage and comprehensive unit/type tests for all new hooks, including pagination, Suspense behavior, effects, and mutation pacing.
- 1
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
Diff Package Supply Chain
SecurityVulnerability Quality Maintenance License npm/@octanejs/vite-plugin@0.1.13 npm/@octanejs/testing-library@0.1.10 npm/octane@0.1.13 Warning
Review the following alerts detected in dependencies.
According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
Action Severity Alert (click "▶" to expand/collapse) Warn Low adoption: npm
octaneLocation: Package overview
From: packages/octane-db/package.json →
npm/octane@0.1.13ℹ Read more on: This package | This alert | What are unpopular packages?
Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at
support@socket.dev.Suggestion: Unpopular packages may have less maintenance and contain other problems.
Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment
@SocketSecurity ignore npm/octane@0.1.13. You can also ignore all packages with@SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.More templates
@tanstack/angular-db
npm i https://pkg.pr.new/TanStack/db/@tanstack/angular-db@1699@tanstack/browser-db-sqlite-persistence
npm i https://pkg.pr.new/TanStack/db/@tanstack/browser-db-sqlite-persistence@1699@tanstack/capacitor-db-sqlite-persistence
npm i https://pkg.pr.new/TanStack/db/@tanstack/capacitor-db-sqlite-persistence@1699@tanstack/cloudflare-durable-objects-db-sqlite-persistence
npm i https://pkg.pr.new/TanStack/db/@tanstack/cloudflare-durable-objects-db-sqlite-persistence@1699@tanstack/db
npm i https://pkg.pr.new/TanStack/db/@tanstack/db@1699@tanstack/db-ivm
npm i https://pkg.pr.new/TanStack/db/@tanstack/db-ivm@1699@tanstack/db-sqlite-persistence-core
npm i https://pkg.pr.new/TanStack/db/@tanstack/db-sqlite-persistence-core@1699@tanstack/electric-db-collection
npm i https://pkg.pr.new/TanStack/db/@tanstack/electric-db-collection@1699@tanstack/electron-db-sqlite-persistence
npm i https://pkg.pr.new/TanStack/db/@tanstack/electron-db-sqlite-persistence@1699@tanstack/expo-db-sqlite-persistence
npm i https://pkg.pr.new/TanStack/db/@tanstack/expo-db-sqlite-persistence@1699@tanstack/node-db-sqlite-persistence
npm i https://pkg.pr.new/TanStack/db/@tanstack/node-db-sqlite-persistence@1699@tanstack/octane-db
npm i https://pkg.pr.new/TanStack/db/@tanstack/octane-db@1699@tanstack/offline-transactions
npm i https://pkg.pr.new/TanStack/db/@tanstack/offline-transactions@1699@tanstack/powersync-db-collection
npm i https://pkg.pr.new/TanStack/db/@tanstack/powersync-db-collection@1699@tanstack/query-db-collection
npm i https://pkg.pr.new/TanStack/db/@tanstack/query-db-collection@1699@tanstack/react-db
npm i https://pkg.pr.new/TanStack/db/@tanstack/react-db@1699@tanstack/react-native-db-sqlite-persistence
npm i https://pkg.pr.new/TanStack/db/@tanstack/react-native-db-sqlite-persistence@1699@tanstack/rxdb-db-collection
npm i https://pkg.pr.new/TanStack/db/@tanstack/rxdb-db-collection@1699@tanstack/solid-db
npm i https://pkg.pr.new/TanStack/db/@tanstack/solid-db@1699@tanstack/svelte-db
npm i https://pkg.pr.new/TanStack/db/@tanstack/svelte-db@1699@tanstack/tauri-db-sqlite-persistence
npm i https://pkg.pr.new/TanStack/db/@tanstack/tauri-db-sqlite-persistence@1699@tanstack/trailbase-db-collection
npm i https://pkg.pr.new/TanStack/db/@tanstack/trailbase-db-collection@1699@tanstack/vue-db
npm i https://pkg.pr.new/TanStack/db/@tanstack/vue-db@1699commit:
f212053Size Change: 0 B
Total Size: 125 kB
compressed-size-action::db-package-sizeℹ️ View Unchanged
Filename Size packages/db/dist/esm/collection/change-events.js1.43 kB packages/db/dist/esm/collection/changes.js1.38 kB packages/db/dist/esm/collection/cleanup-queue.js810 B packages/db/dist/esm/collection/events.js434 B packages/db/dist/esm/collection/index.js3.62 kB packages/db/dist/esm/collection/indexes.js1.99 kB packages/db/dist/esm/collection/lifecycle.js1.69 kB packages/db/dist/esm/collection/mutations.js2.47 kB packages/db/dist/esm/collection/state.js5.48 kB packages/db/dist/esm/collection/subscription.js3.74 kB packages/db/dist/esm/collection/sync.js2.88 kB packages/db/dist/esm/collection/transaction-metadata.js144 B packages/db/dist/esm/deferred.js207 B packages/db/dist/esm/errors.js5.1 kB packages/db/dist/esm/event-emitter.js748 B packages/db/dist/esm/index.js3.16 kB packages/db/dist/esm/indexes/auto-index.js829 B packages/db/dist/esm/indexes/base-index.js784 B packages/db/dist/esm/indexes/basic-index.js2.17 kB packages/db/dist/esm/indexes/btree-index.js2.29 kB packages/db/dist/esm/indexes/index-registry.js820 B packages/db/dist/esm/indexes/reverse-index.js557 B packages/db/dist/esm/live-query-adapter.js318 B packages/db/dist/esm/local-only.js916 B packages/db/dist/esm/local-storage.js2.12 kB packages/db/dist/esm/optimistic-action.js359 B packages/db/dist/esm/paced-mutations.js496 B packages/db/dist/esm/proxy.js3.75 kB packages/db/dist/esm/query/builder/functions.js1.47 kB packages/db/dist/esm/query/builder/index.js5.84 kB packages/db/dist/esm/query/builder/ref-proxy.js1.24 kB packages/db/dist/esm/query/compiler/evaluators.js1.89 kB packages/db/dist/esm/query/compiler/expressions.js430 B packages/db/dist/esm/query/compiler/group-by.js3.56 kB packages/db/dist/esm/query/compiler/index.js6.67 kB packages/db/dist/esm/query/compiler/joins.js2.5 kB packages/db/dist/esm/query/compiler/lazy-targets.js923 B packages/db/dist/esm/query/compiler/order-by.js1.74 kB packages/db/dist/esm/query/compiler/select.js1.53 kB packages/db/dist/esm/query/effect.js4.77 kB packages/db/dist/esm/query/expression-helpers.js1.43 kB packages/db/dist/esm/query/ir.js1.25 kB packages/db/dist/esm/query/live-query-collection.js360 B packages/db/dist/esm/query/live/collection-config-builder.js9.1 kB packages/db/dist/esm/query/live/collection-registry.js264 B packages/db/dist/esm/query/live/collection-subscriber.js1.93 kB packages/db/dist/esm/query/live/internal.js145 B packages/db/dist/esm/query/live/utils.js1.81 kB packages/db/dist/esm/query/optimizer.js2.92 kB packages/db/dist/esm/query/predicate-utils.js2.97 kB packages/db/dist/esm/query/query-once.js359 B packages/db/dist/esm/query/subset-dedupe.js960 B packages/db/dist/esm/scheduler.js1.3 kB packages/db/dist/esm/SortedMap.js1.3 kB packages/db/dist/esm/strategies/debounceStrategy.js247 B packages/db/dist/esm/strategies/queueStrategy.js428 B packages/db/dist/esm/strategies/throttleStrategy.js246 B packages/db/dist/esm/transactions.js3.04 kB packages/db/dist/esm/utils.js927 B packages/db/dist/esm/utils/array-utils.js273 B packages/db/dist/esm/utils/browser-polyfills.js304 B packages/db/dist/esm/utils/btree.js5.61 kB packages/db/dist/esm/utils/comparison.js1.15 kB packages/db/dist/esm/utils/cursor.js457 B packages/db/dist/esm/utils/index-optimization.js2.39 kB packages/db/dist/esm/utils/type-guards.js157 B packages/db/dist/esm/utils/uuid.js449 B packages/db/dist/esm/virtual-props.js360 B Size Change: 0 B
Total Size: 4.22 kB
compressed-size-action::react-db-package-sizeℹ️ View Unchanged
Filename Size packages/react-db/dist/esm/index.js249 B packages/react-db/dist/esm/useLiveInfiniteQuery.js1.32 kB packages/react-db/dist/esm/useLiveQuery.js1.33 kB packages/react-db/dist/esm/useLiveQueryEffect.js355 B packages/react-db/dist/esm/useLiveSuspenseQuery.js567 B packages/react-db/dist/esm/usePacedMutations.js401 B Actionable comments posted: 8
🧹 Nitpick comments (11)
packages/octane-db/src/useLiveInfiniteQuery.ts (1)
182-191: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winJSON.stringifyfor dep comparison rejects deps thatuseLiveQueryaccepts.useLiveQuerycompares deps by element identity, so a collection, aDate, a function, or any non-serializable value is a valid dep there. Here the same array throws. Beyond the divergence, stringifying on every render is O(size of deps) and treats{a:1,b:2}and{b:2,a:1}as different.Element-wise identity comparison (as
useLiveQueryalready does) removes the whole failure mode.As per coding guidelines: "Be mindful of time complexity in algorithms".
♻️ Proposed refactor
- // Track deps for query functions (stringify for comparison) - let depsKey: string - try { - depsKey = JSON.stringify(deps) - } catch { - throw new Error( - `useLiveInfiniteQuery: dependency array contains values that cannot be serialized (e.g. circular references). ` + - `Ensure all dependency values are JSON-serializable.`, - ) - } - const prevDepsKeyRef = useRef(depsKey, subSlot(slot, `deps-key-ref`)) + // Track deps for query functions (identity comparison, matching useLiveQuery) + const prevDepsRef = useRef<Array<unknown>>(deps, subSlot(slot, `deps-ref`)) + const depsChanged = + prevDepsRef.current.length !== deps.length || + prevDepsRef.current.some((dep, i) => dep !== deps[i])The effect at lines 204-213 then keys off
depsChangedand assignsprevDepsRef.current = deps. Note this also makes thethrows a descriptive error when deps contain non-serializable valuestest atpackages/octane-db/tests/useLiveInfiniteQuery.test.tsxlines 1876-1906 obsolete.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/octane-db/src/useLiveInfiniteQuery.ts` around lines 182 - 191, Replace the JSON.stringify-based dependency key logic in useLiveInfiniteQuery with element-wise identity comparison matching useLiveQuery, using the existing previous-dependencies ref and deriving depsChanged from that comparison. Preserve the effect’s update behavior by assigning the current deps to prevDepsRef.current after processing, and remove the obsolete serialization-error path and test.Source: Coding guidelines
packages/octane-db/tests/useLiveInfiniteQuery.test.tsx (2)
1640-1670: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSkipped test leaves the
orderByvalidation error path uncovered.The throw at
packages/octane-db/src/useLiveInfiniteQuery.tslines 240-244 now has no coverage. Since Octane surfaces it from a passive effect rather than during render, assert on it via the effect instead ofexpect(renderHook).toThrow— e.g. spy on the error channel after flushing effects, or expose the validation as a synchronous check during render so it behaves like the other input validation at lines 154-159.Want me to write the effect-based version of this test, or open an issue to track it?
As per coding guidelines: "Always add unit tests that reproduce a bug before fixing it to ensure the bug is fixed and prevent regression".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/octane-db/tests/useLiveInfiniteQuery.test.tsx` around lines 1640 - 1670, Replace the skipped test around useLiveInfiniteQuery with an active regression test for the missing-orderBy validation. Because the error is emitted from a passive effect rather than render, flush effects and assert through the established error channel instead of using expect(renderHook).toThrow; preserve the existing collection setup and ORDER BY/setWindow() validation expectation.Source: Coding guidelines
10-11: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse a shared test entry instead of importing
@tanstack/dbinternals.mockSyncCollectionOptionsis only exported frompackages/db/tests/utils.js, andcreateFilterFunctionFromExpressioncomes frompackages/db/src/collection/change-events.js, so this adapter test is coupled to another package’s internal path instead of using the package’s public API or a shared test-utils entry.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/octane-db/tests/useLiveInfiniteQuery.test.tsx` around lines 10 - 11, Update useLiveInfiniteQuery.test.tsx to stop importing mockSyncCollectionOptions and createFilterFunctionFromExpression through packages/db test or source internals; use the shared test entry or public `@tanstack/db` API that exposes these helpers instead, while preserving the test behavior.packages/octane-db/tests/useLiveSuspenseQuery.test.tsx (2)
13-13: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuechildren: unknownis looser than needed. Use Octane's node type (e.g.JSX.Element/ the framework'sNodetype) so the wrappers get real type checking on what they render.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/octane-db/tests/useLiveSuspenseQuery.test.tsx` at line 13, Update the ChildrenProps type used by the test wrappers to replace children: unknown with Octane’s node type, such as JSX.Element or the framework’s established Node type, so rendered children receive proper type checking.Source: Coding guidelines
662-668: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueTest reaches into
collection._syncinternals. Underscore-prefixed access couples this suite to private plumbing; if@tanstack/dbexposes (or can expose) a public helper for tracking a load promise, prefer that.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/octane-db/tests/useLiveSuspenseQuery.test.tsx` around lines 662 - 668, Update the test around the live query collection’s load-promise setup to use a public API for tracking the promise instead of reaching through collection._sync.trackLoadPromise. Reuse an existing exposed helper if available, or add the smallest public helper needed, while preserving the assertions that isLoadingSubset is true and status remains ready.Source: Coding guidelines
packages/octane-db/tests/usePacedMutations.test.tsx (2)
44-47: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuelet txis implicitlyany. Annotate asTransaction<Item>(orTransaction<Item> | undefined) sotx!.stateandtx!.isPersistedare actually type-checked.Also applies to: 83-86, 121-124
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/octane-db/tests/usePacedMutations.test.tsx` around lines 44 - 47, Annotate the transaction variables assigned from result.current in the affected usePacedMutations test cases as Transaction<Item> (or Transaction<Item> | undefined), including the cases around lines 44, 83, and 121, so subsequent tx!.state and tx!.isPersisted accesses are type-checked.Source: Coding guidelines
21-32: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the identical "create + ready a collection" setup. The same six lines (create with
mockSyncCollectionOptionsNoInitialState, preload, begin/commit/markReady, await) appear verbatim in all three smoke tests, and all three reuse the idtest. A small helper taking a unique id removes the duplication and the id collision.♻️ Suggested helper
+async function createReadyCollection(id: string) { + const collection = createCollection( + mockSyncCollectionOptionsNoInitialState<Item>({ + id, + getKey: (item) => item.id, + }), + ) + const preloadPromise = collection.preload() + collection.utils.begin() + collection.utils.commit() + collection.utils.markReady() + await preloadPromise + return collection +}- const collection = createCollection( - mockSyncCollectionOptionsNoInitialState<Item>({ - id: `test`, - getKey: (item) => item.id, - }), - ) - - const preloadPromise = collection.preload() - collection.utils.begin() - collection.utils.commit() - collection.utils.markReady() - await preloadPromise + const collection = await createReadyCollection(`paced-debounce`)Also applies to: 60-71, 98-109
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/octane-db/tests/usePacedMutations.test.tsx` around lines 21 - 32, Extract the repeated collection initialization sequence from the three smoke tests into a shared async helper that accepts a unique collection id, creates the collection with mockSyncCollectionOptionsNoInitialState, preloads it, runs begin/commit/markReady, awaits preload completion, and returns the ready collection. Replace each duplicated setup with this helper and pass a distinct id for each test instead of reusing “test”.Source: Coding guidelines
packages/octane-db/tests/useLiveQuery.test.tsx (2)
1227-1228: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winThree comments state the opposite of the assertion they precede. Line 1227 says "isLoading should be true" before
expect(...isLoading).toBe(false); Line 1463 says "transitions from false to true" (it's true→false); Line 1506 says "Initially should be false" beforeexpect(...).toBe(true). Inverted comments are worse than none here.Also applies to: 1462-1463, 1506-1507
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/octane-db/tests/useLiveQuery.test.tsx` around lines 1227 - 1228, Correct the three misleading comments in the live-query tests: update the comment near the pre-created syncing collection to state that isLoading is false, the transition comment near line 1463 to describe true-to-false behavior, and the initial-state comment near line 1506 to state that isLoading is true. Leave the assertions unchanged.Source: Coding guidelines
90-90: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDuplicate collection ids reused across independent tests. Both ported suites create multiple collections under the same ids, which muddies debugging and risks interference if any id-keyed registry behavior changes.
packages/octane-db/tests/useLiveQuery.test.tsx#L90-L90: give each collection a unique id instead of reusingtest-persons(L90, L126) andtest-persons-2(L168, L202, L237, L274).packages/octane-db/tests/useLiveQuery.test-d.tsx#L27-L27: give each of the four type tests its own id instead of reusingtest-persons-2(L27, L50, L74, L104).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/octane-db/tests/useLiveQuery.test.tsx` at line 90, Use distinct collection ids for every independent test in packages/octane-db/tests/useLiveQuery.test.tsx, replacing repeated test-persons and test-persons-2 values at all referenced locations. Also assign unique ids to each of the four type tests in packages/octane-db/tests/useLiveQuery.test-d.tsx instead of reusing test-persons-2; no other test behavior needs to change.packages/octane-db/tests/conformance.test.tsx (1)
1-11: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueStale React references in the Octane driver docs. The header says the realm-sensitive imports come from the "React package's
@tanstack/db", and Line 139 calls null-return "React's disabled convention". Retitle both to Octane to avoid confusion for the next porter.♻️ Suggested wording
- * Everything realm-sensitive — collection creation and query operators — is - * imported here (React package's `@tanstack/db`) and handed to the shared - * scenarios, so instances match what this package's `useLiveQuery` expects. + * Everything realm-sensitive — collection creation and query operators — is + * imported here (this package's `@tanstack/db` realm) and handed to the shared + * scenarios, so instances match what this package's `useLiveQuery` expects.- // React's disabled convention: the query callback returns null. + // Octane adapter's disabled convention: the query callback returns null.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/octane-db/tests/conformance.test.tsx` around lines 1 - 11, Update the Octane driver documentation to remove stale React references: revise the header comment to identify the imports as coming from Octane’s `@tanstack/db`, and update the null-return wording near the disabled-convention documentation to refer to Octane rather than React. Keep the documented behavior unchanged.Source: Coding guidelines
packages/octane-db/tests/useLiveQuery.test-d.tsx (1)
42-44: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAlign
expectTypeOfmatchers totoExtend. This file already usestoExtendfor collection assertions, but thedataassertions still use the deprecatedtoMatchTypeOf; replace the remaining occurrences at lines 42, 66, 96, and 124.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/octane-db/tests/useLiveQuery.test-d.tsx` around lines 42 - 44, Replace the deprecated toMatchTypeOf matcher with toExtend in the data assertions of useLiveQuery tests at the referenced occurrences, while preserving each existing expected type and assertion structure.🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Inline comments: In `@docs/framework/octane/overview.md`: - Around line 26-33: Update the Octane documentation examples, including TodoList and the snippets around postsCollection, category, and gt, so every referenced identifier is either declared in the example setup or imported from the appropriate package. Add only the minimal shared setup needed, or explicitly indicate that values are defined earlier, and ensure each snippet compiles as written. In `@packages/octane-db/skills/octane-db/SKILL.md`: - Around line 220-232: Update the comment following the useLiveQuery projection to document project.issues as an array of objects containing id and title, matching the objects selected inside toArray, rather than string[]. - Around line 135-143: Update the useLiveInfiniteQuery call to either apply category in the query predicate so changing category affects results, or remove category from the dependency array if the query is intentionally category-independent; keep the remaining pagination and ordering behavior unchanged. - Around line 19-23: Register useLiveQueryEffect consistently across the Octane metadata: in packages/octane-db/skills/octane-db/SKILL.md at lines 19-23 add useLiveQueryEffect.ts to the source list, and at lines 57-59 add its hook section; in _artifacts/skill_tree.yaml at lines 172-185 include the hook in the description and source references; in domain_map.yaml at lines 306-308 add it to config_surface. In `@packages/octane-db/src/slot.ts`: - Around line 23-29: Adopt splitTrailingSlot as the single non-mutating implementation for trailing slot extraction. In packages/octane-db/src/slot.ts:23-29, retain or extend splitTrailingSlot to provide the parsed argument array needed by callers; update packages/octane-db/src/useLiveQuery.ts:322-326, packages/octane-db/src/useLiveQueryEffect.ts:39-42, packages/octane-db/src/useLiveSuspenseQuery.ts:160-164, packages/octane-db/src/usePacedMutations.ts:101-104, and packages/octane-db/src/useLiveInfiniteQuery.ts:141-145 to call it, using the returned args for deps where required and eliminating inline rest-array mutation. In `@packages/octane-db/src/useLiveInfiniteQuery.ts`: - Around line 18-22: Update isLiveQueryCollectionUtils to handle null and undefined inputs before accessing setWindow, returning false for absent utils while preserving the existing function-type check for populated values. - Around line 147-148: Update the pageSize defaulting in useLiveInfiniteQuery to use nullish coalescing so an explicit 0 is not silently replaced with 20. If pageSize 0 is invalid, add explicit validation and reject it rather than allowing empty-page fetchNextPage loops; leave initialPageParam unchanged. In `@packages/octane-db/src/useLiveSuspenseQuery.ts`: - Around line 170-184: Namespace nested useLiveQuery calls to prevent ref-slot collisions: in packages/octane-db/src/useLiveSuspenseQuery.ts lines 170-184, pass subSlot(slot, 'lq') to the useLiveQuery call; in packages/octane-db/src/useLiveInfiniteQuery.ts lines 172-175, pass the same namespaced slot to both useLiveQuery calls. Preserve the existing collection-change reset logic in each wrapper. --- Nitpick comments: In `@packages/octane-db/src/useLiveInfiniteQuery.ts`: - Around line 182-191: Replace the JSON.stringify-based dependency key logic in useLiveInfiniteQuery with element-wise identity comparison matching useLiveQuery, using the existing previous-dependencies ref and deriving depsChanged from that comparison. Preserve the effect’s update behavior by assigning the current deps to prevDepsRef.current after processing, and remove the obsolete serialization-error path and test. In `@packages/octane-db/tests/conformance.test.tsx`: - Around line 1-11: Update the Octane driver documentation to remove stale React references: revise the header comment to identify the imports as coming from Octane’s `@tanstack/db`, and update the null-return wording near the disabled-convention documentation to refer to Octane rather than React. Keep the documented behavior unchanged. In `@packages/octane-db/tests/useLiveInfiniteQuery.test.tsx`: - Around line 1640-1670: Replace the skipped test around useLiveInfiniteQuery with an active regression test for the missing-orderBy validation. Because the error is emitted from a passive effect rather than render, flush effects and assert through the established error channel instead of using expect(renderHook).toThrow; preserve the existing collection setup and ORDER BY/setWindow() validation expectation. - Around line 10-11: Update useLiveInfiniteQuery.test.tsx to stop importing mockSyncCollectionOptions and createFilterFunctionFromExpression through packages/db test or source internals; use the shared test entry or public `@tanstack/db` API that exposes these helpers instead, while preserving the test behavior. In `@packages/octane-db/tests/useLiveQuery.test-d.tsx`: - Around line 42-44: Replace the deprecated toMatchTypeOf matcher with toExtend in the data assertions of useLiveQuery tests at the referenced occurrences, while preserving each existing expected type and assertion structure. In `@packages/octane-db/tests/useLiveQuery.test.tsx`: - Around line 1227-1228: Correct the three misleading comments in the live-query tests: update the comment near the pre-created syncing collection to state that isLoading is false, the transition comment near line 1463 to describe true-to-false behavior, and the initial-state comment near line 1506 to state that isLoading is true. Leave the assertions unchanged. - Line 90: Use distinct collection ids for every independent test in packages/octane-db/tests/useLiveQuery.test.tsx, replacing repeated test-persons and test-persons-2 values at all referenced locations. Also assign unique ids to each of the four type tests in packages/octane-db/tests/useLiveQuery.test-d.tsx instead of reusing test-persons-2; no other test behavior needs to change. In `@packages/octane-db/tests/useLiveSuspenseQuery.test.tsx`: - Line 13: Update the ChildrenProps type used by the test wrappers to replace children: unknown with Octane’s node type, such as JSX.Element or the framework’s established Node type, so rendered children receive proper type checking. - Around line 662-668: Update the test around the live query collection’s load-promise setup to use a public API for tracking the promise instead of reaching through collection._sync.trackLoadPromise. Reuse an existing exposed helper if available, or add the smallest public helper needed, while preserving the assertions that isLoadingSubset is true and status remains ready. In `@packages/octane-db/tests/usePacedMutations.test.tsx`: - Around line 44-47: Annotate the transaction variables assigned from result.current in the affected usePacedMutations test cases as Transaction<Item> (or Transaction<Item> | undefined), including the cases around lines 44, 83, and 121, so subsequent tx!.state and tx!.isPersisted accesses are type-checked. - Around line 21-32: Extract the repeated collection initialization sequence from the three smoke tests into a shared async helper that accepts a unique collection id, creates the collection with mockSyncCollectionOptionsNoInitialState, preloads it, runs begin/commit/markReady, awaits preload completion, and returns the ready collection. Replace each duplicated setup with this helper and pass a distinct id for each test instead of reusing “test”.🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID:
a9941cbc-6d8f-4dea-93f1-cb4c32476bdb📥 Commits
Reviewing files that changed from the base of the PR and between 67c840fe7a45d818de768fa790ebec2f27654d04 and 2235dfe5e2fe6d38a1a7ff85df152acfe94cab64.
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (32)
.changeset/octane-db-package.md_artifacts/skill_tree.yamldocs/framework/octane/overview.mddocs/framework/octane/reference/index.mddocs/installation.mddomain_map.yamlpackages/db/src/live-query-adapter.tspackages/octane-db/CHANGELOG.mdpackages/octane-db/README.mdpackages/octane-db/package.jsonpackages/octane-db/skills/octane-db/SKILL.mdpackages/octane-db/src/index.tspackages/octane-db/src/slot.tspackages/octane-db/src/useLiveInfiniteQuery.tspackages/octane-db/src/useLiveQuery.tspackages/octane-db/src/useLiveQueryEffect.tspackages/octane-db/src/useLiveSuspenseQuery.tspackages/octane-db/src/usePacedMutations.tspackages/octane-db/tests/conformance.test.tsxpackages/octane-db/tests/test-setup.tspackages/octane-db/tests/useLiveInfiniteQuery.test.tsxpackages/octane-db/tests/useLiveQuery.eager-onstorechange.test.tsxpackages/octane-db/tests/useLiveQuery.test-d.tsxpackages/octane-db/tests/useLiveQuery.test.tsxpackages/octane-db/tests/useLiveQueryEffect.test.tsxpackages/octane-db/tests/useLiveSuspenseQuery.test.tsxpackages/octane-db/tests/usePacedMutations.test.tsxpackages/octane-db/tsconfig.docs.jsonpackages/octane-db/tsconfig.jsonpackages/octane-db/vite.config.tsscripts/generate-docs.tsskill_spec.md
docs/framework/octane/overview.md lines 28 to 35Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +13,21 @@13+14+`@tanstack/octane-db` re-exports everything from `@tanstack/db`. Import collections, query helpers, and hooks from `@tanstack/octane-db`.15+16+## Octane Hooks17+18+See the [Octane Functions Reference](./reference/index.md) for the full hook list.19+20+For comprehensive documentation on writing queries (filtering, joins, aggregations, etc.), see the [Live Queries Guide](../../guides/live-queries).21+22+## Basic Usage23+24+### useLiveQuery25+26+```tsx27+import { useLiveQuery, eq } from '@tanstack/octane-db'28+29+function TodoList() {30+ const { data, isLoading } = useLiveQuery((q) =>31+ q.from({ todos: todosCollection })32+ .where(({ todos }) => eq(todos.completed, false))33+ .select(({ todos }) => ({ id: todos.id, text: todos.text }))🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Make the Octane examples compile as written.
These snippets reference undeclared or unimported identifiers such as
todosCollection,postsCollection,category, andgt. Add minimal setup/imports or explicitly state that these values are defined earlier.Also applies to: 50-60, 64-76, 83-92
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@docs/framework/octane/overview.md` around lines 26 - 33, Update the Octane documentation examples, including TodoList and the snippets around postsCollection, category, and gt, so every referenced identifier is either declared in the example setup or imported from the appropriate package. Add only the minimal shared setup needed, or explicitly indicate that values are defined earlier, and ensure each snippet compiles as written.✅ Addressed in commit f2d1096
packages/octane-db/skills/octane-db/SKILL.md lines 19 to 23Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +3,21 @@3+description: >4+ Octane bindings for TanStack DB. useLiveQuery hook with dependency arrays5+ (8 overloads: query function, config object, pre-created collection,6+ disabled state via returning undefined/null). useLiveSuspenseQuery for7+ Octane Suspense with Error Boundaries (data always defined).8+ useLiveInfiniteQuery for cursor-based pagination (pageSize, fetchNextPage,9+ hasNextPage, isFetchingNextPage). usePacedMutations for debounced Octane10+ state updates. Return shape: data, state, collection, status, isLoading,11+ isReady, isError. Import from @tanstack/octane-db (re-exports all of12+ @tanstack/db).13+type: framework14+library: db15+framework: octane16+library_version: '0.6.0'17+requires:18+ - db-core19+sources:20+ - 'TanStack/db:docs/framework/octane/overview.md'21+ - 'TanStack/db:docs/guides/live-queries.md'22+ - 'TanStack/db:packages/octane-db/src/useLiveQuery.ts'23+ - 'TanStack/db:packages/octane-db/src/useLiveInfiniteQuery.ts'📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Register
useLiveQueryEffectconsistently across Octane metadata. The package exports it inpackages/octane-db/src/index.tsLine 6 and the reference lists it indocs/framework/octane/reference/index.mdLine 9, but the skill and domain registrations omit it.packages/octane-db/skills/octane-db/SKILL.md#L19-L23: adduseLiveQueryEffect.tsto the source list.packages/octane-db/skills/octane-db/SKILL.md#L57-L59: add auseLiveQueryEffecthook section._artifacts/skill_tree.yaml#L172-L185: include the hook in the description and source references.domain_map.yaml#L306-L308: include the hook inconfig_surface.
📍 Affects 3 files
packages/octane-db/skills/octane-db/SKILL.md#L19-L23(this comment)packages/octane-db/skills/octane-db/SKILL.md#L57-L59_artifacts/skill_tree.yaml#L172-L185domain_map.yaml#L306-L308
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/octane-db/skills/octane-db/SKILL.md` around lines 19 - 23, Register useLiveQueryEffect consistently across the Octane metadata: in packages/octane-db/skills/octane-db/SKILL.md at lines 19-23 add useLiveQueryEffect.ts to the source list, and at lines 57-59 add its hook section; in _artifacts/skill_tree.yaml at lines 172-185 include the hook in the description and source references; in domain_map.yaml at lines 306-308 add it to config_surface.✅ Addressed in commit f2d1096
packages/octane-db/skills/octane-db/SKILL.md lines 136 to 145Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +123,21 @@123+const { data } = useLiveSuspenseQuery(124+ (q) =>125+ q126+ .from({ todo: todoCollection })127+ .where(({ todo }) => eq(todo.category, category)),128+ [category],129+)130+```131+132+### useLiveInfiniteQuery133+134+```tsx135+const { data, fetchNextPage, hasNextPage, isFetchingNextPage } =136+ useLiveInfiniteQuery(137+ (q) =>138+ q139+ .from({ posts: postsCollection })140+ .orderBy(({ posts }) => posts.createdAt, 'desc'),141+ { pageSize: 20 },142+ [category],143+ )🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use
categoryin the infinite query or remove it from dependencies.The example recreates the query when
categorychanges, but the query never filters or otherwise referencescategory. Add the intended predicate, or remove[category].🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/octane-db/skills/octane-db/SKILL.md` around lines 135 - 143, Update the useLiveInfiniteQuery call to either apply category in the query predicate so changing category affects results, or remove category from the dependency array if the query is intentionally category-independent; keep the remaining pagination and ordering behavior unchanged.✅ Addressed in commit f2d1096
packages/octane-db/skills/octane-db/SKILL.md lines 220 to 232OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +212,21 @@212+213+Only the affected `IssueList` re-renders when an issue changes — the parent does not.214+215+With `toArray()`, child results are plain arrays and the parent re-renders on child changes:216+217+```tsx218+import { toArray, eq } from '@tanstack/octane-db'219+220+const { data: projects } = useLiveQuery((q) =>221+ q.from({ p: projectsCollection }).select(({ p }) => ({222+ id: p.id,223+ name: p.name,224+ issues: toArray(225+ q226+ .from({ i: issuesCollection })227+ .where(({ i }) => eq(i.projectId, p.id))228+ .select(({ i }) => ({ id: i.id, title: i.title })),229+ ),230+ })),231+)232+// project.issues is string[] — no subcomponent needed🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Correct the documented
toArray()result type.The projection returns
{ id, title }objects, soproject.issuesis an array of objects, notstring[].🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/octane-db/skills/octane-db/SKILL.md` around lines 220 - 232, Update the comment following the useLiveQuery projection to document project.issues as an array of objects containing id and title, matching the objects selected inside toArray, rather than string[].✅ Addressed in commit f2d1096
packages/octane-db/src/slot.ts lines 23 to 29Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +9,21 @@9+ tag: string,10+): symbol | undefined {11+ if (slot === undefined) return undefined12+ let byTag = subSlotCache.get(slot)13+ if (byTag === undefined) subSlotCache.set(slot, (byTag = new Map()))14+ let sym = byTag.get(tag)15+ if (sym === undefined) {16+ sym = Symbol.for(`${slot.description ?? ``}:${tag}`)17+ byTag.set(tag, sym)18+ }19+ return sym20+}21+22+/** Split a compiler-injected trailing slot symbol off hook runtime args. */23+export function splitTrailingSlot<T extends Array<unknown>>(24+ args: T,25+): [Array<unknown>, symbol | undefined] {26+ const tail = args[args.length - 1]27+ const slot = typeof tail === `symbol` ? tail : undefined28+ return [slot !== undefined ? args.slice(0, -1) : args, slot]29+}📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
splitTrailingSlotis unused while all five hooks re-implement it inline. The shared root cause is that the helper was added toslot.tsbut never adopted; each hook hand-rollstypeof rest[rest.length - 1] === 'symbol' ? rest.pop() : undefined, which also mutates the caller's rest array in place.packages/octane-db/src/slot.ts#L23-L29: keep the helper as the single implementation; consider returning the deps array too so callers don't indexrest[0]separately.packages/octane-db/src/useLiveQuery.ts#L322-L326: replace the inline extraction withconst [args, slot] = splitTrailingSlot(rest)and readdepsfromargs[0].packages/octane-db/src/useLiveQueryEffect.ts#L39-L42: replace withconst [, slot] = splitTrailingSlot(rest).packages/octane-db/src/useLiveSuspenseQuery.ts#L160-L164: replace withsplitTrailingSlot(rest)and derivedepsfrom the returned args.packages/octane-db/src/usePacedMutations.ts#L101-L104: replace withconst [, slot] = splitTrailingSlot(rest).packages/octane-db/src/useLiveInfiniteQuery.ts#L141-L145: replace withsplitTrailingSlot(rest)and derivedepsfrom the returned args.
As per coding guidelines: "Extract common logic into utility functions when identical or near-identical code blocks appear in multiple places".
📍 Affects 6 files
packages/octane-db/src/slot.ts#L23-L29(this comment)packages/octane-db/src/useLiveQuery.ts#L322-L326packages/octane-db/src/useLiveQueryEffect.ts#L39-L42packages/octane-db/src/useLiveSuspenseQuery.ts#L160-L164packages/octane-db/src/usePacedMutations.ts#L101-L104packages/octane-db/src/useLiveInfiniteQuery.ts#L141-L145
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/octane-db/src/slot.ts` around lines 23 - 29, Adopt splitTrailingSlot as the single non-mutating implementation for trailing slot extraction. In packages/octane-db/src/slot.ts:23-29, retain or extend splitTrailingSlot to provide the parsed argument array needed by callers; update packages/octane-db/src/useLiveQuery.ts:322-326, packages/octane-db/src/useLiveQueryEffect.ts:39-42, packages/octane-db/src/useLiveSuspenseQuery.ts:160-164, packages/octane-db/src/usePacedMutations.ts:101-104, and packages/octane-db/src/useLiveInfiniteQuery.ts:141-145 to call it, using the returned args for deps where required and eliminating inline rest-array mutation.Source: Coding guidelines
✅ Addressed in commit f2d1096
packages/octane-db/src/useLiveInfiniteQuery.ts lines 18 to 26Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +2,21 @@2+import { CollectionImpl } from '@tanstack/db'3+import { subSlot } from './slot'4+import { useLiveQuery } from './useLiveQuery'5+import type {6+ Collection,7+ Context,8+ InferResultType,9+ InitialQueryBuilder,10+ LiveQueryCollectionUtils,11+ NonSingleResult,12+ QueryBuilder,13+} from '@tanstack/db'14+15+/**16+ * Type guard to check if utils object has setWindow method (LiveQueryCollectionUtils)17+ */18+function isLiveQueryCollectionUtils(19+ utils: unknown,20+): utils is LiveQueryCollectionUtils {21+ return typeof (utils as any).setWindow === `function`22+}🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Type guard dereferences
utilswithout a null check.Declared as accepting
unknown, but(utils as any).setWindowthrows aTypeErrorwhenutilsisnull/undefined. At the call site (line 237)utilscomes fromqueryResult.collection.utils, which is not guaranteed to be populated for an arbitrary pre-created collection.🛡️ Proposed fix
function isLiveQueryCollectionUtils( utils: unknown, ): utils is LiveQueryCollectionUtils { - return typeof (utils as any).setWindow === `function` + return ( + typeof utils === `object` && + utils !== null && + typeof (utils as { setWindow?: unknown }).setWindow === `function` + ) }📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
Suggested change18+function isLiveQueryCollectionUtils(19+ utils: unknown,20+): utils is LiveQueryCollectionUtils {21+ return (22+ typeof utils === `object` &&23+ utils !== null &&24+ typeof (utils as { setWindow?: unknown }).setWindow === `function`25+ )26+}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/octane-db/src/useLiveInfiniteQuery.ts` around lines 18 - 22, Update isLiveQueryCollectionUtils to handle null and undefined inputs before accessing setWindow, returning false for absent utils while preserving the existing function-type check for populated values.✅ Addressed in commit f2d1096
packages/octane-db/src/useLiveInfiniteQuery.ts lines 147 to 148OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +128,21 @@128+// Overload for query function129+export function useLiveInfiniteQuery<TContext extends Context>(130+ queryFn: (q: InitialQueryBuilder) => QueryBuilder<TContext>,131+ config: UseLiveInfiniteQueryConfig<TContext>,132+ deps?: Array<unknown>,133+): UseLiveInfiniteQueryReturn<TContext>134+135+// Implementation136+export function useLiveInfiniteQuery<TContext extends Context>(137+ queryFnOrCollection: any,138+ config: UseLiveInfiniteQueryConfig<TContext>,139+ ...rest: Array<unknown>140+): UseLiveInfiniteQueryReturn<TContext> {141+ const slot =142+ typeof rest[rest.length - 1] === `symbol`143+ ? (rest.pop() as symbol)144+ : undefined145+ const deps = (rest[0] as Array<unknown> | undefined) ?? []146+147+ const pageSize = config.pageSize || 20148+ const initialPageParam = config.initialPageParam ?? 0🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
pageSize: 0silently becomes 20.||treats0as absent. Line 148 already uses??forinitialPageParam; be consistent. If0is genuinely invalid, reject it explicitly rather than substituting a default (notepageSize: 0would also makefetchNextPagea no-op loop over empty pages).As per coding guidelines: "Use the nullish coalescing operator
??for default values instead of checking for null and undefined separately" and "Handle limit and offset edge cases: consider what happens when limit is 0".🐛 Proposed fix
- const pageSize = config.pageSize || 20 + const pageSize = config.pageSize ?? 20 + if (pageSize <= 0) { + throw new Error( + `useLiveInfiniteQuery: pageSize must be a positive integer. Received: ${pageSize}`, + ) + } const initialPageParam = config.initialPageParam ?? 0📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
Suggested change147- const pageSize = config.pageSize || 20148- const initialPageParam = config.initialPageParam ?? 0147+ const pageSize = config.pageSize ?? 20148+ if (pageSize <= 0) {149+ throw new Error(150+ `useLiveInfiniteQuery: pageSize must be a positive integer. Received: ${pageSize}`,151+ )152+ }153+ const initialPageParam = config.initialPageParam ?? 0🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/octane-db/src/useLiveInfiniteQuery.ts` around lines 147 - 148, Update the pageSize defaulting in useLiveInfiniteQuery to use nullish coalescing so an explicit 0 is not silently replaced with 20. If pageSize 0 is invalid, add explicit validation and reject it rather than allowing empty-page fetchNextPage loops; leave initialPageParam unchanged.Source: Coding guidelines
✅ Addressed in commit f2d1096
packages/octane-db/src/useLiveSuspenseQuery.ts lines 167 to 187Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +164,21 @@164+ const deps = (rest[0] as Array<unknown> | undefined) ?? []165+166+ const promiseRef = useRef<Promise<void> | null>(167+ null,168+ subSlot(slot, `promise-ref`),169+ )170+ const collectionRef = useRef<Collection<any, any, any> | null>(171+ null,172+ subSlot(slot, `coll-ref`),173+ )174+ const hasBeenReadyRef = useRef(false, subSlot(slot, `ready-ref`))175+176+ // Use useLiveQuery to handle collection management and reactivity177+ const result = (useLiveQuery as any)(configOrQueryOrCollection, deps, slot)178+179+ // Reset promise and ready state when collection changes (deps changed)180+ if (collectionRef.current !== result.collection) {181+ promiseRef.current = null182+ collectionRef.current = result.collection183+ hasBeenReadyRef.current = false184+ }🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
Wrapper hooks forward their parent slot verbatim into
useLiveQuery, so sub-slot tags collide. Both wrappers pass the sameslotsymbol down touseLiveQuery, which derives its own refs withsubSlot(slot, 'coll-ref')(packages/octane-db/src/useLiveQuery.tsline 333). Each wrapper independently uses the tagcoll-refagainst that same parent slot, sosubSlothands both hooks the identical symbol and they alias one ref cell — defeating each wrapper's "did the collection change?" check. Namespace the nested call (e.g.subSlot(slot, 'lq')) so the child hook's tag space is disjoint from the parent's.packages/octane-db/src/useLiveSuspenseQuery.ts#L170-L184: passsubSlot(slot, 'lq')to theuseLiveQuerycall on line 177 sopromiseRef/hasBeenReadyRefactually reset when the collection changes.packages/octane-db/src/useLiveInfiniteQuery.ts#L172-L175: passsubSlot(slot, 'lq')to bothuseLiveQuerycalls on lines 219 and 226 so the pre-created-collection reset at line 195 can fire.
📍 Affects 2 files
packages/octane-db/src/useLiveSuspenseQuery.ts#L170-L184(this comment)packages/octane-db/src/useLiveInfiniteQuery.ts#L172-L175
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/octane-db/src/useLiveSuspenseQuery.ts` around lines 170 - 184, Namespace nested useLiveQuery calls to prevent ref-slot collisions: in packages/octane-db/src/useLiveSuspenseQuery.ts lines 170-184, pass subSlot(slot, 'lq') to the useLiveQuery call; in packages/octane-db/src/useLiveInfiniteQuery.ts lines 172-175, pass the same namespaced slot to both useLiveQuery calls. Preserve the existing collection-change reset logic in each wrapper.✅ Addressed in commit f2d1096
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Inline comments: In `@docs/framework/octane/overview.md`: - Around line 70-83: Update the useLiveInfiniteQuery example to demonstrate pagination by adding a “Load more” control that is rendered only when hasNextPage is true and invokes fetchNextPage when activated; keep the existing query and page-parameter logic unchanged.🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID:
61b61441-d0d3-4c4b-b7e7-8776228b6c34📥 Commits
Reviewing files that changed from the base of the PR and between 2235dfe5e2fe6d38a1a7ff85df152acfe94cab64 and f2d1096cd768bce8160e1e697f905015a1ac593f.
📒 Files selected for processing (9)
_artifacts/skill_tree.yamldocs/framework/octane/overview.mddomain_map.yamlpackages/octane-db/skills/octane-db/SKILL.mdpackages/octane-db/src/useLiveInfiniteQuery.tspackages/octane-db/src/useLiveQuery.tspackages/octane-db/src/useLiveQueryEffect.tspackages/octane-db/src/useLiveSuspenseQuery.tspackages/octane-db/src/usePacedMutations.ts
🚧 Files skipped from review as they are similar to previous changes (8)
- domain_map.yaml
- _artifacts/skill_tree.yaml
- packages/octane-db/skills/octane-db/SKILL.md
- packages/octane-db/src/useLiveQueryEffect.ts
- packages/octane-db/src/usePacedMutations.ts
- packages/octane-db/src/useLiveInfiniteQuery.ts
- packages/octane-db/src/useLiveSuspenseQuery.ts
- packages/octane-db/src/useLiveQuery.ts
docs/framework/octane/overview.md lines 70 to 83OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +63,21 @@63+64+### useLiveInfiniteQuery65+66+```tsx67+import { useLiveInfiniteQuery, eq } from '@tanstack/octane-db'68+69+function PostFeed({ category }: { category: string }) {70+ const { data, pages, fetchNextPage, hasNextPage } = useLiveInfiniteQuery(71+ (q) => q72+ .from({ posts: postsCollection })73+ .where(({ posts }) => eq(posts.category, category))74+ .orderBy(({ posts }) => posts.createdAt, 'desc'),75+ {76+ pageSize: 20,77+ getNextPageParam: (lastPage, allPages) =>78+ lastPage.length === 20 ? allPages.length : undefined79+ },80+ [category]81+ )82+83+ return <div>{data.length} posts loaded</div>🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Demonstrate fetching subsequent pages.
The example destructures
fetchNextPageandhasNextPagebut never uses them, so it does not show how the feed actually loads more results. Add a guarded “Load more” control invokingfetchNextPage, or remove those values from the example.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@docs/framework/octane/overview.md` around lines 70 - 83, Update the useLiveInfiniteQuery example to demonstrate pagination by adding a “Load more” control that is rendered only when hasNextPage is true and invokes fetchNextPage when activated; keep the existing query and page-parameter logic unchanged.✅ Addressed in commit f212053
hey this is great! Could you port this though on top of @kevin-dp's in-progress refactor to a live query framework binding library? https://github.com/TanStack/db/pull/1675 & RFC https://github.com/TanStack/db/issues/1623
Can this be added to the octane repository under packages/bindings like other tanstack product adaptations for octane ?
Sign in to join this conversation.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID:
bb3d8e36-9b09-4d58-9051-57e72e65c0e9📥 Commits
Reviewing files that changed from the base of the PR and between f2d1096cd768bce8160e1e697f905015a1ac593f and f21205347f73e6a091f1b46207d56c7de4148274.
📒 Files selected for processing (1)
docs/framework/octane/overview.md🚧 Files skipped from review as they are similar to previous changes (1)
📝 Walkthrough
Walkthrough#
Adds
@tanstack/octane-dbwith Octane-compatible live-query, Suspense, infinite-query, effect, and paced-mutation hooks, compiler slot support, package tooling, tests, generated references, installation guidance, and skill metadata.Changes#
Octane DB adapter
.changeset/*,packages/octane-db/package.json,packages/octane-db/src/index.ts,packages/octane-db/tsconfig*.json,packages/octane-db/vite.config.ts,docs/framework/octane/*,docs/installation.md,scripts/generate-docs.ts,domain_map.yaml,_artifacts/skill_tree.yamlpackages/octane-db/src/slot.ts,packages/octane-db/src/useLiveQuery.ts,packages/db/src/live-query-adapter.tspackages/octane-db/src/useLiveSuspenseQuery.ts,packages/octane-db/src/useLiveQueryEffect.ts,packages/octane-db/src/usePacedMutations.tspackages/octane-db/src/useLiveInfiniteQuery.tshasNextPagedetection, dependency and collection resets, and flattened pagination results.packages/octane-db/tests/*Estimated code review effort: 5 (Critical) | ~120 minutes
Sequence Diagram(s)#
🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)#
✅ Passed checks (3 passed)
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share