Wave-5 chunk B: three model slots, search-engine row, first-run setup flow
Chunk B (owner-designed, model-slots wave) on the merged engine surface (main 1d66a17): AGENT SECTION — SLOTS ONLY (owner ruling) - The six per-role model rows are GONE; three slot rows instead: Strong (Prober + Teacher), Cheap (five workhorse roles), Vision (visual maker + PDF reader), roster + resolved-default in every hint. - Slot dropdowns share the app's menu language over the FEDERATED catalog (/api/models = keyed providers only, fresh per call — saving a key in Keys immediately widens the picker); the vision slot filters to image-capable models (Model.input); the menu's highlight now matches provider+id (ids can collide across providers). - Slots write the new models section (PUT /api/settings/models) through the dialog's write seam; per-role overrides stay schema-only. - ModelMenuList rows read 'provider · id' — federation makes the provider bookkeeping-relevant. Usage stamps render provider-qualified (prettyModel(qualified): 'Glm 5.3 Flash · openrouter') in the stats bar's turn lines. SEARCH ENGINE (search wave: no default, owner) - A row in Tools: Tavily/Brave via the shared-menu look, Automatic = the pin removed (auto-activation). The live reason line comes from /api/search; no engine key at all grays the whole row + disables the trigger (a keyless choice would only block auto-activation). FIRST-RUN SETUP FLOW (owner design A: composer CTA + send interception) - Chats cannot start until all three slots are picked — no defaults for 33 providers (slotsConfigured: all three slot models required). - The graph view's new-session dock (home) shows a 'Set up your models' CTA while unconfigured; submitting a topic opens the SetupDialog WITH THE DRAFT PRESERVED; Save stores the models section and the queued message sends. Same interception on /chat/new sends. - STAGED BY DEPENDENCY (owner: keys first, models after): no keyed provider → stage 1 deep-links the settings dialog on Keys (open now takes a section); a saved key reopens at stage 2 on the next submit. - Stage 2: Strong → Cheap → Vision pickers (federated, vision-filtered, all three required). Closable without configuring — browsing stays possible; the gate is the send, not the dialog. Layered Esc: an open slot menu eats Esc before the dialog. - Two closure bugs caught live: onDone→start/send captured the stale pre-save 'configured' (the flow now forces the replayed send); menu-Esc used to close the whole dialog. Settings-dialog provider: open(section?) lands on a section (stage 1 deep-link). Tests: composeSlotModel/composeSearchEngine pure, slot SSR replacing role rows, slotsConfigured/setupStage first-run gates, provider-qualified prettyModel. Gates: typecheck, lint, 792/792, build.
This commit is contained in:
@@ -59,42 +59,60 @@ describe("SettingsDialog (the designed surface, SSR)", () => {
|
||||
});
|
||||
|
||||
describe("AgentSection (thin SSR)", () => {
|
||||
it("renders all six background-role rows, Default-triggered dropdowns", () => {
|
||||
const html = renderToStaticMarkup(<AgentSection agent={undefined} onSectionChange={() => {}} />);
|
||||
for (const role of ["researcher", "demoBuilder", "visualMaker", "extractor", "auditor", "labeler"]) {
|
||||
assert.ok(html.includes(`data-testid="role-row-${role}"`), role);
|
||||
it("renders the three model SLOT rows (slots-only, owner ruling 2026-09-20), Default-triggered dropdowns", () => {
|
||||
const html = renderToStaticMarkup(<AgentSection agent={undefined} models={undefined} onSectionChange={() => {}} onModelsChange={() => {}} />);
|
||||
for (const slot of ["strong", "cheap", "vision"]) {
|
||||
assert.ok(html.includes(`data-testid="slot-row-${slot}"`), slot);
|
||||
// The shared model-picker dropdown as the opened menu (owner,
|
||||
// 2026-09-20), the thin trigger as the collapsed look.
|
||||
assert.ok(html.includes(`data-testid="role-model-${role}"`), `${role} model trigger`);
|
||||
assert.ok(html.includes(`data-testid="role-thinking-${role}"`), `${role} thinking trigger`);
|
||||
assert.ok(html.includes(`data-testid="slot-model-${slot}"`), `${slot} model trigger`);
|
||||
assert.ok(html.includes(`data-testid="slot-thinking-${slot}"`), `${slot} thinking trigger`);
|
||||
// the roster hint rides every row
|
||||
assert.ok(html.includes("Prober + Teacher") || slot !== "strong", "strong roster");
|
||||
}
|
||||
assert.equal((html.match(/>Default<\/span>/g) ?? []).length, 6, "three slots × two Default triggers");
|
||||
// the per-role rows are GONE (slots-only)
|
||||
for (const role of ["researcher", "demoBuilder", "visualMaker"]) {
|
||||
assert.ok(!html.includes(`data-testid="role-row-${role}"`), `${role} retired`);
|
||||
}
|
||||
assert.equal((html.match(/>Default<\/span>/g) ?? []).length, 12, "six roles × two Default triggers");
|
||||
assert.ok(html.includes('data-testid="group-models"'), "Models sub-group");
|
||||
assert.ok(html.includes('data-testid="group-tools"'), "Tools sub-group");
|
||||
assert.ok(html.includes('data-testid="group-prompts"'), "System prompts sub-group");
|
||||
});
|
||||
|
||||
it("the search-engine row renders with its live reason (search wave 2026-09-20)", () => {
|
||||
const html = renderToStaticMarkup(<AgentSection agent={undefined} models={undefined} onSectionChange={() => {}} onModelsChange={() => {}} />);
|
||||
assert.ok(html.includes('data-testid="search-engine-row"'), "the row");
|
||||
assert.ok(html.includes('data-testid="search-engine-trigger"'), "the trigger");
|
||||
// SSR: /api/search never fired → no reason line yet, trigger reads Automatic
|
||||
assert.ok(html.includes("Automatic"), "unset engine reads Automatic");
|
||||
// the explicit preference shows the chosen engine in the trigger
|
||||
const html2 = renderToStaticMarkup(
|
||||
<AgentSection agent={{ search: { engine: "tavily" } }} models={undefined} onSectionChange={() => {}} onModelsChange={() => {}} />,
|
||||
);
|
||||
assert.ok(html2.includes("Tavily"), "pinned engine visible in the trigger");
|
||||
});
|
||||
|
||||
it("renders the owner's FINAL tool list — research, demo, visual, pdf", () => {
|
||||
assert.deepEqual([...TOGGLE_TOOLS], ["research", "demo", "visual", "pdf"]);
|
||||
const html = renderToStaticMarkup(<AgentSection agent={undefined} onSectionChange={() => {}} />);
|
||||
const html = renderToStaticMarkup(<AgentSection agent={undefined} models={undefined} onSectionChange={() => {}} onModelsChange={() => {}} />);
|
||||
for (const id of TOGGLE_TOOLS) assert.ok(html.includes(`data-testid="tool-row-${id}"`), id);
|
||||
});
|
||||
|
||||
it("tools default ON (absent key = enabled)", () => {
|
||||
const html = renderToStaticMarkup(<AgentSection agent={undefined} onSectionChange={() => {}} />);
|
||||
const html = renderToStaticMarkup(<AgentSection agent={undefined} models={undefined} onSectionChange={() => {}} onModelsChange={() => {}} />);
|
||||
for (const id of TOGGLE_TOOLS) {
|
||||
assert.ok(tagOf(html, `toggle-tool-${id}`).includes('aria-checked="true"'), `${id} defaults on`);
|
||||
}
|
||||
});
|
||||
|
||||
it("an overridden role shows its model in the select, tools carry the delta", () => {
|
||||
it("an overridden SLOT shows its model in the trigger, tools carry the delta", () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<AgentSection
|
||||
agent={{
|
||||
models: { researcher: { model: { provider: "openrouter", id: "z-ai/glm-4.7-flash" } } },
|
||||
tools: { demo: false },
|
||||
}}
|
||||
agent={{ tools: { demo: false } }}
|
||||
models={{ strong: { model: { provider: "zai", id: "glm-4.7-flash" } } }}
|
||||
onSectionChange={() => {}}
|
||||
onModelsChange={() => {}}
|
||||
/>,
|
||||
);
|
||||
// The trigger shows the stored id even with no catalog loaded (a
|
||||
@@ -105,7 +123,7 @@ describe("AgentSection (thin SSR)", () => {
|
||||
});
|
||||
|
||||
it("prompts show the loading state under SSR (effects never fire)", () => {
|
||||
const html = renderToStaticMarkup(<AgentSection agent={undefined} onSectionChange={() => {}} />);
|
||||
const html = renderToStaticMarkup(<AgentSection agent={undefined} models={undefined} onSectionChange={() => {}} onModelsChange={() => {}} />);
|
||||
assert.ok(html.includes("Loading prompt segments"));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -73,4 +73,15 @@ describe("stats bar", () => {
|
||||
assert.equal(prettyModel("z-ai/glm-5.3-flash"), "Glm 5.3 Flash");
|
||||
assert.equal(prettyModel("qwen/qwen3.8-max-0902"), "Qwen3.8 Max");
|
||||
});
|
||||
|
||||
it("provider-qualified stamps (usage contract, model-slots wave)", () => {
|
||||
// qualified: the provider rides as a quiet suffix — federation makes
|
||||
// the same model via two providers different bookkeeping
|
||||
assert.equal(prettyModel("openrouter:z-ai/glm-5.3-flash", true), "Glm 5.3 Flash · openrouter");
|
||||
assert.equal(prettyModel("openai:gpt-5.2", true), "Gpt 5.2 · openai");
|
||||
// unqualified on a qualified stamp: provider silently dropped (old shape)
|
||||
assert.equal(prettyModel("openrouter:z-ai/glm-5.3-flash"), "Glm 5.3 Flash");
|
||||
// qualified on a bare id: no suffix invented
|
||||
assert.equal(prettyModel("z-ai/glm-5.3-flash", true), "Glm 5.3 Flash");
|
||||
});
|
||||
});
|
||||
+78
-12
@@ -8,10 +8,12 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { describe, it } from "node:test";
|
||||
import { appearanceVars, derivedPalette, resolveAppearance } from "../components/settings/appearance.tsx";
|
||||
import { composePromptSwitch, composeRoleModel, composeTool } from "../components/settings/agent-section.tsx";
|
||||
import { composePromptSwitch, composeSearchEngine, composeSlotModel, composeTool } from "../components/settings/agent-section.tsx";
|
||||
import { nextOverrides } from "../components/settings/keyboard-section.tsx";
|
||||
import { classifyKeys, keyStatusLine, type ProviderKeyInfo } from "../components/settings/keys-section.tsx";
|
||||
import type { AuthKeyStatus } from "../src/core";
|
||||
import type { AgentSettings, AuthKeyStatus, ModelsSettings } from "../src/core";
|
||||
import { slotsConfigured } from "../src/core";
|
||||
import { setupStage } from "../components/setup-dialog.tsx";
|
||||
|
||||
describe("resolveAppearance — delta over factory", () => {
|
||||
it("absent everything = the factory view", () => {
|
||||
@@ -105,23 +107,50 @@ describe("agent section compose helpers — the replace-whole PUT body", () => {
|
||||
assert.deepEqual(after.prompts, { "system-prompt.md": true }, "prompts untouched");
|
||||
});
|
||||
|
||||
it("composeRoleModel: empty+empty REMOVES the role (absent = config pin)", () => {
|
||||
const after = composeRoleModel({ models: { researcher: { model: { provider: "openrouter", id: "x" } }, auditor: {} } }, "researcher", "", "");
|
||||
assert.equal(after.models?.researcher, undefined, "role dropped");
|
||||
assert.deepEqual(after.models?.auditor, {}, "sibling untouched");
|
||||
it("composeSlotModel: empty+empty REMOVES the slot (absent = factory pin)", () => {
|
||||
const after = composeSlotModel(
|
||||
{ strong: { model: { provider: "openrouter", id: "x" } }, cheap: {} },
|
||||
"strong",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
);
|
||||
assert.equal(after.strong, undefined, "slot dropped");
|
||||
assert.deepEqual(after.cheap, {}, "sibling untouched");
|
||||
});
|
||||
|
||||
it("composeRoleModel: model alone, thinking alone, and both", () => {
|
||||
assert.deepEqual(composeRoleModel(undefined, "labeler", "z-ai/glm-4.7-flash", "").models?.labeler, {
|
||||
model: { provider: "openrouter", id: "z-ai/glm-4.7-flash" },
|
||||
it("composeSlotModel: model alone, thinking alone, and both — provider rides the swap (federation)", () => {
|
||||
assert.deepEqual(composeSlotModel(undefined, "strong", "zai", "glm-4.7-flash", "").strong, {
|
||||
model: { provider: "zai", id: "glm-4.7-flash" },
|
||||
});
|
||||
assert.deepEqual(composeRoleModel(undefined, "labeler", "", "low").models?.labeler, { thinkingLevel: "low" });
|
||||
assert.deepEqual(composeRoleModel(undefined, "labeler", "m1", "high").models?.labeler, {
|
||||
model: { provider: "openrouter", id: "m1" },
|
||||
assert.deepEqual(composeSlotModel(undefined, "cheap", "", "", "low").cheap, { thinkingLevel: "low" });
|
||||
assert.deepEqual(composeSlotModel(undefined, "vision", "openai", "gpt-5.2", "high").vision, {
|
||||
model: { provider: "openai", id: "gpt-5.2" },
|
||||
thinkingLevel: "high",
|
||||
});
|
||||
});
|
||||
|
||||
it("composeSlotModel: per-field independence — clearing the model keeps the thinking pin", () => {
|
||||
const prev: ModelsSettings = { strong: { model: { provider: "zai", id: "glm-4.7-flash" }, thinkingLevel: "high" } };
|
||||
const after = composeSlotModel(prev, "strong", "", "", "high");
|
||||
assert.deepEqual(after.strong, { model: { provider: "zai", id: "glm-4.7-flash" }, thinkingLevel: "high" }, "model carried, thinking kept");
|
||||
// clearing thinking keeps the model
|
||||
const after2 = composeSlotModel(prev, "strong", "zai", "glm-4.7-flash", "");
|
||||
assert.deepEqual(after2.strong, { model: { provider: "zai", id: "glm-4.7-flash" } }, "thinking dropped, model kept");
|
||||
});
|
||||
|
||||
it("composeSearchEngine: null REMOVES the pin (auto-activation's resting state)", () => {
|
||||
const withPin: AgentSettings = { search: { engine: "tavily" } };
|
||||
const cleared = composeSearchEngine(withPin, null);
|
||||
assert.equal(cleared.search, undefined);
|
||||
// no pin to begin with → carried verbatim
|
||||
assert.deepEqual(composeSearchEngine({ tools: { demo: true } }, null).tools, { demo: true });
|
||||
});
|
||||
|
||||
it("composeSearchEngine: the explicit preference writes agent.search.engine", () => {
|
||||
assert.deepEqual(composeSearchEngine(undefined, "brave").search, { engine: "brave" });
|
||||
});
|
||||
|
||||
it("composePromptSwitch: on = explicit true, off = key REMOVED (absent = off)", () => {
|
||||
assert.deepEqual(composePromptSwitch({ prompts: { a: true } }, "b", true).prompts, { a: true, b: true });
|
||||
assert.deepEqual(composePromptSwitch({ prompts: { a: true, b: true } }, "b", false).prompts, { a: true });
|
||||
@@ -216,3 +245,40 @@ describe("keyStatusLine — the minimal at-a-glance state", () => {
|
||||
assert.equal(keyStatusLine({ id: "X", info: null, present: false, masked: null, source: "none", shadowedByEnv: false }), "not set");
|
||||
});
|
||||
});
|
||||
|
||||
describe("first-run gate — slotsConfigured + setupStage (model-slots wave)", () => {
|
||||
it("slotsConfigured: all three slot models required — thinking levels are optional", () => {
|
||||
assert.equal(slotsConfigured(undefined), false, "no record = unconfigured");
|
||||
assert.equal(slotsConfigured({}), false, "empty models section");
|
||||
assert.equal(
|
||||
slotsConfigured({
|
||||
strong: { model: { provider: "zai", id: "glm-5.3-flash" } },
|
||||
cheap: { model: { provider: "zai", id: "glm-4.7-flash" } },
|
||||
}),
|
||||
false,
|
||||
"vision missing",
|
||||
);
|
||||
assert.equal(
|
||||
slotsConfigured({
|
||||
strong: { model: { provider: "zai", id: "glm-5.3-flash" } },
|
||||
cheap: { model: { provider: "zai", id: "glm-4.7-flash" } },
|
||||
vision: { model: { provider: "openai", id: "gpt-5.2" } },
|
||||
}),
|
||||
true,
|
||||
"all three picked",
|
||||
);
|
||||
// a thinking-only pin does NOT configure the slot
|
||||
assert.equal(
|
||||
slotsConfigured({ strong: { thinkingLevel: "low" }, cheap: { thinkingLevel: "low" }, vision: { thinkingLevel: "low" } }),
|
||||
false,
|
||||
"thinking pins are not models",
|
||||
);
|
||||
});
|
||||
|
||||
it("setupStage: keys before models (owner's dependency ordering)", () => {
|
||||
assert.equal(setupStage(null), "keys", "fetch failed → the honest fallback");
|
||||
assert.equal(setupStage([]), "keys", "no providers = keys");
|
||||
assert.equal(setupStage([{ id: "zai", keyPresent: false }]), "keys", "provider present but keyless");
|
||||
assert.equal(setupStage([{ id: "zai", keyPresent: false }, { id: "openai", keyPresent: true }]), "pickers", "one keyed provider widens the pickers");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user