mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-19 17:01:37 +03:00
feat(app): group Manage models into provider cards and drop the picker's check column
Manage models: each provider is a card (50% bg-layer-01, 8px radius, 6px apart) with its models inside, aligned with the provider name. The provider toggle becomes a status after the name (No / N of M / All models enabled) and an Enable all / Disable all action that lines up with the model toggles. Disabled models are muted, row dividers are gone, and the search below the title drops its hairline and fills while focused or holding a query. An empty search reads No results for "query" on one line, capped at 60% like Settings. Model picker: the selected model loses its check and the column reserved for it, so names and section headers line up with the search icon; the current model keeps an overlay-pressed fill instead.
This commit is contained in:
@@ -1,6 +1,19 @@
|
||||
.manage-models-search {
|
||||
/* Below the title, the search is a field of its own: no hairline, and a fill while it is focused or has a query. */
|
||||
.settings-manage-models-dialog .manage-models-search {
|
||||
flex-shrink: 0;
|
||||
padding: 0 6px 8px;
|
||||
padding: 4px 8px 12px;
|
||||
|
||||
&::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
[data-component="text-input-v2"] {
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
[data-component="text-input-v2"]:is(:focus-within, :has(input:not(:placeholder-shown))):not([data-disabled]) {
|
||||
background: var(--v2-overlay-simple-overlay-hover);
|
||||
}
|
||||
}
|
||||
|
||||
[data-component="dialog-v2"]:has(.settings-manage-models-dialog) [data-slot="dialog-container"] {
|
||||
@@ -10,21 +23,53 @@
|
||||
|
||||
.settings-manage-models-dialog .settings-panel.settings-models {
|
||||
height: 100%;
|
||||
gap: 0;
|
||||
gap: 6px;
|
||||
padding: 0 8px 8px;
|
||||
}
|
||||
|
||||
/* Each provider is a card; its models sit inside it while it is open. */
|
||||
.settings-manage-models-dialog .settings-models .settings-section {
|
||||
gap: 4px;
|
||||
padding-block: 8px;
|
||||
gap: 0;
|
||||
padding: 2px 6px;
|
||||
border-radius: 8px;
|
||||
background: color-mix(in srgb, var(--v2-background-bg-layer-01) 50%, var(--v2-background-bg-base));
|
||||
}
|
||||
|
||||
.settings-manage-models-dialog .settings-models .settings-section[data-expanded] {
|
||||
padding-bottom: 8px;
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
|
||||
.settings-manage-models-dialog .settings-models .settings-section + .settings-section {
|
||||
border-top: 0.5px solid var(--v2-border-border-base);
|
||||
.settings-manage-models-dialog .settings-models-group-header {
|
||||
height: 36px;
|
||||
padding-inline-end: 8px;
|
||||
}
|
||||
|
||||
.settings-manage-models-dialog .settings-models-group-trigger {
|
||||
flex: 1;
|
||||
height: 36px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.manage-models-status {
|
||||
margin-inline-start: 8px;
|
||||
color: var(--v2-text-text-faint);
|
||||
font-size: 12px;
|
||||
font-weight: 440;
|
||||
font-variant-numeric: tabular-nums;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* The label lines up with the model toggles; its hover reaches the same edge as a model row's. */
|
||||
.settings-manage-models-dialog [data-component="button-v2"].manage-models-bulk {
|
||||
flex-shrink: 0;
|
||||
margin-inline-end: -8px;
|
||||
padding-inline: 8px;
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.manage-models-empty {
|
||||
padding-block: 48px;
|
||||
}
|
||||
|
||||
.settings-manage-models-dialog .provider-model-groups {
|
||||
@@ -81,33 +126,25 @@
|
||||
.manage-models-rows {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1px;
|
||||
}
|
||||
|
||||
.manage-models-rows .search-list-row {
|
||||
position: relative;
|
||||
height: 36px;
|
||||
height: 32px;
|
||||
padding-inline: 8px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.manage-models-rows .search-list-row:not(:last-child)::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset-inline: 8px;
|
||||
bottom: -0.75px;
|
||||
height: 0.5px;
|
||||
background: var(--v2-border-border-base);
|
||||
pointer-events: none;
|
||||
/* Model names line up with their provider's name: the trigger's 4px inset, 20px chevron, 4px gap, 16px icon, 8px gap. */
|
||||
.settings-manage-models-dialog [data-component="settings-models-provider"] .manage-models-rows .search-list-row {
|
||||
padding-inline-start: 52px;
|
||||
}
|
||||
|
||||
.manage-models-rows .search-list-row:not([data-enabled]) .search-list-title {
|
||||
color: var(--v2-text-text-faint);
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
.manage-models-rows .search-list-row:hover {
|
||||
background: var(--v2-overlay-simple-overlay-hover);
|
||||
}
|
||||
|
||||
.manage-models-rows .search-list-row:hover::after,
|
||||
.manage-models-rows .search-list-row:has(+ .search-list-row:hover)::after {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,11 @@ import { popularProviders } from "@/providers/catalog/providers"
|
||||
import { useLanguage } from "@/runtime/i18n/language"
|
||||
import { useDialog } from "@opencode/ui/context/dialog"
|
||||
import { DialogConnectProvider } from "@/providers/connect/dialog"
|
||||
import { SettingsSearchEmpty } from "@/settings/search-empty"
|
||||
import { decode64 } from "@/runtime/persistence/base64"
|
||||
import { consoleModelGroup, ProviderModelSections } from "@/providers/models/provider-group"
|
||||
import "@/settings/settings.css"
|
||||
import "@/settings/search.css"
|
||||
import "@/shell/search-list.css"
|
||||
import "./manage.css"
|
||||
|
||||
@@ -32,8 +34,21 @@ export const DialogManageModels: Component = () => {
|
||||
|
||||
const providerList = (providerID: string) => local.model.list().filter((x) => x.provider.id === providerID)
|
||||
|
||||
const providerVisible = (providerID: string) =>
|
||||
providerList(providerID).every((x) => local.model.visible({ modelID: x.id, providerID: x.provider.id }))
|
||||
const enabledCount = (providerID: string) =>
|
||||
providerList(providerID).filter((x) => local.model.visible({ modelID: x.id, providerID: x.provider.id })).length
|
||||
|
||||
const providerVisible = (providerID: string) => enabledCount(providerID) === providerList(providerID).length
|
||||
|
||||
const providerStatus = (providerID: string) => {
|
||||
const count = enabledCount(providerID)
|
||||
const total = providerList(providerID).length
|
||||
|
||||
if (count === 0) return language.t("dialog.model.manage.status.none")
|
||||
|
||||
if (count === total) return language.t("dialog.model.manage.status.all")
|
||||
|
||||
return language.t("dialog.model.manage.status.some", { count, total })
|
||||
}
|
||||
|
||||
const setProviderVisibility = (providerID: string, checked: boolean) => {
|
||||
providerList(providerID).forEach((x) => {
|
||||
@@ -80,6 +95,7 @@ export const DialogManageModels: Component = () => {
|
||||
{(item) => (
|
||||
<div
|
||||
class="search-list-row"
|
||||
data-enabled={visible(item) ? "" : undefined}
|
||||
onMouseDown={(event) => event.preventDefault()}
|
||||
onClick={() => setModelVisibility(item, !visible(item))}
|
||||
>
|
||||
@@ -145,12 +161,16 @@ export const DialogManageModels: Component = () => {
|
||||
<Show
|
||||
when={list.flat().length > 0}
|
||||
fallback={
|
||||
<div class="settings-models-status">
|
||||
<span>{language.t("dialog.model.empty")}</span>
|
||||
<Show when={list.filter()}>
|
||||
<span class="settings-models-status-filter">"{list.filter()}"</span>
|
||||
</Show>
|
||||
</div>
|
||||
<Show
|
||||
when={list.filter()}
|
||||
fallback={<div class="settings-models-status">{language.t("dialog.model.empty")}</div>}
|
||||
>
|
||||
{(query) => (
|
||||
<div class="settings-tab-search-empty manage-models-empty">
|
||||
<SettingsSearchEmpty query={query()} />
|
||||
</div>
|
||||
)}
|
||||
</Show>
|
||||
}
|
||||
>
|
||||
<ProviderModelSections
|
||||
@@ -160,15 +180,27 @@ export const DialogManageModels: Component = () => {
|
||||
disabled={searching()}
|
||||
onExpandedChange={(key, value) => setStore("collapsed", key, !value)}
|
||||
onSetVisibility={setProviderVisibility}
|
||||
detail={(group) => <span class="manage-models-status">{providerStatus(group.category)}</span>}
|
||||
action={(group) => (
|
||||
<Switch
|
||||
class="me-6"
|
||||
checked={providerVisible(group.category)}
|
||||
onChange={(checked) => setProviderVisibility(group.category, checked)}
|
||||
hideLabel
|
||||
// When only some models are enabled, the action enables the rest.
|
||||
<Button
|
||||
variant="ghost-muted"
|
||||
size="small"
|
||||
class="manage-models-bulk"
|
||||
aria-label={language.t(
|
||||
providerVisible(group.category)
|
||||
? "dialog.model.manage.disableAll.label"
|
||||
: "dialog.model.manage.enableAll.label",
|
||||
{ provider: group.items[0].provider.name },
|
||||
)}
|
||||
onClick={() => setProviderVisibility(group.category, !providerVisible(group.category))}
|
||||
>
|
||||
{group.items[0].provider.name}
|
||||
</Switch>
|
||||
{language.t(
|
||||
providerVisible(group.category)
|
||||
? "dialog.model.manage.disableAll"
|
||||
: "dialog.model.manage.enableAll",
|
||||
)}
|
||||
</Button>
|
||||
)}
|
||||
rows={(items) => <ModelRows items={items} />}
|
||||
/>
|
||||
|
||||
@@ -25,6 +25,7 @@ function CustomManagedProviderIcon(props: { class?: string }) {
|
||||
}
|
||||
|
||||
export function ProviderModelIcon(props: { provider: ModelProvider; class?: string }) {
|
||||
// SAFETY: the cast only lets `includes` look up any string; the type guard narrows on the result.
|
||||
const icon = () =>
|
||||
[
|
||||
props.provider.canonical,
|
||||
@@ -62,6 +63,8 @@ export function ProviderModelSections<T extends ModelItem>(props: {
|
||||
rows: (items: T[]) => JSX.Element
|
||||
/** Trailing control in a direct provider's header. */
|
||||
action?: (group: ModelGroup<T>) => JSX.Element
|
||||
/** Text after a direct provider's name, such as how many of its models are enabled. */
|
||||
detail?: (group: ModelGroup<T>) => JSX.Element
|
||||
onSetVisibility?: (providerID: string, visible: boolean) => void
|
||||
ref?: (providerID: string, element: HTMLElement) => void
|
||||
}) {
|
||||
@@ -95,7 +98,14 @@ export function ProviderModelSections<T extends ModelItem>(props: {
|
||||
? language.t("provider.connect.opencode.freeName")
|
||||
: group.items[0].provider.name
|
||||
|
||||
function Header(input: { id: string; icon: JSX.Element; title: JSX.Element; badge?: string; action?: JSX.Element }) {
|
||||
function Header(input: {
|
||||
id: string
|
||||
icon: JSX.Element
|
||||
title: JSX.Element
|
||||
badge?: string
|
||||
detail?: JSX.Element
|
||||
action?: JSX.Element
|
||||
}) {
|
||||
return (
|
||||
<h3 class="settings-models-group-header" classList={{ "justify-between": !!input.action }}>
|
||||
<button
|
||||
@@ -112,6 +122,7 @@ export function ProviderModelSections<T extends ModelItem>(props: {
|
||||
{input.icon}
|
||||
<bdi class="settings-models-group-title">{input.title}</bdi>
|
||||
<Show when={input.badge}>{(badge) => <Badge>{badge()}</Badge>}</Show>
|
||||
{input.detail}
|
||||
</span>
|
||||
</button>
|
||||
{input.action}
|
||||
@@ -137,6 +148,7 @@ export function ProviderModelSections<T extends ModelItem>(props: {
|
||||
id={group().category}
|
||||
icon={<ProviderModelIcon provider={group().items[0].provider} class="shrink-0" />}
|
||||
title={name(group())}
|
||||
detail={props.detail?.(group())}
|
||||
action={props.action?.(group())}
|
||||
/>
|
||||
<Show when={props.expanded(group().category)}>{props.rows(group().items)}</Show>
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
[data-component="search-list"] [data-slot="search-list-header"] {
|
||||
height: auto;
|
||||
padding-block: 16px 2px;
|
||||
padding-inline: 34px 6px;
|
||||
padding-inline: 12px 6px;
|
||||
background: var(--v2-background-bg-base);
|
||||
color: var(--v2-text-text-faint);
|
||||
font-size: 12px;
|
||||
@@ -186,15 +186,6 @@
|
||||
letter-spacing: -0.04px;
|
||||
}
|
||||
|
||||
[data-slot="model-dialog-check"] {
|
||||
display: flex;
|
||||
width: 16px;
|
||||
flex-shrink: 0;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--v2-icon-icon-base);
|
||||
}
|
||||
|
||||
[data-slot="model-dialog-name"] {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
@@ -223,6 +214,14 @@
|
||||
background: var(--v2-overlay-simple-overlay-hover);
|
||||
}
|
||||
|
||||
/* The current model keeps a pressed fill, also while it is the active row. */
|
||||
[data-component="dialog-v2"]
|
||||
.model-dialog
|
||||
[data-component="search-list"]
|
||||
[data-slot="search-list-row"][aria-current="true"] {
|
||||
background: var(--v2-overlay-simple-overlay-pressed);
|
||||
}
|
||||
|
||||
[data-component="menu-v2-content"][data-slot="model-dialog-flyout"] {
|
||||
position: fixed;
|
||||
/* One width for every model, matching the 160px its placement assumes. */
|
||||
|
||||
@@ -944,11 +944,6 @@ export function DialogSelectModel(props: { provider?: string; model?: ModelState
|
||||
dispatch({ type: "row.left", into, point: { x: event.clientX, y: event.clientY }, flyout: flyoutRect() })
|
||||
}}
|
||||
>
|
||||
<span data-slot="model-dialog-check">
|
||||
<Show when={selected()}>
|
||||
<Icon name="check" size="small" />
|
||||
</Show>
|
||||
</span>
|
||||
<span data-slot="model-dialog-name">
|
||||
<span class="min-w-0 truncate">
|
||||
<SearchHighlight text={item().name} />
|
||||
|
||||
@@ -161,6 +161,13 @@ export const dict = {
|
||||
"dialog.model.unavailable": "{{model}} (unavailable)",
|
||||
"dialog.model.manage": "Manage models",
|
||||
"dialog.model.manage.description": "Customize which models appear in the model selector.",
|
||||
"dialog.model.manage.status.none": "No models enabled",
|
||||
"dialog.model.manage.status.all": "All models enabled",
|
||||
"dialog.model.manage.status.some": "{{count}} of {{total}} models enabled",
|
||||
"dialog.model.manage.enableAll": "Enable all",
|
||||
"dialog.model.manage.disableAll": "Disable all",
|
||||
"dialog.model.manage.enableAll.label": "Enable all {{provider}} models",
|
||||
"dialog.model.manage.disableAll.label": "Disable all {{provider}} models",
|
||||
"dialog.model.chatgptPlan": "Using ChatGPT plan",
|
||||
"dialog.model.chatgptManageUsage": "Manage usage",
|
||||
"dialog.model.favorites": "Favorites",
|
||||
|
||||
Reference in New Issue
Block a user