fix(webui): hide model details until AI setup is complete

This commit is contained in:
Xubin Ren committed 2026-09-18 02:29:35 +08:00
1 parent 24c41a6af0
commit 4420ad58e1
3 files changed
+91 -3

No files matched your search

+35
View File
@@ -1158,6 +1158,41 @@ describe("ThreadShell", () => {
expect(screen.getByText("Default")).toBeInTheDocument();
});
it.each([false, true])("hides unconfigured model details in setup tooltips (existing history: %s)", async (hasHistory) => {
const client = makeClient();
const settings = modelSettings("anthropic/claude-opus-4-5", "anthropic");
settings.agent.has_api_key = false;
settings.providers = [{ name: "anthropic", label: "Anthropic", configured: false }];
vi.stubGlobal("fetch", vi.fn((input: RequestInfo | URL) => {
if (String(input).includes("websocket%3Asetup-tooltip/webui-thread")) {
return Promise.resolve(httpJson(transcriptFromSimpleMessages(
hasHistory ? [{ role: "user", content: "Previous message" }] : [],
)));
}
return Promise.resolve({ ok: false, status: 404, json: async () => ({}) });
}));
const onOpenModelSettings = vi.fn();
render(wrap(
client,
<ThreadShell
session={session("setup-tooltip")}
title="Setup tooltip"
onToggleSidebar={() => {}}
settingsSnapshot={settings}
onOpenModelSettings={onOpenModelSettings}
/>,
"anthropic/claude-opus-4-5",
));
await screen.findByText(hasHistory ? "Previous message" : HERO_GREETING_PATTERN);
const badge = screen.getByRole("button", { name: "Choose your AI" });
fireEvent.focus(badge);
expect(await screen.findByRole("tooltip")).toHaveTextContent(/^Choose your AI$/);
fireEvent.click(badge);
expect(onOpenModelSettings).toHaveBeenCalledTimes(1);
expect(client.sendMessage).not.toHaveBeenCalled();
});
it("opens model settings directly without clearing the draft", async () => {
const client = makeClient();
const settings = modelSettings("openai-codex/gpt-5.1-codex", "openai_codex");