fix(frontend): deep-linked switches frozen — commit selection via History API#9
Merged
Merged
Conversation
…es work Opening a shared link that already carries query params (e.g. ?b=basic/coin_toss&hw=rpi5-8gb) left every switch dead — selecting a value did nothing, while a fresh load with no params worked. useSelection committed each selection through router.replace, which runs the App Router's navigation/ transition machinery. Under static export (output: export), that path fails to update the URL on a deep-linked load (most visibly in Safari), so useSearchParams never changes and the controlled Selects stay frozen. Switch to window.history.replaceState, which Next.js syncs with useSearchParams/usePathname without a route transition — the documented idiom for query-param-only state updates. URL-building logic is unchanged. Tests now spy on history.replaceState instead of router.replace. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
Opening a shared link that already carries query params (e.g.
https://benchmarks.rxinfer.com/?b=basic%2Fcoin_toss&hw=rpi5-8gb) left everyselector dead — the hardware/Julia/scenario/metric switchers and the left sidebar
examples. Selecting anything did nothing. Starting fresh from the bare
benchmarks.rxinfer.com(no params) worked. First reported in Safari, but reproducesin Chrome too.
Root cause
All dashboard state lives in query params via
useSelection(), and every selectorfunnels through its single
select()function, which committed each change withrouter.replace(...). That runs the App Router's navigation/transition machinery. Onthis static export (
output: "export"), a query-onlyrouter.replaceon adeep-linked load silently no-ops — no exception, it just doesn't navigate, so
useSearchParams()never updates and the controlled<Select>s/buttons stay frozen.One broken commit function = every selector frozen at once.
Fix
Commit selections with
window.history.replaceStateinstead ofrouter.replace.Next.js syncs
useSearchParams/usePathnamewithpushState/replaceStateand skipsthe route transition — the documented idiom for query-param-only state updates. URL
building is unchanged;
replaceState(no new history entry) preserves the priorrouter.replacebehavior.Verification
useSelection+DashboardPagetests updated to assert onhistory.replaceState; full suite 161 passing,tsc+ eslint clean.raw.githubusercontent.com), opening the exact deep link above:router.replacehistory.replaceStatehw=rpi5-8gb→hw=github-actions-ubuntu✅b=coin_toss→b=iid_normal✅No console/page errors in either build.
🤖 Generated with Claude Code