Show selected model name in selector trigger

This commit is contained in:
Danila Poyarkov 2026-03-01 11:33:12 +03:00
parent f6434bc4f9
commit 299b668e7b
2 changed files with 7 additions and 4 deletions

View file

@ -2,10 +2,10 @@
import {
SelectContent,
SelectItem,
SelectItemText,
SelectPortal,
SelectRoot,
SelectTrigger,
SelectValue,
SelectViewport,
TooltipContent,
TooltipPortal,
@ -31,6 +31,9 @@ const emit = defineEmits<{
const input = ref('')
const isStreaming = computed(() => props.status === 'streaming' || props.status === 'submitted')
const selectedModelName = computed(
() => MODELS.find((m) => m.id === modelId.value)?.name ?? modelId.value
)
function handleSubmit(e: Event) {
e.preventDefault()
@ -51,7 +54,7 @@ function handleSubmit(e: Event) {
class="flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-muted hover:bg-hover hover:text-surface"
>
<icon-lucide-bot class="size-3" />
<SelectValue />
{{ selectedModelName }}
<icon-lucide-chevron-down class="size-2.5" />
</SelectTrigger>
<SelectPortal>
@ -68,7 +71,7 @@ function handleSubmit(e: Event) {
:value="model.id"
class="flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-[11px] text-surface outline-none data-[highlighted]:bg-hover"
>
<span class="flex-1">{{ model.name }}</span>
<SelectItemText class="flex-1">{{ model.name }}</SelectItemText>
<span
v-if="model.tag"
class="rounded bg-accent/10 px-1 py-px text-[9px] text-accent"

View file

@ -137,7 +137,7 @@ test('model selector is visible and clickable', async () => {
await expect(trigger).toBeVisible()
await trigger.click()
await expect(page.getByText('Claude Sonnet 4')).toBeVisible()
await expect(page.getByRole('option', { name: /Claude Sonnet 4/ })).toBeVisible()
await expect(page.getByText('Recommended')).toBeVisible()
await expect(page.getByText('Free').first()).toBeVisible()