@firstpick/pi-package-webui 0.8.0 → 0.8.2

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 (63) hide show
  1. package/README.md +34 -5
  2. package/bin/pi-webui.mjs +606 -102
  3. package/lib/component-update-state.mjs +126 -0
  4. package/lib/npm-command.mjs +81 -0
  5. package/lib/queue-mutation.mjs +6 -0
  6. package/lib/trust-boundaries.mjs +1 -0
  7. package/lib/workspace-files-live-watcher.mjs +138 -0
  8. package/package.json +8 -3
  9. package/public/app.js +4231 -376
  10. package/public/index.html +265 -52
  11. package/public/mobile-shell-state.mjs +166 -0
  12. package/public/service-worker.js +60 -13
  13. package/public/styles.css +1790 -383
  14. package/public/subagent-gate-visibility.mjs +16 -0
  15. package/public/subagent-launch-slot-state.mjs +16 -0
  16. package/public/transcript-renderer.mjs +433 -0
  17. package/tests/boot-failure-diagnostics.test.mjs +63 -5
  18. package/tests/browser/control-deck-component-updates.spec.mjs +180 -0
  19. package/tests/browser/interaction-continuity.spec.mjs +897 -0
  20. package/tests/browser/mobile-foundation.spec.mjs +363 -0
  21. package/tests/browser/optimistic-prompt.spec.mjs +130 -0
  22. package/tests/browser/side-panel-section-reorder.spec.mjs +101 -0
  23. package/tests/browser/stats-overlay.spec.mjs +265 -0
  24. package/tests/chat-scroll-intent-static.test.mjs +6 -1
  25. package/tests/codex-fast-mode-static.test.mjs +8 -5
  26. package/tests/compact-sections-static.test.mjs +20 -2
  27. package/tests/compaction-mutation-contract.test.mjs +18 -4
  28. package/tests/compaction-static.test.mjs +1 -0
  29. package/tests/completion-signal-contract.test.mjs +13 -2
  30. package/tests/component-update-api-static.test.mjs +67 -0
  31. package/tests/component-update-state.test.mjs +80 -0
  32. package/tests/control-deck-component-updates-static.test.mjs +251 -0
  33. package/tests/fast-mode-client-static.test.mjs +7 -4
  34. package/tests/fixtures/fake-pi.mjs +305 -2
  35. package/tests/footer-provider-usage-visual-static.test.mjs +71 -0
  36. package/tests/git-panel-gitignore-static.test.mjs +104 -0
  37. package/tests/http-endpoints-harness.test.mjs +228 -2
  38. package/tests/interaction-state-stability-static.test.mjs +271 -0
  39. package/tests/mobile-continuity-tablet-static.test.mjs +55 -0
  40. package/tests/mobile-foundation-static.test.mjs +71 -0
  41. package/tests/mobile-phone-experience-static.test.mjs +65 -0
  42. package/tests/mobile-shell-state.test.mjs +69 -0
  43. package/tests/mobile-static.test.mjs +246 -39
  44. package/tests/mobile-transcript-cache-characterization.test.mjs +34 -0
  45. package/tests/native-parity-harness.test.mjs +2 -0
  46. package/tests/npm-command.test.mjs +64 -1
  47. package/tests/open-issue-wizard-static.test.mjs +2 -1
  48. package/tests/queue-edit-reorder-static.test.mjs +9 -1
  49. package/tests/queue-mutation-contract.test.mjs +22 -0
  50. package/tests/service-worker-lifecycle.test.mjs +120 -0
  51. package/tests/side-panel-section-reorder-static.test.mjs +68 -0
  52. package/tests/sse-backpressure-harness.test.mjs +137 -0
  53. package/tests/stats-dashboard-static.test.mjs +266 -0
  54. package/tests/streaming-ui-coupling.test.mjs +7 -1
  55. package/tests/subagent-gate-visibility.test.mjs +18 -2
  56. package/tests/subagent-launch-slot-state.test.mjs +32 -0
  57. package/tests/subagent-launch-slots-static.test.mjs +8 -2
  58. package/tests/subagents-helper.test.mjs +90 -0
  59. package/tests/terminal-tab-workspace-static.test.mjs +1 -1
  60. package/tests/update-commands.test.mjs +4 -0
  61. package/tests/workspace-files-live-updates-static.test.mjs +76 -0
  62. package/tests/workspace-files-live-watcher.test.mjs +95 -0
  63. package/webui-rpc-helper.mjs +175 -3
@@ -0,0 +1,251 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFile } from "node:fs/promises";
3
+ import vm from "node:vm";
4
+ import { dirname, join } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+
7
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
8
+ const [html, css, app, server, readme] = await Promise.all([
9
+ readFile(join(root, "public", "index.html"), "utf8"),
10
+ readFile(join(root, "public", "styles.css"), "utf8"),
11
+ readFile(join(root, "public", "app.js"), "utf8"),
12
+ readFile(join(root, "bin", "pi-webui.mjs"), "utf8"),
13
+ readFile(join(root, "README.md"), "utf8"),
14
+ ]);
15
+
16
+ function functionSource(name, nextName) {
17
+ const start = app.indexOf(`function ${name}(`);
18
+ const end = app.indexOf(`\nfunction ${nextName}(`, start);
19
+ assert.ok(start >= 0 && end > start, `${name} should remain a standalone frontend helper`);
20
+ return app.slice(start, end);
21
+ }
22
+
23
+ const piDialog = html.match(/<dialog id="piReleaseNotesDialog"[\s\S]*?<\/dialog>/)?.[0] || "";
24
+ assert.match(piDialog, /aria-labelledby="piReleaseNotesTitle"/, "the Pi version tag should keep its accessible release-notes dialog");
25
+ assert.match(piDialog, /id="piComponentUpdateStatus"[^>]*role="status"[^>]*aria-live="polite"/, "the Pi dialog should announce component update state");
26
+ assert.match(piDialog, /id="piComponentUpdateButton"[^>]*>Update Pi<\/button>/, "the Pi dialog should expose a targeted update action");
27
+
28
+ const webuiDialog = html.match(/<dialog id="webuiPackageDialog"[\s\S]*?<\/dialog>/)?.[0] || "";
29
+ assert.match(html, /id="webuiVersionButton"[^>]*aria-haspopup="dialog"[^>]*aria-controls="webuiPackageDialog"/, "the Web UI version tag should control its dedicated package dialog");
30
+ assert.match(webuiDialog, /aria-labelledby="webuiPackageTitle"/, "the Web UI package dialog should have an accessible title");
31
+ assert.match(webuiDialog, /<dt>Installed<\/dt>[\s\S]*id="webuiPackageCurrentVersion"[\s\S]*<dt>Latest on npm<\/dt>[\s\S]*id="webuiPackageLatestVersion"/, "the Web UI dialog should show installed and latest versions");
32
+ assert.match(webuiDialog, /id="webuiPackageNpmButton"[^>]*>View on npm<\/button>/, "the Web UI dialog should retain the npm package action");
33
+ assert.match(webuiDialog, /id="webuiComponentUpdateStatus"[^>]*role="status"[^>]*aria-live="polite"/, "the Web UI dialog should announce component update state");
34
+ assert.match(webuiDialog, /id="webuiComponentUpdateButton"[^>]*>Update Web UI<\/button>/, "the Web UI dialog should expose a targeted update action");
35
+ assert.match(app, /webuiPackageNpmButton\?\.addEventListener\("click", \(\) => \{[\s\S]*confirmOpenWebuiNpmPage\(\)/, "the package dialog npm action should reuse the guarded external-link flow");
36
+
37
+ for (const state of ["available", "running", "succeeded", "failed"]) {
38
+ assert.match(css, new RegExp(`\\.pi-version-button\\[data-update-state="${state}"\\]::after[\\s\\S]*\\.webui-version-button\\[data-update-state="${state}"\\]::after`), `both component tags should render the ${state} indicator`);
39
+ }
40
+ assert.match(css, /prefers-reduced-motion: reduce[\s\S]*data-update-state="running"/, "the running indicator should respect reduced-motion preferences");
41
+
42
+ const renderPiVersionButtonSource = functionSource("renderPiVersionButton", "renderWebuiVersionButton");
43
+ const renderWebuiVersionButtonSource = functionSource("renderWebuiVersionButton", "renderWebuiDevBadge");
44
+ assert.match(renderPiVersionButtonSource, /componentUpdateTagState\("pi"\)[\s\S]*setAttribute\("aria-label", stateText/, "the Pi tag should use Pi-only state in its accessible name");
45
+ assert.match(renderWebuiVersionButtonSource, /componentUpdateTagState\("webui"\)[\s\S]*setAttribute\("aria-label", stateText/, "the Web UI tag should use Web-UI-only state in its accessible name");
46
+
47
+ const componentBlockStart = app.indexOf('const COMPONENT_UPDATE_TARGETS = ["pi", "webui"];');
48
+ const componentBlockEnd = app.indexOf("\nfunction initializeUpdateNotifications()", componentBlockStart);
49
+ assert.ok(componentBlockStart >= 0 && componentBlockEnd > componentBlockStart, "component update helpers should remain a focused frontend block");
50
+ const componentBlock = app.slice(componentBlockStart, componentBlockEnd);
51
+
52
+ const calls = [];
53
+ const events = [];
54
+ const scheduled = [];
55
+ const cleared = [];
56
+ const makeButton = () => ({
57
+ hidden: false,
58
+ textContent: "",
59
+ title: "",
60
+ disabled: false,
61
+ dataset: {},
62
+ attributes: {},
63
+ setAttribute(name, value) { this.attributes[name] = value; },
64
+ });
65
+ const makeStatus = () => ({ textContent: "", hidden: false, dataset: {} });
66
+ const elements = {
67
+ piVersionButton: makeButton(),
68
+ webuiVersionButton: makeButton(),
69
+ piComponentUpdateStatus: makeStatus(),
70
+ piComponentUpdateButton: makeButton(),
71
+ webuiComponentUpdateStatus: makeStatus(),
72
+ webuiComponentUpdateButton: makeButton(),
73
+ webuiPackageCurrentVersion: makeStatus(),
74
+ webuiPackageLatestVersion: makeStatus(),
75
+ webuiPackageDialog: { open: false, showModal() { this.open = true; } },
76
+ };
77
+ let nextTimer = 1;
78
+ let refreshShouldFail = false;
79
+ const context = {
80
+ elements,
81
+ console,
82
+ setTimeout(callback, delay) {
83
+ const id = nextTimer++;
84
+ scheduled.push({ id, callback, delay });
85
+ return id;
86
+ },
87
+ clearTimeout(id) { cleared.push(id); },
88
+ formatWebuiVersion(value) {
89
+ const text = String(value || "").trim();
90
+ return text ? (text.startsWith("v") ? text : `v${text}`) : "";
91
+ },
92
+ packageUpdateText(label, status = {}) {
93
+ return `${label} ${status.currentVersion || ""} → ${status.latestVersion || ""}`.trim();
94
+ },
95
+ appConfirmText: async (_message, options) => {
96
+ calls.push({ kind: "confirm", options });
97
+ return true;
98
+ },
99
+ api: async (path, options) => {
100
+ calls.push({ kind: "api", path, options });
101
+ return { data: { target: options.body.target, state: "running", canStart: false, message: "Update is running." } };
102
+ },
103
+ addEvent(message, level) { events.push({ message, level }); },
104
+ refreshUpdateStatus: async () => {
105
+ if (refreshShouldFail) throw new Error("temporary status failure");
106
+ return null;
107
+ },
108
+ };
109
+ vm.runInNewContext(`
110
+ let latestUpdateStatus = null;
111
+ let piVersion = "0.83.0";
112
+ let webuiVersion = "0.8.1";
113
+ let componentUpdatePollTimer = null;
114
+ let componentUpdateStartInProgress = false;
115
+ let updateRequestInProgress = false;
116
+ const COMPONENT_UPDATE_POLL_MS = 1000;
117
+ ${renderPiVersionButtonSource}
118
+ ${renderWebuiVersionButtonSource}
119
+ ${componentBlock}
120
+ globalThis.componentHarness = {
121
+ setStatus(value) { latestUpdateStatus = value; },
122
+ getStatus() { return latestUpdateStatus; },
123
+ tagState: componentUpdateTagState,
124
+ statusText: componentUpdateStatusText,
125
+ buttonState: componentUpdateButtonState,
126
+ renderIndicators: renderComponentUpdateIndicators,
127
+ renderDialogs: renderComponentUpdateDialogs,
128
+ syncPolling: syncComponentUpdatePolling,
129
+ pollTimer() { return componentUpdatePollTimer; },
130
+ start: startComponentUpdate,
131
+ };
132
+ `, context);
133
+ const harness = context.componentHarness;
134
+
135
+ harness.setStatus({
136
+ updateInProgress: false,
137
+ pi: { currentVersion: "0.83.0", latestVersion: "0.84.0", updateAvailable: true },
138
+ webui: { currentVersion: "0.8.1", latestVersion: "0.8.1", updateAvailable: false, checked: true },
139
+ componentUpdates: {
140
+ pi: { target: "pi", state: "idle", canStart: true },
141
+ webui: { target: "webui", state: "idle", canStart: true },
142
+ },
143
+ });
144
+ harness.renderIndicators();
145
+ assert.equal(elements.piVersionButton.dataset.updateState, "available", "Pi availability should mark only the Pi tag");
146
+ assert.equal(elements.piVersionButton.attributes["aria-label"], "View Pi v0.83.0 release notes, update available", "Pi availability should be present in the accessible name");
147
+ assert.equal(elements.webuiVersionButton.dataset.updateState, undefined, "Pi availability should not mark the Web UI tag");
148
+ assert.doesNotMatch(elements.webuiVersionButton.attributes["aria-label"], /update available/, "Pi availability should not leak into the Web UI accessible name");
149
+
150
+ harness.setStatus({
151
+ updateInProgress: false,
152
+ pi: { updateAvailable: true },
153
+ webui: { updateAvailable: true },
154
+ componentUpdates: {
155
+ pi: { state: "succeeded", canStart: true, message: "Pi update completed." },
156
+ webui: { state: "failed", canStart: true, message: "Web UI update failed.", error: "bounded failure" },
157
+ },
158
+ });
159
+ assert.equal(harness.tagState("pi"), "succeeded", "terminal Pi success should outrank stale availability");
160
+ assert.equal(harness.tagState("webui"), "failed", "terminal Web UI failure should outrank stale availability");
161
+ assert.match(harness.statusText("pi").text, /New or reloaded Pi sessions use the update; already-running tabs keep their current runtime/, "Pi success should explain activation without interrupting active tabs");
162
+ assert.match(harness.statusText("webui").text, /bounded failure[\s\S]*retry the update/, "Web UI failure should remain visible and permit retry");
163
+ assert.equal(harness.buttonState("webui").label, "Retry Web UI update", "a failed Web UI update should expose retry");
164
+ assert.equal(harness.buttonState("webui").disabled, false, "retry should be enabled when no update is running");
165
+
166
+ harness.setStatus({
167
+ updateInProgress: false,
168
+ webui: { currentVersion: "0.8.1", latestVersion: "0.8.2", updateAvailable: true },
169
+ componentUpdates: {
170
+ pi: { state: "idle", canStart: true },
171
+ webui: { state: "idle", canStart: false, unavailableReason: "Automatic Web UI update is unavailable from a source or development checkout." },
172
+ },
173
+ });
174
+ assert.equal(harness.buttonState("webui").disabled, true, "source/development Web UI self-update should be disabled");
175
+ assert.match(harness.statusText("webui").text, /source or development checkout/, "source/development refusal should be explained in the live status");
176
+
177
+ harness.setStatus({
178
+ updateInProgress: true,
179
+ pi: { updateAvailable: true },
180
+ webui: { updateAvailable: true },
181
+ componentUpdates: {
182
+ pi: { state: "running", canStart: false, message: "Updating Pi…" },
183
+ webui: { state: "idle", canStart: false },
184
+ },
185
+ });
186
+ assert.equal(harness.buttonState("pi").disabled, true, "the running target should reject duplicate starts");
187
+ assert.equal(harness.buttonState("webui").disabled, true, "a running Pi update should disable the conflicting Web UI start");
188
+ harness.syncPolling();
189
+ assert.equal(scheduled.length, 1, "a running update should create one short polling timer");
190
+ assert.equal(scheduled[0].delay, 1000, "running status should poll at the bounded one-second interval");
191
+ harness.syncPolling();
192
+ assert.equal(scheduled.length, 1, "re-rendering while running should not create duplicate poll timers");
193
+ refreshShouldFail = true;
194
+ scheduled[0].callback();
195
+ await new Promise((resolve) => setImmediate(resolve));
196
+ assert.equal(scheduled.length, 2, "a transient status failure should re-arm polling while the last known job remains running");
197
+ assert.match(events.at(-1)?.message || "", /status check failed/i, "a transient polling failure should remain visible in the event log");
198
+ refreshShouldFail = false;
199
+ const rearmedTimer = harness.pollTimer();
200
+ harness.setStatus({
201
+ updateInProgress: false,
202
+ componentUpdates: {
203
+ pi: { state: "succeeded", canStart: true },
204
+ webui: { state: "idle", canStart: true },
205
+ },
206
+ });
207
+ harness.syncPolling();
208
+ assert.deepEqual(cleared, [rearmedTimer], "terminal state should clear the re-armed running poll");
209
+ assert.equal(harness.pollTimer(), null, "terminal state should release the polling timer reference");
210
+
211
+ calls.length = 0;
212
+ harness.setStatus({
213
+ updateInProgress: false,
214
+ pi: { currentVersion: "0.83.0", latestVersion: "0.84.0", updateAvailable: true },
215
+ webui: { updateAvailable: false },
216
+ componentUpdates: {
217
+ pi: { state: "idle", canStart: true },
218
+ webui: { state: "idle", canStart: true },
219
+ },
220
+ });
221
+ await harness.start("pi");
222
+ const piStartCall = calls.find((call) => call.kind === "api");
223
+ assert.equal(piStartCall?.path, "/api/component-update", "the Pi dialog should use the component-update endpoint");
224
+ assert.equal(piStartCall?.options.method, "POST", "component update starts should use POST");
225
+ assert.equal(piStartCall?.options.scoped, false, "component update starts should not inherit a Pi tab scope");
226
+ assert.equal(JSON.stringify(piStartCall?.options.body), '{"target":"pi"}', "the Pi dialog should send only the exact Pi target");
227
+ assert.equal(harness.getStatus().componentUpdates.pi.state, "running", "the accepted 202-shaped state should render immediately as running");
228
+ assert.equal(harness.buttonState("pi").disabled, true, "the accepted job should immediately disable duplicate starts");
229
+ assert.match(componentBlock, /statusElement\.hidden = false;[\s\S]*statusElement\.textContent = text;/, "component live regions should remain rendered before their status text changes");
230
+ assert.match(app, /openPiReleaseNotes\(\)[\s\S]*refreshUpdateStatus\(\{ notify: false \}\)/, "opening Pi details should refresh component status even when cached state exists");
231
+
232
+ assert.match(
233
+ server,
234
+ /url\.pathname === "\/api\/component-update" && req\.method === "POST"[\s\S]*requireLocalhostRoute\(req, url\.pathname\)[\s\S]*validateComponentUpdateRequest\(body\)[\s\S]*sendJson\(res, 202/,
235
+ "the server should keep exact validation, localhost restriction, and 202 acceptance for component starts",
236
+ );
237
+ assert.match(
238
+ app,
239
+ /async function runPiUpdateAndRestart\([\s\S]*api\(all \? "\/api\/update\?all=1" : "\/api\/update", \{ method: "POST", scoped: false \}\)[\s\S]*waitForServerRestart\(\)/,
240
+ "the legacy browser update-and-restart flow should remain compatible",
241
+ );
242
+ assert.match(
243
+ server,
244
+ /url\.pathname === "\/api\/update" && req\.method === "POST"[\s\S]*runPiUpdateAndPrepareRestart\(\{ all: queryAll \|\| bodyAll \}\)[\s\S]*sendJson\(res, 200[\s\S]*shutdown\("api update", \{ preserveSessions: true \}\)/,
245
+ "the legacy server route should retain update-all selection, completion response, restart, and managed-session preservation",
246
+ );
247
+ assert.match(readme, /Control Deck component updates[\s\S]*component-specific `available`, `running`, `succeeded`, or `failed` status/, "README should explain the component-specific tag indicators");
248
+ assert.match(readme, /Update Pi[\s\S]*does not restart the Web UI or interrupt managed Pi tabs[\s\S]*Update Web UI[\s\S]*restart the Web UI after success/, "README should explain Pi and Web UI activation behavior");
249
+ assert.match(readme, /only from localhost[\s\S]*disabled for source\/development checkouts[\s\S]*verify the installed version before retrying[\s\S]*broader legacy behavior/, "README should document security, source refusal, recovery, and legacy compatibility");
250
+
251
+ console.log("control deck component update static tests passed");
@@ -84,7 +84,8 @@ assert.doesNotMatch(compactUpdate, /event\.message|assistantMessageEvent\.partia
84
84
  assert.match(compactUpdate, /reduceFastOutputLiveEvent\(compactLiveState, event\)/, "compact deltas should use the pure reducer");
85
85
  assert.match(compactUpdate, /shouldConsumeFastOutputLiveEvent\(reduced\)/, "recognized compact empty end variants should be consumed instead of reaching normal handlers with stripped snapshots");
86
86
  assert.match(helper, /function shouldConsumeFastOutputLiveEvent\(reduction = \{\}\)[\s\S]*?"text-end"[\s\S]*?"thinking-end"[\s\S]*?"toolcall-end"/, "the reducer policy should consume only recognized compact end variants when no DOM state changes");
87
- assert.match(compactFlush, /\.textContent = compactLiveState\.text/, "compact assistant text must render through a stable plain-text node while streaming");
87
+ assert.match(compactFlush, /transcriptRenderer\.updateTextSurface\(\{[\s\S]*?surface: compactTextNode,[\s\S]*?text: compactLiveState\.text/, "compact assistant text must update through the stable transcript text surface");
88
+ assert.doesNotMatch(compactFlush, /compactTextNode\.textContent\s*=/, "compact assistant streaming must not replace its selected text node");
88
89
  assert.match(compactThinkingBubble, /title: "thinking \(live\)"[\s\S]*?compactThinkingAggregate: true[\s\S]*?compactThinkingKey: "live"[\s\S]*?compactThinkingDefaultExpanded: true[\s\S]*?make\("div", "markdown-body thinking-text compact-live-thinking"\)/, "compact live thinking should use one expanded-by-default aggregate disclosure with a stable key and established Markdown styles");
89
90
  assert.match(resetCompactLiveOutput, /clearCompactThinkingDisclosureState\("live"\)/, "a new compact stream should clear any explicit live override and restore its expanded default");
90
91
  assert.match(compactFlush, /compactThinkingNode\?\._rawThinkingText !== compactLiveState\.thinking[\s\S]*?renderThinkingMarkdown\(compactThinkingNode, compactLiveState\.thinking\)/, "compact live thinking should preserve Markdown formatting");
@@ -92,7 +93,7 @@ assert.doesNotMatch(compactFlush, /compactThinkingNode\.textContent|renderStream
92
93
  assert.doesNotMatch(compactToolShell, /normalizeToolExecution|toolExecutionRenderSignature|renderToolExecution|handleToolExecutionUpdate|JSON\.stringify/, "compact tool shells must defer rich bodies and raw serialization");
93
94
  assert.match(app, /case "tool_execution_update":\s+if \(!compactOutputActive\(\)\) handleToolExecutionUpdate\(event\);/, "compact mode should not build intermediate rich tool updates");
94
95
  assert.match(app, /case "tool_execution_end":[\s\S]*?compactLiveScheduler\.flushNow\(\)[\s\S]*?renderCompactToolShell\(event, \{ complete: true \}\)[\s\S]*?finishCompactLiveOutput\(tabContext\)/, "compact tool completion should remain lightweight and request final reconciliation");
95
- assert.match(resetStream, /resetCompactLiveOutput\(\)/, "reset and tab changes should cancel compact pending work");
96
+ assert.match(resetStream, /resetCompactLiveOutput\(\{ remove: !preserveCompact \}\)/, "reset and tab changes should cancel compact pending work while exact compact settlement may retain its adopted owner");
96
97
  assert.match(app, /case "message_end": \{\s+if \(compactOutputActive\(\)\) finishCompactLiveOutput\(tabContext\);/, "message ends should synchronously flush compact output before reconciliation");
97
98
  assert.match(app, /case "agent_end":\s+if \(compactOutputActive\(\)\) finishCompactLiveOutput\(tabContext\);/, "agent ends should synchronously flush compact output before reconciliation");
98
99
  assert.match(compactTranscript, /message\.role !== "assistant"[\s\S]*?appendMarkdown\(body, output \|\| "_\[non-text output omitted in compact mode\]_"\)[\s\S]*?classList\.add\("compact-transcript-text"\)/, "reconciled compact-mode assistant output should preserve Markdown and explain omitted non-text output");
@@ -115,7 +116,8 @@ assert.match(orderedTranscriptItems, /if \(!compactOutputActive\(\)\) \{[\s\S]*?
115
116
  assert.match(transcriptRenderEpoch, /compactOutputActive\(\) \? "compact" : "normal"/, "mode changes should invalidate the keyed transcript renderer");
116
117
  assert.match(clearCompactToolShells, /removeCompactLiveBubble\(shell\?\.bubble\)[\s\S]*?compactToolShells\.clear\(\)/, "fast mode should remove previous transient tool shells from the DOM and registry");
117
118
  assert.match(compactToolShell, /if \(!shell\) \{\s+clearCompactToolShells\(\)/, "a newly-started tool should replace the previous transient tool shell");
118
- assert.match(compactToolShell, /shell\.status\.textContent = complete[\s\S]*?event\?\.isError \? "failed" : "done"[\s\S]*?: "running"/, "the current transient tool shell should expose only a non-duplicated status");
119
+ assert.match(compactToolShell, /transcriptRenderer\.updateTextSurface\(\{[\s\S]*?surface: shell\.status[\s\S]*?text: complete[\s\S]*?event\?\.isError \? "failed" : "done"[\s\S]*?: "running"/, "the current transient tool shell should expose only a non-duplicated status through its stable transcript text surface");
120
+ assert.doesNotMatch(compactToolShell, /shell\.status\.textContent\s*=/, "compact tool status updates must not replace selected text nodes");
119
121
  assert.match(styles, /\.message\.compact-tool-shell\s*\{[\s\S]*?display: grid[\s\S]*?grid-template-columns:[\s\S]*?padding: 0\.46rem 0\.62rem[\s\S]*?box-shadow: none/, "fast-mode tool activity should render as a compact horizontal row");
120
122
  assert.match(styles, /\.compact-tool-shell \.compact-tool-status\s*\{[\s\S]*?display: inline-flex[\s\S]*?border-radius: 999px[\s\S]*?font-size: 0\.7rem[\s\S]*?text-transform: uppercase/, "the minimal tool status should remain visually distinct as a small pill");
121
123
  assert.match(styles, /\.compact-tool-shell\.tool-running \.compact-tool-status[\s\S]*?\.compact-tool-shell\.tool-success \.compact-tool-status[\s\S]*?\.compact-tool-shell\.tool-error \.compact-tool-status/, "running, success, and failure tool states should have distinct visual tones");
@@ -152,7 +154,8 @@ assert.match(helper, /FAST_OUTPUT_FLUSH_INTERVAL_MS = 100/, "the live scheduler
152
154
  assert.match(worker, /pi-webui-pwa-v\d+[\s\S]*?"\/fast-output-live\.mjs"/, "PWA cache identity and app shell should include the compact helper");
153
155
  assert.match(html, /<label for="fastOutputModeSelect">Compact mode \(Experimental\)<\/label>/, "the sidebar should mark compact mode as experimental");
154
156
  assert.match(html, /Lightweight browser rendering; Markdown final output; live thinking expanded; stored thinking grouped and collapsed/, "the sidebar should distinguish compact rendering from model inference");
155
- assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=94"/, "the guarded PWA entry point should cache-bust browser wiring");
157
+ // Intent preserved: the guarded PWA entry point must advance whenever app wiring changes.
158
+ assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=104"/, "the guarded PWA entry point should cache-bust browser wiring");
156
159
  assert.match(JSON.parse(packageRaw).scripts.check, /node --check public\/fast-output-live\.mjs/, "package checks should parse the compact helper");
157
160
 
158
161
  const events = createFastModeOutputEvents();