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

+99
View File
@@ -0,0 +1,99 @@
import { Link } from "@tanstack/react-router";
import type { RefObject } from "react";
import { useTranslation } from "react-i18next";
import { Icon } from "@/components/icons";
import { NAV, type NavKey, type PageName } from "@/components/shared/nav-list";
import { Modal } from "@/components/ui/dialog";
import { cn } from "@/lib/utils";
import { useConnectionStore } from "@/stores/connection";
import { useSessionsStore } from "@/stores/sessions";
import { useWorkspacesStore } from "@/stores/workspaces";
export interface PageSheetProps {
open: boolean;
onOpenChange: (open: boolean) => void;
page: PageName;
/** Closes the sheet, then opens the command palette (the <600 search entry). */
onSearch: () => void;
/** Element focused when the sheet closes — the page pill. */
returnFocusTo?: RefObject<HTMLElement | null>;
}
/**
* Page sheet (CHG-20): one dialog with two layouts — 26rem centered ≥600,
* bottom sheet <600 (top radius 20px, starts at translateY(24px), padding-bottom
* 20px + safe area). Five rows: three pages, a separator, search, connection.
* The current row carries `aria-current="page"` + a check; the other page rows
* show a live fact on the right.
*/
export function PageSheet({ open, onOpenChange, page, onSearch, returnFocusTo }: PageSheetProps) {
const { t } = useTranslation();
const workspaces = useWorkspacesStore((state) => state.items);
const byWorkspace = useSessionsStore((state) => state.byWorkspace);
const server = useConnectionStore((state) => state.server);
const sessionCount = Object.values(byWorkspace).reduce((total, list) => total + list.length, 0);
const status = server?.status ?? "unknown";
const version = server?.pluginVersion ?? server?.version ?? "";
function fact(key: NavKey): string {
if (key === "workspaces") return t("shell.pageFactWorkspaces", { n: workspaces.length });
if (key === "chat") return t("shell.pageFactChat", { n: sessionCount });
return t("shell.pageFactStatus", { state: t(`state.${status}`), version });
}
return (
<Modal
open={open}
onOpenChange={onOpenChange}
title={t("shell.pages")}
returnFocusTo={returnFocusTo}
>
<div className="sheet-list">
{NAV.map((entry) => {
const current = entry.key === page;
return (
<Link
key={entry.to}
to={entry.to}
className={cn("sheet-row", current && "is-current")}
aria-current={current ? "page" : undefined}
onClick={() => onOpenChange(false)}
>
<Icon name={entry.icon} />
<span className="sheet-row__label">{t(entry.labelKey)}</span>
{current ? (
<span className="sheet-row__check">
<Icon name="check" />
</span>
) : (
<span className="sheet-row__fact">{fact(entry.key)}</span>
)}
</Link>
);
})}
<div className="sheet-sep" />
<button
type="button"
className="sheet-row sheet-row--quiet"
onClick={() => {
onOpenChange(false);
onSearch();
}}
>
<Icon name="search" />
<span className="sheet-row__label">{t("shell.searchAction")}</span>
</button>
<Link
to="/connect"
className="sheet-row sheet-row--quiet"
onClick={() => onOpenChange(false)}
>
<Icon name="plug" />
<span className="sheet-row__label">{t("shell.connection")}</span>
</Link>
</div>
</Modal>
);
}