# ShellBook web Install from the repository root with `npx -y pnpm@9.15.0 install` (Node 22). The viewer, demo and tests all use the real `@shellbook/core` parser and renderer. Scripts are rendered only by core; the server uses the same substitution path. ## Demo without a server ```powershell $env:VITE_MOCK = '1' npx -y pnpm@9.15.0 --filter @shellbook/web dev ``` Open the Vite URL (normally http://localhost:5173). Select staging, run the checks (one deliberately fails), generate the SSH key pair, download the dummy private key, then authorize the public key with confirmation. The private key is marked **sensitive ยท one download** and its link is disabled after download. The authorize request carries the earlier artifacts' run IDs in `artifactSources`. Production demonstrates the changed host key warning. No commands execute; artifacts contain dummy text. The fixture is parsed from `src/mock/ssh-key.md`. Markdown edits (including frontmatter) preview through core and save in memory. The terminal echoes input without opening a WebSocket or running a shell. Never deploy a build made with `VITE_MOCK=1`. ## Real server ```powershell Remove-Item Env:VITE_MOCK -ErrorAction SilentlyContinue npx -y pnpm@9.15.0 dev ``` Configure the server's workspace and hosts first (see `../server/README.md`). Vite proxies `/api`, including WebSocket upgrades, to 127.0.0.1:8080. Open **Terminal** and run `claude` using your own CLI login. The server needs tmux and the real Claude Code CLI installed; see `../server/src/terminal/README.md`. The panel lazily loads xterm and its fit addon on first opening. It attaches to `/api/terminal?session=main` using ws/wss according to the page protocol. Input and resize frames follow the core contract; server output is raw terminal text. Resize messages are debounced by 100 ms. The panel stays mounted when collapsed, retaining the connection and scrollback. A closed connection offers **Reconnect**; there is no automatic retry loop. Reconnecting attaches to the existing tmux session. Theme follows the OS dark/light preference, including live changes. Changes made by Claude reload the notebook through the existing file event stream; unsaved editor drafts are retained with a conflict notice. ## Run results and downloads Successful `capture` results enter notebook-scoped runtime values for subsequent scripts and prose. Success/failure `:::after` sections follow the latest run for that step in this browser session. Artifacts from successful runs supply provenance for `upload=` requests. Downloads use one fetch GET followed by a blob download so HTTP 410 can be shown as **no longer available**. There is no HEAD/preflight request that could accidentally consume a one-shot file. Sensitive links disable immediately while fetching and remain consumed in session state after success. If a sensitive request fails, the link remains disabled because the server may already have consumed it; an error explains this. Ordinary failed downloads can be retried. Download state is kept across notebook navigation/reloads within the mounted app, not page refreshes; the server enforces one-shot downloads and expiry across tabs and refreshes. Clipboard APIs require HTTPS or localhost. SSH copy uses a quoted heredoc with strict bash flags matching execution; secret env values are never copied. Steps using secret environment variables require the operator to provide them when pasting manually. Event WebSocket disconnects disable execution and require a page reload (terminal reconnection is independent). ## Verification From the root: ```powershell npx -y pnpm@9.15.0 typecheck npx -y pnpm@9.15.0 test npx -y pnpm@9.15.0 build ``` Web-only tests: `npx -y pnpm@9.15.0 --filter @shellbook/web test`. Vitest/Testing Library tests run in jsdom, with xterm modules mocked only in terminal tests. A fake WebSocket checks raw output, input/resize framing, collapse lifetime, and reconnect. App tests drive the SSH-key fixture through keygen, sensitive artifact downloads (including 410), after sections, capture substitution, and authorize artifact provenance. Real tmux/Claude login and browser terminal rendering still need an interactive server check. ## Notebook management and authoring The sidebar groups notebooks into folders and filters by title or path. **New notebook** asks for a name, optional folder and title, then opens a valid starter with a host parameter, a read-only check, and a confirmed run placeholder. **Rename / move** and **Duplicate** take a destination path relative to `notebooks/` (including `.md`). Folders are created automatically; empty folders disappear after moves or deletes. **Delete** requires explicit confirmation. Names use letters, numbers, spaces, dots, underscores and hyphens; traversal, absolute paths, symlinks and Windows device names are rejected. Management needs a real server; the demo reports that limitation. In edit mode, the toolbar inserts Check, Run, Artifacts, Upload or Capture examples at the cursor, targeting the local ShellBook server or a declared host parameter. Review example commands and file names before execution. **Parameter** adds a YAML mapping via a form (including choice options and secret rules), preserving unrelated YAML and comments. **After step** selects an existing step for conditional instructions. **Format help** explains attributes and parameter references. Save and live preview continue to use the core parser. Attribute editing remains available in Markdown. All mutations use authenticated, same-origin API calls. Save, move, duplicate and delete use optimistic versions (409 means stale content or an occupied destination). Files publish atomically, and the existing watcher refreshes other tabs' lists and clean open documents. External rename/delete retains the old open draft with a notice; select the new path from the refreshed list. Unsaved edits require confirmation before navigation or management. External filesystem writers must be trusted: as with other workspace operations, symlink checks cannot prevent a privileged local process from swapping path components between filesystem calls.