refactor(webui): open models directly for first-run setup
This commit is contained in:
1 parent
1c1f746903
commit
05100b70ad
22 files changed
+75
-627
No files matched your search
@@ -481,7 +481,7 @@ describe("App layout", () => {
|
||||
expect(screen.getByRole("heading", { level: 1, name: "Settings" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("carries a first-run setup path into settings and restores composer focus", async () => {
|
||||
it("opens the full Models settings directly from the first-run prompt", async () => {
|
||||
const user = userEvent.setup();
|
||||
const base = baseSettingsPayload();
|
||||
mockFetchRoutes({
|
||||
@@ -496,26 +496,6 @@ describe("App layout", () => {
|
||||
},
|
||||
model_presets: [],
|
||||
model_call_order: [],
|
||||
providers: [
|
||||
{
|
||||
name: "openai_codex",
|
||||
label: "OpenAI Codex",
|
||||
configured: false,
|
||||
auth_type: "oauth",
|
||||
},
|
||||
{
|
||||
name: "deepseek",
|
||||
label: "DeepSeek",
|
||||
configured: false,
|
||||
auth_type: "api_key",
|
||||
},
|
||||
{
|
||||
name: "ollama",
|
||||
label: "Ollama",
|
||||
configured: false,
|
||||
api_base: "http://127.0.0.1:11434",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
@@ -523,23 +503,14 @@ describe("App layout", () => {
|
||||
|
||||
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
|
||||
await user.click(await screen.findByRole("button", { name: "Choose your AI" }));
|
||||
await user.click(await screen.findByRole("button", { name: "Run locally" }));
|
||||
|
||||
expect(
|
||||
await screen.findByRole("navigation", { name: "Settings sections" }),
|
||||
).toBeInTheDocument();
|
||||
const providerMenu = await screen.findByRole("menu");
|
||||
expect(within(providerMenu).getByRole("menuitem", { name: "Ollama" }))
|
||||
expect(screen.getByText("Model providers")).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "Add your own model provider" }))
|
||||
.toBeInTheDocument();
|
||||
expect(within(providerMenu).queryByRole("menuitem", { name: "OpenAI Codex" }))
|
||||
.not.toBeInTheDocument();
|
||||
expect(within(providerMenu).queryByRole("menuitem", { name: "DeepSeek" }))
|
||||
.not.toBeInTheDocument();
|
||||
|
||||
const composer = screen.getByRole("textbox", { name: "Message input" });
|
||||
expect(composer).not.toHaveFocus();
|
||||
await user.click(screen.getByRole("button", { name: "Back to chat" }));
|
||||
await waitFor(() => expect(composer).toHaveFocus());
|
||||
expect(screen.queryByRole("dialog", { name: "Choose your AI" })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("places Automations after Skills in the main sidebar", async () => {
|
||||
|
||||
@@ -14,48 +14,6 @@ async function chooseProviderToConfigure(label: string) {
|
||||
describe("Settings providers", () => {
|
||||
installSettingsViewTestHooks();
|
||||
|
||||
it.each([
|
||||
["account", "OpenAI Codex", ["DeepSeek", "Ollama", "Custom provider"]],
|
||||
["apiKey", "DeepSeek", ["OpenAI Codex", "Ollama"]],
|
||||
["local", "Ollama", ["OpenAI Codex", "DeepSeek", "Custom provider"]],
|
||||
] as const)("opens the %s first-run provider path", async (intent, expected, excluded) => {
|
||||
const base = settingsPayload();
|
||||
const payload: SettingsPayload = {
|
||||
...base,
|
||||
providers: [
|
||||
{
|
||||
name: "openai_codex",
|
||||
label: "OpenAI Codex",
|
||||
configured: false,
|
||||
auth_type: "oauth",
|
||||
},
|
||||
{
|
||||
name: "deepseek",
|
||||
label: "DeepSeek",
|
||||
configured: false,
|
||||
auth_type: "api_key",
|
||||
},
|
||||
{
|
||||
name: "ollama",
|
||||
label: "Ollama",
|
||||
configured: false,
|
||||
api_base: "http://127.0.0.1:11434",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
renderSettingsView({
|
||||
initialSection: "models",
|
||||
initialSettings: payload,
|
||||
modelSetupIntent: intent,
|
||||
});
|
||||
|
||||
const menu = await screen.findByRole("menu");
|
||||
expect(within(menu).getByRole("menuitem", { name: expected })).toBeInTheDocument();
|
||||
for (const label of excluded) {
|
||||
expect(within(menu).queryByRole("menuitem", { name: label })).not.toBeInTheDocument();
|
||||
}
|
||||
});
|
||||
|
||||
it("signs in to the xAI Grok provider", async () => {
|
||||
const base = settingsPayload();
|
||||
|
||||
@@ -3,7 +3,6 @@ import userEvent from "@testing-library/user-event";
|
||||
import { afterEach, beforeEach, vi } from "vitest";
|
||||
import { SettingsView } from "@/components/settings/SettingsView";
|
||||
import { ClientProvider } from "@/providers/ClientProvider";
|
||||
import type { ModelSetupIntent } from "@/lib/model-setup";
|
||||
import type { SettingsPayload } from "@/lib/types";
|
||||
|
||||
export const requestMutationMock = vi.fn();
|
||||
@@ -138,7 +137,6 @@ export function renderSettingsView(
|
||||
| "browser"
|
||||
| "runtime";
|
||||
initialSettings?: SettingsPayload;
|
||||
modelSetupIntent?: ModelSetupIntent;
|
||||
showSidebar?: boolean;
|
||||
onBackToChat?: () => void;
|
||||
onSettingsChange?: (payload: SettingsPayload) => void;
|
||||
@@ -151,7 +149,6 @@ export function renderSettingsView(
|
||||
theme="light"
|
||||
initialSection={options.initialSection ?? "apps"}
|
||||
initialSettings={options.initialSettings}
|
||||
modelSetupIntent={options.modelSetupIntent}
|
||||
showSidebar={options.showSidebar}
|
||||
onToggleTheme={() => {}}
|
||||
onBackToChat={options.onBackToChat ?? (() => {})}
|
||||
|
||||
@@ -835,7 +835,7 @@ describe("ThreadShell", () => {
|
||||
expect(screen.getByText("Default")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("opens first-run model setup without clearing the draft", async () => {
|
||||
it("opens model settings directly without clearing the draft", async () => {
|
||||
const client = makeClient();
|
||||
const settings = modelSettings("openai-codex/gpt-5.1-codex", "openai_codex");
|
||||
settings.agent.has_api_key = false;
|
||||
@@ -882,55 +882,26 @@ describe("ThreadShell", () => {
|
||||
expect(screen.getByTestId("composer-model-setup-label")).toHaveTextContent("Choose your AI");
|
||||
expect(badge).not.toHaveClass("border-amber-500/35");
|
||||
expect(screen.queryByTestId("composer-model-logo-openai_codex")).not.toBeInTheDocument();
|
||||
fireEvent.click(badge);
|
||||
expect(await screen.findByRole("dialog", { name: "Choose your AI" })).toBeInTheDocument();
|
||||
expect(screen.getAllByText("Ready")).toHaveLength(3);
|
||||
expect(onOpenModelSettings).not.toHaveBeenCalled();
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Close" }));
|
||||
|
||||
const input = screen.getByRole("textbox", { name: "Message input" });
|
||||
await waitFor(() => expect(input).toHaveFocus());
|
||||
fireEvent.change(input, {
|
||||
target: { value: "hello" },
|
||||
});
|
||||
fireEvent.click(badge);
|
||||
|
||||
expect(screen.queryByRole("dialog", { name: "Choose your AI" })).not.toBeInTheDocument();
|
||||
expect(onOpenModelSettings).toHaveBeenCalledTimes(1);
|
||||
expect(input).toHaveValue("hello");
|
||||
expect(client.sendMessage).not.toHaveBeenCalled();
|
||||
|
||||
onOpenModelSettings.mockClear();
|
||||
fireEvent.keyDown(input, { key: "Enter", code: "Enter" });
|
||||
|
||||
expect(await screen.findByRole("dialog", { name: "Choose your AI" })).toBeInTheDocument();
|
||||
expect(onOpenModelSettings).toHaveBeenCalledTimes(1);
|
||||
expect(input).toHaveValue("hello");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Use an API key" }));
|
||||
|
||||
expect(onOpenModelSettings).toHaveBeenCalledWith("apiKey");
|
||||
expect(input).toHaveValue("hello");
|
||||
expect(input).not.toHaveFocus();
|
||||
expect(client.sendMessage).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("focuses the composer when returning from model setup", async () => {
|
||||
const client = makeClient();
|
||||
const settings = modelSettings("openai-codex/gpt-5.1-codex", "openai_codex");
|
||||
settings.agent.has_api_key = false;
|
||||
const view = (focusComposerRequest: number) => wrap(
|
||||
client,
|
||||
<ThreadShell
|
||||
session={session("setup-focus")}
|
||||
title="Setup focus"
|
||||
onToggleSidebar={() => {}}
|
||||
settingsSnapshot={settings}
|
||||
focusComposerRequest={focusComposerRequest}
|
||||
/>,
|
||||
"openai-codex/gpt-5.1-codex",
|
||||
);
|
||||
const { rerender } = render(view(0));
|
||||
const input = await screen.findByRole("textbox", { name: "Message input" });
|
||||
input.blur();
|
||||
expect(input).not.toHaveFocus();
|
||||
|
||||
rerender(view(1));
|
||||
|
||||
await waitFor(() => expect(input).toHaveFocus());
|
||||
});
|
||||
|
||||
it("keeps image generation controls out of the composer", async () => {
|
||||
const client = makeClient();
|
||||
const disabledSettings = modelSettings("deepseek-v4-pro", "deepseek");
|
||||
|
||||
Reference in new issue
Block a user