Skip to content

Commit 05581e8

Browse files
webui: address review feedback from allozaur
Normalized streamed model names during chat updates by trimming input and removing directory components before saving or persisting them, so the conversation UI shows only the filename Forced model names within the chat form selector dropdown to render as a single-line, truncated entry with a tooltip revealing the full name
1 parent 8d7cf91 commit 05581e8

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

tools/server/webui/src/lib/components/app/chat/ChatForm/ChatFormModelSelector.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,9 @@
378378
aria-selected={option.id === selectedOption?.id}
379379
onclick={() => handleOptionSelect(option.id)}
380380
>
381-
<span class="font-medium">{option.name}</span>
381+
<span class="block w-full truncate font-medium" title={option.name}>
382+
{option.name}
383+
</span>
382384

383385
{#if option.description}
384386
<span class="text-xs text-muted-foreground">{option.description}</span>

tools/server/webui/src/lib/stores/chat.svelte.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -358,28 +358,44 @@ class ChatStore {
358358
): Promise<void> {
359359
let streamedContent = '';
360360
let streamedReasoningContent = '';
361+
362+
const normalizeModelName = (modelName: string): string => {
363+
const trimmed = modelName.trim();
364+
if (!trimmed) {
365+
return '';
366+
}
367+
368+
const segments = trimmed.split(/[\\/]/);
369+
const candidate = segments.pop();
370+
const normalized = candidate?.trim();
371+
372+
return normalized && normalized.length > 0 ? normalized : trimmed;
373+
};
374+
361375
let resolvedModel: string | null = null;
362376
let modelPersisted = false;
363377

364378
const recordModel = (modelName: string, persistImmediately = true): void => {
365-
const trimmedModel = modelName.trim();
379+
const normalizedModel = normalizeModelName(modelName);
366380

367-
if (!trimmedModel || trimmedModel === resolvedModel) {
381+
if (!normalizedModel || normalizedModel === resolvedModel) {
368382
return;
369383
}
370384

371-
resolvedModel = trimmedModel;
385+
resolvedModel = normalizedModel;
372386

373387
const messageIndex = this.findMessageIndex(assistantMessage.id);
374388

375-
this.updateMessageAtIndex(messageIndex, { model: trimmedModel });
389+
this.updateMessageAtIndex(messageIndex, { model: normalizedModel });
376390

377391
if (persistImmediately && !modelPersisted) {
378392
modelPersisted = true;
379-
DatabaseStore.updateMessage(assistantMessage.id, { model: trimmedModel }).catch((error) => {
380-
console.error('Failed to persist model name:', error);
381-
modelPersisted = false;
382-
});
393+
DatabaseStore.updateMessage(assistantMessage.id, { model: normalizedModel }).catch(
394+
(error) => {
395+
console.error('Failed to persist model name:', error);
396+
modelPersisted = false;
397+
}
398+
);
383399
}
384400
};
385401

0 commit comments

Comments
 (0)