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

+23 -104
View File
@@ -1,5 +1,4 @@
import type { CSSProperties, ReactNode } from "react";
import { useCallback } from "react";
import type { ReactNode } from "react";
import { useTranslation } from "react-i18next";
import { cn } from "@/lib/utils";
@@ -7,125 +6,45 @@ import { cn } from "@/lib/utils";
export interface ChatLayoutProps {
tree: ReactNode;
stream: ReactNode;
panel: ReactNode;
/** Narrow-viewport tree drawer (≥1000px the tree is a fixed column). */
treeOpen: boolean;
panelOpen: boolean;
treeCollapsed: boolean;
treeWidth: number;
panelWidth: number;
onWidths: (widths: { treeWidth?: number; panelWidth?: number }) => void;
onCloseDrawers: () => void;
className?: string;
}
const TREE_MIN = 220;
const TREE_MAX = 460;
const PANEL_MIN = 260;
const PANEL_MAX = 520;
function clamp(value: number, min: number, max: number): number {
return Math.min(max, Math.max(min, value));
}
/**
* Three-column chat grid with resizable dividers.
* ≥840: tree | stream | panel; 600–839: tree | stream (panel drawer);
* <600: single column with tree/panel drawers.
* Chat shell, v0.1.1 Chat IA v3: **two columns, no right panel**
* (the Todo/Tasks surfaces are the anchored `SessionTray`, not a third pane).
*
* - ≥1100: tree 280px + stream
* - 1000–1099: tree 240px + stream
* - <1000: single column, the tree becomes a left drawer (`.tree-open`)
*
* The tree is fixed and non-collapsible on desktop: there is no rail, no
* resize handle and no keyboard nudge — collapsing is a per-node concern.
* Structural CSS lives in `styles/pages/chat-tray.css`
* (`.chat-page--v3`), visual tokens in `styles/pages/chat.css`.
*/
export function ChatLayout({
tree,
stream,
panel,
treeOpen,
panelOpen,
treeCollapsed,
treeWidth,
panelWidth,
onWidths,
onCloseDrawers,
className,
}: ChatLayoutProps) {
export function ChatLayout({ tree, stream, treeOpen, onCloseDrawers, className }: ChatLayoutProps) {
const { t } = useTranslation();
const startResize = useCallback(
(which: "tree" | "panel", event: React.PointerEvent<HTMLDivElement>) => {
event.preventDefault();
const startX = event.clientX;
const startWidth = which === "tree" ? treeWidth : panelWidth;
const move = (moveEvent: PointerEvent) => {
const delta = which === "tree" ? moveEvent.clientX - startX : startX - moveEvent.clientX;
if (which === "tree") onWidths({ treeWidth: clamp(startWidth + delta, TREE_MIN, TREE_MAX) });
else onWidths({ panelWidth: clamp(startWidth + delta, PANEL_MIN, PANEL_MAX) });
};
const up = () => {
window.removeEventListener("pointermove", move);
window.removeEventListener("pointerup", up);
};
window.addEventListener("pointermove", move);
window.addEventListener("pointerup", up, { once: true });
},
[onWidths, panelWidth, treeWidth],
);
const nudge = useCallback(
(which: "tree" | "panel", delta: number) => {
if (which === "tree") onWidths({ treeWidth: clamp(treeWidth + delta, TREE_MIN, TREE_MAX) });
else onWidths({ panelWidth: clamp(panelWidth + delta, PANEL_MIN, PANEL_MAX) });
},
[onWidths, panelWidth, treeWidth],
);
const separator = (which: "tree" | "panel") => (
<div
role="separator"
aria-orientation="vertical"
aria-label={which === "tree" ? t("chat.resizeTree") : t("chat.resizePanel")}
tabIndex={0}
className={cn("resize-handle", which === "tree" ? "resize-handle--tree" : "resize-handle--panel")}
onPointerDown={(event) => startResize(which, event)}
onDoubleClick={() => {
if (which === "tree") onWidths({ treeWidth: 300 });
else onWidths({ panelWidth: 340 });
}}
onKeyDown={(event) => {
if (event.key === "ArrowLeft") {
event.preventDefault();
nudge(which, -16);
} else if (event.key === "ArrowRight") {
event.preventDefault();
nudge(which, 16);
}
}}
/>
);
const style = {
"--tree-w": `${treeWidth}px`,
"--panel-w": `${panelWidth}px`,
} as CSSProperties;
return (
<div
className={cn(
"chat-page",
treeOpen && "tree-open",
panelOpen && "panel-open",
treeCollapsed && "tree-collapsed",
className,
)}
style={style}
className={cn("chat-page", "chat-page--v3", treeOpen && "tree-open", className)}
data-testid="chat-layout"
data-tree-open={treeOpen ? "true" : "false"}
>
<aside className="tree-pane">
<aside className="tree-pane" data-testid="chat-tree-pane">
{tree}
</aside>
{separator("tree")}
<section className="stream-pane">{stream}</section>
{separator("panel")}
<aside className="panel-pane">{panel}</aside>
<section className="stream-pane" data-testid="chat-stream-pane">
{stream}
</section>
<button
type="button"
className="drawer-backdrop"
data-testid="drawer-backdrop"
aria-label={t("common.close")}
tabIndex={treeOpen || panelOpen ? 0 : -1}
tabIndex={treeOpen ? 0 : -1}
onClick={onCloseDrawers}
/>
</div>