feat(web): port the pi2-web-ui-design v0.1.1 UI
Sync the React console with the v0.1.1 prototype (20 CHGs): Quiet Workbench
shell, Chat IA v3, tool-family rendering, and the mobile page pill.
Shell / tokens (CHG-01/04/15/20):
- tokens.css rewritten from the prototype (three-layer light/dark/system),
`--tabbar-h` removed, new faint/border-subtle/surface-1-2/fs-*/dur-*/reading-max
- 56px icon-only nav rail/sidebar (44x44 hit targets, CSS tooltips, active is a
solid primary fill, no left bar), 52px topbar, merged preferences menu,
⌘K/Cmd-K palette
- `<600` gets a topbar page pill + page sheet; the bottom tabbar is gone
Pages (CHG-01): workspaces becomes a card grid with whole-card links and a
320px recent-activity column; status gets four metric tiles + a zero-primary
layout; connect gets a two-column hero, one primary per state and a collapsed
manual form.
Chat IA v3 (CHG-02/10-14/16-19): two columns, single-workspace tree with a
workspace switch, single-line rows with attention, body-level row popover,
session tray (todo/tasks) replacing the right panel, context ring moved into a
composer telemetry line, right-aligned user messages, queued messages as one
stream entity plus a composer status bar, and an in-place subagent child view.
Tool rendering (CHG-05/06/09): new `features/chat/tools` module — one row per
call, DTO adapter for the daemon's block shape, 11 kind families, state
semantics ("one state, one meaning"), 44px touch targets and the diff row
contrast fix.
i18n: 729 keys per language (zh/en parity checked), 0 unresolved keys.
Verification: web typecheck + 297 vitest + vite build green, root typecheck
green, `scripts/smoke.sh` green, and a new visual harness
(`scripts/ui-mock-server.mjs` + `scripts/ui-shots.mjs`, docs/ui-parity.md)
shoots 4 pages x 3 viewports x 2 themes = 24 screenshots clean with
overflow/console/primary/tabbar assertions. `scripts/e2e/ui-e2e.mjs` selectors
are updated to the new DOM; that suite still needs a real pi + nvim to run.
This commit is contained in:
1 parent
a8425a51b6
commit
88e73c7737
98 files changed
+17676
-2871
No files matched your search
@@ -0,0 +1,87 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { FAMILY_IDS, KIND_ICON, KIND_OF, humanName, kindOf } from "@/features/chat/tools/kind";
|
||||
import type { FamilyId } from "@/features/chat/tools/types";
|
||||
|
||||
/** Table-driven: every documented tool name → its family (contract §5, `core.js:13-27`). */
|
||||
const TABLE: [string, FamilyId][] = [
|
||||
["bash", "shell"],
|
||||
["exec", "shell"],
|
||||
["shell", "shell"],
|
||||
["read", "read"],
|
||||
["edit", "write"],
|
||||
["write", "write"],
|
||||
["patch", "write"],
|
||||
["apply_patch", "write"],
|
||||
["edit_file", "write"],
|
||||
["multi_edit", "write"],
|
||||
["grep", "search"],
|
||||
["search", "search"],
|
||||
["find", "find"],
|
||||
["glob", "find"],
|
||||
["ls", "find"],
|
||||
["list_dir", "find"],
|
||||
["web_search", "web"],
|
||||
["web_fetch", "web"],
|
||||
["fetch_content", "web"],
|
||||
["source_check", "web"],
|
||||
["get_search_content", "web"],
|
||||
["web", "web"],
|
||||
["todo_write", "plan"],
|
||||
["update_plan", "plan"],
|
||||
["plan", "plan"],
|
||||
["dispatch_subagents", "subagent"],
|
||||
["list_subagents", "subagent"],
|
||||
["read_subagent", "subagent"],
|
||||
["poll_subagents", "subagent"],
|
||||
["wait_subagents", "subagent"],
|
||||
["list_batches", "subagent"],
|
||||
["stop_subagents", "subagent"],
|
||||
["vision", "vision"],
|
||||
["image", "vision"],
|
||||
["screenshot", "vision"],
|
||||
["task", "task"],
|
||||
["tasks", "task"],
|
||||
];
|
||||
|
||||
describe("kindOf", () => {
|
||||
it("covers every registered tool name (37 names, 11 kinds)", () => {
|
||||
expect(TABLE.length).toBeGreaterThanOrEqual(22);
|
||||
for (const [name, kind] of TABLE) {
|
||||
expect(kindOf(name), name).toBe(kind);
|
||||
expect(KIND_OF[name], name).toBe(kind);
|
||||
}
|
||||
// `generic` is the fallback, so every *other* family must be reachable by name.
|
||||
const named = new Set(TABLE.map(([, kind]) => kind));
|
||||
expect(named).toEqual(new Set(FAMILY_IDS.filter((kind) => kind !== "generic")));
|
||||
expect(FAMILY_IDS).toHaveLength(11);
|
||||
});
|
||||
|
||||
it("trims and lowercases before lookup", () => {
|
||||
expect(kindOf(" BASH ")).toBe("shell");
|
||||
expect(kindOf("Web_Search")).toBe("web");
|
||||
});
|
||||
|
||||
it("falls back to generic for unknown names and MCP tools", () => {
|
||||
expect(kindOf("mcp__slack__post")).toBe("generic");
|
||||
expect(kindOf("totally_unknown")).toBe("generic");
|
||||
expect(kindOf("")).toBe("generic");
|
||||
expect(kindOf(undefined)).toBe("generic");
|
||||
expect(kindOf(null)).toBe("generic");
|
||||
expect(kindOf(42)).toBe("generic");
|
||||
});
|
||||
|
||||
it("has a glyph for every family", () => {
|
||||
for (const kind of FAMILY_IDS) expect(KIND_ICON[kind], kind).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("humanName", () => {
|
||||
it("humanizes MCP names and keeps everything else verbatim", () => {
|
||||
expect(humanName("mcp__slack__post")).toBe("slack · post");
|
||||
expect(humanName("mcp__only")).toBe("only");
|
||||
expect(humanName("grep")).toBe("grep");
|
||||
expect(humanName("")).toBe("");
|
||||
expect(humanName(undefined)).toBe("tool");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user