Uh oh!
There was an error while loading. Please reload this page.
feat(svelte-db): add infinite query binding - #1723
Conversation
Co-authored-by: Reijhanniel Jearl Campos <devcsrj@gmail.com>
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughChangesAdds the Svelte Svelte live infinite query
Estimated code review effort: 4 (Complex) | ~45 minutes Mergeability Score:⚪ Minimal · up to This PR adds the Svelte infinite-query binding and associated tests and release metadata; no actionable merge-blocking risk remains beyond normal checks and review. Sequence Diagram(s)sequenceDiagram
participant SvelteComponent
participant useLiveInfiniteQuery
participant createLiveQueryWindowController
participant LiveQueryCollection
SvelteComponent->>useLiveInfiniteQuery: invoke query binding
useLiveInfiniteQuery->>LiveQueryCollection: resolve or create ordered collection
useLiveInfiniteQuery->>createLiveQueryWindowController: initialize controller
createLiveQueryWindowController->>LiveQueryCollection: configure collection window
createLiveQueryWindowController-->>useLiveInfiniteQuery: publish snapshot
useLiveInfiniteQuery-->>SvelteComponent: expose reactive query state
SvelteComponent->>useLiveInfiniteQuery: fetchNextPage()
useLiveInfiniteQuery->>createLiveQueryWindowController: fetch next page
createLiveQueryWindowController-->>useLiveInfiniteQuery: publish updated snapshot
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 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 `@packages/svelte-db/src/useLiveInfiniteQuery.svelte.ts`:
- Around line 141-145: Update the pageSize derivation in useLiveInfiniteQuery so
only positive integers from config.pageSize are accepted; fractional, zero,
negative, and otherwise invalid values must use DEFAULT_PAGE_SIZE. Ensure the
validated integer is the value passed to limit() and the window controller.
- Around line 117-126: Update useLiveInfiniteQuery so its configuration and
return types are parameterized by the inferred TResult, TKey, and TUtils instead
of any. Introduce or reuse collection-specific generic types for
UseLiveInfiniteQueryConfig and UseLiveInfiniteQueryReturn, preserving those
inferred types through getNextPageParam, data, pages, and related values.
- Line 103: Update the fetchNextPage binding in useLiveInfiniteQuery to return
the promise from LiveQueryWindowController.fetchNextPage instead of discarding
it, preserving its resolve/reject behavior. Adjust the related tests to await
fetchNextPage before making assertions.
In `@packages/svelte-db/tests/useLiveInfiniteQuery.svelte.test.ts`:
- Around line 45-182: Extend the useLiveInfiniteQuery pagination tests with
empty-collection, single-row, and pageSize: 0 cases, asserting hasNextPage,
pages, and effective window limits. In the existing multi-page tests, await each
fetchNextPage() promise before flushSync and subsequent assertions so
asynchronous completion order is covered.
🪄 Autofix
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: 492335f2-05fa-4c8b-9453-e15bad8d0f11
📒 Files selected for processing (4)
.changeset/spicy-roses-hide.mdpackages/svelte-db/src/index.tspackages/svelte-db/src/useLiveInfiniteQuery.svelte.tspackages/svelte-db/tests/useLiveInfiniteQuery.svelte.test.ts
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
More templates@tanstack/angular-db@tanstack/browser-db-sqlite-persistence@tanstack/capacitor-db-sqlite-persistence@tanstack/cloudflare-durable-objects-db-sqlite-persistence@tanstack/db@tanstack/db-ivm@tanstack/db-sqlite-persistence-core@tanstack/electric-db-collection@tanstack/electron-db-sqlite-persistence@tanstack/expo-db-sqlite-persistence@tanstack/node-db-sqlite-persistence@tanstack/offline-transactions@tanstack/powersync-db-collection@tanstack/query-db-collection@tanstack/react-db@tanstack/react-native-db-sqlite-persistence@tanstack/rxdb-db-collection@tanstack/solid-db@tanstack/svelte-db@tanstack/tauri-db-sqlite-persistence@tanstack/trailbase-db-collection@tanstack/vue-dbcommit: |
Size Change: 0 B Total Size: 132 kB ℹ️ View Unchanged
|
Size Change: 0 B Total Size: 3.79 kB ℹ️ View Unchanged
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/svelte-db/src/useLiveInfiniteQuery.svelte.ts (1)
50-52: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReplace the local
anyplaceholders with shared generic bounds.Use
object,string | number, andUtilsRecordfor the internal collection, snapshot, and controller types, or propagate the actual generics. KeepTUtils extends Record<string, any>because the sharedCollectionandUseLiveQueryReturnWithCollectioncontracts currently require that bound.🤖 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/svelte-db/src/useLiveInfiniteQuery.svelte.ts` around lines 50 - 52, Update hasSetWindow and its related collection, snapshot, and controller type annotations to use the shared bounds object, string | number, and UtilsRecord instead of local any placeholders, or propagate the actual generics where available. Preserve TUtils extends Record<string, any> to satisfy the existing Collection and UseLiveQueryReturnWithCollection contracts.Source: Coding guidelines
🤖 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.
Nitpick comments:
In `@packages/svelte-db/src/useLiveInfiniteQuery.svelte.ts`:
- Around line 50-52: Update hasSetWindow and its related collection, snapshot,
and controller type annotations to use the shared bounds object, string |
number, and UtilsRecord instead of local any placeholders, or propagate the
actual generics where available. Preserve TUtils extends Record<string, any> to
satisfy the existing Collection and UseLiveQueryReturnWithCollection contracts.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 6520ccca-06b9-41d2-a8de-bc4b4e77c655
📒 Files selected for processing (2)
packages/svelte-db/src/useLiveInfiniteQuery.svelte.tspackages/svelte-db/tests/useLiveInfiniteQuery.svelte.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/svelte-db/tests/useLiveInfiniteQuery.svelte.test.ts
🎯 Changes
useLiveInfiniteQueryas a Svelte 5 binding over the shared live-query window controller.Reworks #1447 without closing it.
✅ Checklist
pnpm test.Validation:
pnpm --filter @tanstack/svelte-db test(64 tests)pnpm --filter @tanstack/svelte-db test:typespnpm --filter @tanstack/svelte-db build🚀 Release Impact
Summary by CodeRabbit
New Features
useLiveInfiniteQueryfor reactive infinite queries in Svelte.Bug Fixes
Tests