fix(status): scope tab/range/refresh search params to the status route#1469
Merged
Conversation
The Status tab's search params were hand-validated inside StatusTabs and cleaned up by a navigate-on-unmount effect. That cleanup fires after the destination route has committed, so it could clobber the destination's own search params, issued a spurious history replace on every departure, and double-fired under StrictMode. The params are now declared on the route: a light statusSearch.ts module (outside the lazy analytics chunk) defines the schema, defaults, and validator; the status route wires validateSearch plus a stripSearchParams(defaults) middleware so default values stay out of the URL; and StatusTabs reads the already-validated values through the same validator instead of hand-rolled casts. The unmount effect and the duplicated VALID_PRESETS/VALID_REFRESH constants are deleted. Fixes #1440 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors search parameter handling for the instance status route by moving validation and defaulting from the StatusTabs component to the route definition level using TanStack Router's validateSearch and stripSearchParams. This declarative approach prevents status-related parameters from bleeding into sibling routes, resolving issue #1440 and eliminating the need for imperative cleanup on unmount. New tests have been added to verify search parameter validation and scoping. I have no feedback to provide as the changes are well-implemented and covered by tests.
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||
dawsontoth
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1440 — Status tab unmount cleanup can clobber the destination route's search params.
Summary
The Status tab's
tab/range/refreshsearch params were hand-validated insideStatusTabsand stripped by a navigate-on-unmount effect. That cleanup fires after the destination route commits, so it could wipe the destination's own search params, added a spurious historyreplaceon every departure, and double-fired under StrictMode.The params are now the router's job: a new light
statusSearch.tsmodule (deliberately outside the lazy-loaded analytics chunk; its only import is the constants-onlytimePresets.ts) defines the schema, defaults, and validator. The status route wiresvalidateSearch+ astripSearchParams(defaults)middleware, so invalid deep links normalize to defaults, default values stay out of the URL, and sibling routes never see the params — verified against router-core 1.171 source that aLink/navigatewithoutsearchresolves to{}, so nothing inherits them.StatusTabsreads the already-validated values through the same validator (narrowing thestrict: falsetyping), and the unmount effect plus the duplicatedVALID_PRESETS/VALID_REFRESHconstants are gone.Where to look
src/features/instance/status/routes.ts— the route wiring (the behavioral core, 4 lines).src/features/instance/status/statusSearch.ts— schema/validator; note the empty-stringrefreshguard (Number('')is0, which would silently match the "Off" option).src/router/__tests__/statusSearchScope.test.ts— router-level regression tests (matchRoutes/buildLocation, no loaders, same pattern asorgUndefinedRepro): deep-link validation, invalid-value normalization, default-stripping, and sibling-navigation scoping.Cross-model review: Codex found no issues; Gemini passed all criteria (its one suggestion, the empty-string refresh guard, is included).
Generated by kAIle (Claude Fable 5).