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:
yuez committed 2026-10-26 20:28:47 +08:00
1 parent a8425a51b6
commit 88e73c7737
98 files changed
+17676 -2871

No files matched your search

+31 -11
View File
@@ -4,15 +4,18 @@ import appCss from "@/styles/app.css?raw";
import tokensCss from "@/styles/tokens.css?raw";
function block(source: string, selector: string): string {
const start = source.indexOf(selector);
// Strip comments first: the file header mentions `html[data-theme="dark"]`,
// which would otherwise make `indexOf` land inside the header and return `:root`.
const text = source.replace(/\/\*[\s\S]*?\*\//g, "");
const start = text.indexOf(selector);
expect(start, `missing selector ${selector}`).toBeGreaterThanOrEqual(0);
const open = source.indexOf("{", start);
const open = text.indexOf("{", start);
let depth = 0;
for (let i = open; i < source.length; i += 1) {
if (source[i] === "{") depth += 1;
if (source[i] === "}") {
for (let i = open; i < text.length; i += 1) {
if (text[i] === "{") depth += 1;
if (text[i] === "}") {
depth -= 1;
if (depth === 0) return source.slice(open + 1, i);
if (depth === 0) return text.slice(open + 1, i);
}
}
throw new Error(`unclosed block ${selector}`);
@@ -70,15 +73,32 @@ describe("design tokens", () => {
"topbar-h",
"sidebar-w",
"rail-w",
"tabbar-h",
// v0.1.1 additions (pi2-web-ui-design CHG-2026-10-23-01 / -04 / -20)
"faint",
"border-subtle",
"surface-1",
"surface-2",
"overlay",
"focus-ring",
"fs-2xs",
"fs-body",
"fs-xl",
"fw-strong",
"radius-pill",
"reading-max",
"dur-fast",
"ease-out",
]) {
expect(light[name], `--${name}`).toBeTruthy();
}
// CHG-2026-10-26-20 removed the mobile tabbar; the token must be gone.
expect(light["tabbar-h"]).toBeUndefined();
expect(dark["tabbar-h"]).toBeUndefined();
});
it("overrides the same surfaces in the dark data-theme block", () => {
expect(light.background).toBe("oklch(0.985 0.004 90)");
expect(dark.background).toBe("oklch(0.145 0.008 60)");
expect(light.background).toBe("oklch(0.987 0.003 85)");
expect(dark.background).toBe("oklch(0.148 0.006 65)");
expect(light.foreground).not.toBe(dark.foreground);
for (const name of ["background", "foreground", "card", "muted", "muted-foreground", "primary", "border", "input", "ok", "warn", "role-user", "role-agent", "role-thinking"]) {
expect(dark[name], `--${name} dark override`).toBeTruthy();
@@ -131,12 +151,12 @@ describe("design tokens", () => {
document.documentElement.dataset.theme = "light";
expect(getComputedStyle(document.documentElement).getPropertyValue("--background").trim()).toBe(
"oklch(0.985 0.004 90)",
"oklch(0.987 0.003 85)",
);
document.documentElement.dataset.theme = "dark";
expect(getComputedStyle(document.documentElement).getPropertyValue("--background").trim()).toBe(
"oklch(0.145 0.008 60)",
"oklch(0.148 0.006 65)",
);
style.remove();