fix(llmodels): don't evaluate on cluster seed before a model is selected

The basic form seeds a default cluster on open, which fired the full cluster-change handler and triggered an evaluate request before any model was picked. Split off a seed callback that refreshes scoped options without evaluating, and guard the evaluate handler with a model-selected check as a backstop.
This commit is contained in:
jialin
2026-07-13 17:14:43 +08:00
committed by jialin
parent 35ed397c2a
commit d0b6498bda
3 changed files with 43 additions and 4 deletions
+6 -2
View File
@@ -85,6 +85,7 @@ interface BasicFormProps {
}
>[];
handleClusterChange: (value: number) => void;
onClusterSeed: (value: number) => void;
onSourceChange?: (value: string) => void;
}
@@ -94,6 +95,7 @@ const BasicForm: React.FC<BasicFormProps> = (props) => {
clusterList,
sourceDisable,
handleClusterChange,
onClusterSeed,
onSourceChange
} = props;
const intl = useIntl();
@@ -148,6 +150,8 @@ const BasicForm: React.FC<BasicFormProps> = (props) => {
// selection and fall back to the scope's default cluster (then a Ready one,
// then the first) so GPU/backend options refetch for it. A selection that's
// still valid is left untouched, so a user's (or edit's) choice is kept.
// Use the seed callback (not handleClusterChange) so this auto-pick refreshes
// options without firing an evaluate request before a model is selected.
useEffect(() => {
if (!clusterOptions?.length) {
return;
@@ -167,8 +171,8 @@ const BasicForm: React.FC<BasicFormProps> = (props) => {
return;
}
form.setFieldValue('cluster_id', next);
handleClusterChange?.(next);
}, [clusterOptions, form, handleClusterChange]);
onClusterSeed?.(next);
}, [clusterOptions, form, onClusterSeed]);
const clusterOptionRender = (option: any) => {
const { data } = option;