From ea4b19e89958b7233444b26eccf382d51e454c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ng=C3=B4=20Quang=20H=C3=B2a?= Date: Tue, 26 May 2026 13:11:10 +0700 Subject: [PATCH] fix(filters): fall back to first available model when default is empty The dashboard hardcodes Model.DeepSeek_R1 as the default selectedModel. On a fresh-truncated self-host DB where only gemma4 has been ingested, this leaves every tab showing "No data" until the user manually picks a model from the dropdown. Add an auto-switch effect that kicks in once availabilityRows loads: if the selected model isn't in availableModels and the user didn't explicitly request it via ?g_model=, fall through to availableModels[0]. Guarded by a ref so it only fires once per mount; explicit URL pick still wins. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../app/src/components/GlobalFilterContext.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/app/src/components/GlobalFilterContext.tsx b/packages/app/src/components/GlobalFilterContext.tsx index d2a171eec..21b47da02 100644 --- a/packages/app/src/components/GlobalFilterContext.tsx +++ b/packages/app/src/components/GlobalFilterContext.tsx @@ -259,6 +259,21 @@ export function GlobalFilterProvider({ } }, [unofficialAvailable, selectedModel]); + // Auto-switch when the (URL- or default-) selected model has zero rows in + // availability — e.g. a small / freshly-truncated self-host DB where the + // upstream default (DeepSeek-R1) was never ingested. Without this, /evaluation + // and /inference both show "No data" on first paint and the user has to know + // to manually pick a model from the dropdown. + const didFallbackToFirstAvailableRef = useRef(false); + useEffect(() => { + if (!availabilityRows || availableModels.length === 0) return; + if (didFallbackToFirstAvailableRef.current) return; + if (availableModels.includes(selectedModel)) return; + if (getUrlParam('g_model')) return; // honor explicit URL pick even if empty + didFallbackToFirstAvailableRef.current = true; + setSelectedModel(availableModels[0]); + }, [availabilityRows, availableModels, selectedModel, getUrlParam]); + // Sequences available for the selected model (DB ∪ unofficial run for this model) const availableSequences = useMemo(() => { const unofficialSeqs = unofficialAvailable