From dbb0caa7e740120c47b3d0a09ff083f5f5e4d794 Mon Sep 17 00:00:00 2001
From: Adrian Bonpin
Date: Fri, 15 May 2026 01:02:13 +0800
Subject: [PATCH] feat(steamdb): integrate version auto-fetch into submit
wizard UI
---
components/wizard/game-entry-wizard.tsx | 64 ++++++++++++++++++++++++-
components/wizard/steps/setup-step.tsx | 61 ++++++++++++++++++++++-
2 files changed, 122 insertions(+), 3 deletions(-)
diff --git a/components/wizard/game-entry-wizard.tsx b/components/wizard/game-entry-wizard.tsx
index 6d47ea0..467e9c7 100644
--- a/components/wizard/game-entry-wizard.tsx
+++ b/components/wizard/game-entry-wizard.tsx
@@ -129,6 +129,13 @@ export function GameEntryWizard({ gameId, gameVersions, defaultVersionId, editEn
// Step 4: Notes
const [userNotes, setUserNotes] = useState(editEntry?.userNotes ?? "")
+ // SteamDB version suggestion
+ const [steamdbVersion, setSteamdbVersion] = useState<{
+ versionString: string | null
+ buildId: string | null
+ } | null>(null)
+ const [steamdbLoading, setSteamdbLoading] = useState(false)
+
// Fetch hardware name when slug changes
const handleHardwareChange = useCallback(async (slug: string) => {
setHardwareSlug(slug)
@@ -183,10 +190,39 @@ export function GameEntryWizard({ gameId, gameVersions, defaultVersionId, editEn
if (selectedVersionId === "__new__") {
return newVersionString || "New version"
}
+ if (selectedVersionId === "__steamdb__") {
+ return steamdbVersion
+ ? steamdbVersion.versionString || `Build ${steamdbVersion.buildId}`
+ : "SteamDB version"
+ }
const v = gameVersions.find((v) => v.id === selectedVersionId)
if (!v) return "Unknown"
return v.versionString || (v.buildId ? `Build ${v.buildId}` : "Unknown version")
- }, [selectedVersionId, newVersionString, gameVersions])
+ }, [selectedVersionId, newVersionString, gameVersions, steamdbVersion])
+
+ const fetchSteamDBVersion = useCallback(async () => {
+ setSteamdbLoading(true)
+ try {
+ const res = await fetch(`/api/games/${gameId}/steamdb-version`)
+ if (!res.ok) return
+ const data = await res.json()
+ if (data.versionString || data.buildId) {
+ setSteamdbVersion({
+ versionString: data.versionString,
+ buildId: data.buildId,
+ })
+ }
+ } catch {
+ // Silently fail — SteamDB is best-effort
+ } finally {
+ setSteamdbLoading(false)
+ }
+ }, [gameId])
+
+ // Fetch SteamDB version on mount
+ useEffect(() => {
+ fetchSteamDBVersion()
+ }, [fetchSteamDBVersion])
const canProceed = () => {
switch (currentStep) {
@@ -194,6 +230,8 @@ export function GameEntryWizard({ gameId, gameVersions, defaultVersionId, editEn
if (hardwareSlug === "") return false
// If new version selected, require version string
if (selectedVersionId === "__new__" && !newVersionString.trim()) return false
+ // SteamDB option is always valid (data comes from external source)
+ if (selectedVersionId === "__steamdb__" && !steamdbVersion) return false
return true
case 1: // Performance
return performance.fpsAvg !== undefined && performance.fpsAvg > 0
@@ -228,10 +266,29 @@ export function GameEntryWizard({ gameId, gameVersions, defaultVersionId, editEn
// Resolve the final version ID — create a new version if needed
const resolveVersionId = async (): Promise => {
- if (selectedVersionId !== "__new__") {
+ if (selectedVersionId !== "__new__" && selectedVersionId !== "__steamdb__") {
return selectedVersionId
}
+ if (selectedVersionId === "__steamdb__" && steamdbVersion) {
+ // Create version from SteamDB data
+ const res = await fetch(`/api/games/${gameId}/versions`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ versionString: steamdbVersion.versionString,
+ buildId: steamdbVersion.buildId,
+ isLatest: true,
+ }),
+ })
+ if (!res.ok) {
+ const data = await res.json()
+ throw new Error(data.error || "Failed to create version from SteamDB")
+ }
+ const data = await res.json() as { id: string }
+ return data.id
+ }
+
// Create a new version via API
setIsCreatingVersion(true)
try {
@@ -375,6 +432,9 @@ export function GameEntryWizard({ gameId, gameVersions, defaultVersionId, editEn
antiCheat={antiCheat}
onAntiCheatChange={setAntiCheat}
platformSupport={platformSupport}
+ steamdbVersion={steamdbVersion}
+ steamdbLoading={steamdbLoading}
+ onRefreshSteamDB={fetchSteamDBVersion}
/>
)}
{currentStep === 1 && (
diff --git a/components/wizard/steps/setup-step.tsx b/components/wizard/steps/setup-step.tsx
index 0dddca8..a038f76 100644
--- a/components/wizard/steps/setup-step.tsx
+++ b/components/wizard/steps/setup-step.tsx
@@ -1,6 +1,6 @@
"use client"
-import { GitBranch } from "lucide-react"
+import { GitBranch, DatabaseIcon, RefreshCwIcon } from "lucide-react"
import { HardwareStep } from "./hardware-step"
import { AntiCheatStep, type AntiCheatData } from "./anti-cheat-step"
@@ -11,6 +11,11 @@ export interface GameVersionInfo {
isLatest: boolean
}
+export interface SteamDBVersion {
+ versionString: string | null
+ buildId: string | null
+}
+
interface SetupStepProps {
gameId: string
gameVersions: GameVersionInfo[]
@@ -30,6 +35,9 @@ interface SetupStepProps {
antiCheatName: string | null
antiCheatStatus: "none" | "supported" | "unsupported" | "unknown"
}[]
+ steamdbVersion: SteamDBVersion | null
+ steamdbLoading: boolean
+ onRefreshSteamDB: () => void
}
export function SetupStep({
@@ -48,8 +56,12 @@ export function SetupStep({
antiCheat,
onAntiCheatChange,
platformSupport,
+ steamdbVersion,
+ steamdbLoading,
+ onRefreshSteamDB,
}: SetupStepProps) {
const isNewVersion = selectedVersionId === "__new__"
+ const isSteamDBVersion = selectedVersionId === "__steamdb__"
return (
@@ -80,6 +92,20 @@ export function SetupStep({
onChange={(e) => onVersionChange(e.target.value)}
className="w-full appearance-none px-4 py-3 rounded-lg border border-border bg-text/5 text-text text-sm outline-none focus:border-primary focus:ring-2 focus:ring-primary/50 transition-colors cursor-pointer"
>
+ {/* SteamDB suggestion — appears at top when available */}
+ {steamdbVersion && (steamdbVersion.versionString || steamdbVersion.buildId) && (
+
+ )}
+ {steamdbLoading && (
+
+ )}
+
{gameVersions.map((v) => (
+
+ {/* Refresh button for SteamDB */}
+
{isNewVersion && (
@@ -114,6 +151,28 @@ export function SetupStep({
)}
+
+ {isSteamDBVersion && steamdbVersion && (
+
+
+
+
+
Version
+
{steamdbVersion.versionString || "—"}
+
+
+
Build ID
+
{steamdbVersion.buildId || "—"}
+
+
+
+ This version will be created when you submit your benchmark.
+
+
+ )}