You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .claude/rules/sim-url-state.md
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,6 +46,19 @@ These reads/mutations are **not** anti-patterns and stay as-is:
46
46
-**Route navigations** — `router.push('/path/[id]?folderId=x')` that changes the route *path*, not just the current query. A nuqs setter only mutates the query on the current path; cross-path navigation stays on `router`.
47
47
-**Read-once auth / redirect signals** — `token`, `callbackUrl`, `redirect`, `error`, `invite_flow`, `new` (invite signup flow), `upgraded`, `redirect_workflow`, etc. These are navigation signals consumed once (often read-then-strip), not synced view-state. Leave them on `useSearchParams`. Key names are per-surface: files' `new` is a genuine nuqs param (`files/search-params.ts`), while invite's `new` is a one-shot signup signal.
48
48
49
+
### Remembered list-preference exception
50
+
51
+
Files, Tables, and Knowledge may persist their last-used filter/sort snapshot through
52
+
`useResourceListPreferences`. This is a fallback preference, not a second live source of truth:
53
+
54
+
- nuqs remains authoritative while the module is open.
55
+
- Zustand is consulted once on a clean module entry, after persisted state hydrates.
56
+
- Effective URL filter/sort state wins as one complete snapshot and becomes the remembered value;
57
+
omitted fields use URL defaults rather than merging with storage.
58
+
- Explicit filter/sort gestures commit the same complete snapshot to nuqs and Zustand together.
59
+
- Never mirror subsequent URL changes with a synchronization effect or `popstate` listener.
60
+
- Search and folder navigation remain URL-only and are excluded from the persisted snapshot.
61
+
49
62
## Per-feature `search-params.ts` — single source of truth
50
63
51
64
Co-locate a `search-params.ts` next to the feature. Export the parser map (and shared options). Both the client (`useQueryStates`/`useQueryState`) and any server component (`createSearchParamsCache` from `nuqs/server`) import from this one file. Import parsers from `nuqs/server` so the module is safe to import in both client and server contexts.
0 commit comments