Skip to content

feat(store): add url query persist#70

Merged
yzuyr merged 2 commits into
mainfrom
feat/store-persist-query
Jul 17, 2026
Merged

feat(store): add url query persist#70
yzuyr merged 2 commits into
mainfrom
feat/store-persist-query

Conversation

@yzuyr

@yzuyr yzuyr commented Jul 17, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Added URL query-string persistence for store state via persistQuery, including initialization from URL params and bidirectional sync with navigation (back/forward, link navigation).
    • Supports custom query param mapping, serialization/deserialization, debounced updates, history mode, and omission of default values.
    • Handles invalid URL values safely and is a no-op during server-side rendering.
  • Documentation

    • Expanded guide and README with persistQuery usage and option details.
  • Tests

    • Added a comprehensive test suite for synchronization, debouncing, edge cases, and SSR behavior.
  • Chores

    • Updated package version and added a public ./query export.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 99bd50f5-3a32-4d29-9229-ff0fa33b8789

📥 Commits

Reviewing files that changed from the base of the PR and between fc40f8c and a987ae4.

📒 Files selected for processing (2)
  • packages/store/src/query.test.ts
  • packages/store/src/query.ts

📝 Walkthrough

Walkthrough

Changes

The store package adds persistQuery() to hydrate and synchronize selected store state with URL search parameters, supporting navigation history, debouncing, codecs, default omission, SSR no-op behavior, and teardown flushing. It is exported as @ilha/store/query, tested, documented, and released as version 0.7.3.

Query persistence

Layer / File(s) Summary
Query persistence runtime
packages/store/src/query.ts
Defines the public API and synchronizes store state with URL parameters through router navigation or History API fallback.
Query persistence validation
packages/store/src/query.test.ts, packages/store/happydom.ts
Tests hydration, navigation, codecs, debouncing, multi-store isolation, teardown, and SSR behavior.
Package build and export integration
packages/store/package.json, packages/store/tsconfig.json, packages/store/tsdown.config.ts
Adds the ./query export, builds query.ts, resolves the router dependency, and updates package metadata.
Documentation and release references
packages/store/README.md, apps/website/src/pages/(content)/guide/libraries/store.mdx, apps/website/package.json, templates/*/package.json
Documents persistQuery() and updates consumers to version 0.7.3.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant persistQuery
  participant Store
  participant Router
  Browser->>persistQuery: Provide URL search parameters
  persistQuery->>Store: Deserialize and hydrate state
  Store->>persistQuery: Emit persisted state changes
  persistQuery->>Router: Navigate with updated parameters
  Router->>persistQuery: Deliver navigation updates
  persistQuery->>Store: Apply URL changes without echo navigation
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding URL query persistence to the store package.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/store-persist-query

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

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 `@packages/store/src/query.ts`:
- Around line 238-240: Update applyFromUrl around the differs check to cancel
any pending debounced write before applying the external URL state: clear timer
and discard the pending state, then proceed with applying = true. Preserve the
early return when the URL state does not differ.
🪄 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: e4851a24-ef88-4d65-84cf-fc5f737439f1

📥 Commits

Reviewing files that changed from the base of the PR and between ebe3897 and fc40f8c.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (13)
  • apps/website/package.json
  • apps/website/src/pages/(content)/guide/libraries/store.mdx
  • packages/store/README.md
  • packages/store/happydom.ts
  • packages/store/package.json
  • packages/store/src/query.test.ts
  • packages/store/src/query.ts
  • packages/store/tsconfig.json
  • packages/store/tsdown.config.ts
  • templates/elysia/package.json
  • templates/hono/package.json
  • templates/nitro/package.json
  • templates/vite/package.json

Comment thread packages/store/src/query.ts
@yzuyr
yzuyr merged commit d80adcd into main Jul 17, 2026
4 of 5 checks passed
@yzuyr
yzuyr deleted the feat/store-persist-query branch July 17, 2026 19:50
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.

1 participant