From 88e73c7737344d196c0f1ca2788bb0a389a966cc Mon Sep 17 00:00:00 2001 From: yuez Date: Mon, 26 Oct 2026 20:28:47 +0800 Subject: [PATCH] feat(web): port the pi2-web-ui-design v0.1.1 UI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- docs/ui-parity.md | 253 +++++ scripts/e2e/ui-e2e.mjs | 516 +++++++--- scripts/ui-fixtures.mjs | 913 ++++++++++++++++++ scripts/ui-mock-server.mjs | 736 ++++++++++++++ scripts/ui-shots.mjs | 691 +++++++++++++ web/src/components/app-shell.tsx | 108 +-- web/src/components/icons.tsx | 3 + web/src/components/shared/command-palette.tsx | 291 ++++++ web/src/components/shared/nav-list.tsx | 106 ++ web/src/components/shared/page-pill.tsx | 51 + web/src/components/shared/page-sheet.tsx | 99 ++ web/src/components/shared/prefs-menu.tsx | 187 ++++ web/src/components/ui/dialog.tsx | 93 +- web/src/components/ui/sidebar-item.tsx | 30 +- web/src/features/chat/blocks.tsx | 142 ++- web/src/features/chat/composer.tsx | 360 +++---- web/src/features/chat/head-chips.tsx | 88 ++ web/src/features/chat/layout.tsx | 127 +-- web/src/features/chat/message-stream.tsx | 187 ++-- web/src/features/chat/queued-messages.tsx | 110 +++ web/src/features/chat/session-row-menu.tsx | 215 +++++ web/src/features/chat/session-tray.tsx | 315 ++++++ web/src/features/chat/session-tree-model.ts | 182 +++- web/src/features/chat/session-tree.tsx | 710 +++++++------- web/src/features/chat/side-panel.tsx | 15 +- web/src/features/chat/store.ts | 113 ++- web/src/features/chat/subagent-view.tsx | 412 ++++++++ web/src/features/chat/telemetry.tsx | 269 ++++++ web/src/features/chat/tools/adapt.ts | 196 ++++ web/src/features/chat/tools/facts.ts | 75 ++ web/src/features/chat/tools/families/file.tsx | 343 +++++++ .../features/chat/tools/families/generic.tsx | 106 ++ .../features/chat/tools/families/search.tsx | 516 ++++++++++ .../features/chat/tools/families/shell.tsx | 274 ++++++ web/src/features/chat/tools/format.ts | 123 +++ web/src/features/chat/tools/index.ts | 9 + web/src/features/chat/tools/kind.ts | 97 ++ web/src/features/chat/tools/registry.ts | 36 + web/src/features/chat/tools/state.ts | 63 ++ web/src/features/chat/tools/tool-body.tsx | 129 +++ web/src/features/chat/tools/tool-row.tsx | 203 ++++ web/src/features/chat/tools/types.ts | 258 +++++ web/src/features/chat/tools/use-elapsed.ts | 29 + web/src/features/chat/workspace-switch.tsx | 165 ++++ web/src/features/connect/hero.tsx | 45 + web/src/features/connect/manual-form.tsx | 61 +- web/src/features/status/card-parts.tsx | 4 +- web/src/features/status/connection-card.tsx | 196 ++-- web/src/features/status/devices-card.tsx | 29 +- web/src/features/status/health-card.tsx | 37 +- web/src/features/status/metrics-block.tsx | 152 +++ web/src/features/status/models-card.tsx | 13 +- web/src/features/status/resources-card.tsx | 107 -- web/src/features/status/tasks-card.tsx | 20 +- .../features/workspaces/activity-column.tsx | 76 ++ .../workspaces/new-workspace-dialog.tsx | 4 + web/src/features/workspaces/status-line.tsx | 67 ++ .../features/workspaces/workspace-card.tsx | 120 +++ web/src/features/workspaces/workspace-row.tsx | 139 --- web/src/locales/en.json | 321 +++++- web/src/locales/zh.json | 319 +++++- web/src/pages/chat.tsx | 344 +++++-- web/src/pages/connect.tsx | 396 ++++++-- web/src/pages/status.tsx | 161 +-- web/src/pages/workspaces.tsx | 212 ++-- web/src/router.tsx | 8 +- web/src/styles/app.css | 533 +++++++--- web/src/styles/pages/chat-composer.css | 125 +++ web/src/styles/pages/chat-msg.css | 127 +++ web/src/styles/pages/chat-stream.css | 178 ++++ web/src/styles/pages/chat-telemetry.css | 279 ++++++ web/src/styles/pages/chat-tray.css | 425 ++++++++ web/src/styles/pages/chat.css | 711 +++++++++----- web/src/styles/pages/connect.css | 386 ++++++-- web/src/styles/pages/status.css | 558 ++++++++--- web/src/styles/pages/workspaces.css | 346 +++++-- web/src/styles/tokens.css | 258 +++-- web/src/styles/tool-core.css | 351 +++++++ web/src/styles/tool-file.css | 318 ++++++ web/src/styles/tool-generic.css | 50 + web/src/styles/tool-search.css | 263 +++++ web/src/styles/tool-shell.css | 132 +++ web/tests/chat.blocks.test.tsx | 160 +++ web/tests/chat.composer.test.tsx | 151 ++- web/tests/chat.stream.test.tsx | 255 ++++- web/tests/chat.subview.test.tsx | 218 +++++ web/tests/chat.telemetry.test.tsx | 216 +++++ web/tests/chat.tree.test.tsx | 473 +++++++-- web/tests/connect-page.test.tsx | 193 +++- web/tests/session-tree-model.test.ts | 137 ++- web/tests/status-page.test.tsx | 118 ++- web/tests/tokens.test.ts | 42 +- web/tests/tools.adapt.test.ts | 139 +++ web/tests/tools.kind.test.ts | 87 ++ web/tests/tools.row.test.tsx | 268 +++++ web/tests/tools.state.test.ts | 89 ++ web/tests/workspaces-page.test.tsx | 144 ++- web/tests/workspaces-visibility.test.tsx | 42 +- 98 files changed, 17676 insertions(+), 2871 deletions(-) create mode 100644 docs/ui-parity.md create mode 100644 scripts/ui-fixtures.mjs create mode 100644 scripts/ui-mock-server.mjs create mode 100644 scripts/ui-shots.mjs create mode 100644 web/src/components/shared/command-palette.tsx create mode 100644 web/src/components/shared/nav-list.tsx create mode 100644 web/src/components/shared/page-pill.tsx create mode 100644 web/src/components/shared/page-sheet.tsx create mode 100644 web/src/components/shared/prefs-menu.tsx create mode 100644 web/src/features/chat/head-chips.tsx create mode 100644 web/src/features/chat/queued-messages.tsx create mode 100644 web/src/features/chat/session-row-menu.tsx create mode 100644 web/src/features/chat/session-tray.tsx create mode 100644 web/src/features/chat/subagent-view.tsx create mode 100644 web/src/features/chat/telemetry.tsx create mode 100644 web/src/features/chat/tools/adapt.ts create mode 100644 web/src/features/chat/tools/facts.ts create mode 100644 web/src/features/chat/tools/families/file.tsx create mode 100644 web/src/features/chat/tools/families/generic.tsx create mode 100644 web/src/features/chat/tools/families/search.tsx create mode 100644 web/src/features/chat/tools/families/shell.tsx create mode 100644 web/src/features/chat/tools/format.ts create mode 100644 web/src/features/chat/tools/index.ts create mode 100644 web/src/features/chat/tools/kind.ts create mode 100644 web/src/features/chat/tools/registry.ts create mode 100644 web/src/features/chat/tools/state.ts create mode 100644 web/src/features/chat/tools/tool-body.tsx create mode 100644 web/src/features/chat/tools/tool-row.tsx create mode 100644 web/src/features/chat/tools/types.ts create mode 100644 web/src/features/chat/tools/use-elapsed.ts create mode 100644 web/src/features/chat/workspace-switch.tsx create mode 100644 web/src/features/connect/hero.tsx create mode 100644 web/src/features/status/metrics-block.tsx delete mode 100644 web/src/features/status/resources-card.tsx create mode 100644 web/src/features/workspaces/activity-column.tsx create mode 100644 web/src/features/workspaces/status-line.tsx create mode 100644 web/src/features/workspaces/workspace-card.tsx delete mode 100644 web/src/features/workspaces/workspace-row.tsx create mode 100644 web/src/styles/pages/chat-composer.css create mode 100644 web/src/styles/pages/chat-msg.css create mode 100644 web/src/styles/pages/chat-stream.css create mode 100644 web/src/styles/pages/chat-telemetry.css create mode 100644 web/src/styles/pages/chat-tray.css create mode 100644 web/src/styles/tool-core.css create mode 100644 web/src/styles/tool-file.css create mode 100644 web/src/styles/tool-generic.css create mode 100644 web/src/styles/tool-search.css create mode 100644 web/src/styles/tool-shell.css create mode 100644 web/tests/chat.blocks.test.tsx create mode 100644 web/tests/chat.subview.test.tsx create mode 100644 web/tests/chat.telemetry.test.tsx create mode 100644 web/tests/tools.adapt.test.ts create mode 100644 web/tests/tools.kind.test.ts create mode 100644 web/tests/tools.row.test.tsx create mode 100644 web/tests/tools.state.test.ts diff --git a/docs/ui-parity.md b/docs/ui-parity.md new file mode 100644 index 0000000..df52c04 --- /dev/null +++ b/docs/ui-parity.md @@ -0,0 +1,253 @@ +# Web UI visual parity harness + +The visual gate for the pi2-web-ui-design v0.1.1 port (PLAN §3.3). Two scripts, +no new dependencies, no daemon and no `pi`: + +``` +scripts/ui-mock-server.mjs zero-dependency mock of the daemon's browser surface +scripts/ui-shots.mjs Playwright screenshot + assertion matrix +scripts/ui-fixtures.mjs the fixture data both of them share +``` + +The mock answers the exact REST + WS contract the console speaks (`web/src/lib/api.ts`, +`web/src/lib/ws.ts`); the shooter drives the **built** console the way a user would, +then asserts the invariants a screenshot cannot show. Nothing here patches product +code: a red assertion is a finding, not something this harness may fix. + +## 1. Prerequisites + +| Requirement | Why | Check | +|---|---|---| +| `web/dist/index.html` | the shooter serves the production bundle | `pnpm --dir web build` | +| Node ≥ 22 | `node:http`, `crypto`, `fetch` | `node -v` | +| Playwright **resolvable** (not a dependency) | browser driver, resolved like `scripts/e2e/ui-e2e.mjs` | `node -e "require('playwright')"` or a mise npm-global install | +| Chromium | headless browser | `/usr/bin/google-chrome-stable`, else Playwright's bundled build | + +Playwright is resolved from `PI2_SHOTS_PLAYWRIGHT_MODULE`, `PI2_E2E_PLAYWRIGHT_MODULE`, +`require("playwright")`, then the mise `npm-playwright` install roots. Chrome comes from +`PI2_SHOTS_CHROME` / `PI2_E2E_CHROME` / the distro paths. Neither is added to +`package.json` — the harness must not change what the daemon ships. + +## 2. Usage + +```bash +# 1. build the UI you want to inspect +pnpm --dir web build + +# 2. full matrix: 4 pages × 3 viewports × light/dark = 24 PNGs + report.json +node scripts/ui-shots.mjs --serve-static --round r1 --out /tmp/pi2d-port/shots/r1 + +# 3. quick matrix: 1440×900 × light/dark = 8 PNGs (fast loop while iterating) +node scripts/ui-shots.mjs --serve-static --matrix=quick --round scratch + +# 4. shoot an already running daemon instead of the mock (real data, real auth) +node scripts/ui-shots.mjs --base http://127.0.0.1:7676 --round live +``` + +| Flag | Default | Meaning | +|---|---|---| +| `--serve-static` | off | spawn the mock daemon and serve `web/dist` from it | +| `--base ` | — | shoot a running daemon; disables spawning and the unpaired check | +| `--out ` | `/tmp/pi2d-port/shots/` | where PNGs and `report.json` go | +| `--round