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,89 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { STATE_ALIAS, STATE_KEY, isFailure, isRunning, isSoft, stateOf } from "@/features/chat/tools/state";
|
||||
import type { ToolState } from "@/features/chat/tools/types";
|
||||
|
||||
/** Alias → canonical state matrix (contract §3, `core.js:68-104`). */
|
||||
const ALIASES: [string, ToolState][] = [
|
||||
["running", "running"],
|
||||
["spinning", "running"],
|
||||
["in_progress", "running"],
|
||||
["in-progress", "running"],
|
||||
["pending", "queued"],
|
||||
["queued", "queued"],
|
||||
["done", "done"],
|
||||
["completed", "done"],
|
||||
["success", "done"],
|
||||
["ok", "done"],
|
||||
["failed", "failed"],
|
||||
["error", "failed"],
|
||||
["err", "failed"],
|
||||
["timeout", "timeout"],
|
||||
["timed_out", "timeout"],
|
||||
["interrupted", "interrupted"],
|
||||
["aborted", "interrupted"],
|
||||
["rejected", "rejected"],
|
||||
["cancelled", "cancelled"],
|
||||
["canceled", "cancelled"],
|
||||
["stopped", "cancelled"],
|
||||
];
|
||||
|
||||
describe("stateOf", () => {
|
||||
it("normalizes all 21 aliases", () => {
|
||||
for (const [alias, state] of ALIASES) {
|
||||
expect(stateOf({ state: alias }), alias).toBe(state);
|
||||
expect(STATE_ALIAS[alias], alias).toBe(state);
|
||||
}
|
||||
});
|
||||
|
||||
it("normalizes case and surrounding whitespace", () => {
|
||||
expect(stateOf({ state: " RUNNING " })).toBe("running");
|
||||
expect(stateOf({ state: "Cancelled" })).toBe("cancelled");
|
||||
});
|
||||
|
||||
it("never turns an unknown or empty state into a spinner — it lands on done", () => {
|
||||
for (const raw of ["", "weird", "in_flux", "PAUSED", null, undefined]) {
|
||||
expect(stateOf({ state: raw ?? undefined }), String(raw)).toBe("done");
|
||||
}
|
||||
expect(stateOf(null)).toBe("done");
|
||||
expect(stateOf(undefined)).toBe("done");
|
||||
expect(stateOf("")).toBe("done");
|
||||
expect(stateOf("exploded")).toBe("done");
|
||||
});
|
||||
|
||||
it("accepts a bare state string as well as an object", () => {
|
||||
expect(stateOf("failed")).toBe("failed");
|
||||
expect(stateOf("pending")).toBe("queued");
|
||||
});
|
||||
});
|
||||
|
||||
describe("state predicates", () => {
|
||||
const MATRIX: [ToolState, boolean, boolean, boolean][] = [
|
||||
// state, isFailure, isRunning, isSoft
|
||||
["failed", true, false, false],
|
||||
["timeout", true, false, false],
|
||||
["running", false, true, false],
|
||||
["queued", false, false, false],
|
||||
["done", false, false, false],
|
||||
["interrupted", false, false, true],
|
||||
["rejected", false, false, true],
|
||||
["cancelled", false, false, true],
|
||||
];
|
||||
|
||||
it("matches the failure / running / soft matrix", () => {
|
||||
for (const [state, failure, running, soft] of MATRIX) {
|
||||
expect(isFailure(state), state).toBe(failure);
|
||||
expect(isRunning(state), state).toBe(running);
|
||||
expect(isSoft(state), state).toBe(soft);
|
||||
}
|
||||
});
|
||||
|
||||
it("maps every state to an aria key", () => {
|
||||
const keys = Object.values(STATE_KEY);
|
||||
expect(keys).toHaveLength(8);
|
||||
for (const key of keys) expect(key).toMatch(/^(state|chat\.meta)\./);
|
||||
expect(STATE_KEY.running).toBe("state.running");
|
||||
expect(STATE_KEY.queued).toBe("state.queued");
|
||||
expect(STATE_KEY.cancelled).toBe("state.stopped");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user