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: global error toasts, error boundary, 404 page, unified confirm-delete
Tashfeen4f63bad57f86
diff --git a/client/src/App.tsx b/client/src/App.tsxindex 857dd217..e7bea814 100644--- a/client/src/App.tsx+++ b/client/src/App.tsx@@ -1,6 +1,6 @@-import { useEffect, useState } from 'react'+import { useEffect, useState, type ReactNode } from 'react'import { BrowserRouter, Routes, Route, Navigate, NavLink, Link, useLocation, useNavigate } from 'react-router-dom'-import { QueryClient, QueryClientProvider } from '@tanstack/react-query'+import { MutationCache, QueryClient, QueryClientProvider } from '@tanstack/react-query'import { Languages, Menu, MoreHorizontal, Moon, Sun } from 'lucide-react'import { buttonVariants } from '@/components/ui/button'import {@@ -17,8 +17,11 @@ import {DropdownMenuTrigger,} from '@/components/ui/dropdown-menu'import { AuthGate } from '@/components/auth-gate'+import { ErrorBoundary } from '@/components/error-boundary'+import { Toaster } from '@/components/toaster'import { I18nProvider, useI18n, SUPPORTED_LOCALES, type Locale } from '@/i18n'import { logout } from '@/lib/api'+import { toast } from '@/lib/toast'import KeysPage from '@/pages/KeysPage'import PlaygroundPage from '@/pages/PlaygroundPage'import FallbackPage from '@/pages/FallbackPage'@@ -31,8 +34,19 @@ import MediaDetailPage from '@/pages/MediaDetailPage'import EmbeddingDetailPage from '@/pages/EmbeddingDetailPage'import AnalyticsPage from '@/pages/AnalyticsPage'import PremiumPage from '@/pages/PremiumPage'+import NotFoundPage from '@/pages/NotFoundPage'-const queryClient = new QueryClient()+// Every failed mutation surfaces as an error toast, so no action fails+// silently. A page that already shows the failure inline can opt out with+// `meta: { silenceToast: true }` on the mutation.+const queryClient = new QueryClient({+ mutationCache: new MutationCache({+ onError: (error, _variables, _context, mutation) => {+ if (mutation.meta?.silenceToast) return+ toast.error(error instanceof Error ? error.message : String(error))+ },+ }),+})const navItems = [{ to: '/models', labelKey: 'nav.models' },@@ -229,6 +243,12 @@ function Navbar() {)}+// Keyed by pathname so navigating away from a crashed page resets the boundary.+function PageBoundary({ children }: { children: ReactNode }) {+ const location = useLocation()+ return <ErrorBoundary key={location.pathname}>{children}</ErrorBoundary>+}+function App() {return (<QueryClientProvider client={queryClient}>@@ -238,6 +258,7 @@ function App() {<div className={`min-h-screen ${isDesktopApp ? 'desktop-backdrop' : 'bg-background'}`}><Navbar /><main className="max-w-6xl mx-auto px-6 py-8">+ <PageBoundary><Routes><Route path="/" element={<Navigate to="/models/chat" replace />} /><Route path="/models" element={<Navigate to="/models/chat" replace />} />@@ -257,8 +278,11 @@ function App() {<Route path="/premium" element={<PremiumPage />} /><Route path="/test" element={<Navigate to="/playground" replace />} /><Route path="/health" element={<Navigate to="/keys" replace />} />+ <Route path="*" element={<NotFoundPage />} /></Routes>+ </PageBoundary></main>+ <Toaster /></div></AuthGate></BrowserRouter>diff --git a/client/src/components/confirm-button.tsx b/client/src/components/confirm-button.tsxnew file mode 100644index 00000000..11b9c0a8--- /dev/null+++ b/client/src/components/confirm-button.tsx@@ -0,0 +1,74 @@+import { useEffect, useState, type ReactNode } from 'react'+import { Button } from '@/components/ui/button'+import { cn } from '@/lib/utils'+import { useI18n } from '@/i18n'++// The dashboard's one destructive-action idiom: first click arms the button+// (label flips to "Confirm" in destructive color), second click within the+// timeout fires onConfirm, and doing nothing disarms it again. Extracted from+// the hand-rolled copies on Keys and ModelDetail so Embeddings/Media deletes+// (which used to fire immediately, with no confirmation) behave the same way.+type ButtonSize = 'default' | 'xs' | 'sm' | 'lg' | 'icon' | 'icon-xs' | 'icon-sm' | 'icon-lg'+type ButtonVariant = 'default' | 'outline' | 'secondary' | 'ghost' | 'destructive' | 'link'++export function ConfirmButton({+ onConfirm,+ children,+ confirmLabel,+ timeout = 3000,+ variant = 'ghost',+ size = 'xs',+ armedSize,+ className,+ armedClassName,+ disabled,+ title,+ 'aria-label': ariaLabel,+}: {+ onConfirm: () => void+ /** Idle content: a text label or an icon. */+ children: ReactNode+ /** Armed label; defaults to the shared "Confirm". */+ confirmLabel?: string+ timeout?: number+ variant?: ButtonVariant+ size?: ButtonSize+ /** Optional size swap while armed (icon buttons widen to fit the text). */+ armedSize?: ButtonSize+ className?: string+ armedClassName?: string+ disabled?: boolean+ title?: string+ 'aria-label'?: string+}) {+ const { t } = useI18n()+ const [armed, setArmed] = useState(false)++ useEffect(() => {+ if (!armed) return+ const timer = window.setTimeout(() => setArmed(false), timeout)+ return () => window.clearTimeout(timer)+ }, [armed, timeout])++ return (+ <Button+ type="button"+ variant={variant}+ size={armed ? (armedSize ?? size) : size}+ className={cn(className, armed && (armedClassName ?? 'text-destructive'))}+ disabled={disabled}+ title={title}+ aria-label={armed ? undefined : ariaLabel}+ onClick={() => {+ if (armed) {+ setArmed(false)+ onConfirm()+ } else {+ setArmed(true)+ }+ }}+ >+ {armed ? (confirmLabel ?? t('common.confirm')) : children}+ </Button>+ )+}diff --git a/client/src/components/error-boundary.tsx b/client/src/components/error-boundary.tsxnew file mode 100644index 00000000..ea2f428d--- /dev/null+++ b/client/src/components/error-boundary.tsx@@ -0,0 +1,56 @@+import { Component, type ReactNode } from 'react'+import { Link } from 'react-router-dom'+import { CircleAlert } from 'lucide-react'+import { Button } from '@/components/ui/button'+import { useI18n } from '@/i18n'++// Route-level error boundary: a render throw inside a page shows a friendly+// crash card instead of white-screening the whole app. Keyed by pathname in+// App.tsx, so navigating away from the crashed page automatically resets it.+interface ErrorBoundaryState {+ error: Error | null+}++export class ErrorBoundary extends Component<{ children: ReactNode }, ErrorBoundaryState> {+ state: ErrorBoundaryState = { error: null }++ static getDerivedStateFromError(error: Error): ErrorBoundaryState {+ return { error }+ }++ componentDidCatch(error: Error) {+ console.error('[dashboard] page crashed:', error)+ }++ render() {+ if (this.state.error) {+ return <CrashScreen error={this.state.error} onRetry={() => this.setState({ error: null })} />+ }+ return this.props.children+ }+}++// Functional child so it can use the i18n hook (the class itself cannot).+function CrashScreen({ error, onRetry }: { error: Error; onRetry: () => void }) {+ const { t } = useI18n()+ return (+ <div className="flex justify-center py-16">+ <div className="w-full max-w-md rounded-3xl border bg-card p-8 text-center">+ <CircleAlert className="mx-auto size-8 text-destructive" />+ <h1 className="mt-4 text-lg font-semibold">{t('errors.boundaryTitle')}</h1>+ <p className="mt-1 text-sm text-muted-foreground">{t('errors.boundaryDescription')}</p>+ {error.message && (+ <code className="mt-3 block truncate rounded-lg bg-muted px-3 py-2 font-mono text-[11px] text-muted-foreground" title={error.message}>+ {error.message}+ </code>+ )}+ <div className="mt-5 flex items-center justify-center gap-2">+ <Button variant="outline" size="sm" onClick={onRetry}>{t('errors.tryAgain')}</Button>+ <Link to="/" onClick={onRetry}>+ <Button size="sm">{t('errors.goHome')}</Button>+ </Link>+ </div>+ </div>+ </div>+ )+}diff --git a/client/src/components/media-models.tsx b/client/src/components/media-models.tsxindex 03e35dd6..547409b7 100644--- a/client/src/components/media-models.tsx+++ b/client/src/components/media-models.tsx@@ -2,7 +2,7 @@ import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'import { Link } from 'react-router-dom'import { apiFetch } from '@/lib/api'import { Switch } from '@/components/ui/switch'-import { Button } from '@/components/ui/button'+import { ConfirmButton } from '@/components/confirm-button'import { PageHeader } from '@/components/page-header'import { ModelsTabs } from '@/components/models-tabs'import { useI18n } from '@/i18n'@@ -124,15 +124,13 @@ export function MediaModelsView({ modality }: { modality: 'image' | 'audio' }) {onCheckedChange={(c) => toggle.mutate({ id: m.id, enabled: c })}/>{m.isCustom && (- <Button- variant="ghost"- size="xs"+ <ConfirmButtonclassName="text-muted-foreground hover:text-destructive"- onClick={() => deleteCustom.mutate(m.id)}+ onConfirm={() => deleteCustom.mutate(m.id)}disabled={deleteCustom.isPending}>{t('common.remove')}- </Button>+ </ConfirmButton>)}</div>))}diff --git a/client/src/components/toaster.tsx b/client/src/components/toaster.tsxnew file mode 100644index 00000000..94125026--- /dev/null+++ b/client/src/components/toaster.tsx@@ -0,0 +1,59 @@+import { useEffect, useSyncExternalStore } from 'react'+import { CircleAlert, CircleCheck, Info, X } from 'lucide-react'+import { dismissToast, getToasts, subscribeToasts, type ToastItem } from '@/lib/toast'+import { useI18n } from '@/i18n'++// Bottom-right toast stack. FloatingBar owns bottom-center, so the two never+// collide. Errors are assertive for screen readers; the rest are polite.+export function Toaster() {+ const toasts = useSyncExternalStore(subscribeToasts, getToasts, getToasts)+ if (toasts.length === 0) return null+ return (+ <div className="pointer-events-none fixed bottom-6 right-4 z-[60] flex w-full max-w-sm flex-col gap-2 sm:right-6">+ {toasts.map(t => (+ <Toast key={t.id} toast={t} />+ ))}+ </div>+ )+}++const ICONS = {+ success: CircleCheck,+ error: CircleAlert,+ info: Info,+} as const++const ICON_CLASS = {+ success: 'text-emerald-600 dark:text-emerald-400',+ error: 'text-destructive',+ info: 'text-muted-foreground',+} as const++function Toast({ toast }: { toast: ToastItem }) {+ const { t } = useI18n()++ useEffect(() => {+ const timer = window.setTimeout(() => dismissToast(toast.id), toast.duration)+ return () => window.clearTimeout(timer)+ }, [toast.id, toast.duration])++ const Icon = ICONS[toast.kind]+ return (+ <div+ role={toast.kind === 'error' ? 'alert' : 'status'}+ aria-live={toast.kind === 'error' ? 'assertive' : 'polite'}+ className="pointer-events-auto flex items-start gap-2.5 rounded-2xl border bg-card px-3.5 py-2.5 shadow-lg animate-in slide-in-from-bottom-2 fade-in duration-200"+ >+ <Icon className={`mt-0.5 size-4 shrink-0 ${ICON_CLASS[toast.kind]}`} />+ <p className="min-w-0 flex-1 break-words text-sm leading-snug">{toast.message}</p>+ <button+ type="button"+ aria-label={t('common.dismiss')}+ onClick={() => dismissToast(toast.id)}+ className="rounded-md p-0.5 text-muted-foreground/60 transition-colors hover:text-foreground"+ >+ <X className="size-3.5" />+ </button>+ </div>+ )+}diff --git a/client/src/i18n/locales/en.json b/client/src/i18n/locales/en.jsonindex 5b198c78..0dbe5a9b 100644--- a/client/src/i18n/locales/en.json+++ b/client/src/i18n/locales/en.json@@ -61,7 +61,8 @@"model": "Model","provider": "Provider","success": "Success",- "failures": "Failures"+ "failures": "Failures",+ "dismiss": "Dismiss"},"models": {"title": "Models",@@ -466,5 +467,15 @@"es": "Español","pt-BR": "Português (Brasil)","it": "Italiano"+ },+ "errors": {+ "boundaryTitle": "Something went wrong",+ "boundaryDescription": "The dashboard hit an unexpected error. Your data is safe. Try again or go back to the models page.",+ "tryAgain": "Try again",+ "goHome": "Back to models"+ },+ "notFound": {+ "title": "Page not found",+ "description": "This page does not exist or may have moved."}}diff --git a/client/src/i18n/locales/es.json b/client/src/i18n/locales/es.jsonindex 547260f3..f4bf57f9 100644--- a/client/src/i18n/locales/es.json+++ b/client/src/i18n/locales/es.json@@ -61,7 +61,8 @@"model": "Modelo","provider": "Proveedor","success": "Aciertos",- "failures": "Fallos"+ "failures": "Fallos",+ "dismiss": "Descartar"},"models": {"title": "Modelos",@@ -387,5 +388,15 @@"es": "Español","pt-BR": "Português (Brasil)","it": "Italiano"+ },+ "errors": {+ "boundaryTitle": "Algo salió mal",+ "boundaryDescription": "El panel encontró un error inesperado. Tus datos están a salvo. Inténtalo de nuevo o vuelve a la página de modelos.",+ "tryAgain": "Intentar de nuevo",+ "goHome": "Volver a modelos"+ },+ "notFound": {+ "title": "Página no encontrada",+ "description": "Esta página no existe o puede haberse movido."}}diff --git a/client/src/i18n/locales/fr.json b/client/src/i18n/locales/fr.jsonindex 42cf0c5f..bdd7e5ca 100644--- a/client/src/i18n/locales/fr.json+++ b/client/src/i18n/locales/fr.json@@ -61,7 +61,8 @@"model": "Modèle","provider": "Fournisseur","success": "Réussite",- "failures": "Échecs"+ "failures": "Échecs",+ "dismiss": "Fermer"},"models": {"title": "Modèles",@@ -387,5 +388,15 @@"es": "Español","pt-BR": "Português (Brasil)","it": "Italiano"+ },+ "errors": {+ "boundaryTitle": "Une erreur est survenue",+ "boundaryDescription": "Le tableau de bord a rencontré une erreur inattendue. Vos données sont en sécurité. Réessayez ou revenez à la page des modèles.",+ "tryAgain": "Réessayer",+ "goHome": "Retour aux modèles"+ },+ "notFound": {+ "title": "Page introuvable",+ "description": "Cette page n'existe pas ou a peut-être été déplacée."}}diff --git a/client/src/i18n/locales/it.json b/client/src/i18n/locales/it.jsonindex 354c6291..97fcd8fa 100644--- a/client/src/i18n/locales/it.json+++ b/client/src/i18n/locales/it.json@@ -61,7 +61,8 @@"model": "Modello","provider": "Fornitore","success": "Successo",- "failures": "Fallimenti"+ "failures": "Fallimenti",+ "dismiss": "Chiudi"},"models": {"title": "Modelli",@@ -408,5 +409,15 @@"es": "Español","pt-BR": "Português (Brasil)","it": "Italiano"+ },+ "errors": {+ "boundaryTitle": "Qualcosa è andato storto",+ "boundaryDescription": "La dashboard ha riscontrato un errore imprevisto. I tuoi dati sono al sicuro. Riprova o torna alla pagina dei modelli.",+ "tryAgain": "Riprova",+ "goHome": "Torna ai modelli"+ },+ "notFound": {+ "title": "Pagina non trovata",+ "description": "Questa pagina non esiste o potrebbe essere stata spostata."}}diff --git a/client/src/i18n/locales/pt-BR.json b/client/src/i18n/locales/pt-BR.jsonindex 6a68615b..c727ca86 100644--- a/client/src/i18n/locales/pt-BR.json+++ b/client/src/i18n/locales/pt-BR.json@@ -61,7 +61,8 @@"model": "Modelo","provider": "Provedor","success": "Sucessos",- "failures": "Falhas"+ "failures": "Falhas",+ "dismiss": "Dispensar"},"models": {"title": "Modelos",@@ -387,5 +388,15 @@"es": "Español","pt-BR": "Português (Brasil)","it": "Italiano"+ },+ "errors": {+ "boundaryTitle": "Algo deu errado",+ "boundaryDescription": "O painel encontrou um erro inesperado. Seus dados estão seguros. Tente novamente ou volte para a página de modelos.",+ "tryAgain": "Tentar novamente",+ "goHome": "Voltar aos modelos"+ },+ "notFound": {+ "title": "Página não encontrada",+ "description": "Esta página não existe ou pode ter sido movida."}}diff --git a/client/src/i18n/locales/zh-CN.json b/client/src/i18n/locales/zh-CN.jsonindex 4b2267db..1fdd96f0 100644--- a/client/src/i18n/locales/zh-CN.json+++ b/client/src/i18n/locales/zh-CN.json@@ -61,7 +61,8 @@"model": "模型","provider": "提供方","success": "成功",- "failures": "失败"+ "failures": "失败",+ "dismiss": "关闭"},"models": {"title": "模型",@@ -410,5 +411,15 @@"es": "Español","pt-BR": "Português (Brasil)","it": "Italiano"+ },+ "errors": {+ "boundaryTitle": "出错了",+ "boundaryDescription": "仪表盘遇到了意外错误。您的数据是安全的。请重试或返回模型页面。",+ "tryAgain": "重试",+ "goHome": "返回模型页"+ },+ "notFound": {+ "title": "页面未找到",+ "description": "此页面不存在或已被移动。"}}diff --git a/client/src/lib/toast.ts b/client/src/lib/toast.tsnew file mode 100644index 00000000..e7281ede--- /dev/null+++ b/client/src/lib/toast.ts@@ -0,0 +1,60 @@+// Zero-dependency toast store, same spirit as the i18n provider: a module-level+// list plus subscribers, rendered by <Toaster /> (components/toaster.tsx).+// Pages fire `toast.error(...)` / `toast.success(...)`; the App-level+// MutationCache uses toast.error as the global surface for failed mutations so+// no action can fail silently again.++export type ToastKind = 'success' | 'error' | 'info'++export interface ToastItem {+ id: number+ kind: ToastKind+ message: string+ /** Auto-dismiss delay in ms. */+ duration: number+}++type Listener = (toasts: ToastItem[]) => void++let items: ToastItem[] = []+let nextId = 1+const listeners = new Set<Listener>()++function emit() {+ for (const listener of listeners) listener(items)+}++export function subscribeToasts(listener: Listener): () => void {+ listeners.add(listener)+ return () => {+ listeners.delete(listener)+ }+}++export function getToasts(): ToastItem[] {+ return items+}++export function dismissToast(id: number) {+ if (!items.some(t => t.id === id)) return+ items = items.filter(t => t.id !== id)+ emit()+}++function push(kind: ToastKind, message: string, duration?: number): number {+ const id = nextId+++ // Replace an identical pending toast instead of stacking duplicates (a+ // failing poll would otherwise pile up the same error every interval).+ items = [+ ...items.filter(t => !(t.kind === kind && t.message === message)),+ { id, kind, message, duration: duration ?? (kind === 'error' ? 6000 : 3500) },+ ].slice(-4)+ emit()+ return id+}++export const toast = {+ success: (message: string, duration?: number) => push('success', message, duration),+ error: (message: string, duration?: number) => push('error', message, duration),+ info: (message: string, duration?: number) => push('info', message, duration),+}diff --git a/client/src/pages/EmbeddingsPage.tsx b/client/src/pages/EmbeddingsPage.tsxindex 70fa24d6..d93e33d0 100644--- a/client/src/pages/EmbeddingsPage.tsx+++ b/client/src/pages/EmbeddingsPage.tsx@@ -4,6 +4,7 @@ import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'import { ArrowDown, ArrowUp } from 'lucide-react'import { apiFetch } from '@/lib/api'import { Button } from '@/components/ui/button'+import { ConfirmButton } from '@/components/confirm-button'import { Switch } from '@/components/ui/switch'import { PageHeader } from '@/components/page-header'import { FloatingBar } from '@/components/floating-bar'@@ -212,15 +213,13 @@ export default function EmbeddingsPage() {onCheckedChange={(c) => updateProvider(f.family, p.id, { enabled: c })}/>{p.isCustom && (- <Button- variant="ghost"- size="xs"+ <ConfirmButtonclassName="text-muted-foreground hover:text-destructive"- onClick={() => deleteCustom.mutate(p.id)}+ onConfirm={() => deleteCustom.mutate(p.id)}disabled={deleteCustom.isPending}>{t('common.remove')}- </Button>+ </ConfirmButton>)}</div>))}diff --git a/client/src/pages/KeysPage.tsx b/client/src/pages/KeysPage.tsxindex a4577fa9..08de3016 100644--- a/client/src/pages/KeysPage.tsx+++ b/client/src/pages/KeysPage.tsx@@ -2,6 +2,7 @@ import { useState, useRef, useEffect } from 'react'import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'import { apiFetch } from '@/lib/api'import { Button } from '@/components/ui/button'+import { ConfirmButton } from '@/components/confirm-button'import { Input } from '@/components/ui/input'import { Textarea } from '@/components/ui/textarea'import { Label } from '@/components/ui/label'@@ -280,6 +281,7 @@ function ProxySettingsSection() {}, [data?.proxyUrl])const saveProxy = useMutation({+ meta: { silenceToast: true },mutationFn: (body: { proxyUrl?: string; enabled?: boolean; bypassPlatforms?: string[] }) =>apiFetch<{ proxyUrl: string; enabled: boolean; bypassPlatforms: string[]; active: boolean }>('/api/settings/proxy', { method: 'PUT', body: JSON.stringify(body) }),onSuccess: (result: { proxyUrl: string; enabled: boolean; bypassPlatforms: string[]; active: boolean }) => {@@ -382,6 +384,7 @@ function ImportKeysSection() {}const preview = useMutation({+ meta: { silenceToast: true },mutationFn: async (nextFiles: File[]) => {const formData = new FormData()nextFiles.forEach(file => formData.append('files', file))@@ -403,6 +406,7 @@ function ImportKeysSection() {})const importSelected = useMutation({+ meta: { silenceToast: true },mutationFn: (keys: ImportKey[]) =>apiFetch<ImportSelectedResponse>('/api/keys/import-selected', {method: 'POST',@@ -621,6 +625,7 @@ function CustomProviderSection() {})const addCustom = useMutation({+ meta: { silenceToast: true },mutationFn: ({ path, body }: { path: string; body: Record<string, unknown> }) =>apiFetch(path, { method: 'POST', body: JSON.stringify(body) }),onSuccess: () => {@@ -870,8 +875,6 @@ export default function KeysPage() {// Server-supplied notice when a key is saved for a platform with no models in// the current catalog tier yet (e.g. a newly added premium provider, #438).const [addNotice, setAddNotice] = useState<string | null>(null)- const [confirmDeleteId, setConfirmDeleteId] = useState<number | null>(null)- const [confirmDeleteModelKey, setConfirmDeleteModelKey] = useState<string | null>(null)const [expandedKeyIds, setExpandedKeyIds] = useState<Set<number>>(new Set())const editInputRef = useRef<HTMLInputElement>(null)@@ -887,6 +890,7 @@ export default function KeysPage() {})const addKey = useMutation({+ meta: { silenceToast: true },mutationFn: (body: { platform: string; key: string; label?: string }) =>apiFetch<{ notice?: string | null }>('/api/keys', { method: 'POST', body: JSON.stringify(body) }),onSuccess: (data) => {@@ -1250,36 +1254,32 @@ export default function KeysPage() {</span>)}{!isEditing && (- <Button variant="ghost" size="xs" onClick={() => startEditing(k)}>+ <Button+ variant="ghost"+ size="xs"+ onClick={() => startEditing(k)}+ aria-label={t('keys.editLabel')}+ title={t('keys.editLabel')}+ ><Pencil className="size-3" /></Button>)}<Button variant="ghost" size="xs" onClick={() => checkKey.mutate(k.id)} disabled={checkKey.isPending}>{t('common.check')}</Button>- <Button- variant="ghost"- size="xs"- className={confirmDeleteId === k.id ? 'text-destructive' : 'text-muted-foreground hover:text-destructive'}- onClick={() => {- if (confirmDeleteId === k.id) {- deleteKey.mutate(k.id)- setConfirmDeleteId(null)- } else {- setConfirmDeleteId(k.id)- setTimeout(() => setConfirmDeleteId(c => (c === k.id ? null : c)), 3000)- }- }}+ <ConfirmButton+ className="text-muted-foreground hover:text-destructive"+ confirmLabel={t('keys.confirmRemove')}+ onConfirm={() => deleteKey.mutate(k.id)}disabled={deleteKey.isPending}>- {confirmDeleteId === k.id ? t('keys.confirmRemove') : t('common.remove')}- </Button>+ {t('common.remove')}+ </ConfirmButton></div>{hasCustomModels && isExpanded && (<div className="flex flex-wrap gap-2 border-t bg-muted/20 px-4 py-3 pl-12">{customModels.map(model => {const modelKey = customModelDeleteKey(model)- const confirming = confirmDeleteModelKey === modelKeyreturn (<div key={modelKey} className="inline-flex min-w-0 items-center gap-2 rounded-md border bg-background px-2 py-1 text-[11px]"><span className="rounded border px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground">@@ -1293,25 +1293,15 @@ export default function KeysPage() {{model.family}</code>)}- <Button- type="button"- variant="ghost"- size="xs"- className={`h-5 px-1 ${confirming ? 'text-destructive' : 'text-muted-foreground hover:text-destructive'}`}+ <ConfirmButton+ className="h-5 px-1 text-muted-foreground hover:text-destructive"disabled={deleteCustomModel.isPending}- onClick={() => {- if (confirming) {- deleteCustomModel.mutate(model)- setConfirmDeleteModelKey(null)- } else {- setConfirmDeleteModelKey(modelKey)- setTimeout(() => setConfirmDeleteModelKey(c => (c === modelKey ? null : c)), 3000)- }- }}+ onConfirm={() => deleteCustomModel.mutate(model)}title={t('common.remove')}+ aria-label={t('common.remove')}>- {confirming ? t('common.confirm') : <Trash2 className="size-3" />}- </Button>+ <Trash2 className="size-3" />+ </ConfirmButton></div>)})}diff --git a/client/src/pages/ModelDetailPage.tsx b/client/src/pages/ModelDetailPage.tsxindex 1285e270..1bc9847a 100644--- a/client/src/pages/ModelDetailPage.tsx+++ b/client/src/pages/ModelDetailPage.tsx@@ -5,6 +5,7 @@ import { ChevronLeft, Save, Trash2 } from 'lucide-react'import { useI18n } from '@/i18n'import { apiFetch } from '@/lib/api'import { Button } from '@/components/ui/button'+import { ConfirmButton } from '@/components/confirm-button'import { Input } from '@/components/ui/input'import { Switch } from '@/components/ui/switch'import { CopyButton } from '@/components/copy-button'@@ -225,7 +226,6 @@ function ProviderSettingsRow({const [supportsVision, setSupportsVision] = useState(model.supportsVision)const [supportsTools, setSupportsTools] = useState(model.supportsTools)const [fallbackEnabled, setFallbackEnabled] = useState(model.enabled)- const [confirmDelete, setConfirmDelete] = useState(false)useEffect(() => {setDisplayName(model.displayName)@@ -233,15 +233,8 @@ function ProviderSettingsRow({setSupportsVision(model.supportsVision)setSupportsTools(model.supportsTools)setFallbackEnabled(model.enabled)- setConfirmDelete(false)}, [model.modelDbId, model.displayName, model.contextWindow, model.supportsVision, model.supportsTools, model.enabled])- useEffect(() => {- if (!confirmDelete) return- const timer = window.setTimeout(() => setConfirmDelete(false), 3000)- return () => window.clearTimeout(timer)- }, [confirmDelete])-const parsedContext = contextWindow.trim() === '' ? null : Number(contextWindow)const contextInvalid = parsedContext !== null && (!Number.isInteger(parsedContext) || parsedContext <= 0)const nameInvalid = displayName.trim().length === 0@@ -265,14 +258,6 @@ function ProviderSettingsRow({})}- function remove() {- if (!confirmDelete) {- setConfirmDelete(true)- return- }- onDelete()- }-return (<div className="rounded-xl border bg-background/60 p-3"><div className="mb-3 flex flex-wrap items-center gap-2">@@ -325,15 +310,17 @@ function ProviderSettingsRow({<Save className="size-3.5" /></Button></Tooltip>- <Button- type="button"- size={confirmDelete ? 'xs' : 'icon-sm'}+ <ConfirmButtonvariant="destructive"+ size="icon-sm"+ armedSize="xs"+ armedClassName=""disabled={saving || deleting}- onClick={remove}+ onConfirm={onDelete}+ aria-label={t('common.delete')}>- {confirmDelete ? t('common.confirm') : <Trash2 className="size-3.5" />}- </Button>+ <Trash2 className="size-3.5" />+ </ConfirmButton></div></div></div>diff --git a/client/src/pages/NotFoundPage.tsx b/client/src/pages/NotFoundPage.tsxnew file mode 100644index 00000000..f38a84f7--- /dev/null+++ b/client/src/pages/NotFoundPage.tsx@@ -0,0 +1,24 @@+import { Link } from 'react-router-dom'+import { Compass } from 'lucide-react'+import { Button } from '@/components/ui/button'+import { useI18n } from '@/i18n'++// Catch-all route: before this, an unknown URL rendered the navbar over a+// silent empty page.+export default function NotFoundPage() {+ const { t } = useI18n()+ return (+ <div className="flex justify-center py-16">+ <div className="w-full max-w-md rounded-3xl border bg-card p-8 text-center">+ <Compass className="mx-auto size-8 text-muted-foreground" />+ <h1 className="mt-4 text-lg font-semibold">{t('notFound.title')}</h1>+ <p className="mt-1 text-sm text-muted-foreground">{t('notFound.description')}</p>+ <div className="mt-5">+ <Link to="/">+ <Button size="sm">{t('errors.goHome')}</Button>+ </Link>+ </div>+ </div>+ </div>+ )+}diff --git a/client/src/pages/PremiumPage.tsx b/client/src/pages/PremiumPage.tsxindex c7f2fb55..4e89ad4a 100644--- a/client/src/pages/PremiumPage.tsx+++ b/client/src/pages/PremiumPage.tsx@@ -62,6 +62,7 @@ export default function PremiumPage() {}const activate = useMutation({+ meta: { silenceToast: true },mutationFn: (key: string) =>apiFetch('/api/premium/key', { method: 'POST', body: JSON.stringify({ key }) }),onSuccess: () => {@@ -81,6 +82,7 @@ export default function PremiumPage() {})const openPortal = useMutation({+ meta: { silenceToast: true },mutationFn: () => apiFetch<{ url: string }>('/api/premium/portal', { method: 'POST' }),onSuccess: ({ url }) => {window.open(url, '_blank', 'noopener')