Skip to content

refactor: Update to nuqs 2.8 and apply refactors#1782

Draft
teeohhem wants to merge 4 commits intomainfrom
tom/upgrade-nuqs-v2
Draft

refactor: Update to nuqs 2.8 and apply refactors#1782
teeohhem wants to merge 4 commits intomainfrom
tom/upgrade-nuqs-v2

Conversation

@teeohhem
Copy link
Contributor

@teeohhem teeohhem commented Feb 23, 2026

Fixes: HDX-2558

What Changed

nuqs v1 → v2 upgrade

  • Upgraded nuqs from 1.17.0 to 2.8.8
  • Added required NuqsAdapter to _app.tsx (Pages Router) and .storybook/preview.tsx
  • Removed the parseAsStringWithNewLines workaround, which was patching a newline-handling bug fixed upstream in nuqs v2.2.3

Removed use-query-params

  • Migrated all remaining useQueryParam/useQueryParams usages to useQueryState/useQueryStates from nuqs across:
    • timeQuery.ts, AppNav.tsx, SessionsPage.tsx, PodDetailsSidePanel.tsx, NodeDetailsSidePanel.tsx, NamespaceDetailsSidePanel.tsx, DBDashboardImportPage.tsx
  • Removed packages: use-query-params, next-query-params, serialize-query-params, @jedmao/location
  • Deleted: src/useQueryParam.tsx (now redundant), src/fixtures.ts (replaced by NuqsTestingAdapter)

Fixed: side panel close handlers

  • nuqs v2 changed setter semantics — null removes a param, undefined means "no change". Close handlers in SessionsPage.tsx, PodDetailsSidePanel.tsx, NodeDetailsSidePanel.tsx, and NamespaceDetailsSidePanel.tsx were passing undefined and silently doing nothing. Updated to pass null.

Tests

  • Un-skipped the previously disabled timeQuery.test.tsx suite
  • Migrated test wrapper to NuqsTestingAdapter
  • Updated jest.config.js to transpile nuqs ESM modules
  • Rewrote tests to accurately reflect useNewTimeQuery's contract

teeohhem and others added 3 commits February 23, 2026 15:48
nuqs v2 requires NuqsAdapter to be added at the app root when using the
Next.js Pages Router. The parseAsStringWithNewLines workaround (patching
newline encoding) is no longer needed as v2.2.3+ handles this natively.

Co-authored-by: Cursor <cursoragent@cursor.com>
- Migrate all useQueryParam/useQueryParams calls to nuqs useQueryState/useQueryStates
- Remove use-query-params, next-query-params, and serialize-query-params packages
- Remove @jedmao/location (test utility no longer needed)
- Delete custom useQueryParam.tsx hook and fixtures.ts (replaced by NuqsTestingAdapter)
- Strip QueryParamProvider/NextAdapter/HDXQueryParamProvider from _app.tsx and storybook
- Update jest.config.js to transform nuqs (ESM package) for unit tests
- Rewrite timeQuery.test.tsx using NuqsTestingAdapter and remove describe.skip

Co-authored-by: Cursor <cursoragent@cursor.com>
@changeset-bot
Copy link

changeset-bot bot commented Feb 23, 2026

⚠️ No Changeset found

Latest commit: 14bb98a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Feb 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hyperdx-v2-oss-app Ready Ready Preview, Comment Feb 23, 2026 9:49pm

Request Review

@teeohhem teeohhem changed the title Tom/upgrade nuqs v2 refactor: Update to nuqs 2.8 and apply refactors Feb 23, 2026
@github-actions
Copy link
Contributor

PR Review: nuqs v1 → v2 + use-query-params removal

No critical issues found. Clean, well-scoped migration.

Notable observations:

  • null vs undefined fix (close handlers in SessionsPage, PodDetailsSidePanel, NodeDetailsSidePanel, NamespaceDetailsSidePanel) — this was a silent breakage in v2 that is correctly fixed.

  • updateType replaceIn → default — nuqs v2's useQueryState defaults to history: 'replace', so dropping the explicit option preserves the same behavior.

  • Batching behavior change — old code used enableBatching: true across setTimeRangeQuery (from/to) and setInputTimeQuery (tq) in timeQuery.ts. These are now two separate hooks without explicit cross-hook batching. React 19's automatic batching should handle same-tick updates, but if updates happen across async ticks, history: 'push' could produce duplicate history entries. Worth a smoke test on the time range selector.

  • Test improvements — un-skipping the previously disabled timeQuery.test.tsx suite and migrating to NuqsTestingAdapter is a meaningful quality improvement.

  • Dep cleanup — removing use-query-params, next-query-params, serialize-query-params, and @jedmao/location is clean.

Generated with Claude Code

@github-actions
Copy link
Contributor

github-actions bot commented Feb 23, 2026

PR Review: nuqs v1 → v2 migration + remove use-query-params

Clean dependency consolidation. A couple of things worth checking:

  • ⚠️ parseAsJson(v => v as T) provides zero runtime validation — nuqs v2 added validator support for safety, but all usages use v => v as T type casts instead of real validators (e.g. with Zod). This matches nuqs v1 behavior, so it's not a regression, but it's a missed opportunity given the API change. Not a blocker but worth a follow-up.

  • ⚠️ tq URL param behavior is now untested — the old test suite (previously skipped) included tests for the tq named-range param ("Last 4H", "Past 1h") overriding from/to params and being replaced on navigation. The rewritten tests removed all tq-related cases. Since this is live functionality in timeQuery.ts, consider adding at least one test covering tq param initialization.

  • updateType: 'replaceIn' → nuqs default (history: 'replace') is semantically equivalent.

  • enableBatching: true removal is fine — nuqs v2 batches natively.

  • null (remove param) vs undefined (no-op) fix in close handlers is correct.

  • parseAsInteger for timestamp params is correct (millisecond epoch values are always integers).

🤖 Generated with Claude Code

@github-actions
Copy link
Contributor

E2E Test Results

8 tests failed • 63 passed • 4 skipped • 1137s

Status Count
✅ Passed 63
❌ Failed 8
⚠️ Flaky 0
⏭️ Skipped 4

Tests ran across 4 shards in parallel.

View full report →

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