Skip to content

refactor: polish pass#400

Merged
adibarra merged 11 commits into
masterfrom
refactor/polish-pass
May 27, 2026
Merged

refactor: polish pass#400
adibarra merged 11 commits into
masterfrom
refactor/polish-pass

Conversation

@adibarra
Copy link
Copy Markdown
Contributor

@adibarra adibarra commented May 27, 2026

Note

Medium Risk
Compare page static-param removal and redirect logic affect SEO/caching; trend interpolation and JSON-LD escaping change user-visible chart gaps and structured-data safety; feedback failure events include truncated error text sent to analytics.

Overview
This polish pass adds server-side observability via a lightweight trackServer helper (PostHgo /capture/ or console fallback), wired into feedback API failures (E_CRYPTO / E_INSERT) and per-dollar PNG render failures (502 + short cache instead of opaque 500s).

Compare routes stop pre-enumerating slugs in generateStaticParams on the HTML pages (still fully dynamic SSR) and only 308-redirect when the slug differs from canonical after case-insensitive comparison, avoiding redundant CDN cache entries for mixed-case URLs that already match content.

Chart/trend correctness: interpolated trends return null (gaps) when a metric is missing on any frontier point instead of drawing a misleading zero line; lightweight trend points gain optional measured power fields and drop unsafe casts. Dynamic x-axis reads use typed AggDataEntry accessors in chart and trend hooks.

JSON-LD now escapes >, &, and < in inline script payloads (with tests). Feature gate re-lock is centralized in relockFeatureGate() with unit tests. Latest-image age/outdated helpers move to latest-image-utils with Vitest coverage. FeedbackForm loads via next/dynamic in the nudge registry. Root lint/fmt scripts pass --no-error-on-unmatched-pattern consistently.

Reviewed by Cursor Bugbot for commit 7c171aa. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

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

Project Deployment Actions Updated (UTC)
inferencemax-app Ready Ready Preview, Comment May 27, 2026 6:22pm

Request Review

@adibarra adibarra marked this pull request as ready for review May 27, 2026 18:22
@adibarra
Copy link
Copy Markdown
Contributor Author

@claude review

@claude
Copy link
Copy Markdown

claude Bot commented May 27, 2026

Claude finished @adibarra's task in 3m 12s —— View job


Review

🟢 LGTM — no blocking issues found.

Read the diff across all 21 files. The polish pass is well-scoped, with new tests covering the extracted code (29 tests for latest-image-utils + use-feature-gate, additional tests for JsonLd escaping and interpolateMetricAtInteractivity missing-metric path).

Verified

  • analytics-server.ts — fire-and-forget fetch with keepalive, falls back to console when key missing, distinct_id is intentionally synthetic. Both call sites (feedback/route.ts, PNG route) truncate error_message to 500 chars before sending, so internal stack details don't bloat PostHog payloads.
  • JSON-LD escaping (json-ld.tsx:12-15) — order of < / > / & replacements is safe because each replacement produces \u00xx sequences containing none of the three trigger chars, so no double-escape risk. Tests cover the </script> breakout vector explicitly.
  • Trend null-propagation (useInterpolatedTrendData.ts:127-133) — bails out entirely if any frontier point lacks the metric, including the single-point branch (now routes through extractMetric). Prevents the flat-zero regression that motivated the change.
  • Compare lowercase redirect (compare/[slug]/page.tsx:85, compare-per-dollar/[slug]/page.tsx:80) — canonical is always lowercase, so comparing against slug.toLowerCase() correctly avoids redundant 308s for mixed-case URLs that already match canonical content. SEO consolidation still works via alternates.canonical.
  • PNG route try/catch — scope is limited to ImageResponse; parsed/sequence/precision are declared outside the try and remain in scope in the catch. 502 + short s-maxage=60 cache is the right call vs. pinning a permanent failure.
  • useChartData.ts:313-314 / useTrendData.ts:118-123 — typed Partial<AggDataEntry> accessor with typeof === 'number' narrowing replaces the as any. Future field rename would now fall back to d.x cleanly instead of silently masking a regression.
  • relockFeatureGate() — centralizes the localStorage key + event dispatch; three callers (FeedbackViewer, GpuPowerDisplay, SubmissionsDisplay) all migrated. Tests cover idempotency and event firing.
  • Lazy FeedbackForm (registry.tsx:18-21) — next/dynamic with ssr: false is correct since the modal only renders after the eligibility event fires client-side.

Non-blocking observations

  • registry.tsx:18-22 declares const FeedbackForm = dynamic(...) between import statements (GitHubIcon import follows it). ES module imports hoist, so this is functionally fine, but it's an unusual order — moving the const below all imports would read more conventionally. Not worth blocking on.
  • The PNG route's outer DB/data calls (getCachedBenchmarks, computeCompareTableData) still throw uncaught — failures there will surface as opaque 500s without PostHog tagging. Likely intentional (different failure mode from the Satori-render path the new tracking targets), but worth confirming if you want full observability coverage on that endpoint.

  • Read PR diff and analyze changes
  • Review feedback API server-side analytics
  • Review compare-per-dollar PNG route changes
  • Review interpolated trend data null handling
  • Review JSON-LD escaping
  • Review latest-image-utils extraction + tests
  • Review use-feature-gate refactor + tests
  • Check for missing tests on new code
  • Post final review comments
    — branch refactor/polish-pass

@adibarra adibarra merged commit bb24bb8 into master May 27, 2026
24 checks passed
@adibarra adibarra deleted the refactor/polish-pass branch May 27, 2026 18:50
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