@firstpick/pi-package-webui 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +22 -5
  2. package/bin/pi-webui.mjs +434 -100
  3. package/lib/npm-command.mjs +81 -0
  4. package/lib/queue-mutation.mjs +6 -0
  5. package/lib/workspace-files-live-watcher.mjs +138 -0
  6. package/package.json +8 -3
  7. package/public/app.js +2816 -314
  8. package/public/index.html +112 -27
  9. package/public/mobile-shell-state.mjs +166 -0
  10. package/public/service-worker.js +60 -13
  11. package/public/styles.css +1049 -371
  12. package/public/subagent-gate-visibility.mjs +16 -0
  13. package/public/subagent-launch-slot-state.mjs +16 -0
  14. package/public/transcript-renderer.mjs +433 -0
  15. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  16. package/tests/browser/interaction-continuity.spec.mjs +739 -0
  17. package/tests/browser/mobile-foundation.spec.mjs +352 -0
  18. package/tests/browser/optimistic-prompt.spec.mjs +130 -0
  19. package/tests/chat-scroll-intent-static.test.mjs +6 -1
  20. package/tests/codex-fast-mode-static.test.mjs +8 -5
  21. package/tests/compact-sections-static.test.mjs +20 -2
  22. package/tests/compaction-mutation-contract.test.mjs +18 -4
  23. package/tests/compaction-static.test.mjs +1 -0
  24. package/tests/completion-signal-contract.test.mjs +13 -2
  25. package/tests/fast-mode-client-static.test.mjs +7 -4
  26. package/tests/fixtures/fake-pi.mjs +181 -2
  27. package/tests/git-panel-gitignore-static.test.mjs +104 -0
  28. package/tests/http-endpoints-harness.test.mjs +228 -2
  29. package/tests/interaction-state-stability-static.test.mjs +254 -0
  30. package/tests/mobile-continuity-tablet-static.test.mjs +55 -0
  31. package/tests/mobile-foundation-static.test.mjs +69 -0
  32. package/tests/mobile-phone-experience-static.test.mjs +65 -0
  33. package/tests/mobile-shell-state.test.mjs +69 -0
  34. package/tests/mobile-static.test.mjs +244 -38
  35. package/tests/mobile-transcript-cache-characterization.test.mjs +34 -0
  36. package/tests/npm-command.test.mjs +64 -1
  37. package/tests/open-issue-wizard-static.test.mjs +2 -1
  38. package/tests/queue-edit-reorder-static.test.mjs +9 -1
  39. package/tests/queue-mutation-contract.test.mjs +22 -0
  40. package/tests/service-worker-lifecycle.test.mjs +120 -0
  41. package/tests/sse-backpressure-harness.test.mjs +98 -0
  42. package/tests/streaming-ui-coupling.test.mjs +7 -1
  43. package/tests/subagent-gate-visibility.test.mjs +18 -2
  44. package/tests/subagent-launch-slot-state.test.mjs +32 -0
  45. package/tests/subagent-launch-slots-static.test.mjs +8 -2
  46. package/tests/subagents-helper.test.mjs +90 -0
  47. package/tests/terminal-tab-workspace-static.test.mjs +1 -1
  48. package/tests/update-commands.test.mjs +4 -0
  49. package/tests/workspace-files-live-updates-static.test.mjs +76 -0
  50. package/tests/workspace-files-live-watcher.test.mjs +95 -0
  51. package/webui-rpc-helper.mjs +175 -3
package/README.md CHANGED
@@ -130,7 +130,7 @@ Environment variables:
130
130
  - `PI_WEBUI_SETTINGS_FILE=/path/to/settings.json` overrides persisted Web UI settings such as Remote PIN auth, guided Git preferences, and global Tools/Skills defaults.
131
131
  - `PI_WEBUI_OPTIONAL_FEATURE_INSTALL_ROOT=/path/to/package-root` overrides the npm prefix used for optional companion installs.
132
132
  - `PI_WEBUI_FAST_PICKS_FILE=/path/to/paths.json` overrides saved cwd fast-pick storage.
133
- - `PI_WEBUI_NPM_BIN=/path/to/npm` overrides the npm executable used by optional feature install/update actions. By default, Web UI resolves `npm-cli.js` beside the active Node executable (and on `PATH`) and runs it through Node, avoiding Windows `npm.cmd` spawn failures.
133
+ - `PI_WEBUI_NPM_BIN=/path/to/npm` overrides the npm executable used by optional feature install/update actions. By default, Web UI resolves the selected `pi` command, prefers `npm-cli.js` from that Pi installation, and runs it through Node. This prevents stale earlier `PATH` shims such as `%APPDATA%\npm\npm.cmd` from redirecting updates away from the active Pi installation.
134
134
  - `PI_BANG_AUTOCOMPLETE_INCLUDE_HISTORY=1` lets optional bang-command autocomplete include local fish/bash/zsh history executables.
135
135
  - `PI_BANG_AUTOCOMPLETE_RUNTIME_STORE_PATH=/path/to/runtime.json` overrides the runtime store shared with `@firstpick/pi-extension-bang-command-autocomplete`.
136
136
 
@@ -181,7 +181,7 @@ Optional Natural Conversation server-side voice fallback variables:
181
181
  - Pathless `pi-webui` startup: the server opens first, then the browser prompts for the first terminal CWD.
182
182
  - Multi-tab Pi sessions with isolated processes, working directories, prompt drafts, activity state, per-tab settings, and a workspace dashboard for common actions.
183
183
  - The Subagents side panel includes a separate **Agent models** editor above the live monitor. It stores WebUI-owned launch slots for the eight builtin roles (`context-builder`, `delegate`, `oracle`, `planner`, `researcher`, `reviewer`, `scout`, and `worker`): every role keeps a non-removable base slot, while added same-role slots copy a model/thinking draft but retain independent stable IDs. Choose **User default** or **This project**; projects inherit user defaults until saved, and **Use user defaults** removes a project override. Select `Default / inherit` to inherit both values, or an active-tab provider-qualified model and its supported thinking levels. Saves are revision-checked and localhost-only; saved assignments guide only future delegation after **Reload active tab**, never running children. The configuration form has independent load/draft/error state, so its controls are not reset by live subagent monitoring.
184
- - Tracked subagent output can open in the existing non-blocking overlay/widget or in a dedicated **Subagent** terminal tab, selected from the Subagents side-panel section and saved in the browser. Side-panel rows and both output views show the effective model and reasoning effort (or an explicit `unknown` for legacy metadata). Subagent tabs are view-only, reuse the bounded live transcript at the normal full terminal width, show the pulsing **Agent is running:** card with current child activity, and close without stopping or interrupting the child run; use the parent terminal for interaction. The package also registers a generic `subagent_gate` tool that launches task slots through pi-subagents RPC v1, enforces a required success quorum, and performs bounded reason-aware retries only when declared safe; the side panel retains gate quorum, attempt, provider, and failure-class history after children finish.
184
+ - Tracked subagent output can open in the existing non-blocking overlay/widget or in a dedicated **Subagent** terminal tab, selected from the Subagents side-panel section and saved in the browser. The side-panel monitor keeps each status dot, agent type, provider/model, thinking effort, and run action on one compact line; run IDs, source/mode, elapsed state, and current-tool details live in the selected output view instead of being duplicated inline. Subagent tabs are view-only, reuse the bounded live transcript at the normal full terminal width, show the pulsing **Agent is running:** card with current child activity, and close without stopping or interrupting the child run; use the parent terminal for interaction. Dedicated **Subagent** terminal tabs show exactly six telemetry cards: PI, measured token speed, context, model, effort, and input/output tokens from a bounded recent session scan; unavailable or legacy evidence remains `—` or `unknown` rather than an estimate. The package also registers a generic `subagent_gate` tool that launches task slots through pi-subagents RPC v1, enforces a required success quorum, and performs bounded reason-aware retries only when declared safe; the side panel retains gate quorum, attempt, provider, and failure-class history after children finish.
185
185
  - Unified command palette (`Ctrl/Cmd+K`) for commands, tabs, models, sessions, settings, app controls, and frequent Web UI actions.
186
186
  - Automatic tab naming from the first prompt, with `--name <name>` still available for an explicit initial tab name.
187
187
  - Streaming chat transcript with Markdown, copy buttons for fenced code blocks, rendered Mermaid diagrams from fenced `mermaid`/`mmd` code blocks, thinking output, tool/bash cards, queue and compaction events, edit-and-retry from user prompts, transcript search, copy buttons, and guarded abort controls that require holding Esc or the Abort button for 3 seconds.
@@ -200,7 +200,7 @@ Optional Natural Conversation server-side voice fallback variables:
200
200
  - Detected app runner dropdown for the active tab cwd, including Cargo, Bun, npm/npx/pnpm, Python/uv, Go/Golang, Zig, C/C++, Docker Compose, root/dev/scripts shell scripts, and other common project runners with live output pinned at the top of the terminal. Running app runners expose line-oriented stdin in the widget for interactive scripts. Projects can add browseable custom runners in `.pi-webui-runners.json` with a command (default `./`) plus a relative path to the file to run. The same dialog also configures project discovery paths: project-relative directories that are scanned one level deep (no subdirectories) for `.sh`, `.bash`, `.zsh`, `.fish`, and `.py` files plus extensionless files with a bash/sh, zsh, fish, or Python shebang. Python candidates use `uv run` and/or the available `python3`/`python` interpreter. Discovered scripts extend the built-in root, `dev/`, `scripts/`, and `dev/scripts/` detection and run from the resolved project root.
201
201
  - Guided Git workflow for existing repos and new repos with persistent model/reasoning preferences, review-first staging, an optional manual staged repository-review gate from `aur-review`, generated or typed commit messages, explicit push/PR confirmation, and optional PR worktrees. When the review extension is loaded/enabled, both `git add .` and accepting the current staged set send `/aur-review start --scope staged --origin guided-git` to the same tab. Only its matching approval advances to message generation. The browser and server recheck the approved domain-separated staged-content hash before message generation, commit, and PR-worktree transfer; drift, missing hashes, or hash-check errors return to Stage and require a new review. A decline returns to staging and rejects an unchanged declined staged hash until corrected content is restaged. Guided Git never stages, commits, or pushes remediation automatically. The extension remains the decision authority; direct API callers are not granted an approval by this browser workflow.
202
202
  - Browser support for Pi extension UI prompts, widgets, status updates, `/btw` side-question output widgets with optional context transfer/live steering, browser notifications when a tab needs an extension UI response, and an optional side-panel toggle for agent-done notifications.
203
- - Localhost-only Pi/Web UI update checks with a top-right update notification and confirmed restart actions: **Update Pi & restart** runs `pi update --self` for Pi-only updates, while **Update Pi + Packages & Restart** first checks the selected Pi executable's `pi update --help`. It uses `pi update --all` when advertised, otherwise falls back to `pi update --self` followed by `pi update --extensions`, then updates detected Web UI/Optional Feature package roots for configured, local agent, project, global npm, and global Bun installs.
203
+ - Localhost-only Pi/Web UI update checks with a top-right update notification and confirmed restart actions: **Update Pi & restart** runs `pi update --self` for Pi-only updates, while **Update Pi + Packages & Restart** first checks the selected Pi executable's `pi update --help`. It resolves that Pi installation and puts its bin directory first on the update task's `PATH`, so Pi and detected npm package roots use the npm bundled with the selected Pi instead of an unrelated stale shim. It uses `pi update --all` when advertised, otherwise falls back to `pi update --self` followed by `pi update --extensions`, then updates detected Web UI/Optional Feature package roots for configured, local agent, project, global npm, and global Bun installs.
204
204
  - Feedback reactions (`👍`, `👎`, `?`) on final assistant output plus tool/bash action cards, which can ask Pi to create or update a LEARNING.
205
205
  - Mobile-friendly layout, PWA install support where the browser allows it, backend-offline recovery, and a dedicated server-restart overlay while confirmed restart/update actions run.
206
206
 
@@ -406,6 +406,17 @@ For local development, run the checkout helper directly, for example:
406
406
 
407
407
  The `--dev` helper checks this checkout's local npm dependencies before launch, applies available local updates, and force-refreshes `@earendil-works/pi-coding-agent` to the latest npm version so stale bundled Pi runtime packages do not break extension loading. Set `PI_WEBUI_DEV_SKIP_UPDATE=1` to skip this preflight for offline or intentionally pinned local testing.
408
408
 
409
+ ### Browser checks
410
+
411
+ The package-owned Playwright/axe harness starts the real `pi-webui` server with the hermetic fake-Pi fixture. Provision the pinned engines once, then run the suite:
412
+
413
+ ```bash
414
+ npx playwright install chromium
415
+ npm run test:browser
416
+ ```
417
+
418
+ On hosts with WebKit's system libraries installed, provision it and include its project explicitly with `npx playwright install webkit && PI_WEBUI_TEST_WEBKIT=1 npm run test:browser`. The browser suite is intentionally separate from `npm test`; it covers browser-only geometry, flag/rollback, and scoped axe checks without making ordinary Node/static tests download browser engines.
419
+
409
420
  Run `../dev/scripts/sync-pi-package-symlinks.sh` first when developing companion packages from this workspace. The Web UI manifest loads companions through `node_modules/` paths, and the sync script links those paths to the top-level dev packages so only one copy is loaded.
410
421
 
411
422
  ## Optional companion packages
@@ -503,8 +514,14 @@ Keep this browser configuration disabled until the gateway's exact-origin CORS p
503
514
  ## Mobile and PWA notes
504
515
 
505
516
  - The mobile composer starts as a compact `Ask Pi…` input and grows as you type.
506
- - Installable PWA support, blocked-tab browser notifications, and optional agent-done notifications require browser service-worker/notification support and usually require `localhost` or HTTPS.
507
- - Plain `http://<LAN-IP>` can show the app, but some browsers disable PWA install and notifications there.
517
+ - The flagged phone experience is opt-in with `?mobileShell=v2`; use `?mobileShell=legacy` for the immediate rollback. It provides labelled **Chat**, **Sessions**, **Activity**, and **Project** destinations, plus a full-height **More** surface. Sessions preserve the existing tab switch/draft/SSE behavior; Activity and Project reuse the existing blocker, workflow, file, Git, queue, and settings actions rather than creating mobile copies.
518
+ - **Essential** and **Detailed** in More only change phone presentation and progressive disclosures. They never truncate final answers, remove safety/scope/remote warnings, enable `compact-v1`, or change stored transcript/model output. The phone action sheet keeps attachments, queue, session actions, voice entry, and a tap-confirm Abort path available without nested menus.
519
+ - Continuity is browser-scoped: text drafts, the selected destination, and bounded attachment metadata survive reloads. Attachment bytes are never persisted; restored chips say **Reselect required**. A send that the server did not confirm is never replayed automatically and exposes only manual **Retry** (with the original request identity) or **Discard**.
520
+ - **Add Context** unifies Camera, Photos, Files, and Paste text over the existing attachment path. Camera/photo permissions remain browser-controlled and are requested only after the user chooses that source; Files and Paste text remain fallbacks.
521
+ - Browser notifications cover blockers, completion, and failure only while a Web UI client/service worker is active. They carry versioned opaque tab/run/blocker targets and reconcile server state before navigation. This is not Web Push after every client closes; Activity is the in-app fallback.
522
+ - Tablet adaptation is independently opt-in at 721–1050 CSS px with `?tabletShell=v2`; use `?tabletShell=legacy` to roll it back without changing the phone flag. It uses a destination rail, a bounded right inspector, pointer-aware targets, and full-screen files by default.
523
+ - Installable PWA support, blocked-tab browser notifications, and optional agent-done notifications require browser service-worker/notification support and usually require `localhost` or HTTPS. Install education is contextual and dismissible; browser/PWA use is never blocked.
524
+ - Plain `http://<LAN-IP>` can show the app, but some browsers disable PWA install and notifications there. None of these features changes the existing remote-access/authentication model.
508
525
 
509
526
  ## Network safety
510
527