import type React from "react"; import type { LlmProvider } from "../types"; import { inputSolidStyle, sectionBoxStyle, sectionTitleStyle } from "./modalStyles"; interface Props { providers: LlmProvider[]; providerId: string; model: string; loading?: boolean; hint?: string; onChange: (next: { providerId: string; model: string; baseUrl: string }) => void; } /** Cascading backend → model picker sourced from a profile's `providers:` block. */ export function ProviderModelSelect({ providers, providerId, model, loading, hint, onChange, }: Props) { if (loading) { return (
Backend & model
Loading providers…
); } if (providers.length === 0) return null; const selected = providers.find((p) => p.id === providerId) ?? providers[0]; const modelOptions = selected.models.length ? selected.models : [model].filter(Boolean); function pickProvider(id: string) { const p = providers.find((x) => x.id === id) ?? providers[0]; const nextModel = p.default_model || p.models[0] || ""; onChange({ providerId: p.id, model: nextModel, baseUrl: p.base_url }); } function pickModel(m: string) { onChange({ providerId: selected.id, model: m, baseUrl: selected.base_url }); } return (
Backend & model
{selected.base_url}
{hint && (
{hint}
)}
); } const labelStyle: React.CSSProperties = { fontSize: 10, fontWeight: 700, letterSpacing: 0.6, textTransform: "uppercase", color: "var(--text-dim)", }; const selectStyle: React.CSSProperties = { ...inputSolidStyle, width: "100%", fontFamily: "ui-monospace, monospace", };