From 9b45b125089a4ac1e35e5b58c318e18394d72310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Fri, 17 Apr 2026 09:54:46 -0400 Subject: [PATCH] fix(onboarding): drop "Default" sentinel from model picker; auto-select real model MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CEO-runtime model dropdown on the Company onboarding step rendered a {value:"", label:"默认 / Default"} sentinel as the first option, a holdover from the adapter era when "" meant "let the connector pick". Under pi-mono every connector carries a defaultModel and every run must bind a concrete model id, so the sentinel is now misleading — picking it left selectedModel empty and the wizard would advance without a valid model. - CompanyStep: drop the sentinel from the options array; the dropdown now shows only real models (or a single "Loading..." entry while the per-connector fetch is in flight). - useConnectorModelSelection: when the connector's current model is not enabled, auto-select the connector's defaultModel if enabled, otherwise the first enabled model. An empty enabled list still falls back to "" so the CompanyStep hint UI behaves correctly. Result: Fire Pass now shows "Kimi K2.5 Turbo (Fire Pass)" as the sole option (pre-selected). Every other connector picks its catalog default up-front. typecheck 0 / lint 0-0 / build 0-0 / test:unit 508/508. --- .../company-onboarding/CompanyStep.tsx | 9 ++++---- .../useConnectorModelSelection.ts | 23 ++++++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/renderer/components/company-onboarding/CompanyStep.tsx b/src/renderer/components/company-onboarding/CompanyStep.tsx index eabcea58..2172af3f 100644 --- a/src/renderer/components/company-onboarding/CompanyStep.tsx +++ b/src/renderer/components/company-onboarding/CompanyStep.tsx @@ -71,10 +71,11 @@ export function CompanyStep({ onContinue, onBack }: CompanyStepProps) { value={selectedModel} onChange={setSelectedModel} disabled={loadingModels || modelOptions.length === 0} - options={[ - { value: "", label: loadingModels ? (currentLocale === "zh" ? "加载中..." : "Loading...") : (currentLocale === "zh" ? "默认" : "Default") }, - ...modelOptions.map((m) => ({ value: m.id, label: m.label })), - ]} + options={ + loadingModels + ? [{ value: "", label: currentLocale === "zh" ? "加载中..." : "Loading..." }] + : modelOptions.map((m) => ({ value: m.id, label: m.label })) + } />
diff --git a/src/renderer/components/company-onboarding/useConnectorModelSelection.ts b/src/renderer/components/company-onboarding/useConnectorModelSelection.ts index 2d443fe4..6b354e13 100644 --- a/src/renderer/components/company-onboarding/useConnectorModelSelection.ts +++ b/src/renderer/components/company-onboarding/useConnectorModelSelection.ts @@ -128,12 +128,23 @@ export function useConnectorModelSelection( setSelectedModel(""); return; } - setSelectedModel((currentModel) => - currentModel && connectorModels.some((entry) => entry.enabled && entry.id === currentModel) - ? currentModel - : "", - ); - }, [connectorModels, selectedConnectorId]); + const enabledModels = connectorModels.filter((entry) => entry.enabled); + if (enabledModels.length === 0) { + setSelectedModel(""); + return; + } + setSelectedModel((currentModel) => { + if (currentModel && enabledModels.some((entry) => entry.id === currentModel)) { + return currentModel; + } + const connectorDefinition = executionReadyConnectors.find((c) => c.id === selectedConnectorId); + const preferred = connectorDefinition?.model; + if (preferred && enabledModels.some((entry) => entry.id === preferred)) { + return preferred; + } + return enabledModels[0]?.id ?? ""; + }); + }, [connectorModels, selectedConnectorId, executionReadyConnectors]); const modelOptions = useMemo( () => connectorModels