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).
This commit is contained in:
Devika Verma
2026-11-17 18:38:30 +05:30
parent e4fc1a80b5
commit 2d08fa2f0b
5 changed files with 56 additions and 10 deletions
@@ -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}
</div>
) : (
// Unconfigured providers still show their curated models as a read-only preview — what a
@@ -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(<ProviderModels provider="openrouter" knownProviders={["openai", "openrouter"]} suggested={["z-ai/glm-5.2"]} settings={SETTINGS} onChanged={onChanged} />);
function renderPanel(onChanged = vi.fn(), onConfigure?: (model: string) => void) {
render(<ProviderModels provider="openrouter" knownProviders={["openai", "openrouter"]} suggested={["z-ai/glm-5.2"]} settings={SETTINGS} onChanged={onChanged} onConfigure={onConfigure} />);
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);
@@ -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<ProviderCatalog | null>(null);
@@ -216,7 +220,22 @@ export function ProviderModels({
title={isDefault ? t("models.default_locked") : undefined}
onChange={(e) => void tick(row, e.target.checked)}
/>
<span className="mlist-name" title={row.model}>{row.label}</span>
{row.in_picker && onConfigure ? (
<button
type="button"
className="mlist-name text-left hover:underline underline-offset-2"
title={t("manage.configure_model")}
data-testid={`catalog-configure-${row.id}`}
onClick={(e) => {
e.preventDefault(); // the name sits in the checkbox's label: open settings, do not untick
onConfigure(row.model);
}}
>
{row.label}
</button>
) : (
<span className="mlist-name" title={row.model}>{row.label}</span>
)}
{tags.length > 0 && (
<span className="text-meta text-muted shrink-0 flex gap-2" data-testid={`catalog-tags-${row.id}`}>
{tags.map((g) => <span key={g.key} className={g.tone || ""} title={g.title}>{g.text}</span>)}
+1 -1
View File
@@ -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:",
+1 -1
View File
@@ -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": "一键登录即将推出 —— 目前请在下方手动连接:",