Skip to content

Commit 12cb445

Browse files
fix(studio): keep column model_alias in sync when the model changes (#1019)
Selecting a different model in the config panel left the alias pointing at the old model name, so every column referencing that alias silently kept the stale reference. Derive the alias from the new model and rewrite any column whose model_alias matched the old one. Signed-off-by: Sean Teramae <steramae@nvidia.com>
1 parent bc41e06 commit 12cb445

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

  • web/packages/studio/src/components/ModelConfigPanel

web/packages/studio/src/components/ModelConfigPanel/index.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const ModelConfigPanel: FC<ModelConfigPanelProps> = ({
3232
onRemove,
3333
onClose,
3434
}) => {
35-
const { control, getValues } = useFormContext<JobBuilderFormValues>();
35+
const { control, getValues, setValue } = useFormContext<JobBuilderFormValues>();
3636
const modelIndex = getValues('models').findIndex((model) => model.id === modelId);
3737
const aliasPath = `models.${modelIndex}.alias` as const;
3838
const { field: modelField } = useController({ control, name: `models.${modelIndex}.model` });
@@ -56,9 +56,25 @@ export const ModelConfigPanel: FC<ModelConfigPanelProps> = ({
5656
);
5757
const modelValue: ModelSelection | null = modelField.value ? { model: modelField.value } : null;
5858

59+
const { field: aliasField } = useController({ control, name: aliasPath });
60+
5961
const handleModelChange = (selection: ModelSelection) => {
62+
const oldAlias = aliasField.value as string;
63+
const newAlias = selection.model.split('/').pop()?.split('@')[0] ?? selection.model;
64+
6065
modelField.onChange(selection.model);
6166
providerField.onChange(providerForSelection(selection));
67+
68+
if (newAlias && newAlias !== oldAlias) {
69+
aliasField.onChange(newAlias);
70+
const columns = getValues('columns');
71+
const updated = columns.map((col) =>
72+
col.values?.model_alias === oldAlias
73+
? { ...col, values: { ...col.values, model_alias: newAlias } }
74+
: col
75+
);
76+
setValue('columns', updated);
77+
}
6278
};
6379

6480
return (

0 commit comments

Comments
 (0)