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,106 @@
|
||||
import { Link } from "@tanstack/react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Icon, type IconName } from "@/components/icons";
|
||||
import { SidebarItem } from "@/components/ui/sidebar-item";
|
||||
import { serverDotClass } from "@/components/ui/status-dot";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useConnectionStore } from "@/stores/connection";
|
||||
|
||||
/** `NAV` is the single source of truth for the icon strip, the page sheet and the palette. */
|
||||
export type PageName = "workspaces" | "chat" | "status" | "connect";
|
||||
export type NavKey = "workspaces" | "chat" | "status";
|
||||
|
||||
export interface NavEntry {
|
||||
key: NavKey;
|
||||
to: "/workspaces" | "/chat" | "/status";
|
||||
labelKey: string;
|
||||
icon: IconName;
|
||||
match: (pathname: string) => boolean;
|
||||
}
|
||||
|
||||
export const NAV: NavEntry[] = [
|
||||
{
|
||||
key: "workspaces",
|
||||
to: "/workspaces",
|
||||
labelKey: "nav.workspaces",
|
||||
icon: "folder",
|
||||
match: (p) => p === "/workspaces" || p.startsWith("/workspace/"),
|
||||
},
|
||||
{ key: "chat", to: "/chat", labelKey: "nav.chat", icon: "chat", match: (p) => p.startsWith("/chat") },
|
||||
{ key: "status", to: "/status", labelKey: "nav.status", icon: "status", match: (p) => p.startsWith("/status") },
|
||||
];
|
||||
|
||||
/** Resolve the current top-level page; detail routes fall back to their section. */
|
||||
export function pageName(pathname: string): PageName {
|
||||
if (pathname.startsWith("/connect")) return "connect";
|
||||
if (pathname.startsWith("/status")) return "status";
|
||||
if (pathname.startsWith("/chat")) return "chat";
|
||||
return "workspaces";
|
||||
}
|
||||
|
||||
export function navEntryFor(page: PageName): NavEntry {
|
||||
return NAV.find((entry) => entry.key === page) ?? NAV[0]!;
|
||||
}
|
||||
|
||||
export interface NavListProps {
|
||||
/** Sidebar (≥840) and rail (600–839) render the same component; CSS decides visibility. */
|
||||
variant: "sidebar" | "rail";
|
||||
page: PageName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 56px compact icon strip: three 44×44 nav rows (icon only, tooltip carries the
|
||||
* label) plus the shared footer (server status → /status, pairing → /connect).
|
||||
* Both variants render the footer — the design contract explicitly requires it.
|
||||
*/
|
||||
export function NavList({ variant, page }: NavListProps) {
|
||||
const { t } = useTranslation();
|
||||
const server = useConnectionStore((state) => state.server);
|
||||
|
||||
const status = server?.status ?? "offline";
|
||||
const name = server?.name ?? "pi2.nvim";
|
||||
const version = server?.pluginVersion ?? server?.version ?? "";
|
||||
const serverTip = t("shell.railServerTip", { name, status: t(`state.${status}`), version });
|
||||
const connectTip = t("shell.connection");
|
||||
|
||||
return (
|
||||
<aside className={variant} aria-label={t("shell.navLabel")}>
|
||||
{NAV.map((entry) => (
|
||||
<SidebarItem
|
||||
key={entry.to}
|
||||
active={entry.key === page}
|
||||
compact
|
||||
tip={t(entry.labelKey)}
|
||||
asChild
|
||||
>
|
||||
<Link to={entry.to}>
|
||||
<Icon name={entry.icon} />
|
||||
</Link>
|
||||
</SidebarItem>
|
||||
))}
|
||||
<div className="sidebar__foot">
|
||||
<Link
|
||||
to="/status"
|
||||
className="rail-foot__link has-tip"
|
||||
data-tip={serverTip}
|
||||
aria-label={serverTip}
|
||||
>
|
||||
<Icon name="server" />
|
||||
<span
|
||||
className={cn("rail-foot__dot dot dot--lg", serverDotClass(status))}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</Link>
|
||||
<Link
|
||||
to="/connect"
|
||||
className="rail-foot__link has-tip"
|
||||
data-tip={connectTip}
|
||||
aria-label={connectTip}
|
||||
>
|
||||
<Icon name="plug" />
|
||||
</Link>
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user