fix(calculator): SSR with ?g_model so share links open the right model#431
Merged
Conversation
The TCO calculator's SSR'd HTML always rendered DeepSeek R1 (the in-memory default) because URL params were only applied client-side via the useLayoutEffect inside GlobalFilterContext. Users opening a shared link like /calculator?g_model=DeepSeek-V4-Pro&g_rundate=…&g_runid=… saw a flash of R1 until JS finished hydrating — and any preview or scraper that does not run JS saw R1 outright. Read g_model / i_seq / i_prec from searchParams in the calculator page (server component) and, when present, mount a fresh GlobalFilterProvider with the URL-derived initials inside the calculator's client tree. SSR now renders the requested model straight away. Mirrors the per-page provider pattern used by the compare/[slug] route. Fixes #430. Co-authored-by: Bryan Shan <Oseltamivir@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9489674. Configure here.
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 #430.
Summary
The TCO calculator's SSR'd HTML always rendered DeepSeek R1 (the in-memory default) because URL params were only applied client-side via the
useLayoutEffectinsideGlobalFilterContext. Users opening a shared link like/calculator?g_model=DeepSeek-V4-Pro&…saw a flash of R1 until JS finished hydrating — and any preview/scraper that does not run JS saw R1 outright.Read
g_model/i_seq/i_precfromsearchParamsin the calculator page (server component) and, when present, mount a freshGlobalFilterProviderwith the URL-derived initials inside the calculator's client tree. SSR now renders the requested model straight away. Mirrors the per-page-provider pattern used by thecompare/[slug]route.Test plan
curl /calculator?g_model=DeepSeek-V4-Pro→ SSR HTML containsDeepSeek V4 Pro 1.6Tcurl /calculator(no params) → SSR still shows R1 defaultg_model=DeepSeek-V4-ProresolveCalculatorUrlSeed(8 cases)throughput-calculator.cy.tspnpm typecheck && pnpm lint && pnpm fmt && pnpm test:e2eall green🤖 Generated with Claude Code
Note
Low Risk
Scoped to calculator routing and filter initialization; unknown URL values are ignored and behavior without params is unchanged.
Overview
Fixes #430: shared calculator links like
/calculator?g_model=DeepSeek-V4-Prono longer flash the default model (DeepSeek R1) on first paint.The calculator page is now an async server component that reads
searchParamsand passes a typed seed from newresolveCalculatorUrlSeed(g_model,i_seq,i_prec, validated against known enums).ThroughputCalculatorDisplaymounts a nestedGlobalFilterProviderwith those initials when the seed is non-empty, so SSR HTML matches the URL before client hydration (same idea as compare routes).Coverage adds Vitest for the resolver and Cypress checks that raw HTML and the model dropdown show the URL model.
Reviewed by Cursor Bugbot for commit 9489674. Bugbot is set up for automated code reviews on this repo. Configure here.