fix(agent): use native model selector

This commit is contained in:
ginnoir
2026-07-08 18:52:19 -05:00
parent 1092941c45
commit 716bca0fcb
2 changed files with 23 additions and 29 deletions
@@ -1,18 +1,10 @@
"use client";
import { useEffect, useRef, useState, useTransition } from "react";
import { ImagePlus, Loader2, Mic, Send, Square } from "lucide-react";
import { ChevronDown, ImagePlus, Loader2, Mic, Send, Square } from "lucide-react";
import { setAssistantModel } from "@/app/settings/assistant-actions";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { consumeAgentChatStream } from "../assistant-chat-stream";
import {
clearAssistantChat,
@@ -259,25 +251,25 @@ export function AssistantPanel({ configured, userId, assistantName, assistantMod
</div>
<div className="flex shrink-0 items-center gap-2">
{modelOptions.length > 0 ? (
<Select
items={modelOptions.map((model) => ({ value: model.id, label: model.label }))}
value={selectedModel}
onValueChange={changeModel}
disabled={modelsLoading || savingModel || isPending}
>
<SelectTrigger size="sm" className="max-w-36" aria-label="Assistant model">
<SelectValue>{selectedModel || "Model"}</SelectValue>
</SelectTrigger>
<SelectContent align="end">
<SelectGroup>
{modelOptions.map((model) => (
<SelectItem key={model.id} value={model.id}>
{model.label}
</SelectItem>
))}
</SelectGroup>
</SelectContent>
</Select>
<div className="relative max-w-36">
<select
aria-label="Assistant model"
value={selectedModel}
onChange={(event) => changeModel(event.target.value)}
disabled={modelsLoading || savingModel || isPending}
className="h-7 w-full max-w-36 appearance-none truncate rounded-[min(var(--radius-md),10px)] border border-input bg-transparent py-1 pr-7 pl-2.5 text-sm outline-none transition-colors focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50"
>
{modelOptions.map((model) => (
<option key={model.id} value={model.id}>
{model.label}
</option>
))}
</select>
<ChevronDown
className="pointer-events-none absolute top-1/2 right-2 size-4 -translate-y-1/2 text-muted-foreground"
aria-hidden="true"
/>
</div>
) : null}
{messages.length > 0 ? (
<button
+3 -1
View File
@@ -26,7 +26,9 @@ test("assistant chat smoke after opt-in", async ({ page }) => {
await page.goto("/");
await page.getByRole("button", { name: "Open assistant" }).click();
await expect(page.getByRole("dialog", { name: "Assistant" })).toBeVisible();
await expect(page.getByRole("combobox", { name: "Assistant model" })).toBeVisible();
const modelSelector = page.getByRole("combobox", { name: "Assistant model" });
await expect(modelSelector).toBeVisible();
await expect.poll(() => modelSelector.evaluate((node) => node.tagName)).toBe("SELECT");
await page.getByLabel("Message for Assistant").fill("hello assistant");
await page.getByRole("button", { name: "Send" }).click();