feat(web): settings form polish — dialog layout, homepage button, no default rows, unified dropdown text (#39)

Co-authored-by: Alice <alice@prismshadow.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Yaowei Zheng
2026-07-23 01:07:45 +08:00
committed by GitHub
parent 6d56ce9ccc
commit d01d0faf7a
10 changed files with 363 additions and 183 deletions
@@ -0,0 +1,34 @@
/**
* agent-settings-page.ts optionRows unit tests: the runtime dropdowns build from the
* dictionary's [value, description] pairs with the "" (inherit) row dropped and dictionary
* order kept — pinned so a future reconciliation (e.g. with the no-none branch's option
* assembly) cannot silently regress the filter.
*/
import { describe, expect, it } from "vitest";
import { optionRows } from "../src/features/agents/agent-settings-page";
const ENTRIES: ReadonlyArray<readonly [string, string]> = [
["", "Send no override."],
["low", "Low tier."],
["medium", "Medium tier."],
["high", "High tier."],
["xhigh", "Extra-high tier."],
];
describe("optionRows", () => {
it("drops the '' inherit row and keeps dictionary order", () => {
const rows = optionRows(ENTRIES);
expect(rows.map((r) => r.value)).toEqual(["low", "medium", "high", "xhigh"]);
expect(rows.some((r) => r.value === "")).toBe(false);
});
it("maps value into both labels and carries the description through", () => {
const rows = optionRows([["summarize", "Summarize old context."]]);
expect(rows[0]).toEqual({
value: "summarize",
triggerLabel: "summarize",
label: "summarize",
description: "Summarize old context.",
});
});
});
+10 -6
View File
@@ -63,18 +63,22 @@ describe("thinkingLevelOptionsFor (agent-settings dropdown assembly)", () => {
["xhigh", "Extra-high tier."],
];
it("maps the dictionary in order; the '' row renders the default tag; no none row normally", () => {
it("filters the '' inherit row and keeps dictionary order; no none row normally", () => {
for (const stored of [undefined, "", "medium", "xhigh"]) {
const rows = thinkingLevelOptionsFor(OPTIONS, "(default)", "legacy none", stored);
expect(rows.map((r) => r.value)).toEqual(["", "low", "medium", "high", "xhigh"]);
expect(rows[0]).toMatchObject({ triggerLabel: "(default)", label: "(default)" });
const rows = thinkingLevelOptionsFor(OPTIONS, "legacy none", stored);
expect(rows.map((r) => r.value)).toEqual(["low", "medium", "high", "xhigh"]);
expect(rows.some((r) => r.value === "none")).toBe(false);
expect(rows[0]).toMatchObject({
triggerLabel: "low",
label: "low",
description: "Low tier.",
});
}
});
it("appends a display-only none row when the persisted config stores none (backward compat)", () => {
const rows = thinkingLevelOptionsFor(OPTIONS, "(default)", "legacy none", "none");
expect(rows.map((r) => r.value)).toEqual(["", "low", "medium", "high", "xhigh", "none"]);
const rows = thinkingLevelOptionsFor(OPTIONS, "legacy none", "none");
expect(rows.map((r) => r.value)).toEqual(["low", "medium", "high", "xhigh", "none"]);
expect(rows.at(-1)).toEqual({
value: "none",
triggerLabel: "none",