Skip to content

Commit 382223d

Browse files
committed
fix: filter model dropdown to match saved provider, auto-select first model
1 parent 202f981 commit 382223d

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

dashboard/src/pages/Chat.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,20 @@ export function Chat() {
6363
)
6464

6565
const apiKey = llmKeys?.[0]?.api_key || ''
66+
const savedProvider = llmKeys?.[0]?.provider || ''
67+
const availableModels = savedProvider ? MODELS.filter(m => m.provider === savedProvider) : MODELS
6668

6769
useEffect(() => {
6870
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' })
6971
}, [messages, streamContent])
7072

73+
// Auto-select first model when provider changes
74+
useEffect(() => {
75+
if (availableModels.length > 0 && !availableModels.find(m => m.id === model)) {
76+
setModel(availableModels[0].id)
77+
}
78+
}, [savedProvider])
79+
7180
// Live detection as user types
7281
useEffect(() => {
7382
if (!input.trim()) {
@@ -305,7 +314,7 @@ export function Chat() {
305314
onChange={(e) => setModel(e.target.value)}
306315
className="w-full px-2 py-1 bg-[var(--background)] border border-[var(--border)] text-[11px] text-[var(--foreground)] font-mono"
307316
>
308-
{MODELS.map(m => (
317+
{availableModels.map(m => (
309318
<option key={m.id} value={m.id}>{m.label}</option>
310319
))}
311320
</select>

0 commit comments

Comments
 (0)