@firstpick/pi-package-webui 0.9.0 → 0.9.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.
package/README.md CHANGED
@@ -1,60 +1,256 @@
1
1
  # Pi Web UI
2
2
 
3
- Use Pi from a local browser with tabs, streaming responses, uploads, model controls, Git helpers, and optional companion features.
3
+ Run Pi in a local browser with multi-session tabs, streaming output, model controls, file uploads, Git workflows, and optional companion features.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/%40firstpick%2Fpi-package-webui?color=cb3837&logo=npm)](https://www.npmjs.com/package/@firstpick/pi-package-webui)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
7
+ [![Node.js 22.19+](https://img.shields.io/badge/Node.js-22.19%2B-339933?logo=node.js&logoColor=white)](https://nodejs.org/)
8
+ [![Pi package](https://img.shields.io/badge/Pi-package-6c5ce7)](https://www.npmjs.com/package/@earendil-works/pi-coding-agent)
4
9
 
5
10
  ![Pi Web UI main window showing multi-tab chat, streaming output, footer status, composer, and side controls](https://raw.githubusercontent.com/Firstp1ck/pi-coding-agent-forge/main/pi-package-webui/images/Webui_MainWindow_v0.4.8.png)
6
11
 
12
+ **Optional feature needed:** None — the main window is included in Pi Web UI core. Companion widgets appear only when their packages are installed.
13
+
14
+ Pi Web UI keeps the normal Pi agent experience while giving you more room to manage sessions, inspect work, and control common workflows. It listens on localhost by default, runs alongside Pi, and can be opened from Pi or with a standalone launcher.
15
+
7
16
  ## What you can do
8
17
 
9
- - Work in several Pi sessions at once.
10
- - Change models and thinking effort without leaving the browser.
11
- - Upload files and images, use slash-command suggestions, and manage follow-up prompts.
12
- - Search files, transcripts, and live agent output with every match highlighted.
13
- - Resume sessions, switch projects, and use guided Git helpers.
14
- - Keep phone sessions compact with expandable terminal navigation and secondary composer actions.
15
- - Add optional themes, statistics, remote access, voice features, and other companion packages.
18
+ | Area | Highlights |
19
+ | --- | --- |
20
+ | **Sessions and workspaces** | Run several isolated Pi sessions, resume prior work, switch projects, preserve per-tab drafts, and create branch worktrees. |
21
+ | **Live agent work** | Follow streaming Markdown, thinking, tool output, queues, todo progress, subagents, and context usage without leaving the browser. |
22
+ | **Models and controls** | Change models and thinking effort, manage scoped models, configure tools and skills, and use the command palette. |
23
+ | **Files and prompts** | Upload or paste files and images, edit text attachments, use slash-command suggestions, and reference project paths with `@`. |
24
+ | **Git workflows** | Inspect changes, switch branches, review diffs, stage work, generate commit messages, push, and prepare pull requests through guided steps. |
25
+ | **Project utilities** | Launch detected app runners, manage working directories, search files and transcripts, and customize themes. |
26
+ | **Companion features** | Add stats, remote access, voice, `/btw`, richer Git status, themes, release tools, and other supported Pi packages. |
27
+ | **Desktop and mobile** | Use a full desktop workspace or a compact phone layout with touch-friendly navigation and controls. |
28
+
29
+ ## Quick start
30
+
31
+ ### Requirements
32
+
33
+ - Node.js 22.19 or newer
34
+ - [Pi coding agent](https://www.npmjs.com/package/@earendil-works/pi-coding-agent) installed and configured
35
+ - A modern browser
16
36
 
17
- ## Install
37
+ ### Install into Pi
18
38
 
19
39
  ```bash
20
40
  pi install npm:@firstpick/pi-package-webui
21
41
  ```
22
42
 
23
- Restart Pi after installation.
43
+ Restart Pi, then run:
24
44
 
25
- ## Start it
45
+ ```text
46
+ /webui-start
47
+ ```
26
48
 
27
- Inside Pi, run:
49
+ Open the printed address, usually <http://127.0.0.1:31415/>. The browser normally opens automatically.
50
+
51
+ Check the server at any time with:
28
52
 
29
53
  ```text
30
- /webui-start
54
+ /webui-status
55
+ /webui-status detailed
31
56
  ```
32
57
 
33
- Open the printed address, usually <http://127.0.0.1:31415/>. Check a running server with `/webui-status`.
58
+ ### Your first session
59
+
60
+ 1. Start the Web UI with `/webui-start`.
61
+ 2. Confirm the working directory in the footer or choose another project.
62
+ 3. Select a model and thinking effort.
63
+ 4. Enter a prompt, attach context if needed, and follow the live response.
64
+ 5. Open the side panel for sessions, Git, app runners, themes, updates, and optional features.
65
+
66
+ Useful shortcuts:
67
+
68
+ - `Ctrl/Cmd+K` opens the command palette.
69
+ - `Ctrl/Cmd+L` opens the model selector.
70
+ - `Ctrl/Cmd+F` searches the active file, transcript, or subagent output and highlights every match.
71
+ - `Alt+Enter` queues the composer as a follow-up.
72
+ - Hold `Esc` to abort active work.
73
+
74
+ ## Feature gallery
75
+
76
+ Screenshots below show the v0.4.8 interface. Newer releases may contain additional controls while keeping the same core workflows.
77
+
78
+ ### Sessions and workspace
79
+
80
+ #### Workspace dashboard
81
+
82
+ ![Pi Web UI workspace dashboard showing the active project, model, session cards, and quick actions](https://raw.githubusercontent.com/Firstp1ck/pi-coding-agent-forge/main/pi-package-webui/images/Webui_Workspace_v0.4.8.png)
83
+
84
+ **Optional feature needed:** None — included in Pi Web UI core.
85
+
86
+ See the active project, model, context, Git state, queue, sessions, and common actions in one place.
87
+
88
+ #### Control panel
89
+
90
+ ![Pi Web UI side control panel with model, session, workspace, theme, update, optional feature, and usage controls](https://raw.githubusercontent.com/Firstp1ck/pi-coding-agent-forge/main/pi-package-webui/images/Webui_ControlPanel_v0.4.8.png)
91
+
92
+ **Optional feature needed:** None — the control panel is included in Pi Web UI core. Companion-specific sections require their corresponding packages.
93
+
94
+ Manage the current session, workspace, model, theme, notifications, updates, usage, and optional packages.
95
+
96
+ #### Working-directory picker
97
+
98
+ ![Pi Web UI working-directory picker with recent paths, saved directories, and create-directory action](https://raw.githubusercontent.com/Firstp1ck/pi-coding-agent-forge/main/pi-package-webui/images/Webui_CWDpicker_v0.4.8.png)
99
+
100
+ **Optional feature needed:** None — included in Pi Web UI core.
101
+
102
+ Browse, search, save, or create project directories and open them in the active Pi tab.
103
+
104
+ #### Queue manager
105
+
106
+ ![Pi Web UI queue panel with prompt-list controls and queued-message status](https://raw.githubusercontent.com/Firstp1ck/pi-coding-agent-forge/main/pi-package-webui/images/Webui_Queues_v0.4.8.png)
107
+
108
+ **Optional feature needed:** None — queues and prompt lists are included in Pi Web UI core.
109
+
110
+ Review follow-ups, steering messages, user-bash work, and prompt lists while a tab is busy.
111
+
112
+ ### Models, tools, and skills
113
+
114
+ #### Thinking effort
115
+
116
+ ![Pi Web UI thinking effort picker showing off, minimal, low, medium, high, and xhigh choices](https://raw.githubusercontent.com/Firstp1ck/pi-coding-agent-forge/main/pi-package-webui/images/Webui_Effort_v0.4.8.png)
117
+
118
+ **Optional feature needed:** None — included in Pi Web UI core.
119
+
120
+ Choose the supported reasoning effort before sending the next prompt.
121
+
122
+ #### Scoped models
123
+
124
+ ![Pi Web UI scoped models picker listing provider models and the current effective model](https://raw.githubusercontent.com/Firstp1ck/pi-coding-agent-forge/main/pi-package-webui/images/Webui_ScopedModels_v0.4.8.png)
125
+
126
+ **Optional feature needed:** None — included in Pi Web UI core.
127
+
128
+ Search available models and control project or global model scope and cycling order.
129
+
130
+ #### Tools setup
131
+
132
+ ![Pi Web UI tools setup dialog listing available tools with enable and disable controls](https://raw.githubusercontent.com/Firstp1ck/pi-coding-agent-forge/main/pi-package-webui/images/Webui_ToolsSetup_v0.4.8.png)
133
+
134
+ **Optional feature needed:** None — the browser tools setup is included in Pi Web UI core.
135
+
136
+ Enable tools for the current session or save the allowlist inherited by future sessions.
137
+
138
+ #### Skills setup
34
139
 
35
- Press `Ctrl/Cmd+F` while a file, transcript, or subagent output view is active to highlight every match; use `Enter` and `Shift+Enter` to move between matches.
140
+ ![Pi Web UI skills setup dialog listing installed skills and activation controls](https://raw.githubusercontent.com/Firstp1ck/pi-coding-agent-forge/main/pi-package-webui/images/Webui_SkillSetup_v0.4.8.png)
36
141
 
37
- You can leave the Web UI on another desktop workspace while Pi runs. When you return, it replaces hidden live-output updates with one current transcript snapshot so the page does not replay every intermediate render.
142
+ **Optional feature needed:** None — the browser skills setup is included in Pi Web UI core.
38
143
 
39
- You can also install the standalone launcher:
144
+ Find installed skills and manage session-specific or global activation.
145
+
146
+ ### Project automation and Git
147
+
148
+ #### App runners
149
+
150
+ ![Pi Web UI app runner selector showing detected project runners and custom runner creation](https://raw.githubusercontent.com/Firstp1ck/pi-coding-agent-forge/main/pi-package-webui/images/Webui_AppRunner_v0.4.8.png)
151
+
152
+ **Optional feature needed:** None — app runners are included in Pi Web UI core.
153
+
154
+ Launch detected development servers, tests, builds, scripts, and project-defined runners with pinned live output. ANSI colors are rendered safely, while progress written with carriage returns updates in place instead of filling the log with duplicate status lines.
155
+
156
+ #### Guided Git workflow
157
+
158
+ ![Pi Web UI guided Git workflow showing staged changes, generated commit messages, and PR controls](https://raw.githubusercontent.com/Firstp1ck/pi-coding-agent-forge/main/pi-package-webui/images/Webui_GitWorkflow_v0.4.8.png)
159
+
160
+ **Optional feature needed:** `@firstpick/pi-prompts-git-pr` for generated commit messages, branch names, and pull-request content. `@firstpick/pi-extension-aur-review` optionally adds the staged-review gate.
161
+
162
+ Move through review, staging, commit-message generation, commit, push, and pull-request steps with explicit confirmations.
163
+
164
+ #### Git branch picker
165
+
166
+ ![Pi Web UI git branch picker showing the current branch and create-branch action](https://raw.githubusercontent.com/Firstp1ck/pi-coding-agent-forge/main/pi-package-webui/images/Webui_GitBranches_v0.4.8.png)
167
+
168
+ **Optional feature needed:** None — branch and worktree controls are included in Pi Web UI core.
169
+
170
+ Switch branches, create a branch, or create a parallel branch worktree for isolated work.
171
+
172
+ #### Git diff viewer
173
+
174
+ ![Pi Web UI Git Changes dialog showing repository status, file list, and side-by-side diff rows](https://raw.githubusercontent.com/Firstp1ck/pi-coding-agent-forge/main/pi-package-webui/images/Webui_GitDiff_v0.4.8.png)
175
+
176
+ **Optional feature needed:** None — the Git status and diff viewer are included in Pi Web UI core.
177
+
178
+ Inspect staged, unstaged, untracked, and incoming changes before asking Pi to commit or publish them.
179
+
180
+ ### Optional companions and usage
181
+
182
+ #### Optional features
183
+
184
+ ![Pi Web UI optional features list showing companion packages and install or update states](https://raw.githubusercontent.com/Firstp1ck/pi-coding-agent-forge/main/pi-package-webui/images/Webui_OptionalFeatures_v0.4.8.png)
185
+
186
+ **Optional feature needed:** None — the package manager panel is included in Pi Web UI core; each listed companion is installed separately.
187
+
188
+ Install, update, enable, disable, or configure supported companion packages from one panel.
189
+
190
+ #### `/btw` side questions
191
+
192
+ ![Pi Web UI BTW widget showing a side-question input and live side-thread output](https://raw.githubusercontent.com/Firstp1ck/pi-coding-agent-forge/main/pi-package-webui/images/Webui_BTW_v0.4.8.png)
193
+
194
+ **Optional feature needed:** `@firstpick/pi-extension-btw`.
195
+
196
+ Ask a quick side question without derailing the main agent flow, then transfer useful context back when needed.
197
+
198
+ #### Codex usage
199
+
200
+ ![Pi Web UI Codex usage widget showing subscription usage windows and reset timers](https://raw.githubusercontent.com/Firstp1ck/pi-coding-agent-forge/main/pi-package-webui/images/Webui_CodexUsage_v0.4.8.png)
201
+
202
+ **Optional feature needed:** None for usage reporting — included in Pi Web UI core for supported Codex authentication. The Normal/Fast selector requires `@firstpick/pi-extension-codex-fast-mode`.
203
+
204
+ Monitor subscription usage windows and reset times for supported Codex models.
205
+
206
+ #### Pi stats
207
+
208
+ ![Pi Web UI stats dashboard showing token, cost, cache, model, and daily usage analytics](https://raw.githubusercontent.com/Firstp1ck/pi-coding-agent-forge/main/pi-package-webui/images/Webui_Pistats_v0.4.8.png)
209
+
210
+ **Optional feature needed:** `@firstpick/pi-extension-stats`.
211
+
212
+ Explore token, cost, cache, model, session, and daily usage through the optional stats companion.
213
+
214
+ ## Optional features
215
+
216
+ Open **Optional features** in the side panel to discover Web UI-aware companions. Configurable companions expose separate **Enable/Disable** and **Setup** actions, so configuration remains available without forcing a feature on.
217
+
218
+ Popular additions include:
219
+
220
+ - Remote Web UI for trusted-LAN access and PIN protection
221
+ - Pi stats and richer Git/footer status
222
+ - Natural Conversation Mode and voice controls
223
+ - `/btw` side questions
224
+ - Additional themes, release workflows, safety controls, and prompt tools
225
+
226
+ Optional companions are installed separately and remain governed by normal Pi package settings.
227
+
228
+ ## Standalone launcher
229
+
230
+ You can start the browser UI without opening terminal Pi first:
40
231
 
41
232
  ```bash
42
233
  npm install -g @firstpick/pi-package-webui
43
234
  pi-webui
44
235
  ```
45
236
 
46
- If no working directory is supplied, the browser asks which project to open first.
237
+ Choose a project immediately:
47
238
 
48
- To create a parallel checkout, click the Git branch box in the footer and use **Create branch worktree**. After the worktree is created, the browser asks whether to open it in a separate Pi tab and switch there; choosing **Cancel** keeps the current tab active and leaves the new worktree available for later.
49
-
50
- Pushes started from the Git footer or Guided Git target the active tab's currently checked-out branch on the remote and track that same-named remote branch as its upstream, replacing a mismatched upstream such as `origin/main`.
239
+ ```bash
240
+ pi-webui --cwd ~/src/my-project
241
+ ```
51
242
 
52
- On a phone, tap the current terminal name to open full-screen terminal navigation. Grouped terminals use their title as a dropdown; open the group, then choose an individual terminal. The composer keeps the prompt, attachment, Send, and active-run controls visible; tap **More** to open session, workflow, command, and mode controls in a full-screen overlay, then use the top `−` control or `Escape` to minimize it. Todo progress stays on one line until you tap it to expand the full goal, progress bar, and checklist. Git footer **Details** opens full-screen with refresh inside and a top `−` button to minimize it; session metrics and workspace, Git, and runtime details use compact grouped grids instead of stretched rows. Phone layouts use balanced compact text, spacing, cards, and 40-pixel controls so more content remains visible. Hover-only tooltips stay hidden on touch controls. In the **Control Deck**, desktop section dragging and `Alt+Arrow` movement are always available. On a phone, tap **Edit** to enable reordering, then tap **Done** to lock the order again.
243
+ If you omit `--cwd`, the browser asks which project to open first.
53
244
 
54
245
  ## Keep it private
55
246
 
56
- Pi Web UI can do anything the connected Pi session is allowed to do. It listens only on `127.0.0.1` by default. Do not expose it directly to an untrusted network. Use the optional Remote Web UI package when you need trusted-LAN access and PIN protection.
247
+ > [!WARNING]
248
+ > Pi Web UI can do anything the connected Pi session is allowed to do. It listens only on `127.0.0.1` by default. Do not expose it directly to an untrusted network.
249
+
250
+ Use the optional Remote Web UI package when you need trusted-LAN access and PIN protection. Treat that PIN as a convenience for a trusted network, not as hardened multi-user authentication.
57
251
 
58
252
  ## Technical details
59
253
 
60
- See [TECHNICAL.md](https://github.com/Firstp1ck/pi-coding-agent-forge/blob/main/pi-package-webui/TECHNICAL.md) for command-line options, settings, update and rollback behavior, session continuity, security, compatibility, and troubleshooting.
254
+ See [TECHNICAL.md](TECHNICAL.md) for complete commands, configuration, update and rollback behavior, session continuity, security, compatibility, mobile behavior, and troubleshooting.
255
+
256
+ Contributor-only architecture, API, and testing information lives in [DEVELOPMENT.md](DEVELOPMENT.md).
package/bin/pi-webui.mjs CHANGED
@@ -47,6 +47,7 @@ import {
47
47
  } from "../lib/session-actions.mjs";
48
48
  import { sweepStaleTempEntries } from "../lib/temp-artifacts.mjs";
49
49
  import { terminateProcessTree } from "../lib/process-tree.mjs";
50
+ import { consumeAppRunnerTerminalChunk } from "../lib/app-runner-terminal.mjs";
50
51
  import { ThinkingStreamRecovery } from "../lib/thinking-stream-recovery.mjs";
51
52
  import {
52
53
  classifyGitPathFailure,
@@ -4437,19 +4438,27 @@ function appendAppRunnerLine(run, line) {
4437
4438
  function appendAppRunnerChunk(tab, run, chunk, streamName) {
4438
4439
  if (!run || run.status !== "running") return;
4439
4440
  const key = streamName === "stderr" ? "stderrRemainder" : "stdoutRemainder";
4440
- const normalized = `${run[key] || ""}${String(chunk).replace(/\r\n?/g, "\n")}`;
4441
- const lines = normalized.split("\n");
4442
- run[key] = lines.pop() || "";
4443
- for (const line of lines) appendAppRunnerLine(run, line);
4441
+ const carriageReturnKey = streamName === "stderr" ? "stderrCarriageReturnPending" : "stdoutCarriageReturnPending";
4442
+ const reduced = consumeAppRunnerTerminalChunk({
4443
+ line: run[key],
4444
+ carriageReturnPending: run[carriageReturnKey],
4445
+ }, chunk);
4446
+ run[key] = reduced.line;
4447
+ run[carriageReturnKey] = reduced.carriageReturnPending;
4448
+ for (const line of reduced.lines) appendAppRunnerLine(run, line);
4444
4449
  scheduleAppRunnerBroadcast(tab);
4445
4450
  }
4446
4451
 
4447
4452
  function flushAppRunnerRemainders(run) {
4448
- for (const key of ["stdoutRemainder", "stderrRemainder"]) {
4453
+ for (const [key, carriageReturnKey] of [
4454
+ ["stdoutRemainder", "stdoutCarriageReturnPending"],
4455
+ ["stderrRemainder", "stderrCarriageReturnPending"],
4456
+ ]) {
4449
4457
  if (run?.[key]) {
4450
4458
  appendAppRunnerLine(run, run[key]);
4451
4459
  run[key] = "";
4452
4460
  }
4461
+ if (run) run[carriageReturnKey] = false;
4453
4462
  }
4454
4463
  }
4455
4464
 
@@ -0,0 +1,40 @@
1
+ function terminalLineState(state = {}) {
2
+ return {
3
+ line: String(state.line ?? ""),
4
+ carriageReturnPending: state.carriageReturnPending === true,
5
+ };
6
+ }
7
+
8
+ /**
9
+ * Reduce one streamed process chunk into terminal-style committed and live lines.
10
+ * A bare carriage return moves back to the start of the current line, so the
11
+ * next printable data replaces that line instead of creating scrollback.
12
+ */
13
+ export function consumeAppRunnerTerminalChunk(state, chunk) {
14
+ const current = terminalLineState(state);
15
+ const lines = [];
16
+
17
+ for (const character of String(chunk ?? "")) {
18
+ if (character === "\r") {
19
+ current.carriageReturnPending = true;
20
+ continue;
21
+ }
22
+ if (character === "\n") {
23
+ lines.push(current.line);
24
+ current.line = "";
25
+ current.carriageReturnPending = false;
26
+ continue;
27
+ }
28
+ if (current.carriageReturnPending) {
29
+ current.line = "";
30
+ current.carriageReturnPending = false;
31
+ }
32
+ if (character === "\b") {
33
+ current.line = [...current.line].slice(0, -1).join("");
34
+ continue;
35
+ }
36
+ current.line += character;
37
+ }
38
+
39
+ return { lines, ...current };
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firstpick/pi-package-webui",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Pi Web UI companion package with a local browser UI CLI plus /webui-start and /webui-status commands.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/Firstp1ck/pi-coding-agent-forge/tree/main/pi-package-webui#readme",
@@ -30,7 +30,7 @@
30
30
  "pi-webui": "./bin/pi-webui-launcher.mjs"
31
31
  },
32
32
  "scripts": {
33
- "check": "node --check public/app.js && node --check public/middle-button-drag-scroll.mjs && node --check public/stream-output-controller.mjs && node --check public/theme-contract.mjs && node --check public/transcript-renderer.mjs && node --check public/mobile-shell-state.mjs && node --check public/issue-wizard-state.mjs && node --check public/issue-bot-client.mjs && node --check public/workflow-status-stack.mjs && node --check public/fast-output-live.mjs && node --check public/subagent-launch-slot-state.mjs && node --check public/subagent-gate-visibility.mjs && node --check public/voice-conversation.mjs && node --check public/aur-review-payload.mjs && node --check public/guided-git-command-state.mjs && node --check public/guided-git-review-state.mjs && node --check bin/pi-webui.mjs && node --check bin/pi-webui-launcher.mjs && node --check bin/pi-webui-update-supervisor.mjs && node --check lib/update/supervisor.mjs && node --check bin/pi-webui-rpc-supervisor.mjs && node --check lib/rpc-supervisor-protocol.mjs && node --check lib/rpc-supervisor-state.mjs && node --check lib/rpc-supervisor-client.mjs && node --check webui-rpc-helper.mjs && node --check lib/subagent-launch-slots.mjs && node --check lib/git-live-watcher.mjs && node --check lib/workspace-files-live-watcher.mjs && node --check lib/git-message-artifacts.mjs && node --check lib/trust-boundaries.mjs && node --check lib/native-command-adapter.mjs && node --check lib/session-actions.mjs && node --check lib/auth-actions.mjs && node --check lib/temp-artifacts.mjs && node tests/run-all.mjs",
33
+ "check": "node --check public/app.js && node --check lib/app-runner-terminal.mjs && node --check public/middle-button-drag-scroll.mjs && node --check public/stream-output-controller.mjs && node --check public/theme-contract.mjs && node --check public/transcript-renderer.mjs && node --check public/mobile-shell-state.mjs && node --check public/issue-wizard-state.mjs && node --check public/issue-bot-client.mjs && node --check public/workflow-status-stack.mjs && node --check public/fast-output-live.mjs && node --check public/subagent-launch-slot-state.mjs && node --check public/subagent-gate-visibility.mjs && node --check public/voice-conversation.mjs && node --check public/aur-review-payload.mjs && node --check public/guided-git-command-state.mjs && node --check public/guided-git-review-state.mjs && node --check bin/pi-webui.mjs && node --check bin/pi-webui-launcher.mjs && node --check bin/pi-webui-update-supervisor.mjs && node --check lib/update/supervisor.mjs && node --check bin/pi-webui-rpc-supervisor.mjs && node --check lib/rpc-supervisor-protocol.mjs && node --check lib/rpc-supervisor-state.mjs && node --check lib/rpc-supervisor-client.mjs && node --check webui-rpc-helper.mjs && node --check lib/subagent-launch-slots.mjs && node --check lib/git-live-watcher.mjs && node --check lib/workspace-files-live-watcher.mjs && node --check lib/git-message-artifacts.mjs && node --check lib/trust-boundaries.mjs && node --check lib/native-command-adapter.mjs && node --check lib/session-actions.mjs && node --check lib/auth-actions.mjs && node --check lib/temp-artifacts.mjs && node tests/run-all.mjs",
34
34
  "test": "node tests/run-all.mjs",
35
35
  "test:browser": "playwright test"
36
36
  },
package/public/app.js CHANGED
@@ -2472,6 +2472,7 @@ const OPTIONAL_FEATURES = [
2472
2472
  packageName: "@firstpick/pi-prompts-git-pr",
2473
2473
  capabilityLabel: "/git-staged-msg",
2474
2474
  description: "Generate staged commit messages for the guided Git workflow.",
2475
+ setup: "git-workflow",
2475
2476
  },
2476
2477
  {
2477
2478
  id: "releaseNpm",
@@ -2500,6 +2501,7 @@ const OPTIONAL_FEATURES = [
2500
2501
  packageName: "@firstpick/pi-extension-workflows",
2501
2502
  capabilityLabel: "/workflow or workflow subprocess widget event",
2502
2503
  description: "Modular workflow runner with live subprocess output shown in a non-blocking Web UI widget.",
2504
+ setup: "workflows",
2503
2505
  },
2504
2506
  {
2505
2507
  id: "featureSystemPrompt",
@@ -2514,6 +2516,7 @@ const OPTIONAL_FEATURES = [
2514
2516
  packageName: "@firstpick/pi-extension-safety-guard",
2515
2517
  capabilityLabel: "/safety-guard or /safety-guard-setup command",
2516
2518
  description: "Configurable guardrails for dangerous bash commands and protected file edits.",
2519
+ setup: "safety-guard",
2517
2520
  },
2518
2521
  {
2519
2522
  id: "tuiSkillsCommand",
@@ -2550,6 +2553,7 @@ const OPTIONAL_FEATURES = [
2550
2553
  capabilityLabel: "questionnaire tool in /tools",
2551
2554
  description: "Native TUI and WebUI single- or multi-select question series with Other answers and resumable clarification.",
2552
2555
  manageWith: "tools",
2556
+ setup: "tools",
2553
2557
  },
2554
2558
  {
2555
2559
  id: "naturalConversation",
@@ -8849,6 +8853,8 @@ function loadDisabledOptionalFeatures() {
8849
8853
  }
8850
8854
 
8851
8855
  let disabledOptionalFeatures = new Set(loadDisabledOptionalFeatures());
8856
+ const optionalFeatureManagedAccessEnabled = new Map();
8857
+ const optionalFeatureAccessInProgress = new Set();
8852
8858
 
8853
8859
  function storeDisabledOptionalFeatures() {
8854
8860
  try {
@@ -8880,6 +8886,10 @@ function isOptionalFeatureDetected(featureId) {
8880
8886
  }
8881
8887
 
8882
8888
  function isOptionalFeatureDisabled(featureId) {
8889
+ const feature = OPTIONAL_FEATURE_BY_ID.get(featureId);
8890
+ if (feature?.manageWith === "tools" && optionalFeatureManagedAccessEnabled.has(featureId)) {
8891
+ return optionalFeatureManagedAccessEnabled.get(featureId) === false;
8892
+ }
8883
8893
  return disabledOptionalFeatures.has(featureId);
8884
8894
  }
8885
8895
 
@@ -16712,17 +16722,17 @@ function applyFooterContextUsage(node, contextUsage) {
16712
16722
  return node;
16713
16723
  }
16714
16724
 
16715
- // Dedicated Usage visual apply path: sets two independent lane widths (top =
16716
- // primary/first window, bottom = secondary/second window) plus a max-window
16717
- // active foreground/glow reusing the Context color interpolation. Clamps
16718
- // defensively to 0..100; exact text and tooltip remain untouched.
16725
+ // Dedicated Usage visual apply path: sets available independent lane widths
16726
+ // (top = primary/first window, bottom = secondary/second window) plus a
16727
+ // max-window active foreground/glow reusing the Context color interpolation.
16728
+ // Missing lanes remain empty; exact text and tooltip remain untouched.
16719
16729
  function applyFooterUsageWindows(node, usageWindows) {
16720
16730
  node.classList.add("footer-usage-card");
16721
16731
  const primaryPercent = typeof usageWindows?.primaryPercent === "number" ? usageWindows.primaryPercent : Number.NaN;
16722
16732
  const secondaryPercent = typeof usageWindows?.secondaryPercent === "number" ? usageWindows.secondaryPercent : Number.NaN;
16723
- if (Number.isFinite(primaryPercent) && Number.isFinite(secondaryPercent)) {
16724
- const clampedPrimary = Math.min(100, Math.max(0, primaryPercent));
16725
- const clampedSecondary = Math.min(100, Math.max(0, secondaryPercent));
16733
+ if (Number.isFinite(primaryPercent) || Number.isFinite(secondaryPercent)) {
16734
+ const clampedPrimary = Number.isFinite(primaryPercent) ? Math.min(100, Math.max(0, primaryPercent)) : 0;
16735
+ const clampedSecondary = Number.isFinite(secondaryPercent) ? Math.min(100, Math.max(0, secondaryPercent)) : 0;
16726
16736
  const activeColor = contextUsageActiveColor(Math.max(clampedPrimary, clampedSecondary));
16727
16737
  node.classList.add("has-usage-windows");
16728
16738
  node.style.setProperty("--usage-primary", `${clampedPrimary.toFixed(1)}%`);
@@ -16820,7 +16830,7 @@ const GIT_FOOTER_TOOLTIP_COPY = {
16820
16830
  speed: "Assistant streaming speed. Shows live output tokens for the current reply and current or last tokens per second.",
16821
16831
  cost: "Estimated session cost. sub means subscription-backed provider; api means metered API usage.",
16822
16832
  context: "Context window pressure. Shows percent used over the model limit; auto means auto-compaction is enabled.",
16823
- usage: "Provider subscription usage. Shows the used share of the provider-reported primary and secondary rate windows.",
16833
+ usage: "Provider subscription usage. Shows the used share of every available provider-reported rate window.",
16824
16834
  cwd: "Active working directory for this Web UI tab.",
16825
16835
  git: "Current Git branch. detached means HEAD is not on a branch; no repo means the cwd is outside a Git work tree.",
16826
16836
  "git-state": "Active Git operation or detached state. Finish or abort rebase/merge/cherry-pick/revert/bisect before normal commits.",
@@ -17262,8 +17272,11 @@ function normalizeFooterPayloadChip(value, index) {
17262
17272
  if (value.usageWindows && typeof value.usageWindows === "object") {
17263
17273
  const primaryPercent = typeof value.usageWindows.primaryPercent === "number" ? value.usageWindows.primaryPercent : Number.NaN;
17264
17274
  const secondaryPercent = typeof value.usageWindows.secondaryPercent === "number" ? value.usageWindows.secondaryPercent : Number.NaN;
17265
- if (Number.isFinite(primaryPercent) && Number.isFinite(secondaryPercent)) {
17266
- chip.usageWindows = { primaryPercent, secondaryPercent };
17275
+ if (Number.isFinite(primaryPercent) || Number.isFinite(secondaryPercent)) {
17276
+ chip.usageWindows = {
17277
+ ...(Number.isFinite(primaryPercent) ? { primaryPercent } : {}),
17278
+ ...(Number.isFinite(secondaryPercent) ? { secondaryPercent } : {}),
17279
+ };
17267
17280
  }
17268
17281
  }
17269
17282
  return chip;
@@ -35791,6 +35804,7 @@ function scheduleChatFollowScroll({ settle = true } = {}) {
35791
35804
 
35792
35805
  function resumeChatAutoFollow() {
35793
35806
  chatUserScrollAwayIntentUntil = 0;
35807
+ chatPausedScrollRestoreUntil = 0;
35794
35808
  autoFollowChat = true;
35795
35809
  }
35796
35810
 
@@ -36296,6 +36310,7 @@ function setOptionalControlState(button, available, unavailableTitle) {
36296
36310
  function resetOptionalFeatureAvailability() {
36297
36311
  for (const key of Object.keys(optionalFeatureAvailability)) optionalFeatureAvailability[key] = false;
36298
36312
  optionalFeatureAvailability.themeBundle = availableThemes.length > 0;
36313
+ optionalFeatureManagedAccessEnabled.clear();
36299
36314
  renderOptionalFeatureControls();
36300
36315
  if (activeTabId) queueMicrotask(() => refreshQuestionnaireFeatureAvailability());
36301
36316
  }
@@ -36971,13 +36986,18 @@ async function refreshQuestionnaireFeatureAvailability(tabContext = activeTabCon
36971
36986
  try {
36972
36987
  const response = await api("/api/tools?scope=session", { tabId: tabContext.tabId });
36973
36988
  if (!isCurrentTabContext(tabContext)) return false;
36974
- optionalFeatureAvailability.questionnaire = Array.isArray(response.data?.tools)
36975
- && response.data.tools.some((tool) => tool?.name === "questionnaire");
36989
+ const questionnaireTool = Array.isArray(response.data?.tools)
36990
+ ? response.data.tools.find((tool) => tool?.name === "questionnaire")
36991
+ : null;
36992
+ optionalFeatureAvailability.questionnaire = !!questionnaireTool;
36993
+ if (questionnaireTool) optionalFeatureManagedAccessEnabled.set("questionnaire", questionnaireTool.enabled !== false);
36994
+ else optionalFeatureManagedAccessEnabled.delete("questionnaire");
36976
36995
  renderOptionalFeatureControls();
36977
36996
  return true;
36978
36997
  } catch {
36979
36998
  if (isCurrentTabContext(tabContext)) {
36980
36999
  optionalFeatureAvailability.questionnaire = false;
37000
+ optionalFeatureManagedAccessEnabled.delete("questionnaire");
36981
37001
  renderOptionalFeatureControls();
36982
37002
  }
36983
37003
  return false;
@@ -37109,7 +37129,7 @@ function optionalFeatureStatus(featureId) {
37109
37129
  const feature = OPTIONAL_FEATURE_BY_ID.get(featureId);
37110
37130
  const detected = isOptionalFeatureDetected(featureId);
37111
37131
  const managedWithTools = feature?.manageWith === "tools";
37112
- const disabled = managedWithTools ? false : isOptionalFeatureDisabled(featureId);
37132
+ const disabled = isOptionalFeatureDisabled(featureId);
37113
37133
  const packageStatus = optionalFeaturePackageStatus(featureId);
37114
37134
  const installMessage = optionalFeatureInstallMessages.get(featureId);
37115
37135
  const installState = optionalFeatureInstallState(featureId);
@@ -37135,7 +37155,7 @@ function optionalFeatureStatus(featureId) {
37135
37155
  };
37136
37156
  }
37137
37157
  const doneDetail = installState?.phase === "done" ? optionalFeatureInstallDetail(installState, installMessage) : "";
37138
- if (disabled) return {
37158
+ if (disabled && !managedWithTools) return {
37139
37159
  label: "Disabled",
37140
37160
  className: "disabled",
37141
37161
  detail: `Disabled in this browser and excluded from migration selection${versionSuffix}`,
@@ -37149,7 +37169,13 @@ function optionalFeatureStatus(featureId) {
37149
37169
  hint: "Do not install again. Keep either the package entry or the extensions/skills/prompts/themes alias, not both.",
37150
37170
  };
37151
37171
  if (packageStatus?.updateAvailable) return { label: "Update available", className: "updating", detail: packageStatus.updateReason || `Installed package is older than the Web UI expects${versionSuffix}` };
37152
- if (detected && managedWithTools) return { label: "Loaded", className: "enabled", detail: doneDetail || `Detected in the active Pi tab; manage access in Tools${versionSuffix}`, command: installState?.command || "" };
37172
+ if (disabled && managedWithTools) return {
37173
+ label: "Disabled",
37174
+ className: "disabled",
37175
+ detail: `Tool access is disabled for the active Pi session${versionSuffix}`,
37176
+ hint: "Enable it here for this session, or use Setup to manage session and global tool defaults.",
37177
+ };
37178
+ if (detected && managedWithTools) return { label: "Enabled", className: "enabled", detail: doneDetail || `Tool access is enabled for the active Pi session${versionSuffix}`, hint: "Use Setup to manage session and global tool defaults.", command: installState?.command || "" };
37153
37179
  if (detected && !disabled) return { label: "Enabled", className: "enabled", detail: doneDetail || `Detected and enabled in Web UI${versionSuffix}`, command: installState?.command || "" };
37154
37180
  if (detected && disabled) return { label: "Disabled", className: "disabled", detail: `Detected, but disabled in Web UI${versionSuffix}` };
37155
37181
  if (packageStatus?.locallyConfigured) return { label: "Available locally", className: "installed", detail: doneDetail || `Enabled as a top-level Pi resource; reload this tab if the capability is not detected yet${versionSuffix}` };
@@ -37305,9 +37331,64 @@ function renderOptionalFeatureSection(section, features) {
37305
37331
  elements.optionalFeaturesBox.append(sectionNode);
37306
37332
  }
37307
37333
 
37334
+ function optionalFeatureSetupAvailable(feature) {
37335
+ switch (feature?.setup) {
37336
+ case "git-workflow": return hasAvailableCommand("git-workflow-setup");
37337
+ case "workflows": return hasLoadedRpcCommand("workflow-setup");
37338
+ case "safety-guard": return hasAvailableCommand("safety-guard-setup");
37339
+ case "tools": return feature.manageWith !== "tools" || isOptionalFeatureDetected(feature.id);
37340
+ default: return false;
37341
+ }
37342
+ }
37343
+
37344
+ function openOptionalFeatureSetup(feature) {
37345
+ switch (feature?.setup) {
37346
+ case "git-workflow": return openNativeGitWorkflowSetupDialog();
37347
+ case "workflows": return openNativeWorkflowSetupDialog();
37348
+ case "safety-guard": return openNativeSafetyGuardSetupDialog();
37349
+ case "tools": return openNativeToolsSelector();
37350
+ default: return undefined;
37351
+ }
37352
+ }
37353
+
37354
+ async function setToolManagedOptionalFeatureEnabled(feature, enabled) {
37355
+ const toolName = feature?.manageWith === "tools" ? String(feature.managedToolName || feature.id) : "";
37356
+ const tabContext = activeTabContext();
37357
+ if (!toolName || !tabContext.tabId || optionalFeatureAccessInProgress.has(feature.id)) return;
37358
+ optionalFeatureAccessInProgress.add(feature.id);
37359
+ renderOptionalFeatureControls();
37360
+ try {
37361
+ const current = await api("/api/tools?scope=session", { tabId: tabContext.tabId });
37362
+ if (!isCurrentTabContext(tabContext)) return;
37363
+ const tools = Array.isArray(current.data?.tools) ? current.data.tools : [];
37364
+ if (!tools.some((tool) => tool?.name === toolName)) throw new Error(`${toolName} is not available in this Pi tab`);
37365
+ const enabledTools = new Set(tools.filter((tool) => tool?.enabled !== false).map((tool) => tool.name));
37366
+ if (enabled) enabledTools.add(toolName);
37367
+ else enabledTools.delete(toolName);
37368
+ const response = await api("/api/tools", {
37369
+ method: "POST",
37370
+ body: { enabledTools: [...enabledTools], scope: "session" },
37371
+ tabId: tabContext.tabId,
37372
+ });
37373
+ if (!isCurrentTabContext(tabContext)) return;
37374
+ const nextTools = Array.isArray(response.data?.tools) ? response.data.tools : [];
37375
+ const nextTool = nextTools.find((tool) => tool?.name === toolName);
37376
+ optionalFeatureAvailability[feature.id] = !!nextTool;
37377
+ if (nextTool) optionalFeatureManagedAccessEnabled.set(feature.id, nextTool.enabled !== false);
37378
+ else optionalFeatureManagedAccessEnabled.delete(feature.id);
37379
+ addEvent(`${feature.label} was ${enabled ? "enabled" : "disabled"} for this session.`, "success");
37380
+ } catch (error) {
37381
+ if (isCurrentTabContext(tabContext)) addEvent(`${feature.label} access was not changed: ${error.message || String(error)}`, "error");
37382
+ } finally {
37383
+ optionalFeatureAccessInProgress.delete(feature.id);
37384
+ if (isCurrentTabContext(tabContext)) renderOptionalFeatureControls();
37385
+ }
37386
+ }
37387
+
37308
37388
  function renderOptionalFeatureRow(feature) {
37309
37389
  const detected = isOptionalFeatureDetected(feature.id);
37310
37390
  const enabled = isOptionalFeatureEnabled(feature.id);
37391
+ const accessChanging = optionalFeatureAccessInProgress.has(feature.id);
37311
37392
  const installState = optionalFeatureInstallState(feature.id);
37312
37393
  const installing = optionalFeatureInstallInProgress.has(feature.id) || optionalFeatureInstallIsActive(installState);
37313
37394
  const failed = installState?.phase === "failed";
@@ -37317,7 +37398,7 @@ function renderOptionalFeatureRow(feature) {
37317
37398
  const tooltip = optionalFeatureTooltip(feature, status);
37318
37399
  row.dataset.tooltip = tooltip;
37319
37400
  row.setAttribute("aria-label", tooltip.replace(/\s+/g, " "));
37320
- if (installing) row.setAttribute("aria-busy", "true");
37401
+ if (installing || accessChanging) row.setAttribute("aria-busy", "true");
37321
37402
  row.tabIndex = 0;
37322
37403
 
37323
37404
  const main = make("div", "optional-feature-main");
@@ -37347,8 +37428,11 @@ function renderOptionalFeatureRow(feature) {
37347
37428
  const actions = make("div", "optional-feature-actions");
37348
37429
  const action = make("button", "optional-feature-action");
37349
37430
  action.type = "button";
37350
- action.disabled = installing || optionalFeatureBatchIsActive() || (!optionalFeaturePackageStatusesLoaded && !detected);
37351
- if (installing) {
37431
+ action.disabled = accessChanging || installing || optionalFeatureBatchIsActive() || (!optionalFeaturePackageStatusesLoaded && !detected);
37432
+ if (accessChanging) {
37433
+ action.textContent = enabled ? "Disabling…" : "Enabling…";
37434
+ action.setAttribute("aria-busy", "true");
37435
+ } else if (installing) {
37352
37436
  action.textContent = installState?.actionLabel === "Update" ? "Updating…" : "Installing…";
37353
37437
  action.setAttribute("aria-busy", "true");
37354
37438
  } else if (failed) {
@@ -37356,9 +37440,6 @@ function renderOptionalFeatureRow(feature) {
37356
37440
  action.textContent = "Retry…";
37357
37441
  action.classList.add(retryAsUpdate ? "update" : "install");
37358
37442
  action.addEventListener("click", () => installOptionalFeature(feature.id, { update: retryAsUpdate }));
37359
- } else if (isOptionalFeatureDisabled(feature.id)) {
37360
- action.textContent = "Enable";
37361
- action.addEventListener("click", () => setOptionalFeatureDisabled(feature.id, false));
37362
37443
  } else if (packageStatus?.resourceConflict) {
37363
37444
  action.textContent = "Conflict";
37364
37445
  action.disabled = true;
@@ -37367,8 +37448,11 @@ function renderOptionalFeatureRow(feature) {
37367
37448
  action.classList.add("update");
37368
37449
  action.addEventListener("click", () => installOptionalFeature(feature.id, { update: true }));
37369
37450
  } else if (detected && feature.manageWith === "tools") {
37370
- action.textContent = "Tools…";
37371
- action.addEventListener("click", () => openNativeToolsSelector());
37451
+ action.textContent = enabled ? "Disable" : "Enable";
37452
+ action.addEventListener("click", () => setToolManagedOptionalFeatureEnabled(feature, !enabled));
37453
+ } else if (isOptionalFeatureDisabled(feature.id)) {
37454
+ action.textContent = "Enable";
37455
+ action.addEventListener("click", () => setOptionalFeatureDisabled(feature.id, false));
37372
37456
  } else if (detected) {
37373
37457
  action.textContent = enabled ? "Disable" : "Enable";
37374
37458
  action.addEventListener("click", async () => {
@@ -37406,6 +37490,14 @@ function renderOptionalFeatureRow(feature) {
37406
37490
  action.addEventListener("click", () => installOptionalFeature(feature.id));
37407
37491
  }
37408
37492
  actions.append(action);
37493
+ if (detected && feature.setup) {
37494
+ const setup = make("button", "optional-feature-action setup", "Setup");
37495
+ setup.type = "button";
37496
+ setup.disabled = accessChanging || installing || optionalFeatureBatchIsActive() || !optionalFeatureSetupAvailable(feature);
37497
+ setup.setAttribute("aria-label", `Set up ${feature.label}`);
37498
+ setup.addEventListener("click", () => openOptionalFeatureSetup(feature));
37499
+ actions.append(setup);
37500
+ }
37409
37501
  if (failed) {
37410
37502
  const retryFailed = make("button", "optional-feature-action install", "Retry failed");
37411
37503
  retryFailed.type = "button";
@@ -0,0 +1,28 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFile } from "node:fs/promises";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
7
+ const [app, server] = await Promise.all([
8
+ readFile(join(root, "public", "app.js"), "utf8"),
9
+ readFile(join(root, "bin", "pi-webui.mjs"), "utf8"),
10
+ ]);
11
+
12
+ assert.match(
13
+ app,
14
+ /function renderAppRunnerWidget\(\)[\s\S]*appendReleaseNpmTerminalLine\(terminal, line\)/,
15
+ "frontend should render app runner output through the shared terminal-line renderer",
16
+ );
17
+ assert.match(
18
+ app,
19
+ /function appendReleaseNpmTerminalLine\(parent, line\)[\s\S]*renderAnsiText\(row, line\)/,
20
+ "app-runner terminal lines should apply supported ANSI styling and hide unsupported ANSI controls",
21
+ );
22
+ assert.match(
23
+ server,
24
+ /consumeAppRunnerTerminalChunk\([\s\S]*carriageReturnPending/,
25
+ "server should preserve terminal-style carriage-return state across app-runner chunks",
26
+ );
27
+
28
+ console.log("app runner terminal static contracts passed");
@@ -0,0 +1,65 @@
1
+ import assert from "node:assert/strict";
2
+ import { consumeAppRunnerTerminalChunk } from "../lib/app-runner-terminal.mjs";
3
+
4
+ function consume(chunks) {
5
+ let state = { line: "", carriageReturnPending: false };
6
+ const lines = [];
7
+ for (const chunk of chunks) {
8
+ const result = consumeAppRunnerTerminalChunk(state, chunk);
9
+ lines.push(...result.lines);
10
+ state = result;
11
+ }
12
+ return { lines, line: state.line, carriageReturnPending: state.carriageReturnPending };
13
+ }
14
+
15
+ assert.deepEqual(
16
+ consume(["Discovering packages\nChecking package statuses: 1/77\rChecking package statuses: 2/77\rChecking package statuses: 3/77"]),
17
+ {
18
+ lines: ["Discovering packages"],
19
+ line: "Checking package statuses: 3/77",
20
+ carriageReturnPending: false,
21
+ },
22
+ "bare carriage returns should replace one live progress line instead of adding scrollback",
23
+ );
24
+
25
+ assert.deepEqual(
26
+ consume(["first\r", "\nsecond\r\nthird\n"]),
27
+ {
28
+ lines: ["first", "second", "third"],
29
+ line: "",
30
+ carriageReturnPending: false,
31
+ },
32
+ "CRLF should commit one line even when the pair is split across chunks",
33
+ );
34
+
35
+ assert.deepEqual(
36
+ consume(["50% complete\r", "51% complete"]),
37
+ {
38
+ lines: [],
39
+ line: "51% complete",
40
+ carriageReturnPending: false,
41
+ },
42
+ "a trailing carriage return should replace the live line when the next chunk arrives",
43
+ );
44
+
45
+ assert.deepEqual(
46
+ consume(["progress 1\r\u001b[2Kprogress \u001b[32m2\u001b[0m\n"]),
47
+ {
48
+ lines: ["\u001b[2Kprogress \u001b[32m2\u001b[0m"],
49
+ line: "",
50
+ carriageReturnPending: false,
51
+ },
52
+ "ANSI control and SGR sequences should remain intact for the browser renderer",
53
+ );
54
+
55
+ assert.deepEqual(
56
+ consume(["abc\bD"]),
57
+ {
58
+ lines: [],
59
+ line: "abD",
60
+ carriageReturnPending: false,
61
+ },
62
+ "backspace should update the current line without exposing a control glyph",
63
+ );
64
+
65
+ console.log("app runner terminal reducer tests passed");
@@ -1044,3 +1044,35 @@ test("submitting a new turn resumes bottom-follow and keeps the streamed tail an
1044
1044
  await waitForFixtureSettlement(page);
1045
1045
  await expect.poll(() => chat.evaluate((node) => Math.round(node.scrollHeight - node.clientHeight - node.scrollTop))).toBe(0);
1046
1046
  });
1047
+
1048
+ test("Latest reaches the live edge during a paused transcript reconciliation", async ({ page }) => {
1049
+ await page.setViewportSize({ width: 900, height: 420 });
1050
+ await page.goto(baseURL);
1051
+ await expect.poll(() => page.locator("#chat .message").count()).toBeGreaterThanOrEqual(3);
1052
+ await page.addStyleTag({ content: "#chat > .message { min-height: 10rem; }" });
1053
+
1054
+ const chat = page.locator("#chat");
1055
+ const pausedRemaining = await chat.evaluate((node) => {
1056
+ node.style.scrollBehavior = "auto";
1057
+ node.scrollTop = node.scrollHeight;
1058
+ node.dispatchEvent(new WheelEvent("wheel", { deltaY: -180, bubbles: true }));
1059
+ node.scrollTop = Math.max(0, node.scrollHeight - node.clientHeight - 180);
1060
+ node.dispatchEvent(new Event("scroll", { bubbles: true }));
1061
+ node.style.removeProperty("scroll-behavior");
1062
+ return node.scrollHeight - node.clientHeight - node.scrollTop;
1063
+ });
1064
+ assert.ok(pausedRemaining > 96, `the fixture must pause above the bottom threshold, got ${pausedRemaining}px`);
1065
+ await expect(page.locator("#jumpToLatestButton")).toBeVisible();
1066
+
1067
+ await triggerDelayedStream(page);
1068
+ await expect(page.locator("#jumpToLatestButton")).toBeVisible();
1069
+ await page.locator("#jumpToLatestButton").click();
1070
+
1071
+ await expect.poll(() => chat.evaluate((node) => ({
1072
+ following: document.querySelector("#jumpToLatestButton")?.hidden === true,
1073
+ remaining: Math.round(node.scrollHeight - node.clientHeight - node.scrollTop),
1074
+ }))).toEqual({ following: true, remaining: 0 });
1075
+ await expect(page.locator(".message.assistant.streaming .streaming-markdown").last()).toContainText("continuity");
1076
+ await waitForFixtureSettlement(page);
1077
+ await expect.poll(() => chat.evaluate((node) => Math.round(node.scrollHeight - node.clientHeight - node.scrollTop))).toBe(0);
1078
+ });
@@ -57,7 +57,7 @@ assert.doesNotMatch(updateLatest, /isChatNearBottom/, "Latest must not remain hi
57
57
  assert.match(applyFollow, /if \(!autoFollowChat\)[\s\S]*return;/, "already queued streaming frames must honor the immediate follow pause");
58
58
  assert.match(app, /if \(!autoFollowChat\) chatPausedScrollRestoreUntil = performance\.now\(\) \+ CHAT_PROGRAMMATIC_SCROLL_GRACE_MS;/, "paused transcript reconciliation should guard against scroll events from temporary DOM height changes");
59
59
  assert.match(app, /lastChatProgrammaticScrollAt = performance\.now\(\);\s*setChatScrollTopInstant\(Math\.min\(previousScrollTop, elements\.chat\.scrollHeight\)\);/, "transcript reconciliation should mark its instant reader-position restoration as programmatic");
60
- assert.match(resumeFollow, /chatUserScrollAwayIntentUntil = 0;[\s\S]*autoFollowChat = true;/, "explicit resume should clear stale upward intent before following again");
60
+ assert.match(resumeFollow, /chatUserScrollAwayIntentUntil = 0;\s*chatPausedScrollRestoreUntil = 0;\s*autoFollowChat = true;/, "explicit resume should clear stale upward intent and any reconciliation guard before following again");
61
61
  assert.match(forceFollow, /if \(force\) resumeChatAutoFollow\(\)/, "Latest and other forced-bottom actions should use the explicit resume path");
62
62
  assert.match(app, /addEventListener\("touchstart", noteChatTouchStart[\s\S]*addEventListener\("touchend", clearChatTouchIntent[\s\S]*addEventListener\("touchcancel", clearChatTouchIntent/, "touch direction tracking should be initialized and cleared for each gesture");
63
63
 
@@ -26,21 +26,23 @@ assert.match(parser, /x-codex-primary-window-minutes/, "Codex parser should read
26
26
  assert.match(parser, /x-codex-secondary-window-minutes/, "Codex parser should read the secondary window duration");
27
27
  assert.match(parser, /windowMinutes === 10_080\) return "weekly"/, "Codex weekly windows should have a truthful compact label");
28
28
  assert.match(parser, /return fallback;/, "missing Codex durations should use neutral labels rather than guessed 5h\/7d labels");
29
- assert.match(parser, /usage\.primary\.label[\s\S]*usage\.secondary\.label/, "formatted text should use snapshot labels");
29
+ assert.match(parser, /providerUsageWindows\(usage\)[\s\S]*\.map\(\(window\)/, "formatted text should use every available snapshot window");
30
30
 
31
- assert.match(producer, /usageWindows\?:\s*\{\s*primaryPercent:\s*number;\s*secondaryPercent:\s*number;/s, "producer should type the optional usageWindows contract");
32
- assert.match(producer, /usageWindows:\s*\{\s*primaryPercent:\s*providerUsage\.primary\.usedPercent,\s*secondaryPercent:\s*providerUsage\.secondary\.usedPercent,/s, "Usage chip should publish both normalized window percentages");
33
- assert.match(app, /usage:\s*"Provider subscription usage\.[^"]*provider-reported primary and secondary rate windows\./, "Usage tooltip should explain both provider-reported windows rather than using generic fallback copy");
31
+ assert.match(producer, /usageWindows\?:\s*\{\s*primaryPercent\?:\s*number;\s*secondaryPercent\?:\s*number;/s, "producer should type each usage window as independently optional");
32
+ assert.match(producer, /providerUsage\.primary \? \{ primaryPercent: providerUsage\.primary\.usedPercent \}/, "Usage chip should publish an available primary percentage");
33
+ assert.match(producer, /providerUsage\.secondary \? \{ secondaryPercent: providerUsage\.secondary\.usedPercent \}/, "Usage chip should publish an available secondary percentage");
34
+ assert.match(app, /usage:\s*"Provider subscription usage\.[^"]*every available provider-reported rate window\./, "Usage tooltip should explain that partial provider windows remain visible");
34
35
 
35
36
  assert.match(usageNormalization, /value\.usageWindows\.primaryPercent/, "consumer should read structured primary metadata");
36
37
  assert.match(usageNormalization, /value\.usageWindows\.secondaryPercent/, "consumer should read structured secondary metadata");
37
- assert.match(usageNormalization, /Number\.isFinite\(primaryPercent\)\s*&&\s*Number\.isFinite\(secondaryPercent\)/, "consumer should require both finite window values");
38
- assert.match(usageNormalization, /chip\.usageWindows\s*=\s*\{\s*primaryPercent,\s*secondaryPercent\s*\}/, "consumer should preserve the two structured values");
38
+ assert.match(usageNormalization, /Number\.isFinite\(primaryPercent\)\s*\|\|\s*Number\.isFinite\(secondaryPercent\)/, "consumer should accept either finite window value");
39
+ assert.match(usageNormalization, /Number\.isFinite\(primaryPercent\) \? \{ primaryPercent \}/, "consumer should preserve an available primary value");
40
+ assert.match(usageNormalization, /Number\.isFinite\(secondaryPercent\) \? \{ secondaryPercent \}/, "consumer should preserve an available secondary value");
39
41
  assert.doesNotMatch(usageNormalization, /chip\.value|value\.value|5h.*match|7d.*match/s, "usage-window normalization must not parse display text");
40
42
 
41
43
  assert.match(app, /if \(chip\.usageWindows\) applyFooterUsageWindows\(node, chip\.usageWindows\);/, "initial rendering should apply Usage visuals");
42
- assert.match(applyUsage, /Math\.min\(100, Math\.max\(0, primaryPercent\)\)/, "primary visual should clamp defensively");
43
- assert.match(applyUsage, /Math\.min\(100, Math\.max\(0, secondaryPercent\)\)/, "secondary visual should clamp defensively");
44
+ assert.match(applyUsage, /Number\.isFinite\(primaryPercent\) \? Math\.min\(100, Math\.max\(0, primaryPercent\)\) : 0/, "primary visual should clamp available data and leave a missing lane empty");
45
+ assert.match(applyUsage, /Number\.isFinite\(secondaryPercent\) \? Math\.min\(100, Math\.max\(0, secondaryPercent\)\) : 0/, "secondary visual should clamp available data and leave a missing lane empty");
44
46
  assert.match(applyUsage, /--usage-primary/, "primary should have an independent CSS width variable");
45
47
  assert.match(applyUsage, /--usage-secondary/, "secondary should have an independent CSS width variable");
46
48
  assert.doesNotMatch(applyUsage, /\.value|5h.*match|7d.*match/s, "visual application must not parse display text");
@@ -1144,7 +1144,10 @@ assert.match(app, /function renderOptionalFeaturePanel\(\)/, "side panel should
1144
1144
  assert.match(app, /const OPTIONAL_FEATURE_SECTIONS = \[[\s\S]*label: "Composer & commands"[\s\S]*label: "Workflows & releases"[\s\S]*label: "Safety & access"[\s\S]*label: "UI widgets & native parity"[\s\S]*featureIds: \[[^\]]*"questionnaire"[\s\S]*label: "Conversation"/, "optional features should be grouped into five type subsections with questionnaires under native parity");
1145
1145
  assert.match(app, /function renderOptionalFeatureSection\(section, features\)[\s\S]*optional-feature-section[\s\S]*optional-feature-section-title[\s\S]*optional-feature-section-list/, "optional feature panel should render subsection headers and lists");
1146
1146
  assert.match(app, /async function refreshQuestionnaireFeatureAvailability[\s\S]*\/api\/tools\?scope=session[\s\S]*tool\?\.name === "questionnaire"/, "questionnaire availability should be detected from the active Pi tab's loaded tool capability");
1147
- assert.match(app, /detected && feature\.manageWith === "tools"[\s\S]*action\.textContent = "Tools…"[\s\S]*openNativeToolsSelector/, "loaded questionnaire access should be managed through the native Tools selector instead of a cosmetic WebUI disable toggle");
1147
+ assert.match(app, /async function setToolManagedOptionalFeatureEnabled\(feature, enabled\)[\s\S]*\/api\/tools\?scope=session[\s\S]*enabledTools[\s\S]*scope: "session"[\s\S]*\/api\/tools/, "the questionnaire row toggle should update the active session tool allowlist while preserving other tool states");
1148
+ assert.match(app, /detected && feature\.manageWith === "tools"[\s\S]*action\.textContent = enabled \? "Disable" : "Enable"[\s\S]*setToolManagedOptionalFeatureEnabled/, "loaded questionnaire access should expose a dedicated enable or disable action");
1149
+ assert.match(app, /if \(detected && feature\.setup\)[\s\S]*"optional-feature-action setup", "Setup"[\s\S]*openOptionalFeatureSetup/, "detected configurable optional features should expose a separate Setup action");
1150
+ assert.match(app, /case "tools": return openNativeToolsSelector\(\)/, "Native questionnaires Setup should open the browser-native Tools Setup dialog");
1148
1151
  assert.match(app, /function setSidePanelSectionCollapsed\(record, collapsed/, "side panel sections should have explicit collapse/expand behavior");
1149
1152
  assert.match(
1150
1153
  app,
@@ -1600,7 +1603,7 @@ assert.match(app, /id: "safetyGuard"[\s\S]*?@firstpick\/pi-extension-safety-guar
1600
1603
  assert.match(app, /id: "tuiSkillsCommand"[\s\S]*?@firstpick\/pi-extension-setup-skills/, "optional features should include the TUI skills command companion");
1601
1604
  assert.match(app, /id: "tuiToolsCommand"[\s\S]*?@firstpick\/pi-extension-tools/, "optional features should include the TUI tools command companion");
1602
1605
  assert.match(app, /id: "remoteWebui"[\s\S]*?@firstpick\/pi-package-remote-webui/, "optional features should include the Remote WebUI companion");
1603
- assert.match(app, /id: "questionnaire"[\s\S]*?@firstpick\/pi-package-questionnaire[\s\S]*?capabilityLabel: "questionnaire tool in \/tools"[\s\S]*?manageWith: "tools"/, "optional features should include the native questionnaire package and delegate access control to Tools");
1606
+ assert.match(app, /id: "questionnaire"[\s\S]*?@firstpick\/pi-package-questionnaire[\s\S]*?capabilityLabel: "questionnaire tool in \/tools"[\s\S]*?manageWith: "tools"[\s\S]*?setup: "tools"/, "optional features should include the native questionnaire package with session access control and a Tools Setup entry point");
1604
1607
  assert.match(app, /id: "naturalConversation"[\s\S]*?@firstpick\/pi-package-natural-conversation[\s\S]*?capabilityLabel: "\/talk, \/voice, or \/conversation"/, "optional features should include the capability-detected Natural Conversation shell");
1605
1608
  assert.match(app, /NATURAL_CONVERSATION_COMMAND_NAMES = \["talk", "voice", "conversation"\]/, "frontend should detect Natural Conversation only from RPC-visible command aliases");
1606
1609
  assert.match(app, /const conversationModeByTab = new Map\(\)/, "frontend should track Natural Conversation state per terminal tab");