Skip to content

fix(calculator): SSR with ?g_model so share links open the right model#431

Merged
Oseltamivir merged 1 commit into
masterfrom
claude/issue-430-20260608-0505
Jun 8, 2026
Merged

fix(calculator): SSR with ?g_model so share links open the right model#431
Oseltamivir merged 1 commit into
masterfrom
claude/issue-430-20260608-0505

Conversation

@Oseltamivir

@Oseltamivir Oseltamivir commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

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 useLayoutEffect inside GlobalFilterContext. 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_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.

Test plan

  • curl /calculator?g_model=DeepSeek-V4-Pro → SSR HTML contains DeepSeek V4 Pro 1.6T
  • curl /calculator (no params) → SSR still shows R1 default
  • Playwright → V4 Pro selected in dropdown + chart caption + chart data
  • Share button still round-trips g_model=DeepSeek-V4-Pro
  • Unit test for resolveCalculatorUrlSeed (8 cases)
  • Two new Cypress regressions in throughput-calculator.cy.ts
  • pnpm typecheck && pnpm lint && pnpm fmt && pnpm test:e2e all 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-Pro no longer flash the default model (DeepSeek R1) on first paint.

The calculator page is now an async server component that reads searchParams and passes a typed seed from new resolveCalculatorUrlSeed (g_model, i_seq, i_prec, validated against known enums). ThroughputCalculatorDisplay mounts a nested GlobalFilterProvider with 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.

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>
@Oseltamivir Oseltamivir requested a review from adibarra as a code owner June 8, 2026 06:58
@vercel

vercel Bot commented Jun 8, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
inferencemax-app Ready Ready Preview, Comment Jun 8, 2026 6:58am

Request Review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

@Oseltamivir Oseltamivir enabled auto-merge (squash) June 8, 2026 07:04
@Oseltamivir Oseltamivir disabled auto-merge June 8, 2026 07:04
@Oseltamivir Oseltamivir merged commit bc2890e into master Jun 8, 2026
16 of 20 checks passed
@Oseltamivir Oseltamivir deleted the claude/issue-430-20260608-0505 branch June 8, 2026 07:04
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.

TCO calc share link broken

1 participant