import { useFilteredList } from "@opencode-ai/ui/hooks" import { ProviderIcon } from "@opencode-ai/ui/provider-icon" import { Switch } from "@opencode-ai/ui/v2/switch-v2" import { Icon as IconV2 } from "@opencode-ai/ui/v2/icon" import { IconButtonV2 } from "@opencode-ai/ui/v2/icon-button-v2" import { TextInputV2 } from "@opencode-ai/ui/v2/text-input-v2" import { type Component, For, Show } from "solid-js" import { useLanguage } from "@/context/language" import { useModels } from "@/context/models" import { popularProviders } from "@/hooks/use-providers" import { SettingsListV2 } from "./parts/list" import { SettingsRowV2 } from "./parts/row" import "./settings-v2.css" type ModelItem = ReturnType["list"]>[number] const PROVIDER_ICON_SIZE = 16 export const SettingsModelsV2: Component = () => { const language = useLanguage() const models = useModels() const list = useFilteredList({ items: (_filter) => models.list(), key: (x) => `${x.provider.id}:${x.id}`, filterKeys: ["provider.name", "name", "id"], sortBy: (a, b) => a.name.localeCompare(b.name), groupBy: (x) => x.provider.id, sortGroupsBy: (a, b) => { const aIndex = popularProviders.indexOf(a.category) const bIndex = popularProviders.indexOf(b.category) const aPopular = aIndex >= 0 const bPopular = bIndex >= 0 if (aPopular && !bPopular) return -1 if (!aPopular && bPopular) return 1 if (aPopular && bPopular) return aIndex - bIndex const aName = a.items[0].provider.name const bName = b.items[0].provider.name return aName.localeCompare(bName) }, }) return ( <>

{language.t("settings.models.title")}

{language.t("common.loading")} {language.t("common.loading.ellipsis")}
} > 0} fallback={
{language.t("dialog.model.empty")} "{list.filter()}"
} > {(group) => (

{group.items[0].provider.name}

{(item) => { const key = { providerID: item.provider.id, modelID: item.id } return (
{ models.setVisibility(key, checked) }} hideLabel > {item.name}
) }}
)}
) }