7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.
TypeScript
dashboard: shared segmented control + model combobox; real error bubbles in Playground
Tashfeenbd7b5151deb7
diff --git a/client/src/components/model-combobox.tsx b/client/src/components/model-combobox.tsxnew file mode 100644index 00000000..1b1cfee2--- /dev/null+++ b/client/src/components/model-combobox.tsx@@ -0,0 +1,142 @@+import { useState, type ReactNode } from 'react'+import { ChevronsUpDown, Check, Search } from 'lucide-react'+import { Popover, PopoverTrigger, PopoverContent } from '@/components/ui/popover'+import { Tooltip } from '@/components/tooltip'+import { useI18n } from '@/i18n'++// Searchable model picker, extracted from the Playground so every model+// selection in the dashboard can use the same control. Substring match over+// name, provider names, and id; arrow keys + Enter select.+export interface ModelComboOption {+ value: string+ label: string+ /** Right-aligned hint: provider name or "N providers". */+ sub?: string+ isNew?: boolean+ /** Provider names when the model is served by several (hover + search). */+ platforms?: string[]+}++export function ModelCombobox({+ value,+ options,+ onSelect,+ ariaLabel,+ placeholder,+ emptyText,+ footer,+ align = 'end',+ triggerClassName,+}: {+ value: string+ options: ModelComboOption[]+ onSelect: (value: string) => void+ ariaLabel: string+ placeholder: string+ emptyText: string+ /** Optional hint row under the list (e.g. "add a key to see models"). */+ footer?: ReactNode+ align?: 'start' | 'center' | 'end'+ triggerClassName?: string+}) {+ const { t } = useI18n()+ const [open, setOpen] = useState(false)+ const [query, setQuery] = useState('')+ const [active, setActive] = useState(0)++ const q = query.trim().toLowerCase()+ const filtered = q+ ? options.filter(o => `${o.label} ${o.sub ?? ''} ${o.value} ${(o.platforms ?? []).join(' ')}`.toLowerCase().includes(q))+ : options+ const triggerLabel = options.find(o => o.value === value)?.label ?? value++ function pick(v: string) {+ onSelect(v)+ setOpen(false)+ setQuery('')+ }++ function onKeyDown(e: React.KeyboardEvent) {+ if (e.key === 'ArrowDown') {+ e.preventDefault()+ setActive(a => Math.min(a + 1, filtered.length - 1))+ } else if (e.key === 'ArrowUp') {+ e.preventDefault()+ setActive(a => Math.max(a - 1, 0))+ } else if (e.key === 'Enter' && filtered[active]) {+ e.preventDefault()+ pick(filtered[active].value)+ }+ }++ return (+ <Popover+ open={open}+ onOpenChange={o => {+ setOpen(o)+ if (!o) setQuery('')+ else setActive(0)+ }}+ >+ <PopoverTrigger+ aria-label={ariaLabel}+ className={+ triggerClassName ??+ 'flex h-8 w-[260px] items-center justify-between gap-2 whitespace-nowrap rounded-lg border border-input bg-transparent px-3 text-sm outline-none transition-colors hover:bg-muted/50 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 dark:bg-input/30'+ }+ >+ <span className="truncate">{triggerLabel}</span>+ <ChevronsUpDown className="size-4 shrink-0 text-muted-foreground" />+ </PopoverTrigger>+ <PopoverContent align={align} className="w-[300px] p-0" onKeyDown={onKeyDown}>+ <div className="flex items-center gap-2 border-b px-3">+ <Search className="size-4 shrink-0 text-muted-foreground" />+ <input+ autoFocus+ value={query}+ onChange={e => {+ setQuery(e.target.value)+ setActive(0)+ }}+ placeholder={placeholder}+ aria-label={placeholder}+ className="h-9 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"+ />+ </div>+ <div className="max-h-72 overflow-y-auto p-1">+ {filtered.length === 0 ? (+ <div className="px-2 py-6 text-center text-xs text-muted-foreground">{emptyText}</div>+ ) : (+ filtered.map((o, i) => (+ <button+ key={o.value}+ type="button"+ onMouseEnter={() => setActive(i)}+ onClick={() => pick(o.value)}+ className={`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-accent hover:text-accent-foreground ${+ o.value === value ? 'bg-accent/50' : i === active ? 'bg-muted' : ''+ }`}+ >+ <Check className={`size-4 shrink-0 ${o.value === value ? 'opacity-100' : 'opacity-0'}`} />+ <span className="min-w-0 flex-1 truncate">{o.label}</span>+ {o.isNew && (+ <span className="rounded px-1 py-0.5 text-[9px] font-semibold uppercase leading-none tracking-wide bg-emerald-500/15 text-emerald-600 dark:text-emerald-400">+ {t('models.newBadge')}+ </span>+ )}+ {o.sub && ((o.platforms?.length ?? 0) > 1 ? (+ <Tooltip text={t('models.servedBy', { providers: (o.platforms ?? []).join(', ') })}>+ <span className="shrink-0 text-xs text-muted-foreground underline decoration-dotted underline-offset-2">{o.sub}</span>+ </Tooltip>+ ) : (+ <span className="shrink-0 text-xs text-muted-foreground">{o.sub}</span>+ ))}+ </button>+ ))+ )}+ {footer}+ </div>+ </PopoverContent>+ </Popover>+ )+}diff --git a/client/src/components/ui/segmented-control.tsx b/client/src/components/ui/segmented-control.tsxnew file mode 100644index 00000000..a53d15f8--- /dev/null+++ b/client/src/components/ui/segmented-control.tsx@@ -0,0 +1,44 @@+import { cn } from '@/lib/utils'++// The dashboard's one segmented-control idiom (pill bar with a solid active+// segment), shared by the Keys tabs and the Analytics range toggle. ModelsTabs+// renders the same visual with NavLinks for routed tabs.+export interface SegmentOption<T extends string> {+ value: T+ label: string+}++export function SegmentedControl<T extends string>({+ value,+ onValueChange,+ options,+ ariaLabel,+ className,+}: {+ value: T+ onValueChange: (value: T) => void+ options: SegmentOption<T>[]+ ariaLabel?: string+ className?: string+}) {+ return (+ <div role="tablist" aria-label={ariaLabel} className={cn('inline-flex gap-1 rounded-xl border p-1', className)}>+ {options.map(o => (+ <button+ key={o.value}+ type="button"+ role="tab"+ aria-selected={value === o.value}+ onClick={() => onValueChange(o.value)}+ className={`inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs transition-colors ${+ value === o.value+ ? 'bg-foreground text-background font-medium'+ : 'text-muted-foreground hover:text-foreground hover:bg-muted'+ }`}+ >+ {o.label}+ </button>+ ))}+ </div>+ )+}diff --git a/client/src/i18n/locales/en.json b/client/src/i18n/locales/en.jsonindex 66fe2f35..41481df7 100644--- a/client/src/i18n/locales/en.json+++ b/client/src/i18n/locales/en.json@@ -376,7 +376,8 @@"fusionJudgeSynth": "synthesized the final answer","errorPrefix": "Error:","systemPromptLabel": "System prompt",- "systemPromptPlaceholder": "Optional. Sent as a system message before your chat."+ "systemPromptPlaceholder": "Optional. Sent as a system message before your chat.",+ "errorTitle": "Request failed"},"embeddings": {"title": "Models",diff --git a/client/src/i18n/locales/es.json b/client/src/i18n/locales/es.jsonindex 61bbfc8e..c8385c98 100644--- a/client/src/i18n/locales/es.json+++ b/client/src/i18n/locales/es.json@@ -297,7 +297,8 @@"fusionTrace": "{count} respuestas de modelos","fusionFailed": "sin respuesta","fusionJudgeSynth": "sintetizó la respuesta final",- "errorPrefix": "Error:"+ "errorPrefix": "Error:",+ "errorTitle": "La solicitud falló"},"embeddings": {"title": "Modelos",diff --git a/client/src/i18n/locales/fr.json b/client/src/i18n/locales/fr.jsonindex f3375fd0..3cc4ff98 100644--- a/client/src/i18n/locales/fr.json+++ b/client/src/i18n/locales/fr.json@@ -297,7 +297,8 @@"fusionTrace": "{count} réponses de modèles","fusionFailed": "aucune réponse","fusionJudgeSynth": "a synthétisé la réponse finale",- "errorPrefix": "Erreur :"+ "errorPrefix": "Erreur :",+ "errorTitle": "La requête a échoué"},"embeddings": {"title": "Modèles",diff --git a/client/src/i18n/locales/it.json b/client/src/i18n/locales/it.jsonindex 4c560e4e..33f665ac 100644--- a/client/src/i18n/locales/it.json+++ b/client/src/i18n/locales/it.json@@ -318,7 +318,8 @@"fusionTrace": "{count} risposte modello","fusionFailed": "nessuna risposta","fusionJudgeSynth": "ha sintetizzato la risposta finale",- "errorPrefix": "Errore:"+ "errorPrefix": "Errore:",+ "errorTitle": "Richiesta non riuscita"},"embeddings": {"title": "Modelli",diff --git a/client/src/i18n/locales/pt-BR.json b/client/src/i18n/locales/pt-BR.jsonindex a8a49daa..2c9854a0 100644--- a/client/src/i18n/locales/pt-BR.json+++ b/client/src/i18n/locales/pt-BR.json@@ -297,7 +297,8 @@"fusionTrace": "{count} respostas de modelos","fusionFailed": "sem resposta","fusionJudgeSynth": "sintetizou a resposta final",- "errorPrefix": "Erro:"+ "errorPrefix": "Erro:",+ "errorTitle": "A solicitação falhou"},"embeddings": {"title": "Modelos",diff --git a/client/src/i18n/locales/zh-CN.json b/client/src/i18n/locales/zh-CN.jsonindex 1f585bd0..c4bb6ca1 100644--- a/client/src/i18n/locales/zh-CN.json+++ b/client/src/i18n/locales/zh-CN.json@@ -320,7 +320,8 @@"fusionJudgeSynth": "综合出最终答案","errorPrefix": "错误:","systemPromptLabel": "系统提示词",- "systemPromptPlaceholder": "可选。作为系统消息在你的对话之前发送。"+ "systemPromptPlaceholder": "可选。作为系统消息在你的对话之前发送。",+ "errorTitle": "请求失败"},"embeddings": {"title": "模型",diff --git a/client/src/pages/AnalyticsPage.tsx b/client/src/pages/AnalyticsPage.tsxindex fdc49362..b3bac3c3 100644--- a/client/src/pages/AnalyticsPage.tsx+++ b/client/src/pages/AnalyticsPage.tsx@@ -5,7 +5,7 @@ import {LineChart, Line, Legend,} from 'recharts'import { apiFetch } from '@/lib/api'-import { Button } from '@/components/ui/button'+import { SegmentedControl } from '@/components/ui/segmented-control'import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'import { PageHeader } from '@/components/page-header'import { Skeleton } from '@/components/ui/skeleton'@@ -126,18 +126,15 @@ export default function AnalyticsPage() {title={t('analytics.title')}description={t('analytics.description')}actions={- <div className="flex gap-1 rounded-lg border p-0.5">- {(['24h', '7d', '30d'] as TimeRange[]).map(r => (- <Button- key={r}- variant={range === r ? 'secondary' : 'ghost'}- size="xs"- onClick={() => setRange(r)}- >- {t(r === '24h' ? 'analytics.range24h' : r === '7d' ? 'analytics.range7d' : 'analytics.range30d')}- </Button>- ))}- </div>+ <SegmentedControl+ value={range}+ onValueChange={setRange}+ options={(['24h', '7d', '30d'] as TimeRange[]).map(r => ({+ value: r,+ label: t(r === '24h' ? 'analytics.range24h' : r === '7d' ? 'analytics.range7d' : 'analytics.range30d'),+ }))}+ ariaLabel={t('analytics.title')}+ />}/>diff --git a/client/src/pages/KeysPage.tsx b/client/src/pages/KeysPage.tsxindex 50e41bb8..deaef183 100644--- a/client/src/pages/KeysPage.tsx+++ b/client/src/pages/KeysPage.tsx@@ -6,6 +6,7 @@ import { ConfirmButton } from '@/components/confirm-button'import { Input } from '@/components/ui/input'import { Textarea } from '@/components/ui/textarea'import { Label } from '@/components/ui/label'+import { SegmentedControl } from '@/components/ui/segmented-control'import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'import { Switch } from '@/components/ui/switch'import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'@@ -1051,20 +1052,12 @@ export default function KeysPage() {{checkAll.isPending ? t('keys.checking') : t('keys.checkAll')}</Button>)}- <div className="inline-flex gap-1 rounded-xl border p-1">- {KEYS_TABS.map(tb => (- <button- key={tb.id}- type="button"- onClick={() => setTab(tb.id)}- className={`inline-flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-lg transition-colors ${- tab === tb.id ? 'bg-foreground text-background font-medium' : 'text-muted-foreground hover:text-foreground hover:bg-muted'- }`}- >- {t(tb.labelKey)}- </button>- ))}- </div>+ <SegmentedControl+ value={tab}+ onValueChange={setTab}+ options={KEYS_TABS.map(tb => ({ value: tb.id, label: t(tb.labelKey) }))}+ ariaLabel={t('keys.pageTitle')}+ /></>}/>diff --git a/client/src/pages/PlaygroundPage.tsx b/client/src/pages/PlaygroundPage.tsxindex 3d99d7b6..5a017790 100644--- a/client/src/pages/PlaygroundPage.tsx+++ b/client/src/pages/PlaygroundPage.tsx@@ -1,11 +1,10 @@import { useState, useRef, useEffect } from 'react'import { useQuery } from '@tanstack/react-query'-import { ChevronRight, ChevronsUpDown, Check, Search } from 'lucide-react'+import { ChevronRight, CircleAlert } from 'lucide-react'import { apiFetch } from '@/lib/api'import { Button } from '@/components/ui/button'-import { Popover, PopoverTrigger, PopoverContent } from '@/components/ui/popover'+import { ModelCombobox } from '@/components/model-combobox'import { buildModelOptions } from '@/lib/model-groups'-import { Tooltip } from '@/components/tooltip'import { PageHeader } from '@/components/page-header'import { Markdown } from '@/components/markdown'import { CopyButton } from '@/components/copy-button'@@ -26,6 +25,9 @@ interface FallbackEntry {interface ChatMessage {role: 'user' | 'assistant'content: string+ // Request-level failure rendered as a distinct error bubble, not a fake+ // assistant reply.+ isError?: booleanmeta?: {platform?: stringmodel?: string@@ -129,8 +131,6 @@ export default function PlaygroundPage() {const [selectedModel, setSelectedModel] = useState<string>(() => localStorage.getItem('playground.model') ?? 'auto',)- const [modelQuery, setModelQuery] = useState('')- const [modelPickerOpen, setModelPickerOpen] = useState(false)const messagesEndRef = useRef<HTMLDivElement>(null)const inputRef = useRef<HTMLTextAreaElement>(null)@@ -253,7 +253,8 @@ export default function PlaygroundPage() {const err = await res.json().catch(() => ({ error: { message: `HTTP ${res.status}` } }))setMessages([...newMessages, {role: 'assistant',- content: `${t('playground.errorPrefix')} ${err.error?.message ?? t('common.unknownError')}`,+ isError: true,+ content: err.error?.message ?? t('common.unknownError'),}])return}@@ -292,7 +293,8 @@ export default function PlaygroundPage() {} catch (err: any) {setMessages([...newMessages, {role: 'assistant',- content: `${t('playground.errorPrefix')} ${err.message}`,+ isError: true,+ content: err.message,}])} finally {setLoading(false)@@ -334,17 +336,9 @@ export default function PlaygroundPage() {platforms: o.providerCount > 1 ? o.platforms : [],})),]- // Literal, case-insensitive substring match against name, providers, and id.- const modelQ = modelQuery.trim().toLowerCase()- const filteredOptions = modelQ- ? pickerOptions.filter(o => `${o.label} ${o.sub} ${o.value} ${o.platforms.join(' ')}`.toLowerCase().includes(modelQ))- : pickerOptions-function pickModel(v: string) {setSelectedModel(v)localStorage.setItem('playground.model', v)- setModelPickerOpen(false)- setModelQuery('')}const activeModelLabel = selectedModel === 'auto'@@ -360,53 +354,21 @@ export default function PlaygroundPage() {description={t('playground.description')}actions={<>- <Popover open={modelPickerOpen} onOpenChange={(o) => { setModelPickerOpen(o); if (!o) setModelQuery('') }}>- <PopoverTrigger- aria-label={t('playground.selectModel')}- className="flex h-8 w-[260px] items-center justify-between gap-2 whitespace-nowrap rounded-lg border border-input bg-transparent px-3 text-sm outline-none transition-colors hover:bg-muted/50 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 dark:bg-input/30"- >- <span className="truncate">{activeModelLabel}</span>- <ChevronsUpDown className="size-4 shrink-0 text-muted-foreground" />- </PopoverTrigger>- <PopoverContent align="end" className="w-[300px] p-0">- <div className="flex items-center gap-2 border-b px-3">- <Search className="size-4 shrink-0 text-muted-foreground" />- <input- autoFocus- value={modelQuery}- onChange={e => setModelQuery(e.target.value)}- placeholder={t('playground.searchModels')}- className="h-9 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"- />- </div>- <div className="max-h-72 overflow-y-auto p-1">- {filteredOptions.length === 0 ? (- <div className="px-2 py-6 text-center text-xs text-muted-foreground">{t('playground.noModelsFound')}</div>- ) : (- filteredOptions.map(o => (- <button- key={o.value}- type="button"- onClick={() => pickModel(o.value)}- className={`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-accent hover:text-accent-foreground ${o.value === selectedModel ? 'bg-accent/50' : ''}`}- >- <Check className={`size-4 shrink-0 ${o.value === selectedModel ? 'opacity-100' : 'opacity-0'}`} />- <span className="min-w-0 flex-1 truncate">{o.label}</span>- {o.isNew && <span className="rounded px-1 py-0.5 text-[9px] font-semibold uppercase leading-none tracking-wide bg-emerald-500/15 text-emerald-600 dark:text-emerald-400">{t('models.newBadge')}</span>}- {o.sub && (o.platforms.length > 1- ? <Tooltip text={t('models.servedBy', { providers: o.platforms.join(', ') })}><span className="shrink-0 text-xs text-muted-foreground underline decoration-dotted underline-offset-2">{o.sub}</span></Tooltip>- : <span className="shrink-0 text-xs text-muted-foreground">{o.sub}</span>)}- </button>- ))- )}- {!modelQ && availableModels.length === 0 && (- // Models only appear once a platform has an enabled key. Without- // one, the list is just Auto/Fusion and looks broken — say why. (#269)- <div className="px-2 py-1.5 text-xs text-muted-foreground">{t('playground.noModels')}</div>- )}- </div>- </PopoverContent>- </Popover>+ <ModelCombobox+ value={selectedModel}+ options={pickerOptions}+ onSelect={pickModel}+ ariaLabel={t('playground.selectModel')}+ placeholder={t('playground.searchModels')}+ emptyText={t('playground.noModelsFound')}+ footer={+ availableModels.length === 0 ? (+ // Models only appear once a platform has an enabled key. Without+ // one, the list is just Auto/Fusion and looks broken — say why. (#269)+ <div className="px-2 py-1.5 text-xs text-muted-foreground">{t('playground.noModels')}</div>+ ) : undefined+ }+ />{messages.length > 0 && (<Button variant="outline" size="sm" onClick={handleClear}>{t('playground.clear')}@@ -441,15 +403,27 @@ export default function PlaygroundPage() {{showBubble && (<divclassName={`group relative rounded-2xl px-4 py-2.5 text-sm leading-relaxed ${- msg.role === 'user' ? 'bg-primary text-primary-foreground' : 'bg-muted'+ msg.role === 'user'+ ? 'bg-primary text-primary-foreground'+ : msg.isError+ ? 'border border-destructive/25 bg-destructive/10 text-destructive'+ : 'bg-muted'}`}>- {msg.role === 'assistant' ? (+ {msg.isError ? (+ <div className="flex items-start gap-2">+ <CircleAlert className="mt-0.5 size-4 shrink-0" />+ <div className="min-w-0">+ <p className="font-medium">{t('playground.errorTitle')}</p>+ <p className="whitespace-pre-wrap break-words">{msg.content}</p>+ </div>+ </div>+ ) : msg.role === 'assistant' ? (<Markdown>{msg.content}</Markdown>) : (<div className="whitespace-pre-wrap">{msg.content}</div>)}- {msg.role === 'assistant' && msg.content && (+ {msg.role === 'assistant' && !msg.isError && msg.content && (<CopyButtontext={msg.content}label={t('playground.copyReply')}