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.
pi2d — pi2 web console daemon
The always-on web side of pi2.nvim. It is a router + supervisor, not an agent runtime:
browser ──HTTP/WS──▶ pi2 daemon ──JSONL unix socket──▶ one nvim per workspace (pi2.nvim)
└── one pi --mode rpc per active session
Hard rules (see docs/protocol.md):
pi2 daemonnever spawnspi, never reads session JSONL, never owns session state.- A workspace maps to exactly one managed nvim instance.
- All mutations are commands relayed to the plugin; the plugin (inside nvim) is the single source of truth.
- The web client keeps a render cache only; a
snapshotfrom the plugin replaces it wholesale.
Install
Requirements: Node >= 22, Neovim >= 0.9, the pi CLI on PATH.
You do not normally install this by hand. The pi2.nvim plugin detects a missing daemon,
offers to install it into its own data directory (no sudo, no global PATH edits) and
starts it lazily. The result is one command inside Neovim:
:PiWeb
…which opens your browser already signed in, showing the current workspace.
Status. The npm package, the packaged web console and the lazy-start contract are ready (
npm i -g @yuez/pi2dworks today).:PiWeb,:PiWebInstalland the access-mode prompt land with the next pi2.nvim release; until then use:PiWebStartplus a manual install.
Package managers (optional, for CLI-first users)
npm i -g @yuez/pi2d # installs the `pi2` binary
pnpm add -g @yuez/pi2d
bun add -g @yuez/pi2d
Then:
pi2 daemon # foreground; the plugin/browser needs this running
pi2 install-service --write # or run it at login: systemd --user / launchd
pi2 status # daemon + instances + health
pi2 doctor # node/nvim/pi/curl/plugin/runtime/web-dist/protocol checks
pi2 is the only executable (@yuez/pi2d is the npm package name); pi2 daemon is a subcommand
of it, not a separate process. Runtime files, ports, auth, services and troubleshooting:
docs/deployment.md.
Neovim plugin
{
"zgs225/pi2.nvim",
opts = {}, -- add `web = { enabled = true }` to start the bridge at setup
cmd = { "PiWeb", "PiWebStart", "PiWebStatus" },
}
:PiWeb is the whole install path: it resolves the daemon binary, installs it if needed,
spawns it, waits for the socket, and hands the browser a one-time login token. Nothing else
to configure.
The plugin looks for the daemon in this order, and :PiWebStatus reports which one won:
| # | Source | Where |
|---|---|---|
| 1 | web.daemon / $PI2_DAEMON_BIN |
explicit path or command name |
| 2 | pi2 on PATH |
a global install |
| 3 | plugin data dir | <stdpath("data")>/pi2d/node_modules/.bin/pi2 |
| 4 | repo checkout | node_modules/.bin/pi2 (developing pi2d itself) |
| 5 | npx -y @yuez/pi2d@latest |
last resort when nothing is writable |
Remote access (phone, LAN, Tailscale)
The daemon binds 127.0.0.1 by default and never exposes itself to the network on its own.
:PiWeb asks once which access mode you want and remembers the answer; web.access = "lan"
(or "tailscale", or "local") skips the prompt.
| Mode | Bind | Browser access | Login |
|---|---|---|---|
local |
127.0.0.1 |
same machine | automatic (one-time token handed to the browser) |
lan |
0.0.0.0 |
http://<lan-ip>:7676 |
pairing code / QR, never automatic |
tailscale |
127.0.0.1 + tailscale serve |
https://<host>.<tailnet>.ts.net |
pairing code / QR, never automatic |
Pair a device from the CLI:
pi2 pairing # loopback URL + code + QR payload
pi2 pairing --public-url https://myhost.tail1234.ts.net
Or from the web console's device page. Tokens are per-device, revocable, and stored
hashed; pi2 doctor reports the active mode and warns when a non-loopback bind has no TLS.
Developing pi2d
pnpm install
pnpm --dir web install
pnpm dev # daemon on 127.0.0.1:7676 (tsx watch)
pnpm --dir web dev # vite dev server on :5173, proxying /api and /ws to the daemon
pnpm build → dist/, pnpm build:web → web/dist/. The published tarball ships both, so
pi2 daemon serves the web console from its own package with no extra step.
Releasing: bump version in package.json, tag v<version>, push the tag. That is the whole
flow — .github/workflows/release.yml verifies the tag matches package.json, runs the
checks, and publishes to npm. Authentication is OIDC trusted publishing: the publish step
holds no npm token, and id-token: write lets the npm CLI exchange a short-lived GitHub OIDC
token for publish rights (provenance is attached automatically). There is no NPM_TOKEN secret
to configure or rotate, and a guard step fails the run if one ever exists. The one-time bootstrap
(first publish by hand, then the npmjs.com trusted-publisher setup), the local dry run and
troubleshooting: docs/releasing.md.
Layout
| Path | Purpose |
|---|---|
src/protocol/ |
wire types, event/command vocabulary, error codes, canonical reducer |
src/daemon/ |
HTTP/WS/SSE, auth, static assets, routing, event relay |
src/instances/ |
discovery, lazy spawn, single-instance enforcement, crash handling |
src/workspaces/ |
workspace registry, disk discovery, aliases/trust |
src/cli/ |
pi2 — the daemon subcommand plus attach/status/doctor |
web/ |
the React web console (built into web/dist, served by the daemon) |
fixtures/ |
golden event streams + expected session state (shared with pi2.nvim tests) |
docs/protocol.md |
the wire contract (browser ↔ daemon ↔ plugin) |
Testing
Unit contracts are hermetic (pnpm test → vitest run; pnpm lint typechecks). The web-console
gate is end-to-end and real: a daemon, one headless nvim per workspace, a real pi --mode rpc
behind it and, for the browser layer, Playwright against the built bundle.
pnpm test # unit: daemon + web (vitest)
bash scripts/e2e/run-api.sh # A0–A12: API/WS against a real backend
bash scripts/e2e/run-ui.sh # B1–B14, C1–C4: Playwright against web/dist
bash scripts/e2e/run-all.sh # both, API first
Every suite runs in its own mktemp root with isolated runtime/data/state/agent dirs and
pi sessions redirected away from ~/.pi/agent; E2E_SKIP_BUILD=1 reuses an existing build
and E2E_KEEP=1 keeps the artifacts (report, logs, screenshots). Scenario ids, isolation
details, skip conditions and report paths: docs/e2e.md.