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
+18 -2
View File
@@ -236,20 +236,35 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
onOk(allValues);
};
const handleClusterChange = async (value: number) => {
await onClusterChange?.(value);
// Shared work when the target cluster changes: refetch the GPU/backend
// options for the new cluster and reset schedule/gpu selection.
const applyClusterScopedOptions = (value: number) => {
getGPUOptionList({ clusterId: value });
getBackendOptions({ cluster_id: value });
form.setFieldsValue({
scheduleType: ScheduleValueMap.Auto,
gpu_selector: null
});
};
// User explicitly picked a cluster: refresh scoped options and re-evaluate.
const handleClusterChange = async (value: number) => {
await onClusterChange?.(value);
applyClusterScopedOptions(value);
await new Promise((resolve) => {
setTimeout(resolve, 150);
});
onValuesChange?.({}, form.getFieldsValue());
};
// The basic form seeds a default cluster on open, before a model is picked.
// Refresh scoped options for it but don't fire the evaluate request — there
// is no model to evaluate yet.
const handleClusterSeed = async (value: number) => {
await onClusterChange?.(value);
applyClusterScopedOptions(value);
};
const getFieldPaths = (obj: Record<string, any>, prefix = ''): string => {
const result = Object.entries(obj).flatMap(([key, value]) => {
const path = prefix ? `${prefix}.${key}` : key;
@@ -467,6 +482,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
clusterList={clusterList}
sourceDisable={sourceDisable}
handleClusterChange={handleClusterChange}
onClusterSeed={handleClusterSeed}
onSourceChange={onSourceChange}
></BasicForm>
<CollapsePanel