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): apply OpenCode menu intent atomically

cyhe2ce062954e5
diff --git a/core/handlers/model_hub/rpc.py b/core/handlers/model_hub/rpc.py
index b404c74d4..0ba74af0f 100644
--- a/core/handlers/model_hub/rpc.py
+++ b/core/handlers/model_hub/rpc.py
@@ -141,7 +141,10 @@ async def dispatch_model_hub_rpc(
)
if operation == "set_opencode_menu":
await _refresh_agent_presence(service, ("opencode",))
- return await service.set_opencode_menu(payload.get("menu"))
+ return await service.set_opencode_menu(
+ payload.get("baseline"),
+ payload.get("menu"),
+ )
if operation == "add_custom_model":
return await service.add_custom_model(payload.get("source_id"), payload.get("model"))
if operation == "update_model_reasoning_efforts":
diff --git a/core/handlers/model_hub/service.py b/core/handlers/model_hub/service.py
index 91b564162..6eaeb10fd 100644
--- a/core/handlers/model_hub/service.py
+++ b/core/handlers/model_hub/service.py
@@ -3612,17 +3612,45 @@ class ModelHubService:
await self._commit_synced(previous, config)
return self._agent_payload(config, agent)
- async def set_opencode_menu(self, menu: object) -> dict:
+ async def set_opencode_menu(self, baseline: object, menu: object) -> dict:
async with self._mutation_lock:
previous = self.store.load()
config = self._clone_config(previous)
agent = config.agents["opencode"]
try:
+ parsed_baseline = ModelHubMenuConfig.from_payload(cast(dict, baseline))
parsed_menu = ModelHubMenuConfig.from_payload(cast(dict, menu))
+ current_menu = agent.menu or ModelHubMenuConfig()
+ baseline_checked = set(parsed_baseline.checked)
+ requested_checked = set(parsed_menu.checked)
+ removed = baseline_checked - requested_checked
+ added = [
+ identifier
+ for identifier in parsed_menu.checked
+ if identifier not in baseline_checked
+ ]
+ merged_checked = [
+ identifier
+ for identifier in current_menu.checked
+ if identifier not in removed
+ ]
+ present = set(merged_checked)
+ for identifier in added:
+ if identifier not in present:
+ merged_checked.append(identifier)
+ present.add(identifier)
+ merged_menu = ModelHubMenuConfig(
+ view=(
+ parsed_menu.view
+ if parsed_menu.view != parsed_baseline.view
+ else current_menu.view
+ ),
+ checked=merged_checked,
+ )
candidate = agent.to_payload()
- candidate["menu"] = parsed_menu.to_payload()
+ candidate["menu"] = merged_menu.to_payload()
candidate_routes = cast(dict, candidate["routes"])
- for identifier in parsed_menu.checked:
+ for identifier in merged_menu.checked:
candidate_routes.setdefault(identifier, ModelHubRouteConfig().to_payload())
parsed = ModelHubAgentSupplyConfig.from_payload(
candidate,
@@ -3630,9 +3658,8 @@ class ModelHubService:
)
except (TypeError, ValueError) as exc:
raise ModelHubError("mapping_target_unavailable") from exc
- existing_checked = set(agent.menu.checked if agent.menu else ())
- added = set(parsed_menu.checked) - existing_checked
- if not added.issubset(opencode_inventory_menu_ids(config)):
+ added_to_current = set(merged_menu.checked) - set(current_menu.checked)
+ if not added_to_current.issubset(opencode_inventory_menu_ids(config)):
raise ModelHubError("mapping_target_unavailable", status=409)
agent.menu = parsed.menu
agent.routes = parsed.routes
diff --git a/docs/plans/model-hub-contracts/api-response.schema.json b/docs/plans/model-hub-contracts/api-response.schema.json
index 475796dee..890e5f081 100644
--- a/docs/plans/model-hub-contracts/api-response.schema.json
+++ b/docs/plans/model-hub-contracts/api-response.schema.json
@@ -21,7 +21,7 @@
{"method": "PUT", "path": "/api/models/agents/<backend>/sources", "response_schema": "AgentResponse", "exercise": {"path": "/api/models/agents/claude/sources", "status": 200, "json": {"order": ["src_conform001"]}}},
{"method": "POST", "path": "/api/models/agents/<backend>/chains/reorder", "response_schema": "AgentResponse", "exercise": {"path": "/api/models/agents/claude/chains/reorder", "status": 200}},
{"method": "PATCH", "path": "/api/models/agents/<backend>/mode", "response_schema": "AgentResponse", "exercise": {"path": "/api/models/agents/claude/mode", "status": 200, "json": {"mode": "hub"}}},
- {"method": "PUT", "path": "/api/models/agents/opencode/menu", "response_schema": "AgentResponse", "exercise": {"path": "/api/models/agents/opencode/menu", "status": 200, "json": {"menu": {"view": "featured", "checked": []}}}},
+ {"method": "PUT", "path": "/api/models/agents/opencode/menu", "response_schema": "AgentResponse", "exercise": {"path": "/api/models/agents/opencode/menu", "status": 200, "json": {"baseline": {"view": "featured", "checked": []}, "menu": {"view": "featured", "checked": []}}}},
{"method": "GET", "path": "/api/models/agents/<backend>/chains", "response_schema": "ChainListResponse", "exercise": {"path": "/api/models/agents/claude/chains", "status": 200}},
{"method": "GET", "path": "/api/models/agents/<backend>/chain?model=<id>", "response_schema": "ChainResponse", "exercise": {"path": "/api/models/agents/claude/chain?model=claude-opus-4-6", "status": 200}},
{"method": "PUT", "path": "/api/models/agents/<backend>/chain?model=<id>", "response_schema": "ChainMutationResponse", "exercise": {"path": "/api/models/agents/claude/chain?model=claude-opus-4-6", "status": 200, "json": {"hops": [{"source_id": "src_conform001", "model_id": "claude-opus-4-6"}]}}},
diff --git a/docs/plans/model-hub-contracts/api.md b/docs/plans/model-hub-contracts/api.md
index 81b83e689..8f1254dea 100644
--- a/docs/plans/model-hub-contracts/api.md
+++ b/docs/plans/model-hub-contracts/api.md
@@ -40,7 +40,7 @@ compatibility path.
| PUT `/api/models/agents/<backend>/sources` | `{order: string[]}` → `{agent: AgentSupply}` | Stores and re-echoes the complete canonical order; no policy state exists. This route never touches a Route chain and has no guarded `409` branch. |
| POST `/api/models/agents/<backend>/chains/reorder` | `{order?: string[]}` → `{agent: AgentSupply}` | With `order`, atomically stores the complete Source order and idempotently reorders every stored Route by it; with no body, applies the already stored order. In either form it adds, removes, remaps, matches, and guards nothing. The total order is defined below. |
| PATCH `/api/models/agents/<backend>/mode` | `{mode}` → `{agent: AgentSupply}` | Explicit `hub` / `direct` switch. A qualifying Direct → Gateway switch atomically adopts the recognized CLI login as the first native Source; other switches create nothing. |
-| PUT `/api/models/agents/opencode/menu` | `{menu}` → `{agent: AgentSupply}` | Open-menu configuration. A newly checked identifier must still be supplied by current OpenCode-eligible inventory at commit time; already checked route aliases may be preserved or removed without same-name inventory. |
+| PUT `/api/models/agents/opencode/menu` | `{baseline: AgentMenu, menu: AgentMenu}` → `{agent: AgentSupply}` | Atomically applies the additions, removals, and optional view change between `baseline` and `menu` to the latest stored OpenCode menu. Concurrent unrelated selections survive. A newly added identifier must still be supplied by current OpenCode-eligible inventory at commit time; already checked route aliases may be preserved or removed without same-name inventory. |
| GET `/api/models/agents/<backend>/chains` | → `{chains: AgentChain[]}` | Hub only. Returns the complete Overview model set in menu order, followed by a selected model or configured Route not already present. All members share one config snapshot and observation time. Direct returns the documented `direct_mode` error. |
| GET `/api/models/agents/<backend>/chain?model=<id>` | → `{chain: AgentChain}` | Hub only. Direct returns the documented `direct_mode` error. |
| PUT `/api/models/agents/<backend>/chain?model=<id>` | `{hops: RouteHop[], force?: boolean, would_remove_hops?: RouteHopRef[], would_interrupt?: SupplyGap[]}` → guarded `409` or `{chain, removed_hops, interrupted}` | Replaces the exact Source/model pairs in submitted order after validating new or changed pairs; the handler never reads `sources.order`, and the submitted `hops` carry no Source-order semantics. It is the `mutation.route_replace` row of the authoritative mutation matrix. A visible noninterrupting hop removal is ordinary success; only a resulting protected-supply interruption enters the guard. |
diff --git a/tests/test_model_hub_resolution.py b/tests/test_model_hub_resolution.py
index 7ff0e61b5..f626d45a3 100644
--- a/tests/test_model_hub_resolution.py
+++ b/tests/test_model_hub_resolution.py
@@ -1055,6 +1055,7 @@ def test_opencode_menu_validation_rejects_noncanonical_identifier(tmp_path):
with pytest.raises(ModelHubError) as exc:
asyncio.run(
service.set_opencode_menu(
+ {"view": "featured", "checked": []},
{"view": "featured", "checked": ["gpt-5"]}
)
)
@@ -1068,6 +1069,7 @@ def test_opencode_menu_validation_rejects_credential_material(tmp_path):
with pytest.raises(ModelHubError) as exc:
asyncio.run(
service.set_opencode_menu(
+ {"view": "featured", "checked": []},
{
"view": "featured",
"checked": ["custom/sk-test-credential-material"],
@@ -1086,6 +1088,7 @@ def test_opencode_menu_rejects_a_new_model_absent_from_current_inventory(tmp_pat
with pytest.raises(ModelHubError) as exc:
asyncio.run(
service.set_opencode_menu(
+ {"view": "featured", "checked": []},
{"view": "featured", "checked": ["openai/removed-model"]}
)
)
@@ -1115,6 +1118,7 @@ def test_opencode_menu_preserves_an_existing_route_alias_while_adding_inventory(
asyncio.run(
service.set_opencode_menu(
+ {"view": "featured", "checked": ["openai/menu-model"]},
{
"view": "featured",
"checked": ["openai/menu-model", "openai/new-model"],
@@ -1129,6 +1133,63 @@ def test_opencode_menu_preserves_an_existing_route_alias_while_adding_inventory(
)
+def test_opencode_menu_applies_local_intent_to_the_latest_saved_menu(tmp_path):
+ source = _source(
+ "src_opencode03",
+ ("model-a", "model-b", "model-c"),
+ vendor="openai",
+ )
+ config = _config([source])
+ config.agents["opencode"].menu = ModelHubMenuConfig(
+ view="featured",
+ checked=["openai/model-a", "openai/model-b"],
+ )
+ config.agents["opencode"].routes.update(
+ {
+ "openai/model-a": ModelHubRouteConfig(),
+ "openai/model-b": ModelHubRouteConfig(),
+ }
+ )
+ service, store, _ = _service(tmp_path, config)
+
+ asyncio.run(
+ service.set_opencode_menu(
+ {"view": "featured", "checked": ["openai/model-a"]},
+ {
+ "view": "featured",
+ "checked": ["openai/model-a", "openai/model-c"],
+ },
+ )
+ )
+
+ assert store.load().agents["opencode"].menu.checked == [
+ "openai/model-a",
+ "openai/model-b",
+ "openai/model-c",
+ ]
+
+
+def test_opencode_menu_does_not_restore_a_concurrently_removed_model(tmp_path):
+ source = _source(
+ "src_opencode04",
+ ("model-a", "model-c"),
+ vendor="openai",
+ )
+ service, store, _ = _service(tmp_path, _config([source]))
+
+ asyncio.run(
+ service.set_opencode_menu(
+ {"view": "featured", "checked": ["openai/model-a"]},
+ {
+ "view": "featured",
+ "checked": ["openai/model-a", "openai/model-c"],
+ },
+ )
+ )
+
+ assert store.load().agents["opencode"].menu.checked == ["openai/model-c"]
+
+
def test_explicit_opencode_selection_outside_menu_remains_visible(tmp_path):
config = ModelHubConfig()
config.agents["opencode"].mode = "hub"
diff --git a/ui/src/components/settings/models/OpenCodeMenuDialog.test.tsx b/ui/src/components/settings/models/OpenCodeMenuDialog.test.tsx
index a154f09ce..443673821 100644
--- a/ui/src/components/settings/models/OpenCodeMenuDialog.test.tsx
+++ b/ui/src/components/settings/models/OpenCodeMenuDialog.test.tsx
@@ -98,10 +98,10 @@ describe('OpenCodeMenuDialog', () => {
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'],
- }));
+ await waitFor(() => expect(putMenu).toHaveBeenCalledWith(
+ { view: 'featured', checked: [] },
+ { view: 'featured', checked: ['openai/gpt-5.6-luna'] },
+ ));
expect(onSaved).toHaveBeenCalledWith(echoed);
expect(onClose).toHaveBeenCalledOnce();
});
@@ -158,7 +158,10 @@ describe('OpenCodeMenuDialog', () => {
expect(screen.getByText('1 of 3 selected')).toBeTruthy();
await user.click(alias);
await user.click(screen.getByRole('button', { name: 'Save selection' }));
- await waitFor(() => expect(putMenu).toHaveBeenCalledWith({ view: 'featured', checked: [] }));
+ await waitFor(() => expect(putMenu).toHaveBeenCalledWith(
+ { view: 'featured', checked: ['openai/menu-model'] },
+ { view: 'featured', checked: [] },
+ ));
});
it('preserves a checked cross-model route while saving an unrelated addition', async () => {
@@ -188,10 +191,10 @@ describe('OpenCodeMenuDialog', () => {
await user.click(await screen.findByRole('checkbox', { name: /openai\/gpt-5\.6-luna/i }));
await user.click(screen.getByRole('button', { name: 'Save selection' }));
- await waitFor(() => expect(putMenu).toHaveBeenCalledWith({
- view: 'featured',
- checked: ['openai/menu-model', 'openai/gpt-5.6-luna'],
- }));
+ await waitFor(() => expect(putMenu).toHaveBeenCalledWith(
+ { view: 'featured', checked: ['openai/menu-model'] },
+ { view: 'featured', checked: ['openai/menu-model', 'openai/gpt-5.6-luna'] },
+ ));
});
it('blocks editing when its dedicated baseline read fails', async () => {
@@ -220,10 +223,12 @@ describe('OpenCodeMenuDialog', () => {
const user = userEvent.setup();
const committed = {
...agent,
- menu: { view: 'featured' as const, checked: ['openai/gpt-5.6-luna'] },
+ menu: {
+ view: 'featured' as const,
+ checked: ['openai/gpt-5.6-sol', 'openai/gpt-5.6-luna'],
+ },
};
vi.spyOn(modelsApi, 'getAgentSources')
- .mockResolvedValueOnce(agent)
.mockResolvedValueOnce(agent)
.mockResolvedValueOnce(committed);
vi.spyOn(modelsApi, 'putMenu').mockRejectedValue(new ApiCallError('bad_response', undefined, false));
@@ -251,7 +256,6 @@ describe('OpenCodeMenuDialog', () => {
it('rebases a failed draft on the observed menu before enabling retry', async () => {
const user = userEvent.setup();
vi.spyOn(modelsApi, 'getAgentSources')
- .mockResolvedValueOnce(agent)
.mockResolvedValueOnce(agent)
.mockResolvedValueOnce(agent);
vi.spyOn(modelsApi, 'putMenu').mockRejectedValue(new ApiCallError('bad_response', undefined, false));
diff --git a/ui/src/components/settings/models/OpenCodeMenuDialog.tsx b/ui/src/components/settings/models/OpenCodeMenuDialog.tsx
index be380967e..b24b7e50b 100644
--- a/ui/src/components/settings/models/OpenCodeMenuDialog.tsx
+++ b/ui/src/components/settings/models/OpenCodeMenuDialog.tsx
@@ -13,8 +13,8 @@ import { eligibleSources } from './eligibility';
import {
applyOpenCodeMenuIntent,
openCodeMenuIntent,
+ openCodeMenuIntentApplied,
readOpenCodeMenuBaseline,
- sameOpenCodeMenu,
type OpenCodeMenuBaseline,
} from './menuBaseline';
import { buildIdentifier } from './menus/identifiers';
@@ -139,36 +139,20 @@ export const OpenCodeMenuDialog: React.FC<{
current.agent.menu?.checked ?? [],
[...selectedRef.current],
);
+ const baselineMenu: AgentMenu = current.agent.menu ?? { view: 'featured', checked: [] };
+ const requestedMenu: AgentMenu = {
+ view: baselineMenu.view,
+ checked: [...selectedRef.current],
+ };
setSaveFailed(false);
void menuWrite.track(async () => {
- let latest: OpenCodeMenuBaseline;
- try {
- latest = await readOpenCodeMenuBaseline(modelsApi, sourceReads);
- } catch {
- setReadState('error');
- setSaveFailed(true);
- return;
- }
-
- const latestSelectable = new Set(selectableModels(latest.agent, latest.sources).map((model) => model.id));
- const attemptedMenu: AgentMenu = {
- view: latest.agent.menu?.view ?? 'featured',
- checked: applyOpenCodeMenuIntent(latest.agent.menu?.checked ?? [], intent, latestSelectable),
- };
- applyBaseline(latest, attemptedMenu.checked);
- if (sameOpenCodeMenu(latest.agent.menu, attemptedMenu)) {
- await Promise.resolve(onObserved(latest.agent)).catch(() => {});
- onClose();
- return;
- }
-
let echoed: AgentSupply;
try {
- echoed = await modelsApi.putMenu(attemptedMenu);
+ echoed = await modelsApi.putMenu(baselineMenu, requestedMenu);
} catch {
try {
const observed = await readOpenCodeMenuBaseline(modelsApi, sourceReads);
- if (sameOpenCodeMenu(observed.agent.menu, attemptedMenu)) {
+ if (openCodeMenuIntentApplied(observed.agent.menu?.checked ?? [], intent)) {
applyBaseline(observed, observed.agent.menu?.checked ?? []);
await Promise.resolve(onSaved(observed.agent)).catch(() => {});
onClose();
diff --git a/ui/src/components/settings/models/menuBaseline.test.ts b/ui/src/components/settings/models/menuBaseline.test.ts
index 070e1e104..c94858d27 100644
--- a/ui/src/components/settings/models/menuBaseline.test.ts
+++ b/ui/src/components/settings/models/menuBaseline.test.ts
@@ -3,8 +3,8 @@ import { describe, expect, it, vi } from 'vitest';
import {
applyOpenCodeMenuIntent,
openCodeMenuIntent,
+ openCodeMenuIntentApplied,
readOpenCodeMenuBaseline,
- sameOpenCodeMenu,
} from './menuBaseline';
import type { AgentSupply, Source } from './types';
@@ -83,10 +83,10 @@ describe('OpenCode menu intent', () => {
)).toEqual(['openai/concurrent', 'openai/kept', 'openai/added']);
});
- it('compares the server menu as an ordered total value', () => {
- const expected = { view: 'featured' as const, checked: ['openai/a', 'openai/b'] };
- expect(sameOpenCodeMenu(expected, expected)).toBe(true);
- expect(sameOpenCodeMenu({ ...expected, checked: ['openai/b', 'openai/a'] }, expected)).toBe(false);
- expect(sameOpenCodeMenu(null, expected)).toBe(false);
+ it('recognizes an applied intent while ignoring unrelated concurrent selections', () => {
+ const intent = openCodeMenuIntent(['openai/a', 'openai/remove'], ['openai/a', 'openai/add']);
+ expect(openCodeMenuIntentApplied(['openai/a', 'openai/concurrent', 'openai/add'], intent)).toBe(true);
+ expect(openCodeMenuIntentApplied(['openai/a', 'openai/add', 'openai/remove'], intent)).toBe(false);
+ expect(openCodeMenuIntentApplied(['openai/a'], intent)).toBe(false);
});
});
diff --git a/ui/src/components/settings/models/menuBaseline.ts b/ui/src/components/settings/models/menuBaseline.ts
index f55b16439..891ed00dc 100644
--- a/ui/src/components/settings/models/menuBaseline.ts
+++ b/ui/src/components/settings/models/menuBaseline.ts
@@ -1,7 +1,7 @@
import type { CollectionReadAuthority } from './collectionReadAuthority';
import type { ModelsApi } from './modelsApi';
import { combineSourceOrderReads } from './sourceOrderComposition';
-import type { AgentMenu, AgentSupply, Source } from './types';
+import type { AgentSupply, Source } from './types';
export type OpenCodeMenuBaseline = {
agent: AgentSupply;
@@ -62,7 +62,11 @@ export const applyOpenCodeMenuIntent = (
return rebased;
};
-export const sameOpenCodeMenu = (left: AgentMenu | null | undefined, right: AgentMenu): boolean => {
- if (!left || left.view !== right.view || left.checked.length !== right.checked.length) return false;
- return left.checked.every((id, index) => id === right.checked[index]);
+export const openCodeMenuIntentApplied = (
+ current: readonly string[],
+ intent: OpenCodeMenuIntent,
+): boolean => {
+ const currentSet = new Set(current);
+ return intent.added.every((id) => currentSet.has(id))
+ && [...intent.removed].every((id) => !currentSet.has(id));
};
diff --git a/ui/src/components/settings/models/modelsApi.ts b/ui/src/components/settings/models/modelsApi.ts
index 7783a2908..8aa936672 100644
--- a/ui/src/components/settings/models/modelsApi.ts
+++ b/ui/src/components/settings/models/modelsApi.ts
@@ -127,7 +127,8 @@ export type ModelsApi = {
/** One real request through the chain. Hub mode only, same reason. */
probeAgent(backend: AgentBackend, model?: string): Promise<ProbeResult>;
setAgentMode(backend: AgentBackend, mode: AgentMode): Promise<AgentSupply>;
- putMenu(menu: AgentMenu): Promise<AgentSupply>;
+ /** Apply the change between baseline and menu atomically to the latest saved menu. */
+ putMenu(baseline: AgentMenu, menu: AgentMenu): Promise<AgentSupply>;
addCustomModel(sourceId: string, draft: CustomModelCreate): Promise<Source>;
updateModelReasoningEfforts(sourceId: string, modelId: string, reasoningEfforts: string[]): Promise<Source>;
deleteCustomModel(sourceId: string, modelId: string, confirmation?: GuardConfirmation): Promise<Source>;
@@ -466,7 +467,7 @@ export const modelsApi: ModelsApi = {
putAgentChain: (backend, model, body) => call<AgentChainMutation>(`/api/models/agents/${backend}/chain?model=${encodeURIComponent(model)}`, jsonInit('PUT', body)),
probeAgent: (backend, model) => call<{ probe: ProbeResult }>(`/api/models/agents/${backend}/probe`, jsonInit('POST', model ? { model } : {})).then((r) => r.probe),
setAgentMode: (backend, mode) => call<{ agent?: AgentSupply } & AgentSupply>(`/api/models/agents/${backend}/mode`, jsonInit('PATCH', { mode })).then((r) => (r.agent ?? r) as AgentSupply),
- putMenu: (menu) => call<{ agent?: AgentSupply } & AgentSupply>('/api/models/agents/opencode/menu', jsonInit('PUT', { menu })).then((r) => (r.agent ?? r) as AgentSupply),
+ putMenu: (baseline, menu) => call<{ agent?: AgentSupply } & AgentSupply>('/api/models/agents/opencode/menu', jsonInit('PUT', { baseline, menu })).then((r) => (r.agent ?? r) as AgentSupply),
addCustomModel: (sourceId, draft) => call<{ source?: Source } & Source>(`/api/models/sources/${encodeURIComponent(sourceId)}/models`, jsonInit('POST', draft)).then((r) => (r.source ?? r) as Source),
updateModelReasoningEfforts: (sourceId, modelId, reasoningEfforts) => call<{ source?: Source } & Source>(`/api/models/sources/${encodeURIComponent(sourceId)}/models/${encodeURIComponent(modelId)}`, jsonInit('PATCH', { reasoning_efforts: reasoningEfforts })).then((r) => (r.source ?? r) as Source),
deleteCustomModel: (sourceId, modelId, confirmation) => call<{ source?: Source } & Source>(`/api/models/sources/${encodeURIComponent(sourceId)}/models/${encodeURIComponent(modelId)}`, jsonInit('DELETE', confirmation ?? {})).then((r) => (r.source ?? r) as Source),
diff --git a/vibe/model_hub_client.py b/vibe/model_hub_client.py
index a40911b39..12776d3e5 100644
--- a/vibe/model_hub_client.py
+++ b/vibe/model_hub_client.py
@@ -171,8 +171,11 @@ class ModelHubRemoteService:
{"backend": backend, "model_id": model_id, "chain": chain},
)
- async def set_opencode_menu(self, menu: object) -> dict:
- return await _rpc("set_opencode_menu", {"menu": menu})
+ async def set_opencode_menu(self, baseline: object, menu: object) -> dict:
+ return await _rpc(
+ "set_opencode_menu",
+ {"baseline": baseline, "menu": menu},
+ )
async def add_custom_model(self, source_id: object, payload: dict) -> dict:
return await _rpc(
diff --git a/vibe/ui_server.py b/vibe/ui_server.py
index 0bef3a1f7..b10a4bee2 100644
--- a/vibe/ui_server.py
+++ b/vibe/ui_server.py
@@ -4641,8 +4641,10 @@ async def model_hub_opencode_menu_put():
from core.handlers.model_hub import ModelHubError
try:
+ payload = _model_hub_json_object("mapping_target_unavailable")
agent = await _model_hub_service().set_opencode_menu(
- _model_hub_json_object("mapping_target_unavailable").get("menu")
+ payload.get("baseline"),
+ payload.get("menu"),
)
return _model_hub_success(agent=agent)
except ModelHubError as exc: