From 2d08fa2f0bfbb48122829fbaabce53e60c435f50 Mon Sep 17 00:00:00 2001 From: Devika Verma Date: Mon, 9 Nov 2026 14:42:03 +0530 Subject: [PATCH] fix(models): a ticked row's name on the provider page opens the model's settings (OPE-252) The unverified note said "set the window under the model's settings" but the page had no way there: rows were not clickable, and an unticked model is not in the composer's picker either. A ticked row's name is now a button that opens the Pick a model dialog on that model, like the picker card does; the note says "tick the model, then click its name to set it" (en, zh). --- surfaces/gui/src/components/ManageTabs.tsx | 2 + .../components/models/ProviderModels.test.tsx | 39 +++++++++++++++---- .../src/components/models/ProviderModels.tsx | 21 +++++++++- surfaces/gui/src/locales/en.json | 2 +- surfaces/gui/src/locales/zh.json | 2 +- 5 files changed, 56 insertions(+), 10 deletions(-) diff --git a/surfaces/gui/src/components/ManageTabs.tsx b/surfaces/gui/src/components/ManageTabs.tsx index f1300c66..cb738196 100644 --- a/surfaces/gui/src/components/ManageTabs.tsx +++ b/surfaces/gui/src/components/ManageTabs.tsx @@ -294,8 +294,10 @@ export function ModelsTab() { suggested={info?.suggested_models || []} settings={settings} onChanged={(next) => setSettings((s) => (s ? { ...s, models: next.models, model: next.model } : s))} + onConfigure={(m) => setDialog(m)} /> )} + {dialogEl} ) : ( // Unconfigured providers still show their curated models as a read-only preview — what a diff --git a/surfaces/gui/src/components/models/ProviderModels.test.tsx b/surfaces/gui/src/components/models/ProviderModels.test.tsx index fd2c9183..200ce3f9 100644 --- a/surfaces/gui/src/components/models/ProviderModels.test.tsx +++ b/surfaces/gui/src/components/models/ProviderModels.test.tsx @@ -1,8 +1,8 @@ // OPE-252 layer 1: a keyed provider's page lists what its own model list says the key can -// call, merged with the curated rows — New since last check, Recommended, All models — -// with tick-to-add, the facts' provenance, "not on this key", Refresh, and a typed id the -// key cannot call refused with the closest ids. A provider without a list falls back to -// the curated checklist. +// call, merged with the curated rows — one list, models new since the last check on top — +// with tick-to-add, the facts' provenance, "not on this key", Refresh, a ticked row's name +// opening the model's settings, and a typed id the key cannot call refused with the closest +// ids. A provider without a list falls back to the curated checklist. import { afterEach, describe, expect, it, vi } from "vitest"; import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react"; @@ -44,8 +44,8 @@ const SETTINGS = { const flush = () => act(async () => { await Promise.resolve(); await Promise.resolve(); }); -function renderPanel(onChanged = vi.fn()) { - render(); +function renderPanel(onChanged = vi.fn(), onConfigure?: (model: string) => void) { + render(); return onChanged; } @@ -57,7 +57,7 @@ afterEach(() => { }); describe("ProviderModels with a live listing", () => { - it("asks the provider once on open and lays the rows out in three sections with their facts", async () => { + it("asks the provider once on open and lays the rows out in one list with their facts", async () => { vi.mocked(getProviderCatalog).mockResolvedValue(LIVE); renderPanel(); expect(screen.getByTestId("provider-models-loading").textContent).toContain("Checking which models"); @@ -86,6 +86,31 @@ describe("ProviderModels with a live listing", () => { expect(glm.checked && glm.disabled).toBe(true); }); + it("a ticked row's name opens the model's settings without unticking it; an unticked row's name is plain text", async () => { + vi.mocked(getProviderCatalog).mockResolvedValue(LIVE); + const onConfigure = vi.fn(); + renderPanel(vi.fn(), onConfigure); + await flush(); + const kimi = screen.getByTestId("catalog-configure-moonshotai/kimi-k3"); + expect(kimi.tagName).toBe("BUTTON"); + expect(kimi.getAttribute("title")).toBe("Settings for this model"); + fireEvent.click(kimi); + expect(onConfigure).toHaveBeenCalledWith("openrouter:moonshotai/kimi-k3"); + expect(removeModel).not.toHaveBeenCalled(); + expect((screen.getByTestId("catalog-row-moonshotai/kimi-k3").querySelector("input") as HTMLInputElement).checked).toBe(true); + // not ticked: nothing to configure yet, so the name is not a button + expect(screen.queryByTestId("catalog-configure-openai/gpt-6-astra")).toBeNull(); + expect(screen.getByTestId("catalog-row-openai/gpt-6-astra").querySelector(".mlist-name")!.tagName).toBe("SPAN"); + }); + + it("without a settings opener (no dialog on this page) every name is plain text", async () => { + vi.mocked(getProviderCatalog).mockResolvedValue(LIVE); + renderPanel(); + await flush(); + expect(screen.queryByTestId("catalog-configure-moonshotai/kimi-k3")).toBeNull(); + expect(screen.getByTestId("catalog-row-moonshotai/kimi-k3").querySelector(".mlist-name")!.tagName).toBe("SPAN"); + }); + it("tick adds the routed id, untick removes it, and the page learns the new picker", async () => { vi.mocked(getProviderCatalog).mockResolvedValue(LIVE); vi.mocked(addModel).mockResolvedValue({ ok: true, models: [...SETTINGS.models, "openrouter:openai/gpt-6-astra"], model: SETTINGS.model } as any); diff --git a/surfaces/gui/src/components/models/ProviderModels.tsx b/surfaces/gui/src/components/models/ProviderModels.tsx index 356293be..893fa47a 100644 --- a/surfaces/gui/src/components/models/ProviderModels.tsx +++ b/surfaces/gui/src/components/models/ProviderModels.tsx @@ -46,12 +46,16 @@ export function ProviderModels({ suggested, settings, onChanged, + onConfigure, }: { provider: string; knownProviders: string[]; suggested: string[]; // the curated bare ids, for the fallback checklist settings: ModelSettings; onChanged: (next: { models: string[]; model: string }) => void; + // Opens the model's settings (its window, for one): a ticked row's name is the way there, + // the only one on this page (owner, 2026-11-09: the unverified note pointed nowhere). + onConfigure?: (model: string) => void; }) { const { t } = useTranslation(); const [catalog, setCatalog] = useState(null); @@ -216,7 +220,22 @@ export function ProviderModels({ title={isDefault ? t("models.default_locked") : undefined} onChange={(e) => void tick(row, e.target.checked)} /> - {row.label} + {row.in_picker && onConfigure ? ( + + ) : ( + {row.label} + )} {tags.length > 0 && ( {tags.map((g) => {g.text})} diff --git a/surfaces/gui/src/locales/en.json b/surfaces/gui/src/locales/en.json index 4a7c5893..159b1ae7 100644 --- a/surfaces/gui/src/locales/en.json +++ b/surfaces/gui/src/locales/en.json @@ -1469,7 +1469,7 @@ "catalog_tag_context": "{{size}} context", "catalog_tag_unverified": "unverified", "catalog_tag_not_on_key": "not on this key", - "catalog_unverified_help": "Unverified: nobody has checked this model's facts yet. It runs with safe defaults, and the app lowers its window if the provider refuses a long prompt. Set the window under the model's settings if you know it.", + "catalog_unverified_help": "Unverified: nobody has checked this model's facts yet. It runs with safe defaults, and the app lowers its window if the provider refuses a long prompt. If you know the window, tick the model, then click its name to set it.", "catalog_did_you_mean": "Did you mean:", "azure_deployment_help": "On Azure the model id is your deployment name — add each deployment you want to use, as named in the Azure or Foundry portal.", "one_click_coming": "One-click sign-in is coming soon — connect manually below for now:", diff --git a/surfaces/gui/src/locales/zh.json b/surfaces/gui/src/locales/zh.json index fea68bfe..e71639f6 100644 --- a/surfaces/gui/src/locales/zh.json +++ b/surfaces/gui/src/locales/zh.json @@ -1439,7 +1439,7 @@ "catalog_tag_context": "{{size}} 上下文", "catalog_tag_unverified": "未核实", "catalog_tag_not_on_key": "不在此密钥上", - "catalog_unverified_help": "未核实:尚无人核对此模型的参数。它以保守默认值运行;若提供方拒绝过长的提示,应用会自动调低其上下文窗口。如果你知道窗口大小,可在模型设置中设定。", + "catalog_unverified_help": "未核实:尚无人核对此模型的参数。它以保守默认值运行;若提供方拒绝过长的提示,应用会自动调低其上下文窗口。如果你知道窗口大小,请勾选该模型,再点击其名称进行设定。", "catalog_did_you_mean": "你是指:", "azure_deployment_help": "在 Azure 上,模型 ID 就是你的部署名称——按 Azure 或 Foundry 门户中的名称,逐个添加你要使用的部署。", "one_click_coming": "一键登录即将推出 —— 目前请在下方手动连接:",