fix(platform): fall back to the model's own name when displayName is left empty

ModelManagement shows the resolved model name as the display-name placeholder; WorkbenchModel save maps empty displayName to the model's cascader label so the workspace model picker never renders a blank option.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Kinyoo
2026-07-07 15:28:57 +08:00
co-authored by Claude Opus 4.8
parent 1b94ae4248
commit 99bf6c312b
2 changed files with 26 additions and 2 deletions
@@ -43,6 +43,17 @@ export const ModelManagement = forwardRef<HTMLDivElement[], ModelManagementProps
const { t } = useTranslation();
const navigate = useNavigate();
// Resolve the selected model's name from the cascader options so the
// display-name input can fall back to it as placeholder when left empty.
const getModelLabel = (id: string) => {
if (!id) return '';
for (const group of assistantLlmOptions) {
const hit = group.children?.find((el) => el.value == id);
if (hit) return hit.label;
}
return '';
};
const selectFooter = (
<div
className="px-3 py-2 text-sm text-primary cursor-pointer hover:bg-[#EBF0FF] dark:hover:bg-gray-700"
@@ -125,7 +136,7 @@ export const ModelManagement = forwardRef<HTMLDivElement[], ModelManagementProps
<Input
value={model.displayName}
onChange={(e) => onNameChange(index, e.target.value)}
placeholder={t('bench.displayName')}
placeholder={getModelLabel(model.id) || t('bench.displayName')}
/>
{errors[model.key] && <p className="text-red-500 text-xs mt-1">{errors[model.key]?.[1]}</p>}
</div>
@@ -76,6 +76,17 @@ export default function WorkbenchModel({ onBack }) {
const { data: linsightConfig, isLoading: loading, refetch: refetchConfig, error } = useLinsightConfig();
// Look up the model's own name from the cascader options by id, used as
// the default displayName when the admin leaves it empty.
const findModelLabel = (id) => {
if (!id) return '';
for (const group of llmOptions) {
const hit = group.children?.find((el) => el.value == id);
if (hit) return hit.label;
}
return '';
};
const handleSave = async () => {
const { linsightDefaultModelId, sourceModelId, asrModelId, ttsModelId, chatTitleLlmId, models } = form;
const errors = [];
@@ -86,7 +97,9 @@ export default function WorkbenchModel({ onBack }) {
setSaveLoad(true);
try {
const data = {
models,
// Empty displayName falls back to the model's own name so the
// workspace model picker never renders a blank option.
models: models.map((m) => m.displayName ? m : { ...m, displayName: findModelLabel(m.id) }),
embedding_model: { id: String(sourceModelId) },
// Linsight default executor model: one of the workbench chat models' id.
linsight_default_model_id: linsightDefaultModelId ? String(linsightDefaultModelId) : null,