Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(model-hub): restore OpenCode model selection

cyh5954e7d4f0f3
diff --git a/docs/plans/model-hub-ui-spec.md b/docs/plans/model-hub-ui-spec.md
index d4a4eb673..6cf3379c3 100644
--- a/docs/plans/model-hub-ui-spec.md
+++ b/docs/plans/model-hub-ui-spec.md
@@ -231,7 +231,7 @@ make explicit.
| --- | --- |
| `POST /api/models/migration/scan` | The migration surface. None of these frames offers an import, and a scan with nothing to show it is not a screen. This is also the one row here that is not a mutation — the read-only `POST` counted out above — and it is listed anyway, because the question this table answers is 「where is this route drawn」 and not 「what does it write」 |
| `POST /api/models/migration/apply` | The migration surface, following its own scan |
-| `PUT /api/models/agents/opencode/menu` | The open-menu configuration surface, which is where a menu is chosen; frame 01 renders the resulting supply and never edits the menu behind it |
+| `PUT /api/models/agents/opencode/menu` | The OpenCode model-menu dialog opened by frame 01's **Manage models** action. It is the one owner of the explicit open-menu selection; frame 01 renders the saved selection as route rows |
| `POST /api/models/agents/<backend>/probe` | Diagnostics. It answers "would a turn resolve right now", which none of these frames asks — 01 reports the supply it already has, and a probe run from a page that is not asking would report on something the user is not looking at |
### 0.5 Contract-gap registry
@@ -821,7 +821,8 @@ state exit; held intent never bypasses the evidence column.
| §1.1 | Group interrupted — a hop's source is gone | The enabled-Agent aggregate reads `interrupted`, no Agent is usable or waiting, and at least one member's chain names a source that no longer exists `[derived]` | F2 — the group keeps its last rendering | `gateway.group.status.interrupted` | The payload stops reporting the blocker → whichever aggregate the named Agents then produce. Adding the source again produces a different source and does not re-satisfy the stored hop, so the exit is §1.2's explicit remove/change of that exact stale pair |
| §1.1 | Group interrupted — a hop's model is no longer callable | The enabled-Agent aggregate reads `interrupted`, no Agent is usable or waiting, and at least one member's chain pins a model its source no longer advertises `[derived]` | F2 — the group keeps its last rendering | `gateway.group.status.interrupted` | 重新拉取 on 06 puts the model back into that source's inventory → whichever aggregate the named Agents then produce. The contract keeps the hop visible and non-runnable until an explicit refresh or edit and never re-points it `[contract]`; §1.2 owns the explicit remove/change while allowing the unchanged stale pair to remain |
| §1.1 | Backend has no usable source | Every candidate filtered out | F5 | `gateway.supply.none` | Any source becomes eligible; 来源顺序 → 03 |
-| §1.1 | Backend has no models | The group resolves to zero model rows `[derived]` | F5 | `gateway.group.emptyModels` | A model becomes available to that backend |
+| §1.1 | Fixed backend has no models | A fixed-menu backend resolves to zero model rows `[derived]` | F5 | `gateway.group.emptyModels` | A model becomes available to that backend |
+| §1.1 | OpenCode menu has no selection | OpenCode is in Hub mode and `menu.checked` is empty `[contract]` | F5 | `gateway.group.emptySelection`, `gateway.selectedModelCount_*`, `gateway.manageModels` | **Manage models** opens the OpenCode model-menu dialog; saving at least one eligible identifier returns to Ready with one route row per saved model |
| §1.1 | No enabled Agent uses this backend | `mode` reads `hub` and `named_agents` is empty `[contract]` | F5 — a rendered report, not a request | `gateway.group.subtitle.gateway`, `gateway.group.mode.gateway`, `gateway.group.status.unused` | An enabled Agent begins using this backend; its model, Route and live rollup enter the aggregate and select Ready, unconfigured, waiting, degraded or interrupted |
| §1.1 | Per-model route unconfigured | The page-grain `model_supply` row reads `chain_length: 0`; this structural branch is evaluated before the forced `has_runnable_hop: false` reading `[contract]` | F5 for the page-grain statement; an outstanding or failed chain detail read remains F2 only for its other derived columns | server-owned `models.launch.route_unconfigured`, consumed verbatim | Render the existing route-unconfigured family in the current-text slot; never gold 供给已暂停 / Supply paused. A later page-grain payload with `chain_length > 0` leaves this structural state and is dispatched by `has_runnable_hop` |
| §1.1 | Per-model supply paused | The page-grain `model_supply` row reads `chain_length > 0` and `has_runnable_hop: false` `[contract]` | F5 for the page-grain marker; an outstanding or failed chain-collection member remains F2 only for its other derived columns | `legend.unavailable` in the existing current-text slot | Render 供给已暂停 / Supply paused immediately in `$--gold`; do not wait for the backend chain collection. A later page-grain payload with `has_runnable_hop: true` removes the marker; `chain_length: 0` instead enters Per-model route unconfigured. The collection member may still fill its other derived columns, but a pending or failed detail read cannot erase or replace this page-owned marker |
@@ -1457,10 +1458,13 @@ unable to outlive its surface, which is the cheaper answer wherever it is availa
| `gateway.infoLabel` `[derived]` | 什么是网关路由 | What gateway routes are |
| `gateway.info` `[derived]` | 网关路由决定每个 Agent 的型号在已有路由中的来源里先使用哪个上游来源;当额度不足、触发限流、服务端、认证或网络出错导致请求无法完成时,自动切换下一优先级。 | Gateway routes decide which upstream source each Agent's model uses first among the sources already configured in its route. When quota, rate-limit, server, authentication, or network failures prevent a request, the next priority is used automatically. |
| `gateway.sourceOrder` | 调整优先级 | Adjust priority |
+| `gateway.manageModels` `[derived]` | 管理模型 | Manage models |
| `gateway.switchToGateway` | 切换到网关 | Switch to gateway |
| `gateway.switchToDirect` | 切到直连 | Switch to direct |
| `gateway.modelCount_one` | {{count}} 个型号 | {{count}} model |
| `gateway.modelCount_other` | {{count}} 个型号 | {{count}} models |
+| `gateway.selectedModelCount_one` `[derived]` | 已选 {{count}} 个模型 | {{count}} selected |
+| `gateway.selectedModelCount_other` `[derived]` | 已选 {{count}} 个模型 | {{count}} selected |
| `gateway.group.subtitle.direct` `[frame]` | {{mode}} | {{mode}} |
| `gateway.group.subtitle.gateway` `[frame]` | {{mode}} · {{health}} | {{mode}} · {{health}} |
| `gateway.group.mode.direct` | 直连 | Direct |
@@ -1476,7 +1480,17 @@ unable to outlive its surface, which is the cheaper answer wherever it is availa
| `gateway.supply.unread` `[derived]` | 后端供给情况没读到 · 网关本身正常 | Could not read this backend's supply · the gateway itself is fine |
| `gateway.fail.switchToDirect` `[derived]` | 没能切回直连 | The switch back to direct did not go through |
| `gateway.retry` `[derived]` | 重试 | Retry |
+| `gateway.group.emptySelection` `[derived]` | 尚未选择模型 | No models selected |
| `gateway.group.emptyModels` `[derived]` | 这个后端没有可用型号 | This backend has no models |
+| `gateway.menu.title` `[derived]` | OpenCode 模型菜单 | OpenCode model menu |
+| `gateway.menu.search` `[derived]` | 搜索模型或供应商 | Search models or sources |
+| `gateway.menu.selected` `[derived]` | 已选 {{selected}} / {{total}} | {{selected}} of {{total}} selected |
+| `gateway.menu.empty` `[derived]` | 没有可供 OpenCode 选择的模型 | No eligible source models are available |
+| `gateway.menu.noMatch` `[derived]` | 没有匹配的模型 | No models match this search |
+| `gateway.menu.save` `[derived]` | 保存选择 | Save selection |
+| `gateway.menu.saving` `[derived]` | 正在保存… | Saving… |
+| `gateway.menu.cancel` `[derived]` | 取消 | Cancel |
+| `gateway.menu.saveFailed` `[derived]` | 模型选择未保存,请重试 | The model selection was not saved |
| `gateway.row.current` | 来自 {{source}} | From: {{source}} |
| `gateway.row.currentTakeover` | 来自 {{source}}(接管) | From: {{source}} (takeover) |
| `models.launch.route_unconfigured` `[contract]` | 模型 {{model}} 尚未配置路由。请前往 Models 配置。 | Model {{model}} has no configured route. Open Models to configure one. |
@@ -1728,8 +1742,9 @@ dispatch arbitrates → each backend's models resolve to these sources today.
| `YcOFo` status | which Hub-mode backends have this source configured into a route — `adopted_by` (§1.0) | the complete server-derived Source projection, never a computation over chains (D-28) | no | — |
| `wmROQ` / `Xitl7` footer buttons | Add subscription / Add API key | — | yes | 添加订阅 opens frame 13; its selected vendor opens 04. 添加 API Key opens 05 |
| `f8w6Xp` + `pnYa0` rail | dispatch happens between the columns | decorative | no | — |
-| `GLylJ` backend group | backend tile, name, model count, head buttons, and one `{{mode}} · {{health}}` line | per-backend mode + supply health | head: buttons only | — |
+| `GLylJ` backend group | backend tile, name, model count, head buttons, and one `{{mode}} · {{health}}` line. For an open menu the count is the explicit selected count, never the number of models available from Sources | per-backend mode + supply health | head: buttons only | OpenCode's **Manage models** opens its model-menu dialog; other actions are registered below |
| `ehGRK` / `bGsC7` 「调整优先级」 | — | — | yes | Open 03 **for that backend** |
+| OpenCode 「管理模型」 `[derived]` | — | `menu.checked` plus the server-owned eligible Source inventory | yes | Open the OpenCode model-menu dialog; the same action remains available in the empty row area |
| `IyKyp` 「切换到网关」 | — | backend in 直连 | yes | Open the 10 confirm for that backend |
| `z02Ep` / `gbrq2` 「切到直连」 | — | backend on the gateway | yes | That backend leaves the gateway immediately — **no confirm** (D-30) |
| `Exx0a` model row | model id (mono 12), a chain chip, current-source text; `legend.unavailable` occupies that text slot when the page-grain row has no runnable hop | `AgentSupply.model_supply[].has_runnable_hop`; per-model AgentChain and its `current` member | yes | Open 02 for `(backend, model)` |
@@ -1834,19 +1849,22 @@ way into 06. §1.11 owns those controls so the cause vocabulary here and on 06 s
vocabulary rather than a second set of card-only status strings.
**A backend with zero model rows is a different emptiness from a backend with no usable
-source, and they must not share a message** `[derived]`. 没有可用来源 says *this backend
-has models and nothing can serve them* — the fix is a source. 「这个后端没有可用型号」 says
-*this backend has no models to serve* — the fix is a model. One message for both spends
-the single action the user takes on the strength of it, and spends it on the wrong thing
-half the time. The group keeps its header and its `<mode> · <status>` line either way;
+source, and an open menu adds one more distinction** `[derived]`. 没有可用来源 says *this
+backend has selected models and nothing can serve them* — the fix is a source or route.
+「这个后端没有可用型号」 is reserved for a fixed backend whose catalog is genuinely empty.
+OpenCode with `menu.checked == []` instead says 「尚未选择模型」: the eligible Source
+inventory may be full, but none of it belongs to OpenCode's explicit menu until the user
+chooses it. The group keeps its header and its `<mode> · <status>` line in every branch;
only the row area differs.
-**This list states the cause and does not offer the fix, and that is a scope fact rather
-than an omission** `[derived]`. None of the covered frames draws the surface that edits a
-backend's model menu, so there is no add affordance on this list to keep enabled — and
-naming where that surface lives would be a navigation path, which §0.1 forbids this file
-to draw. The empty state claims the message and the preserved shell here, and claims a
-live add affordance only for the lists that actually draw one.
+**The OpenCode empty branch offers the exact fix in place** `[derived]`. **Manage models**
+is present both in the group head and beside 「尚未选择模型」. It opens a dialog populated
+only from the server-owned eligible Source inventory, deduplicated by the contract's
+OpenCode identifier. Saving performs `PUT /api/models/agents/opencode/menu`; a selected
+model with no Route then appears as an ordinary row whose current-text slot reads
+`gateway.group.status.unconfigured`, and that row opens frame 02. The dialog preserves
+the saved menu view, blocks dismissal while its write is outstanding, and retains the
+draft after a failed save.
**Extreme data**
diff --git a/ui/src/components/settings/models/AgentCard.test.tsx b/ui/src/components/settings/models/AgentCard.test.tsx
index 863fff6f5..3cdee8468 100644
--- a/ui/src/components/settings/models/AgentCard.test.tsx
+++ b/ui/src/components/settings/models/AgentCard.test.tsx
@@ -20,8 +20,10 @@ const runtime: RuntimeDependency = {
manifest: { name: 'cliproxyapi', resolution: 'resolved', version: '1.0.0', source_sha: 'fixture', assets: [] },
status: { installed_version: '1.0.0', verified: true, listening: null, health: 'ok', last_check: null },
};
-const AgentCard = (props: Omit<ComponentProps<typeof RuntimeAgentCard>, 'runtime'>) =>
- <RuntimeAgentCard {...props} runtime={freshRuntimeProjection(readyRegion(runtime))} />;
+type AgentCardProps = Omit<ComponentProps<typeof RuntimeAgentCard>, 'runtime' | 'onOpenModels'>
+ & Partial<Pick<ComponentProps<typeof RuntimeAgentCard>, 'onOpenModels'>>;
+const AgentCard = ({ onOpenModels = vi.fn(), ...props }: AgentCardProps) =>
+ <RuntimeAgentCard {...props} onOpenModels={onOpenModels} runtime={freshRuntimeProjection(readyRegion(runtime))} />;
const localeInstance = (lng: 'en' | 'zh') => {
const instance = createInstance();
@@ -45,10 +47,58 @@ const hubAgent: AgentSupply = {
routes: { 'claude-opus-4-6': { hops: [{ source_id: 'src_a', model_id: 'claude-opus-4-6' }, { source_id: 'src_b', model_id: 'claude-opus-4-6' }] } },
supply_status: 'degraded', model_supply: [{ model_id: 'claude-opus-4-6', chain_length: 2, has_runnable_hop: true }], named_agents: [{ name: 'claude', effective_model_id: 'claude-opus-4-6', supply_status: 'degraded' }], builtin_models: ['claude-opus-4-6'], menu: null,
};
+const openCodeAgent: AgentSupply = {
+ backend: 'opencode',
+ cli_present: true,
+ mode: 'hub',
+ menu_kind: 'open',
+ selected_model_id: null,
+ selected_model_explicit: false,
+ sources: { order: ['src_a'], eligibility: [{ source_id: 'src_a', eligible: true }] },
+ routes: {},
+ supply_status: null,
+ model_supply: [],
+ named_agents: [{
+ name: 'opencode',
+ effective_model_id: 'openai/gpt-5.6-terra',
+ supply_status: 'interrupted',
+ route_reason: 'route_unconfigured',
+ }],
+ builtin_models: null,
+ standard_vendors: ['openai'],
+ menu: { view: 'featured', checked: [] },
+};
afterEach(cleanup);
describe('AgentCard', () => {
+ it('renders an empty OpenCode selection as configurable rather than as missing backend supply', async () => {
+ const onOpenModels = vi.fn();
+ render(<I18nextProvider i18n={localeInstance('zh')}><AgentCard agents={[openCodeAgent]} sources={[]} chains={{}} pendingBackends={new Set()} switchFailures={new Set()} connectingBackend={null} onConnectHub={vi.fn()} onSwitchDirect={vi.fn()} onOpenModels={onOpenModels} onOpenOrder={vi.fn()} onOpenRoute={vi.fn()} onProbeSettled={vi.fn()} /></I18nextProvider>);
+
+ expect(screen.getByText('网关 · 未配置模型路由')).toBeTruthy();
+ expect(screen.getByText('已选 0 个模型')).toBeTruthy();
+ expect(screen.getByText('尚未选择模型')).toBeTruthy();
+ expect(screen.queryByText('这个后端没有可用模型')).toBeNull();
+
+ await userEvent.click(screen.getAllByRole('button', { name: '管理模型' })[0]);
+ expect(onOpenModels).toHaveBeenCalledWith(openCodeAgent);
+ });
+
+ it('labels a selected OpenCode model with an empty route as unconfigured', () => {
+ const modelId = 'openai/gpt-5.6-luna';
+ render(<I18nextProvider i18n={localeInstance('zh')}><AgentCard agents={[{
+ ...openCodeAgent,
+ menu: { view: 'featured', checked: [modelId] },
+ model_supply: [{ model_id: modelId, chain_length: 0, has_runnable_hop: false }],
+ }]} sources={[]} chains={{}} pendingBackends={new Set()} switchFailures={new Set()} connectingBackend={null} onConnectHub={vi.fn()} onSwitchDirect={vi.fn()} onOpenOrder={vi.fn()} onOpenRoute={vi.fn()} onProbeSettled={vi.fn()} /></I18nextProvider>);
+
+ expect(screen.getByText('已选 1 个模型')).toBeTruthy();
+ expect(screen.getByText(modelId)).toBeTruthy();
+ expect(screen.getByText('未配置模型路由')).toBeTruthy();
+ expect(screen.queryByText('没有可用供应商')).toBeNull();
+ });
+
it.each([
['en', 'Gateway · Supply unavailable for now'],
['zh', '网关 · 等待供应商恢复'],
@@ -99,7 +149,7 @@ describe('AgentCard', () => {
it('hides current and takeover projections while the runtime is stopped', () => {
const key = modelChainKey('claude', 'claude-opus-4-6');
const stopped = { ...runtime, status: { ...runtime.status, health: 'down' as const } };
- render(<I18nextProvider i18n={i18n}><RuntimeAgentCard runtime={freshRuntimeProjection(readyRegion(stopped))} agents={[hubAgent]} sources={[source('src_a', 'Primary'), source('src_b', 'Backup')]} chains={{ [key]: readyRegion({ contract_version: 6, backend: 'claude', model_id: 'claude-opus-4-6', current: { source_id: 'src_b', model_id: 'claude-opus-4-6' }, chain: [{ source_id: 'src_a', model_id: 'claude-opus-4-6', channel: 'hub', health: 'cooldown', runnable: false, reason: null, retry_at: '2099-01-01T00:00:00Z' }, { source_id: 'src_b', model_id: 'claude-opus-4-6', channel: 'hub', health: 'healthy', runnable: true, reason: null, retry_at: null }], supply_state: 'ok' }) }} pendingBackends={new Set()} switchFailures={new Set()} connectingBackend={null} onConnectHub={vi.fn()} onSwitchDirect={vi.fn()} onOpenOrder={vi.fn()} onOpenRoute={vi.fn()} onProbeSettled={vi.fn()} /></I18nextProvider>);
+ render(<I18nextProvider i18n={i18n}><RuntimeAgentCard runtime={freshRuntimeProjection(readyRegion(stopped))} agents={[hubAgent]} sources={[source('src_a', 'Primary'), source('src_b', 'Backup')]} chains={{ [key]: readyRegion({ contract_version: 6, backend: 'claude', model_id: 'claude-opus-4-6', current: { source_id: 'src_b', model_id: 'claude-opus-4-6' }, chain: [{ source_id: 'src_a', model_id: 'claude-opus-4-6', channel: 'hub', health: 'cooldown', runnable: false, reason: null, retry_at: '2099-01-01T00:00:00Z' }, { source_id: 'src_b', model_id: 'claude-opus-4-6', channel: 'hub', health: 'healthy', runnable: true, reason: null, retry_at: null }], supply_state: 'ok' }) }} pendingBackends={new Set()} switchFailures={new Set()} connectingBackend={null} onConnectHub={vi.fn()} onSwitchDirect={vi.fn()} onOpenModels={vi.fn()} onOpenOrder={vi.fn()} onOpenRoute={vi.fn()} onProbeSettled={vi.fn()} /></I18nextProvider>);
expect(screen.queryByText(/Backup/)).toBeNull();
expect(screen.queryByText(/takeover/i)).toBeNull();
diff --git a/ui/src/components/settings/models/AgentCard.tsx b/ui/src/components/settings/models/AgentCard.tsx
index a1789e47e..3b257fbc3 100644
--- a/ui/src/components/settings/models/AgentCard.tsx
+++ b/ui/src/components/settings/models/AgentCard.tsx
@@ -1,5 +1,5 @@
import * as React from 'react';
-import { ArrowDownUp, Check, ChevronDown, ChevronRight, ChevronUp, PlugZap, Power, RefreshCw, Route } from 'lucide-react';
+import { ArrowDownUp, Check, ChevronDown, ChevronRight, ChevronUp, ListChecks, PlugZap, Power, RefreshCw, Route } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { Badge } from '@/components/ui/badge';
@@ -53,6 +53,8 @@ const ModelRow: React.FC<{
: '—';
const currentCopy = supplyState === 'paused'
? t('settings.models.legend.unavailable') as string
+ : supplyState === 'unconfigured'
+ ? t('settings.models.gateway.group.status.unconfigured') as string
: resolved
? t(takeover ? 'settings.models.gateway.row.currentTakeover' : 'settings.models.gateway.row.current', { source: sourceName(sources, current.source_id) }) as string
: '—';
@@ -84,15 +86,18 @@ const AgentModelCard: React.FC<{
switchFailed: boolean;
onConnectHub: (agent: AgentSupply) => void;
onSwitchDirect: (agent: AgentSupply) => void;
+ onOpenModels: (agent: AgentSupply) => void;
onOpenOrder: (agent: AgentSupply) => void;
onOpenRoute: (agent: AgentSupply, modelId: string, opener: HTMLElement) => void;
onProbeSettled: (agent: AgentSupply) => void;
-}> = ({ agent, runtime, sources, chains, pending, connecting, switchFailed, onConnectHub, onSwitchDirect, onOpenOrder, onOpenRoute, onProbeSettled }) => {
+}> = ({ agent, runtime, sources, chains, pending, connecting, switchFailed, onConnectHub, onSwitchDirect, onOpenModels, onOpenOrder, onOpenRoute, onProbeSettled }) => {
const { t } = useTranslation();
const { Icon, accent } = backendVisual(agent.backend);
const [expanded, setExpanded] = React.useState(false);
const [modeMenuOpen, setModeMenuOpen] = React.useState(false);
const allModels = listedModelIds(agent);
+ const hasOpenMenu = agent.menu_kind === 'open';
+ const displayedModelCount = hasOpenMenu ? agent.menu?.checked.length ?? 0 : allModels.length;
const chainProjectionLive = agentHasLiveChainProjection(runtime, agent);
const collapsed = collapsedModelRows(agent, expanded);
const collapsedAtRest = collapsedModelRows(agent);
@@ -117,7 +122,7 @@ const AgentModelCard: React.FC<{
const retryChains = () => onProbeSettled(agent);
const noUsableSource = agent.mode === 'hub'
&& Boolean(agent.model_supply?.length)
- && agent.model_supply?.every((entry) => !entry.has_runnable_hop);
+ && agent.model_supply?.every((entry) => entry.chain_length > 0 && !entry.has_runnable_hop);
const statusClass = switchFailed || health === 'interrupted'
? 'text-destructive-ink'
: hasTakeover || health === 'degraded' || health === 'waiting'
@@ -146,7 +151,9 @@ const AgentModelCard: React.FC<{
<span className="flex min-w-0 items-center gap-[7px]">
<h2 className="truncate text-[14px] font-bold leading-[17px] text-foreground">{t(`settings.models.backends.${agent.backend}`, { defaultValue: agent.backend })}</h2>
<Badge variant="secondary" className={cn('model-hub-pill model-hub-fill-0a', hasTakeover && 'model-hub-takeover-chip')}>
- {hasTakeover ? t('settings.models.takeover.chip') : t('settings.models.gateway.modelCount', { count: allModels.length })}
+ {hasTakeover
+ ? t('settings.models.takeover.chip')
+ : t(hasOpenMenu ? 'settings.models.gateway.selectedModelCount' : 'settings.models.gateway.modelCount', { count: displayedModelCount })}
</Badge>
</span>
</div>
@@ -198,12 +205,13 @@ const AgentModelCard: React.FC<{
</button>
</div>
</ResponsiveMenu>
+ {hasOpenMenu && <Button variant="outline" size="xs" className="model-hub-agent-head-action rounded-md bg-background px-2.5 text-[11px] font-semibold shadow-sm" onClick={() => onOpenModels(agent)} disabled={pending}><ListChecks aria-hidden="true" />{t('settings.models.gateway.manageModels')}</Button>}
<Button variant="outline" size="xs" className="model-hub-agent-head-action rounded-md bg-background px-2.5 text-[11px] font-semibold shadow-sm" onClick={() => onOpenOrder(agent)} disabled={pending}><ArrowDownUp aria-hidden="true" />{t('settings.models.gateway.sourceOrder')}</Button>
</div>
) : <Button variant="default" size="xs" className="model-hub-agent-head-action shrink-0 self-start rounded-md px-2.5 text-[11px] font-semibold sm:self-auto" onClick={() => onConnectHub(agent)} disabled={connecting}><PlugZap aria-hidden="true" />{t('settings.models.gateway.switchToGateway')}</Button>}
</div>
</div>
- {agent.mode === 'hub' && (models.length === 0 ? <div className="px-4 py-10 text-center sm:px-5"><p className="text-[12.5px] text-muted">{t('settings.models.gateway.group.emptyModels')}</p></div> : <div className="space-y-2 p-2">{noUsableSource && <p className="px-3 py-1 text-[11px] font-semibold text-muted">{t('settings.models.gateway.supply.none')}</p>}{models.map((modelId) => <ModelRow key={modelId} agent={agent} modelId={modelId} sources={sources} read={chainProjectionLive ? chains[modelChainKey(agent.backend, modelId)] : undefined} onOpenRoute={onOpenRoute} />)}{canCollapse ? <button type="button" onClick={toggleCollapsed} className="model-hub-model-collapse flex h-6 w-full items-center gap-1.5 hover:text-foreground">{expanded ? <ChevronUp /> : <ChevronDown />}{expanded ? t('settings.models.gateway.collapse') : t('settings.models.gateway.moreModels', { count: collapsed.hidden.length })}</button> : needsChainRepair ? <button type="button" onClick={retryChains} className="model-hub-model-collapse flex h-6 w-full items-center gap-1.5 hover:text-foreground"><RefreshCw />{t('settings.models.gateway.retry')}</button> : null}</div>)}
+ {agent.mode === 'hub' && (models.length === 0 ? <div className="flex flex-col items-center gap-3 px-4 py-10 text-center sm:px-5"><p className="text-[12.5px] text-muted">{t(hasOpenMenu ? 'settings.models.gateway.group.emptySelection' : 'settings.models.gateway.group.emptyModels')}</p>{hasOpenMenu && <Button variant="outline" size="xs" className="rounded-md bg-background px-2.5 text-[11px] font-semibold shadow-sm" onClick={() => onOpenModels(agent)} disabled={pending}><ListChecks aria-hidden="true" />{t('settings.models.gateway.manageModels')}</Button>}</div> : <div className="space-y-2 p-2">{noUsableSource && <p className="px-3 py-1 text-[11px] font-semibold text-muted">{t('settings.models.gateway.supply.none')}</p>}{models.map((modelId) => <ModelRow key={modelId} agent={agent} modelId={modelId} sources={sources} read={chainProjectionLive ? chains[modelChainKey(agent.backend, modelId)] : undefined} onOpenRoute={onOpenRoute} />)}{canCollapse ? <button type="button" onClick={toggleCollapsed} className="model-hub-model-collapse flex h-6 w-full items-center gap-1.5 hover:text-foreground">{expanded ? <ChevronUp /> : <ChevronDown />}{expanded ? t('settings.models.gateway.collapse') : t('settings.models.gateway.moreModels', { count: collapsed.hidden.length })}</button> : needsChainRepair ? <button type="button" onClick={retryChains} className="model-hub-model-collapse flex h-6 w-full items-center gap-1.5 hover:text-foreground"><RefreshCw />{t('settings.models.gateway.retry')}</button> : null}</div>)}
</section>
);
};
@@ -217,6 +225,7 @@ export const AgentCard: React.FC<{
switchFailures: ReadonlySet<string>;
onConnectHub: (agent: AgentSupply) => void;
onSwitchDirect: (agent: AgentSupply) => void;
+ onOpenModels: (agent: AgentSupply) => void;
onOpenOrder: (agent: AgentSupply) => void;
onOpenRoute: (agent: AgentSupply, modelId: string, opener: HTMLElement) => void;
onProbeSettled: (agent: AgentSupply) => void;
diff --git a/ui/src/components/settings/models/GatewayModule.test.tsx b/ui/src/components/settings/models/GatewayModule.test.tsx
index 9116a2f54..df075b860 100644
--- a/ui/src/components/settings/models/GatewayModule.test.tsx
+++ b/ui/src/components/settings/models/GatewayModule.test.tsx
@@ -40,6 +40,7 @@ describe('GatewayModule region failure treatment', () => {
connectingBackend={null}
onConnectHub={vi.fn()}
onSwitchDirect={vi.fn()}
+ onOpenModels={vi.fn()}
onOpenOrder={vi.fn()}
onOpenRoute={vi.fn()}
onProbeSettled={vi.fn()}
@@ -70,6 +71,7 @@ describe('GatewayModule region failure treatment', () => {
connectingBackend={null}
onConnectHub={vi.fn()}
onSwitchDirect={vi.fn()}
+ onOpenModels={vi.fn()}
onOpenOrder={vi.fn()}
onOpenRoute={vi.fn()}
onProbeSettled={vi.fn()}
diff --git a/ui/src/components/settings/models/OpenCodeMenuDialog.test.tsx b/ui/src/components/settings/models/OpenCodeMenuDialog.test.tsx
new file mode 100644
index 000000000..5f0c11023
--- /dev/null
+++ b/ui/src/components/settings/models/OpenCodeMenuDialog.test.tsx
@@ -0,0 +1,149 @@
+// @vitest-environment jsdom
+import { cleanup, render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { I18nextProvider } from 'react-i18next';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+import i18n from '@/i18n';
+import { modelsApi } from './modelsApi';
+import { OpenCodeMenuDialog } from './OpenCodeMenuDialog';
+import type { AgentSupply, Source } from './types';
+
+const source = (overrides: Partial<Source> & Pick<Source, 'id' | 'vendor' | 'display_name'>): Source => ({
+ last_discovered_at: '2026-08-29T00:00:00Z',
+ kind: 'api_key',
+ protocol: 'openai_responses',
+ supply_channel: 'hub',
+ billing: 'metered',
+ state: { status: 'active', retry_at: null, detail_key: null },
+ models: [],
+ ...overrides,
+});
+
+const sources: Source[] = [
+ source({
+ id: 'src_openai',
+ vendor: 'openai',
+ display_name: 'OpenAI Relay',
+ models: [
+ { id: 'gpt-5.6-luna', origin: 'discovered', reasoning_efforts: [] },
+ { id: 'gpt-5.6-sol', origin: 'discovered', reasoning_efforts: [] },
+ { id: 'gpt-retired', origin: 'discovered', reasoning_efforts: [], retired: true },
+ ],
+ }),
+ source({
+ id: 'src_blocked',
+ vendor: 'anthropic',
+ display_name: 'Blocked Source',
+ protocol: 'anthropic',
+ models: [{ id: 'claude-opus-4-8', origin: 'discovered', reasoning_efforts: [] }],
+ }),
+];
+
+const agent: AgentSupply = {
+ backend: 'opencode',
+ cli_present: true,
+ mode: 'hub',
+ menu_kind: 'open',
+ sources: {
+ order: ['src_openai'],
+ eligibility: [
+ { source_id: 'src_openai', eligible: true },
+ { source_id: 'src_blocked', eligible: false, reason_key: 'models.eligibility.subscription_wrong_client' },
+ ],
+ },
+ routes: {},
+ model_supply: [],
+ named_agents: [],
+ menu: { view: 'featured', checked: [] },
+ standard_vendors: ['openai', 'anthropic'],
+};
+
+afterEach(() => {
+ cleanup();
+ vi.restoreAllMocks();
+});
+
+describe('OpenCodeMenuDialog', () => {
+ it('lists server-eligible inventory and saves the explicit OpenCode selection', async () => {
+ const user = userEvent.setup();
+ const echoed = {
+ ...agent,
+ menu: { view: 'featured' as const, checked: ['openai/gpt-5.6-luna'] },
+ model_supply: [{ model_id: 'openai/gpt-5.6-luna', chain_length: 0, has_runnable_hop: false }],
+ };
+ const putMenu = vi.spyOn(modelsApi, 'putMenu').mockResolvedValue(echoed);
+ const onSaved = vi.fn();
+ const onClose = vi.fn();
+
+ render(
+ <I18nextProvider i18n={i18n}>
+ <OpenCodeMenuDialog
+ open
+ agent={agent}
+ sources={sources}
+ onClose={onClose}
+ onSaved={onSaved}
+ menuWrite={{ pending: false, track: async (work) => work() }}
+ />
+ </I18nextProvider>,
+ );
+
+ expect(screen.getByText('0 of 2 selected')).toBeTruthy();
+ expect(screen.queryByText('Blocked Source')).toBeNull();
+ expect(screen.queryByText(/gpt-retired/)).toBeNull();
+
+ await user.click(screen.getByRole('checkbox', { name: /openai\/gpt-5\.6-luna/i }));
+ expect(screen.getByText('1 of 2 selected')).toBeTruthy();
+ await user.click(screen.getByRole('button', { name: 'Save selection' }));
+
+ await waitFor(() => expect(putMenu).toHaveBeenCalledWith({
+ view: 'featured',
+ checked: ['openai/gpt-5.6-luna'],
+ }));
+ expect(onSaved).toHaveBeenCalledWith(echoed);
+ expect(onClose).toHaveBeenCalledOnce();
+ });
+
+ it('filters by source name without changing the selected menu', async () => {
+ const user = userEvent.setup();
+ render(
+ <I18nextProvider i18n={i18n}>
+ <OpenCodeMenuDialog
+ open
+ agent={{ ...agent, menu: { view: 'full', checked: ['openai/gpt-5.6-sol'] } }}
+ sources={sources}
+ onClose={vi.fn()}
+ onSaved={vi.fn()}
+ menuWrite={{ pending: false, track: async (work) => work() }}
+ />
+ </I18nextProvider>,
+ );
+
+ await user.type(screen.getByRole('textbox', { name: 'Search models or sources' }), 'luna');
+ expect(screen.getByRole('checkbox', { name: /openai\/gpt-5\.6-luna/i })).toBeTruthy();
+ expect(screen.queryByRole('checkbox', { name: /openai\/gpt-5\.6-sol/i })).toBeNull();
+ expect(screen.getByText('1 of 2 selected')).toBeTruthy();
+ });
+
+ it('persists removal of a checked identifier whose last eligible supplier disappeared', async () => {
+ const user = userEvent.setup();
+ const putMenu = vi.spyOn(modelsApi, 'putMenu').mockResolvedValue({ ...agent, menu: { view: 'featured', checked: [] } });
+ render(
+ <I18nextProvider i18n={i18n}>
+ <OpenCodeMenuDialog
+ open
+ agent={{ ...agent, menu: { view: 'featured', checked: ['openai/missing-model'] } }}
+ sources={sources}
+ onClose={vi.fn()}
+ onSaved={vi.fn()}
+ menuWrite={{ pending: false, track: async (work) => work() }}
+ />
+ </I18nextProvider>,
+ );
+
+ expect(screen.getByText('0 of 2 selected')).toBeTruthy();
+ await user.click(screen.getByRole('button', { name: 'Save selection' }));
+ await waitFor(() => expect(putMenu).toHaveBeenCalledWith({ view: 'featured', checked: [] }));
+ });
+});
diff --git a/ui/src/components/settings/models/OpenCodeMenuDialog.tsx b/ui/src/components/settings/models/OpenCodeMenuDialog.tsx
new file mode 100644
index 000000000..670368b1a
--- /dev/null
+++ b/ui/src/components/settings/models/OpenCodeMenuDialog.tsx
@@ -0,0 +1,186 @@
+import * as React from 'react';
+import { LoaderCircle, Search } from 'lucide-react';
+import { useTranslation } from 'react-i18next';
+
+import { Button } from '@/components/ui/button';
+import { Checkbox } from '@/components/ui/checkbox';
+import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
+import { Input } from '@/components/ui/input';
+import { cn } from '@/lib/utils';
+import { initialSeedState, savedMenuKey, seedStep, type PendingWrite } from './asyncLifetime';
+import { eligibleSources } from './eligibility';
+import { buildIdentifier } from './menus/identifiers';
+import { modelsApi } from './modelsApi';
+import type { AgentSupply, Source } from './types';
+
+type MenuModel = {
+ id: string;
+ sourceNames: string[];
+};
+
+const selectableModels = (agent: AgentSupply, sources: Source[]): MenuModel[] => {
+ const standardVendors = new Set(agent.standard_vendors ?? []);
+ const namesById = new Map<string, Set<string>>();
+ for (const source of eligibleSources(sources, agent)) {
+ for (const model of source.models) {
+ if (model.retired) continue;
+ const id = buildIdentifier(source.vendor, model.id, standardVendors);
+ const names = namesById.get(id) ?? new Set<string>();
+ names.add(source.display_name);
+ namesById.set(id, names);
+ }
+ }
+ return [...namesById.entries()]
+ .map(([id, names]) => ({ id, sourceNames: [...names].sort((left, right) => left.localeCompare(right)) }))
+ .sort((left, right) => left.id.localeCompare(right.id));
+};
+
+export const OpenCodeMenuDialog: React.FC<{
+ open: boolean;
+ agent: AgentSupply;
+ sources: Source[];
+ onClose: () => void;
+ onSaved: (echoed: AgentSupply) => void | Promise<void>;
+ menuWrite: PendingWrite;
+}> = ({ open, agent, sources, onClose, onSaved, menuWrite }) => {
+ const { t } = useTranslation();
+ const models = React.useMemo(() => selectableModels(agent, sources), [agent, sources]);
+ const availableIds = React.useMemo(() => new Set(models.map((model) => model.id)), [models]);
+ const rawChecked = React.useMemo(() => agent.menu?.checked ?? [], [agent.menu?.checked]);
+ const savedChecked = React.useMemo(
+ () => (agent.menu?.checked ?? []).filter((id) => availableIds.has(id)),
+ [agent.menu?.checked, availableIds],
+ );
+ const [selected, setSelected] = React.useState<Set<string>>(() => new Set(savedChecked));
+ const [query, setQuery] = React.useState('');
+ const [saveFailed, setSaveFailed] = React.useState(false);
+ const seed = React.useRef(initialSeedState);
+
+ const authoritative = savedMenuKey(agent.menu);
+ React.useEffect(() => {
+ if (!open) return;
+ const step = seedStep(seed.current, authoritative);
+ seed.current = step.state;
+ if (!step.reseed) return;
+ setSelected(new Set(savedChecked));
+ setQuery('');
+ setSaveFailed(false);
+ }, [open, authoritative, savedChecked]);
+
+ const normalizedQuery = query.trim().toLocaleLowerCase();
+ const visibleModels = normalizedQuery
+ ? models.filter((model) => `${model.id} ${model.sourceNames.join(' ')}`.toLocaleLowerCase().includes(normalizedQuery))
+ : models;
+ const savedSet = new Set(rawChecked);
+ const dirty = selected.size !== savedSet.size || [...selected].some((id) => !savedSet.has(id));
+
+ const toggle = (id: string) => {
+ if (menuWrite.pending) return;
+ setSaveFailed(false);
+ setSelected((previous) => {
+ const next = new Set(previous);
+ if (next.has(id)) next.delete(id);
+ else next.add(id);
+ return next;
+ });
+ };
+
+ const save = () => {
+ if (!dirty || menuWrite.pending) return;
+ setSaveFailed(false);
+ void menuWrite.track(async () => {
+ let echoed: AgentSupply;
+ try {
+ const existing = rawChecked.filter((id) => availableIds.has(id) && selected.has(id));
+ const added = models.map((model) => model.id).filter((id) => selected.has(id) && !savedSet.has(id));
+ echoed = await modelsApi.putMenu({
+ view: agent.menu?.view ?? 'featured',
+ checked: [...existing, ...added],
+ });
+ } catch {
+ setSaveFailed(true);
+ return;
+ }
+ await Promise.resolve(onSaved(echoed)).catch(() => {});
+ onClose();
+ });
+ };
+
+ return (
+ <Dialog open={open} onOpenChange={(nextOpen) => { if (!nextOpen && !menuWrite.pending) onClose(); }}>
+ <DialogContent
+ mobileSheetHeight="tall"
+ closeLabel={t('settings.models.gateway.menu.cancel') as string}
+ className="flex h-[min(640px,calc(100dvh-32px))] w-[min(680px,calc(100vw-32px))] max-w-[680px] flex-col gap-4 overflow-hidden rounded-[14px] border-border-strong bg-surface p-5 shadow-[var(--model-hub-dialog-shadow)] max-md:w-full max-md:max-w-none max-md:rounded-t-2xl"
+ onEscapeKeyDown={(event) => { if (menuWrite.pending) event.preventDefault(); }}
+ onPointerDownOutside={(event) => { if (menuWrite.pending) event.preventDefault(); }}
+ >
+ <DialogHeader>
+ <DialogTitle>{t('settings.models.gateway.menu.title')}</DialogTitle>
+ <DialogDescription className="sr-only">{t('settings.models.gateway.menu.description')}</DialogDescription>
+ </DialogHeader>
+
+ <div className="flex min-w-0 flex-col gap-2 sm:flex-row sm:items-center">
+ <div className="flex h-9 min-w-0 flex-1 items-center gap-2 rounded-md border border-border bg-background px-3 focus-within:ring-2 focus-within:ring-ring">
+ <Search className="size-4 shrink-0 text-muted" aria-hidden="true" />
+ <Input
+ variant="bare"
+ value={query}
+ onChange={(event) => setQuery(event.target.value)}
+ placeholder={t('settings.models.gateway.menu.search') as string}
+ aria-label={t('settings.models.gateway.menu.search') as string}
+ className="min-w-0 flex-1 text-[12.5px]"
+ disabled={menuWrite.pending}
+ />
+ </div>
+ <span className="shrink-0 text-[11px] font-semibold text-muted">{t('settings.models.gateway.menu.selected', { selected: selected.size, total: models.length })}</span>
+ </div>
+
+ <div className="min-h-0 flex-1 overflow-y-auto rounded-md border border-border bg-background p-1.5">
+ {models.length === 0 ? (
+ <p className="px-4 py-10 text-center text-[12.5px] text-muted">{t('settings.models.gateway.menu.empty')}</p>
+ ) : visibleModels.length === 0 ? (
+ <p className="px-4 py-10 text-center text-[12.5px] text-muted">{t('settings.models.gateway.menu.noMatch')}</p>
+ ) : (
+ <div className="space-y-1">
+ {visibleModels.map((model) => {
+ const checked = selected.has(model.id);
+ return (
+ <button
+ key={model.id}
+ type="button"
+ role="checkbox"
+ aria-checked={checked}
+ disabled={menuWrite.pending}
+ onClick={() => toggle(model.id)}
+ className={cn(
+ 'flex min-h-11 w-full min-w-0 items-center gap-3 rounded-md px-3 py-2 text-left transition-colors hover:bg-surface-2 disabled:opacity-50',
+ checked && 'bg-surface-2',
+ )}
+ >
+ <Checkbox checked={checked} presentational />
+ <span className="min-w-0 flex-1">
+ <span className="block truncate font-mono text-[12px] font-medium text-foreground" title={model.id}>{model.id}</span>
+ <span className="mt-0.5 block truncate text-[10.5px] text-muted" title={model.sourceNames.join(', ')}>{model.sourceNames.join(' · ')}</span>
+ </span>
+ </button>
+ );
+ })}
+ </div>
+ )}
+ </div>
+
+ <DialogFooter className="items-center sm:justify-between">
+ <div className="min-h-5 text-[11px] font-semibold text-destructive-ink" role="status">{saveFailed ? t('settings.models.gateway.menu.saveFailed') : null}</div>
+ <div className="flex w-full flex-col-reverse gap-2 sm:w-auto sm:flex-row">
+ <Button type="button" variant="outline" onClick={onClose} disabled={menuWrite.pending}>{t('settings.models.gateway.menu.cancel')}</Button>
+ <Button type="button" onClick={save} disabled={!dirty || menuWrite.pending}>
+ {menuWrite.pending && <LoaderCircle className="animate-spin" aria-hidden="true" />}
+ {t(menuWrite.pending ? 'settings.models.gateway.menu.saving' : 'settings.models.gateway.menu.save')}
+ </Button>
+ </div>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ );
+};
diff --git a/ui/src/components/settings/models/SettingsModelsPage.tsx b/ui/src/components/settings/models/SettingsModelsPage.tsx
index 3cd616278..8ab5a8995 100644
--- a/ui/src/components/settings/models/SettingsModelsPage.tsx
+++ b/ui/src/components/settings/models/SettingsModelsPage.tsx
@@ -15,6 +15,7 @@ import { EnableGatewayDialog } from './EnableGatewayDialog';
import { GatewayModule } from './GatewayModule';
import { InstallGatewayDialog } from './InstallGatewayDialog';
import { ModelHubInfoHint } from './ModelHubInfoHint';
+import { OpenCodeMenuDialog } from './OpenCodeMenuDialog';
import { RecentSwitchesCard } from './RecentSwitchesCard';
import { RouteChainDialog, type RouteCollectionObservation, type RouteCommitReconciliation, type RouteReport } from './RouteChainDialog';
import { routeChainMatchesAttempt } from './routeChainDraft';
@@ -378,6 +379,7 @@ export const SettingsModelsPage: React.FC = () => {
const sourceDetailHeadingRef = React.useRef<HTMLHeadingElement>(null);
const sourceDetailReturnFocusRef = React.useRef<(() => HTMLElement | null) | null>(null);
const [orderBackend, setOrderBackend] = React.useState<AgentBackend | null>(null);
+ const [menuBackend, setMenuBackend] = React.useState<AgentBackend | null>(null);
const [adoptAgent, setAdoptAgent] = React.useState<AgentSupply | null>(null);
const [routeTarget, setRouteTarget] = React.useState<{ agent: AgentSupply; modelId: string; opener: HTMLElement | null } | null>(null);
const [routeCommitStatus, setRouteCommitStatus] = React.useState<RouteProjectionStatus | null>(null);
@@ -925,6 +927,7 @@ export const SettingsModelsPage: React.FC = () => {
const selectedSource = sources.find((source) => source.id === selectedSourceId) ?? null;
const sourceDetailOpen = selectedSourceId !== null && subscriptionVendor === null;
const orderAgent = agents.find((agent) => agent.backend === orderBackend && agent.mode === 'hub') ?? null;
+ const menuAgent = agents.find((agent) => agent.backend === menuBackend && agent.backend === 'opencode' && agent.mode === 'hub') ?? null;
const currentRouteAgent = routeTarget
? installedAgents.find((agent) => agent.backend === routeTarget.agent.backend) ?? null
: null;
@@ -1307,7 +1310,7 @@ export const SettingsModelsPage: React.FC = () => {
</PopoverContent>
</Popover>
<div className="hidden xl:block" aria-hidden="true" />
- <GatewayModule supply={installedSupplyRead} readFailureCopy={routeCommitStatus?.failed.has('agents') ? t('settings.models.routeDialog.impact.refreshFail') : undefined} sources={sources} chains={chains} runtime={runtime} runtimeSnapshot={retainedRuntime} onRetry={() => routeCommitStatus?.failed.has('agents') ? retryRouteCommit() : void retrySupply()} pendingBackends={agentWrites} switchFailures={switchFailures} connectingBackend={adoptAgent?.backend ?? null} onConnectHub={setAdoptAgent} onSwitchDirect={switchToDirect} onOpenOrder={(agent) => setOrderBackend(agent.backend)} onOpenRoute={(agent, modelId, opener) => setRouteTarget({ agent, modelId, opener })} onProbeSettled={(agent) => void refreshAgentChains(agent)} />
+ <GatewayModule supply={installedSupplyRead} readFailureCopy={routeCommitStatus?.failed.has('agents') ? t('settings.models.routeDialog.impact.refreshFail') : undefined} sources={sources} chains={chains} runtime={runtime} runtimeSnapshot={retainedRuntime} onRetry={() => routeCommitStatus?.failed.has('agents') ? retryRouteCommit() : void retrySupply()} pendingBackends={agentWrites} switchFailures={switchFailures} connectingBackend={adoptAgent?.backend ?? null} onConnectHub={setAdoptAgent} onSwitchDirect={switchToDirect} onOpenModels={(agent) => setMenuBackend(agent.backend)} onOpenOrder={(agent) => setOrderBackend(agent.backend)} onOpenRoute={(agent, modelId, opener) => setRouteTarget({ agent, modelId, opener })} onProbeSettled={(agent) => void refreshAgentChains(agent)} />
<SupplyGraph containerRef={overviewRef} relations={supplyRelations} />
</div>
<SupplyLegend relations={supplyRelations} />
@@ -1380,6 +1383,7 @@ export const SettingsModelsPage: React.FC = () => {
/>
)}
{orderAgent && <SourceOrderDrawer open agent={orderAgent} sources={sources} sourceReads={sourceCollectionReads} onClose={() => setOrderBackend(null)} onSaved={agentSaved} orderWrite={{ pending: agentWrites.has(orderAgent.backend), track: (work) => agentWriteRegistry.track(orderAgent.backend, work) }} />}
+ {menuAgent && <OpenCodeMenuDialog open agent={menuAgent} sources={sources} onClose={() => setMenuBackend(null)} onSaved={agentSaved} menuWrite={{ pending: agentWrites.has(menuAgent.backend), track: (work) => agentWriteRegistry.track(menuAgent.backend, work) }} />}
<RouteChainDialog
selection={routeSelection}
sources={sources}
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index 2815e68f5..532784259 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -892,6 +892,7 @@
"infoLabel": "What gateway routes are",
"info": "Gateway routes decide which upstream source each Agent's model uses first among the sources already configured in its route. When quota, rate-limit, server, authentication, or network failures prevent a request, the next priority is used automatically.",
"sourceOrder": "Adjust priority",
+ "manageModels": "Manage models",
"switchToGateway": "Switch to gateway",
"switchToDirect": "Switch to direct",
"modeMenu": {
@@ -905,6 +906,8 @@
},
"modelCount_one": "{{count}} model",
"modelCount_other": "{{count}} models",
+ "selectedModelCount_one": "{{count}} selected",
+ "selectedModelCount_other": "{{count}} selected",
"moreModels_one": "{{count}} more model",
"moreModels_other": "{{count}} more models",
"collapse": "Collapse",
@@ -934,7 +937,20 @@
"unconfigured": "No model route configured",
"unused": "No Agent uses this backend"
},
+ "emptySelection": "No models selected",
"emptyModels": "This backend has no models"
+ },
+ "menu": {
+ "title": "OpenCode model menu",
+ "description": "Choose which models OpenCode can use through the gateway, then configure each selected model's route from its row.",
+ "search": "Search models or sources",
+ "selected": "{{selected}} of {{total}} selected",
+ "empty": "No eligible source models are available",
+ "noMatch": "No models match this search",
+ "save": "Save selection",
+ "saving": "Saving…",
+ "cancel": "Cancel",
+ "saveFailed": "The model selection was not saved"
}
},
"takeover": {
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index 48057e7dc..8d26c39c0 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -892,6 +892,7 @@
"infoLabel": "什么是路由",
"info": "路由决定每个 Agent 的模型优先使用哪个供应商;当前供应商不可用时,模型网关按优先级自动切换。",
"sourceOrder": "调整优先级",
+ "manageModels": "管理模型",
"switchToGateway": "切换到模型网关",
"switchToDirect": "切到直连",
"modeMenu": {
@@ -905,6 +906,8 @@
},
"modelCount_one": "{{count}} 个模型",
"modelCount_other": "{{count}} 个模型",
+ "selectedModelCount_one": "已选 {{count}} 个模型",
+ "selectedModelCount_other": "已选 {{count}} 个模型",
"moreModels_one": "还有 {{count}} 个模型",
"moreModels_other": "还有 {{count}} 个模型",
"collapse": "收起",
@@ -934,7 +937,20 @@
"unconfigured": "未配置模型路由",
"unused": "暂无 Agent 使用"
},
+ "emptySelection": "尚未选择模型",
"emptyModels": "这个后端没有可用模型"
+ },
+ "menu": {
+ "title": "OpenCode 模型菜单",
+ "description": "选择 OpenCode 可通过网关使用的模型;保存后,在模型行中配置各自路由。",
+ "search": "搜索模型或供应商",
+ "selected": "已选 {{selected}} / {{total}}",
+ "empty": "没有可供 OpenCode 选择的模型",
+ "noMatch": "没有匹配的模型",
+ "save": "保存选择",
+ "saving": "正在保存…",
+ "cancel": "取消",
+ "saveFailed": "模型选择未保存,请重试"
}
},
"takeover": {