feat: auto select the first model as default model

This commit is contained in:
Henry Li
2026-01-26 17:13:34 +08:00
parent 22004406a7
commit 3ce4968e95
4 changed files with 17 additions and 8 deletions

View File

@@ -72,10 +72,18 @@ export function InputBox({
const { t } = useI18n();
const [modelDialogOpen, setModelDialogOpen] = useState(false);
const { models } = useModels();
const selectedModel = useMemo(
() => models.find((m) => m.name === context.model_name),
[context.model_name, models],
);
const selectedModel = useMemo(() => {
if (!context.model_name && models.length > 0) {
setTimeout(() => {
onContextChange?.({
...context,
model_name: models[0]!.name,
});
}, 0);
return models[0]!;
}
return models.find((m) => m.name === context.model_name);
}, [context, models, onContextChange]);
const supportThinking = useMemo(
() => selectedModel?.supports_thinking ?? false,
[selectedModel],