@firstpick/pi-package-webui 0.10.5 → 0.10.6

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 (47) hide show
  1. package/DEVELOPMENT.md +9 -1
  2. package/README.md +2 -0
  3. package/TECHNICAL.md +3 -1
  4. package/bin/pi-webui.mjs +1 -1
  5. package/lib/thinking-stream-recovery.mjs +29 -142
  6. package/package.json +2 -2
  7. package/public/app.js +44 -79
  8. package/public/fast-output-live.mjs +8 -6
  9. package/public/index.html +2 -2
  10. package/public/service-worker.js +1 -1
  11. package/public/stream-output-controller.mjs +59 -12
  12. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  13. package/tests/codex-fast-mode-static.test.mjs +2 -2
  14. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  15. package/tests/control-visibility-static.test.mjs +3 -3
  16. package/tests/controls-layout-static.test.mjs +3 -3
  17. package/tests/events-tree-context-menu-static.test.mjs +3 -3
  18. package/tests/fast-mode-client-static.test.mjs +2 -2
  19. package/tests/fast-output-live.test.mjs +9 -0
  20. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  21. package/tests/file-viewer-image-static.test.mjs +3 -3
  22. package/tests/fixtures/fake-pi.mjs +2 -2
  23. package/tests/guided-git-activation-static.test.mjs +3 -3
  24. package/tests/guided-git-fallback-ui-static.test.mjs +2 -2
  25. package/tests/intercom-conversation-viewer-static.test.mjs +3 -3
  26. package/tests/intercom-main-transcript-suppression-static.test.mjs +5 -6
  27. package/tests/main-output-loading-static.test.mjs +3 -3
  28. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  29. package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
  30. package/tests/mobile-foundation-static.test.mjs +3 -3
  31. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  32. package/tests/mobile-static.test.mjs +3 -3
  33. package/tests/open-issue-wizard-static.test.mjs +1 -1
  34. package/tests/optional-feature-prompt-impact-static.test.mjs +3 -3
  35. package/tests/persistent-ui-layout-static.test.mjs +3 -3
  36. package/tests/prompt-input-vertical-scroll-static.test.mjs +3 -3
  37. package/tests/questionnaire-dialog.test.mjs +3 -3
  38. package/tests/session-sampling-ui-static.test.mjs +3 -3
  39. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  40. package/tests/stream-output-controller.test.mjs +4 -2
  41. package/tests/streaming-ui-coupling.test.mjs +2 -2
  42. package/tests/subagent-observability-static.test.mjs +2 -2
  43. package/tests/syntax-highlighting-static.test.mjs +3 -3
  44. package/tests/theme-customizer-static.test.mjs +1 -1
  45. package/tests/thinking-stream-recovery.test.mjs +58 -75
  46. package/tests/tool-call-stream.test.mjs +152 -0
  47. package/tests/windows-drive-cwd-picker-static.test.mjs +3 -3
@@ -65,7 +65,7 @@ function makeEnvironment({
65
65
  reload: new FakeElement(),
66
66
  copyStatus: new FakeElement(),
67
67
  };
68
- const styleLink = new FakeElement({ href: "http://127.0.0.1:31415/styles.css?v=152", sheet: stylesheetLoaded ? {} : null });
68
+ const styleLink = new FakeElement({ href: "http://127.0.0.1:31415/styles.css?v=154", sheet: stylesheetLoaded ? {} : null });
69
69
  const listeners = new Map();
70
70
  const timers = new Map();
71
71
  let timerId = 0;
@@ -84,7 +84,7 @@ function makeEnvironment({
84
84
  removeEventListener(name) { listeners.delete(name); },
85
85
  };
86
86
  const document = {
87
- currentScript: new FakeElement({ dataset: { appSrc: "/app.js?v=183" } }),
87
+ currentScript: new FakeElement({ dataset: { appSrc: "/app.js?v=184" } }),
88
88
  readyState: "complete",
89
89
  querySelector(selector) {
90
90
  return {
@@ -232,7 +232,7 @@ for (const moduleName of startupModuleNames) {
232
232
  assert.ok(serviceWorker.includes(`"/${moduleName}"`), `the PWA app shell should include every app.js startup module: ${moduleName}`);
233
233
  }
234
234
  assert.match(serviceWorker, /pi-webui-pwa-v\d+/, "the app-shell cache should retain a versioned identity");
235
- assert.ok(html.indexOf('id="webuiBootLoader"') < html.indexOf("/app.js?v=183"), "the inline loader should own app module startup");
235
+ assert.ok(html.indexOf('id="webuiBootLoader"') < html.indexOf("/app.js?v=184"), "the inline loader should own app module startup");
236
236
  assert.doesNotMatch(html, /<script type="module" src="\/app\.js/, "the app module should not bypass the guarded loader");
237
237
 
238
238
  console.log("boot-failure-diagnostics.test.mjs passed");
@@ -55,7 +55,7 @@ assert.match(app, /statusKey === CODEX_FAST_MODE_STATUS_KEY[\s\S]*?applyCodexFas
55
55
  assert.match(technical, /## Normal and compact output[\s\S]*?select \*\*Compact\*\*[\s\S]*?`compact-v1`/, "technical reference should document Compact mode with the stable identifier");
56
56
  assert.match(development, /### Codex subscription Fast mode[\s\S]*?service_tier: "priority"[\s\S]*?1\.5× faster[\s\S]*?2× Standard credits[\s\S]*?2\.5×/, "development guide should document Fast-mode integration and cost semantics");
57
57
  // Intent preserved: browser-asset changes must advance the coherent cache tuple.
58
- assert.match(serviceWorker, /pi-webui-pwa-v154/, "PWA cache identity should be bumped for changed browser assets");
59
- assert.match(html, /data-app-src="\/app\.js\?v=183"/, "browser module URL should be cache-busted for Fast-mode wiring");
58
+ assert.match(serviceWorker, /pi-webui-pwa-v155/, "PWA cache identity should be bumped for changed browser assets");
59
+ assert.match(html, /data-app-src="\/app\.js\?v=184"/, "browser module URL should be cache-busted for Fast-mode wiring");
60
60
 
61
61
  console.log("codex-fast-mode-static.test.mjs passed");
@@ -57,8 +57,8 @@ assert.match(app, /function initializeComposerActionOrdering\(\)[\s\S]*MutationO
57
57
  assert.match(app, /event\.key === COMPOSER_ACTION_ORDER_STORAGE_KEY\) restoreComposerActionOrder\(\)[\s\S]*event\.key === COMPOSER_ACTION_LAYOUT_STORAGE_KEY\) restoreComposerActionSlotLayout\(\)/, "other tabs should apply persisted composer order and sparse-layout changes");
58
58
  assert.match(app, /initializeComposerActionOrdering\(\);[\s\S]*restoreSidePanelSectionOrder\(\);/, "composer ordering should initialize during guarded app startup");
59
59
 
60
- assert.match(html, /styles\.css\?v=152/, "changed composer styles should advance the stylesheet revision");
61
- assert.match(html, /app\.js\?v=183/, "changed composer behavior should advance the app revision");
62
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "changed browser assets should advance the PWA cache identity");
60
+ assert.match(html, /styles\.css\?v=154/, "changed composer styles should advance the stylesheet revision");
61
+ assert.match(html, /app\.js\?v=184/, "changed composer behavior should advance the app revision");
62
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v155"/, "changed browser assets should advance the PWA cache identity");
63
63
 
64
64
  console.log("composer-action-grid-reorder-static.test.mjs passed");
@@ -348,10 +348,10 @@ assert.match(
348
348
 
349
349
  assert.match(
350
350
  serviceWorker,
351
- /const CACHE_NAME = "pi-webui-pwa-v154";/,
351
+ /const CACHE_NAME = "pi-webui-pwa-v155";/,
352
352
  "browser asset changes should advance the PWA cache identity",
353
353
  );
354
- assert.match(html, /styles\.css\?v=152/, "visibility styles should advance the stylesheet query revision");
355
- assert.match(html, /data-app-src="\/app\.js\?v=183"/, "visibility behavior should advance the app query revision");
354
+ assert.match(html, /styles\.css\?v=154/, "visibility styles should advance the stylesheet query revision");
355
+ assert.match(html, /data-app-src="\/app\.js\?v=184"/, "visibility behavior should advance the app query revision");
356
356
 
357
357
  console.log("control-visibility-static.test.mjs passed");
@@ -15,8 +15,8 @@ assert.equal((html.match(/class="control-row-label"[^>]*data-tooltip=/g) || []).
15
15
  assert.match(app, /function initializeControlSettingTooltips\(\)[\s\S]*#sidePanelSectionControls \.control-row-label\[data-tooltip\][\s\S]*bindStyledTooltipEvents\(label\)[\s\S]*showFooterTooltip\(label\)/, "Controls help should use the viewport-safe floating tooltip for hover and keyboard access");
16
16
  assert.match(html, /class="control-row remote-auth-control-row" hidden[\s\S]*id="remoteAuthToggle"/, "optional PIN protection should retain its guarded visibility");
17
17
  assert.match(app, /remoteAuthToggle\?\.closest\("\.remote-auth-control-row"\)[\s\S]*remoteAuthRow\.hidden = false/, "loading remote status should reveal the optional PIN protection setting");
18
- assert.match(html, /styles\.css\?v=152/, "Controls stylesheet changes should advance the cache query");
19
- assert.match(html, /app\.js\?v=183/, "Controls tooltip wiring should advance the app cache query");
20
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "Controls browser assets should advance the PWA cache identity");
18
+ assert.match(html, /styles\.css\?v=154/, "Controls stylesheet changes should advance the cache query");
19
+ assert.match(html, /app\.js\?v=184/, "Controls tooltip wiring should advance the app cache query");
20
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v155"/, "Controls browser assets should advance the PWA cache identity");
21
21
 
22
22
  console.log("controls-layout-static.test.mjs passed");
@@ -124,8 +124,8 @@ assert.match(styles, /\.event-log\[data-display-mode="compact"\] \.event\[data-e
124
124
  assert.match(styles, /\.event-tree-context-menu \{[\s\S]*max-width: calc\(100vw - 1rem\)/, "the dedicated menu should remain viewport bounded");
125
125
 
126
126
  // Cache tuple for this browser-asset change.
127
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154";/, "the PWA cache identity should advance");
128
- assert.match(html, /styles\.css\?v=152/, "compact-mode styles should advance the stylesheet revision");
129
- assert.match(html, /data-app-src="\/app\.js\?v=183"/, "the app query revision should advance");
127
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v155";/, "the PWA cache identity should advance");
128
+ assert.match(html, /styles\.css\?v=154/, "compact-mode styles should advance the stylesheet revision");
129
+ assert.match(html, /data-app-src="\/app\.js\?v=184"/, "the app query revision should advance");
130
130
 
131
131
  console.log("events-tree-context-menu-static.test.mjs passed");
@@ -96,7 +96,7 @@ assert.match(app, /applyToolExecutionUpdate: \(event\) => \{\s+if \(!compactOutp
96
96
  assert.doesNotMatch(app, /case "tool_execution_update":/, "raw tool updates should have only the controller-owned dispatch path");
97
97
  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");
98
98
  assert.match(resetStream, /resetCompactLiveOutput\(\{ remove: !preserveCompact \}\)/, "reset and tab changes should cancel compact pending work while exact compact settlement may retain its adopted owner");
99
- assert.match(app, /case "message_end": \{\s+if \(compactOutputActive\(\)\) finishCompactLiveOutput\(tabContext\);/, "message ends should synchronously flush compact output before reconciliation");
99
+ assert.match(app, /case "message_end": \{[\s\S]*?if \(compactOutputActive\(\)\) finishCompactLiveOutput\(tabContext\);/, "message ends should synchronously flush compact output before reconciliation");
100
100
  assert.match(app, /case "agent_end":\s+if \(compactOutputActive\(\)\) finishCompactLiveOutput\(tabContext\);/, "agent ends should synchronously flush compact output before reconciliation");
101
101
  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");
102
102
  assert.doesNotMatch(compactTranscript, /appendText|renderToolExecution|normalizeToolExecution|JSON\.stringify|appendToolOutput|appendToolDiff|appendToolImages/, "fast-mode final output must not fall back to plain text or render tool details");
@@ -159,7 +159,7 @@ assert.match(worker, /pi-webui-pwa-v\d+[\s\S]*?"\/fast-output-live\.mjs"/, "PWA
159
159
  assert.match(html, /<label for="fastOutputModeSelect">Compact mode \(Experimental\)<\/label>/, "the sidebar should mark compact mode as experimental");
160
160
  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");
161
161
  // Intent preserved: the guarded PWA entry point must advance whenever app wiring changes.
162
- assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=183"/, "the guarded PWA entry point should cache-bust browser wiring");
162
+ assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=184"/, "the guarded PWA entry point should cache-bust browser wiring");
163
163
  assert.match(JSON.parse(packageRaw).scripts.check, /node --check public\/fast-output-live\.mjs/, "package checks should parse the compact helper");
164
164
 
165
165
  const events = createFastModeOutputEvents();
@@ -76,6 +76,15 @@ assert.equal(shouldConsumeFastOutputLiveEvent(emptyCompactTextEnd), true, "recog
76
76
  assert.equal(shouldConsumeFastOutputLiveEvent(emptyCompactThinkingEnd), true, "recognized empty thinking end variants should be consumed safely");
77
77
  assert.equal(shouldConsumeFastOutputLiveEvent({ changed: false, kind: "ignored" }), false, "unknown compact shapes should still fall through to normal diagnostics");
78
78
 
79
+ for (const [kind, field] of [["text", "text"], ["thinking", "thinking"]]) {
80
+ const draft = { ...createFastOutputLiveState(), [field]: "draft removed tail" };
81
+ for (const content of ["draft", "", "provider correction"]) {
82
+ const corrected = reduceFastOutputLiveEvent(draft, { type: "message_update", assistantMessageEvent: { type: `${kind}_end`, content } });
83
+ assert.equal(corrected.state[field], content, "explicit final content wins over streamed text");
84
+ assert.equal(corrected.changed, true);
85
+ }
86
+ }
87
+
79
88
  const clock = new FakeClock();
80
89
  const flushes = [];
81
90
  const scheduler = createSustainedFlushScheduler({
@@ -166,7 +166,7 @@ assert.match(functionSource("closeTerminalTabs"), /clearFeatureDecisionStateForT
166
166
  assert.match(app, /case "webui_connected":[\s\S]*clearFeatureDecisionStateForTab\(connectedTabId, \{ render: true \}\)[\s\S]*scheduleForegroundReconcile\("event stream reconnect", 0\)/, "reconnect should clear local state before authoritative replay");
167
167
  assert.match(app, /statusKey === FEATURE_DECISION_OUTPUT_STATUS_KEY[\s\S]*handleFeatureDecisionOutputStatus[\s\S]*return;[\s\S]*statusKey === FEATURE_CATEGORY_STATUS_KEY[\s\S]*return;[\s\S]*statusEntries\.set/, "both feature statuses should be intercepted before generic footer storage while preserving category handling");
168
168
 
169
- assert.match(html, /\/styles\.css\?v=152/, "integrated stylesheet changes should advance the cache query");
170
- assert.match(html, /\/app\.js\?v=183/, "integrated app changes should advance the cache query");
169
+ assert.match(html, /\/styles\.css\?v=154/, "integrated stylesheet changes should advance the cache query");
170
+ assert.match(html, /\/app\.js\?v=184/, "integrated app changes should advance the cache query");
171
171
 
172
172
  console.log("feature decision-output popup static checks passed");
@@ -62,8 +62,8 @@ assert.match(css, /\.file-viewer-image img \{[\s\S]*max-width: 100%;[\s\S]*max-h
62
62
  assert.match(readme, /PNG, JPEG, GIF, WebP, and AVIF/i, "the Files panel guide should list supported image formats");
63
63
  assert.match(technical, /supported raster images[\s\S]*2 MiB/i, "the advanced reference should document image support and its size limit");
64
64
  assert.match(development, /kind: "image"[\s\S]*base64/i, "the contributor guide should document the image response contract");
65
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "changed viewer assets should advance the PWA cache identity");
66
- assert.match(html, /styles\.css\?v=152/, "changed image styles should advance the stylesheet revision");
67
- assert.match(html, /app\.js\?v=183/, "changed image rendering should advance the app revision");
65
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v155"/, "changed viewer assets should advance the PWA cache identity");
66
+ assert.match(html, /styles\.css\?v=154/, "changed image styles should advance the stylesheet revision");
67
+ assert.match(html, /app\.js\?v=184/, "changed image rendering should advance the app revision");
68
68
 
69
69
  console.log("file viewer image static tests passed");
@@ -358,8 +358,8 @@ function runIntercomLiveScript() {
358
358
  { afterMs: 30, run: () => emitScriptedEvent({ type: "agent_start" }) },
359
359
  { afterMs: 30, run: () => emitScriptedEvent({ type: "message_start", message: { role: "assistant" } }) },
360
360
  { afterMs: 40, run: () => emitScriptedEvent({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta: normalText } }) },
361
- { afterMs: 40, run: () => emitScriptedEvent({ type: "message_update", assistantMessageEvent: { type: "toolcall_start", contentIndex: 1, name: "intercom", toolCall } }) },
362
- { afterMs: 30, run: () => emitScriptedEvent({ type: "message_update", assistantMessageEvent: { type: "toolcall_delta", contentIndex: 1, name: "intercom", toolCall, delta: "" } }) },
361
+ { afterMs: 40, run: () => emitScriptedEvent({ type: "message_update", assistantMessageEvent: { type: "toolcall_start", contentIndex: 1, id: toolCallId, toolName: "intercom" } }) },
362
+ { afterMs: 30, run: () => emitScriptedEvent({ type: "message_update", assistantMessageEvent: { type: "toolcall_delta", contentIndex: 1, delta: JSON.stringify(toolCall.arguments) } }) },
363
363
  { afterMs: 30, run: () => emitScriptedEvent({ type: "message_update", assistantMessageEvent: { type: "toolcall_end", contentIndex: 1, name: "intercom", toolCall } }) },
364
364
  { afterMs: 30, run: () => emitScriptedEvent({ type: "tool_execution_start", toolCallId, toolName: "intercom", args: toolCall.arguments }) },
365
365
  { afterMs: 40, run: () => emitScriptedEvent({ type: "tool_execution_update", toolCallId, toolName: "intercom", partialResult: { content: toolResult.content } }) },
@@ -89,9 +89,9 @@ test("server dispatch requires extension provenance and completes on a fresh nat
89
89
  test("fixture, cache revisions, and layered docs expose the migration contract", () => {
90
90
  assert.match(fakePi, /FAKE_PI_GUIDED_GIT_ACTIVATION/u);
91
91
  assert.match(fakePi, /git-guided-workflow:webui-start/u);
92
- assert.match(html, /styles\.css\?v=152/u);
93
- assert.match(html, /app\.js\?v=183/u);
94
- assert.match(serviceWorker, /pi-webui-pwa-v154/u);
92
+ assert.match(html, /styles\.css\?v=154/u);
93
+ assert.match(html, /app\.js\?v=184/u);
94
+ assert.match(serviceWorker, /pi-webui-pwa-v155/u);
95
95
  assert.match(serviceWorker, /"\/guided-git-command-state\.mjs"/u);
96
96
  assert.match(readme, /pi-extension-git-guided-workflow/u);
97
97
  assert.match(technical, /\/git-guided-workflow/u);
@@ -54,7 +54,7 @@ assert.match(readme, /fallback model and its own reasoning effort[\s\S]*tries th
54
54
  assert.match(technical, /## Guided Git generation profiles[\s\S]*strict one-retry policy[\s\S]*active model and reasoning effort remain unchanged[\s\S]*dead Pi process cannot run the fallback/i, "technical reference should document configuration and operational limits");
55
55
  assert.match(development, /### Fallback browser\/runtime contract[\s\S]*fallbackUsed: true[\s\S]*webui_git_workflow_generation_fallback_started[\s\S]*never sends a retry/, "development guide should preserve the response/event and browser ownership contract");
56
56
 
57
- assert.match(html, /data-app-src="\/app\.js\?v=183"/, "the changed browser app should use the next query revision");
58
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154";/, "the PWA cache identity should advance with browser behavior");
57
+ assert.match(html, /data-app-src="\/app\.js\?v=184"/, "the changed browser app should use the next query revision");
58
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v155";/, "the PWA cache identity should advance with browser behavior");
59
59
 
60
60
  console.log("guided-git-fallback-ui-static.test.mjs passed");
@@ -96,9 +96,9 @@ assert.match(css, /\.composer-intercom-tag:hover,[\s\S]*\.composer-intercom-tag:
96
96
  assert.match(css, /\.extension-dialog\.intercom-conversation-dialog \{[\s\S]*width: min\(76rem,[\s\S]*height: min\(54rem,/, "the viewer should use a large in-app modal");
97
97
  assert.match(css, /@media \(max-width: 720px\)[\s\S]*\.composer-intercom-tag \{ min-height: 44px;[\s\S]*\.extension-dialog\.intercom-conversation-dialog[\s\S]*width: calc\(100vw - 0\.7rem\)/, "tags and the dialog should remain reachable on narrow and coarse-pointer layouts");
98
98
 
99
- assert.match(html, /\/styles\.css\?v=152/, "the stylesheet URL should advance for the bounded conversation tags");
100
- assert.match(html, /data-app-src="\/app\.js\?v=183"/, "the guarded app URL should advance for current browser wiring");
101
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "the PWA cache identity should advance with browser assets");
99
+ assert.match(html, /\/styles\.css\?v=154/, "the stylesheet URL should advance for the bounded conversation tags");
100
+ assert.match(html, /data-app-src="\/app\.js\?v=184"/, "the guarded app URL should advance for current browser wiring");
101
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v155"/, "the PWA cache identity should advance with browser assets");
102
102
 
103
103
  assert.match(readme, /one compact tag per conversation appears beneath the composer/i, "the README should explain the user-visible entry point");
104
104
  assert.match(technical, /## Agent conversation viewer[\s\S]*Attachments, tool calls and results, thinking, stdout\/stderr, filesystem paths, raw session records/i, "the advanced guide should document privacy exclusions");
@@ -22,8 +22,8 @@ function functionSource(source, name) {
22
22
  assert.match(server, /import \{ filterIntercomTranscriptMessages \} from "\.\.\/lib\/intercom-transcript-filter\.mjs";/, "the server should use the dedicated transcript-boundary filter");
23
23
  assert.match(
24
24
  server,
25
- /filterSessionSummaryTranscriptMessages\(filterIntercomTranscriptMessages\(tab\.thinkingStreamRecovery\.applyToMessages\(response\.data\.messages\)\)\)/,
26
- "thinking recovery should complete before Intercom and session-summary records are removed from the normal transcript",
25
+ /filterSessionSummaryTranscriptMessages\(filterIntercomTranscriptMessages\(response\.data\.messages\)\)/,
26
+ "authoritative messages should be filtered without restoring discarded streamed thinking",
27
27
  );
28
28
 
29
29
  assert.match(filter, /message\?\.role === "custom" && message\.customType === INTERCOM_CUSTOM_TYPE/, "persisted intercom_message records should be excluded structurally");
@@ -35,15 +35,14 @@ assert.match(treeTextSource, /entry\.type === "custom_message" && entry\.customT
35
35
  assert.match(treeTextSource, /entry\.type === "custom_message"\) return extractSessionTextContent\(entry\.content\);/, "unrelated custom session-tree entries should retain their normal labels");
36
36
 
37
37
  const toolNameSource = functionSource(app, "isIntercomTransportToolName");
38
- const updateSource = functionSource(app, "isIntercomToolCallUpdate");
39
38
  const eventSource = functionSource(app, "handleEvent");
40
39
  assert.match(toolNameSource, /trim\(\)\.toLowerCase\(\) === "intercom"/, "live filtering should normalize only the explicit Intercom tool name");
41
- assert.match(updateSource, /assistantMessageEvent[\s\S]*assistantToolCallPartFromUpdate[\s\S]*isIntercomTransportToolName/, "streamed tool-call updates should be identified before their arguments render");
42
- assert.match(app, /applyToolCallUpdate: \(event\) => \{[\s\S]*isIntercomToolCallUpdate\(event\)[\s\S]*resetStreamingToolCallState\(\{ remove: true \}\)[\s\S]*handleMessageUpdate\(event\)/, "Intercom stream cards should be discarded while unrelated stream updates keep the normal path");
40
+ assert.match(app, /createToolCallStreamTracker\(\{ isHiddenTool: isIntercomTransportToolName \}\)/, "tool identities must survive snapshot-free deltas by content index");
41
+ assert.match(app, /applyToolCallUpdate: \(event\) => \{[\s\S]*streamToolCalls\.ingest\(event\)[\s\S]*!call\?\.visible[\s\S]*resetStreamingToolCallState\(\{ remove: true \}\)[\s\S]*updateStreamingToolCallFromState\(call\)/, "unknown and Intercom arguments must be withheld before either output mode can render them");
43
42
  assert.match(app, /applyToolExecutionUpdate: \(event\) => \{[\s\S]*!isIntercomTransportToolName\(event\?\.toolName\)[\s\S]*applyTranscriptToolExecutionUpdate\(event\)/, "partial Intercom execution output should never create a live transcript card");
44
43
  assert.match(eventSource, /case "tool_execution_start":[\s\S]*isIntercomTransportToolName\(event\.toolName\)[\s\S]*resetStreamingToolCallState\(\{ remove: true \}\)[\s\S]*break;[\s\S]*handleToolExecutionStart\(event\)/, "Intercom execution starts should bypass normal cards and event-log lines");
45
44
  assert.match(eventSource, /case "tool_execution_end":[\s\S]*isIntercomTransportToolName\(event\.toolName\)[\s\S]*scheduleSemanticReconcile\(\{ messages: true, footerData: true \}, tabContext\)[\s\S]*break;[\s\S]*handleToolExecutionEnd\(event\)/, "Intercom execution completion should refresh filtered messages and conversation tags without rendering results");
46
- assert.doesNotMatch(`${toolNameSource}\n${updateSource}`, /subagent_supervisor|contact_supervisor/, "unrelated supervisor tools should remain outside this narrowly approved filter");
45
+ assert.doesNotMatch(toolNameSource, /subagent_supervisor|contact_supervisor/, "unrelated supervisor tools should remain outside this narrowly approved filter");
47
46
  assert.match(fakePi, /intercomLiveEnabled = process\.env\.FAKE_PI_INTERCOM_LIVE === "1"/, "the live Intercom fixture should be explicitly env-gated");
48
47
  const liveFixtureSource = functionSource(fakePi, "runIntercomLiveScript");
49
48
  assert.match(liveFixtureSource, /LIVE NORMAL OUTPUT VISIBLE/, "the live Intercom fixture should preserve unrelated normal output");
@@ -58,9 +58,9 @@ assert.match(css, /@media \(prefers-reduced-motion: reduce\)[\s\S]*?animation-du
58
58
  assert.match(css, /body\.terminal-tabs-left \.main-output-surface \{ grid-row: 4; \}[\s\S]*body\.terminal-tabs-left \.footer-status-host \{ grid-row: 7; \}[\s\S]*body\.terminal-tabs-left \.context-meter-bar \{ grid-row: 8; \}/, "sidebar tab placement should keep the loading overlay anchored to the footer host");
59
59
  assert.match(css, /body\.subagent-terminal-active \.main-output-surface,[\s\S]*body\.subagent-terminal-active \.main-output-loading,/, "dedicated subagent output should hide the main transcript and its loading status");
60
60
 
61
- assert.match(html, /styles\.css\?v=152/, "the stylesheet cache query should advance");
62
- assert.match(html, /app\.js\?v=183/, "the app cache query should advance");
63
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "the PWA cache identity should advance with browser assets");
61
+ assert.match(html, /styles\.css\?v=154/, "the stylesheet cache query should advance");
62
+ assert.match(html, /app\.js\?v=184/, "the app cache query should advance");
63
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v155"/, "the PWA cache identity should advance with browser assets");
64
64
  assert.match(readme, /Loading conversation history/, "user documentation should describe the plain-language loading feedback");
65
65
  assert.match(development, /main output loading/i, "developer documentation should preserve the request-ownership contract");
66
66
 
@@ -16,9 +16,9 @@ assert.match(app, /import \{ installMiddleButtonDragScroll \} from "\.\/middle-b
16
16
  assert.match(app, /installMiddleButtonDragScroll\(\{[\s\S]*onDirection: \(\{ target, offsetY \}\)[\s\S]*noteChatUserScrollIntent\(\{ type: "middle-drag", deltaY: offsetY \}\)/, "chat auto-scroll direction should feed the existing follow/pause intent state");
17
17
  assert.match(app, /event\?\.type === "middle-drag"\) return event\.deltaY > 0;/, "moving below the press point should be recognized as intent to read later chat output");
18
18
  assert.match(css, /body\.middle-button-auto-scrolling,[\s\S]*cursor: all-scroll !important;[\s\S]*user-select: none !important;/, "active automatic scrolling should expose a directional-scroll affordance and suppress accidental selection");
19
- assert.match(html, /styles\.css\?v=152/, "changed drag-scroll styles should advance the stylesheet revision");
20
- assert.match(html, /app\.js\?v=183/, "changed drag-scroll wiring should advance the app revision");
21
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154";[\s\S]*"\/middle-button-drag-scroll\.mjs"/, "offline PWA installs should refresh and cache the new controller module");
19
+ assert.match(html, /styles\.css\?v=154/, "changed drag-scroll styles should advance the stylesheet revision");
20
+ assert.match(html, /app\.js\?v=184/, "changed drag-scroll wiring should advance the app revision");
21
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v155";[\s\S]*"\/middle-button-drag-scroll\.mjs"/, "offline PWA installs should refresh and cache the new controller module");
22
22
  assert.match(JSON.parse(packageJson).scripts.check, /node --check public\/middle-button-drag-scroll\.mjs/, "the package check should parse the startup-critical controller module");
23
23
 
24
24
  console.log("middle-button-drag-scroll-static.test.mjs passed");
@@ -47,9 +47,9 @@ assert.match(css, /html\[data-tablet-shell="v2"\] \.mobile-shell-nav[\s\S]*?widt
47
47
  assert.match(css, /html\[data-tablet-shell="v2"\] \.mobile-shell-surface[\s\S]*?width: min\(30rem, 72vw\)/, "tablet inspector must be a bounded right-side sheet");
48
48
  assert.match(css, /html\[data-tablet-shell="v2"\] \.file-viewer-pane[\s\S]*?position: fixed[\s\S]*?inset: 0/, "tablet files must default to full-screen replacement");
49
49
  assert.match(css, /and \(pointer: coarse\)[\s\S]*?min-height: 44px/, "coarse tablet pointers must retain the 44px target floor");
50
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "continuity/tablet assets need a coherent cache identity");
51
- assert.match(html, /styles\.css\?v=152/, "tablet CSS must have a coherent HTML revision");
52
- assert.match(html, /app\.js\?v=183/, "continuity app logic must have a coherent HTML revision");
50
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v155"/, "continuity/tablet assets need a coherent cache identity");
51
+ assert.match(html, /styles\.css\?v=154/, "tablet CSS must have a coherent HTML revision");
52
+ assert.match(html, /app\.js\?v=184/, "continuity app logic must have a coherent HTML revision");
53
53
  assert.match(technical, /tabletShell=v2[\s\S]*tabletShell=legacy/, "technical reference should document tablet preview and rollback");
54
54
 
55
55
  console.log("mobile-continuity-tablet-static.test.mjs passed");
@@ -37,9 +37,9 @@ assert.match(pkg.scripts.check, /node --check public\/transcript-renderer\.mjs/,
37
37
  assert.match(server, /STATIC_PUBLIC_FILE_EXTENSIONS[\s\S]*"\.mjs"/, "the server must serve typed startup modules from the public asset boundary");
38
38
  assert.match(serviceWorker, /"\/mobile-shell-state\.mjs"/, "the PWA shell must cache the new startup module");
39
39
  assert.match(serviceWorker, /"\/transcript-renderer\.mjs"/, "the PWA shell must cache the transcript startup module");
40
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "the cache identity must change with the startup graph");
41
- assert.match(html, /styles\.css\?v=152/, "the stylesheet revision must change with mobile/tablet CSS fixes");
42
- assert.match(html, /app\.js\?v=183/, "the app revision must change with continuity/tablet wiring");
40
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v155"/, "the cache identity must change with the startup graph");
41
+ assert.match(html, /styles\.css\?v=154/, "the stylesheet revision must change with mobile/tablet CSS fixes");
42
+ assert.match(html, /app\.js\?v=184/, "the app revision must change with continuity/tablet wiring");
43
43
  assert.match(serviceWorker, /const APP_SHELL_NETWORK_TIMEOUT_MS = 8_000;[\s\S]*?event\.waitUntil\([\s\S]*?cache\.put\(request, response\.clone\(\)\)[\s\S]*?return networkResponse;/, "runtime cache writes must extend the event lifetime without blocking bounded network responses");
44
44
  assert.match(serviceWorker, /MOBILE_NAVIGATION_MESSAGE_TYPE = "pi-webui:navigate:v1"/, "the service worker must use a versioned active-client navigation message");
45
45
  assert.match(serviceWorker, /client\.postMessage\(\{ type: MOBILE_NAVIGATION_MESSAGE_TYPE, target \}\)/, "existing clients must receive only a validated target message");
@@ -60,6 +60,6 @@ assert.match(css, /data-mobile-presentation="essential"/, "Essential presentatio
60
60
  assert.match(css, /html\[data-mobile-shell="v2"\] body\.mobile-keyboard-open \.widget-area,[\s\S]*?\.composer-actions-button \{ display: block !important; \}/, "v2 keyboard mode must keep run widgets and the actions entry available");
61
61
  assert.match(css, /@media \(prefers-reduced-motion: reduce\)/, "reduced-motion behavior is required");
62
62
  assert.match(css, /@media \(forced-colors: active\)/, "forced-color affordances are required");
63
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "browser asset changes need a coherent cache tuple");
63
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v155"/, "browser asset changes need a coherent cache tuple");
64
64
 
65
65
  console.log("mobile-phone-experience-static.test.mjs passed");
@@ -1990,7 +1990,7 @@ assert.match(app, /function visibleThinkingText\(text\)[\s\S]*?trimmed === UNEXP
1990
1990
  assert.match(app, /if \(isThinkingPart\) \{[\s\S]*?visibleThinkingText\(assistantThinkingText\(part\)\)[\s\S]*?if \(thinking\) displayMessages\.push/, "assistant transcript splitting should skip empty or unexposed thinking parts");
1991
1991
  assert.match(app, /message\.role === "thinking"[\s\S]*?visibleThinkingText\(message\.thinking \|\| textFromContent\(message\.content\)\)[\s\S]*?if \(thinkingOutputVisible && thinkingText\) appendThinkingMarkdown\(body, thinkingText\);/, "thinking cards should suppress empty and provider no-thinking placeholder output while rendering visible reasoning as markdown");
1992
1992
  assert.match(app, /function showStreamingThinking\(initialText = ""\)[\s\S]*?if \(initialText && !streamThinking\.textContent\) renderThinkingMarkdown\(streamThinking, initialText\);/, "live thinking should not create a visible placeholder card before content arrives");
1993
- assert.match(app, /function setStreamingThinkingText\(text, \{ complete = false \} = \{\}\)[\s\S]*?const thinking = visibleThinkingText\(text\);[\s\S]*?if \(!thinkingOutputVisible \|\| !thinking\) return false;[\s\S]*?return true;/, "live thinking text setters should ignore empty text instead of clearing or flashing the card");
1993
+ assert.match(app, /function setStreamingThinkingText\(text, \{ complete = false \} = \{\}\)[\s\S]*?if \(!thinking\) \{[\s\S]*?removeLiveTranscriptBubble\(streamThinkingBubble, "thinking-correction"\)/, "explicit empty thinking corrections should remove the draft card");
1994
1994
  assert.match(app, /function syncStreamingThinkingFromUpdate\(event, update, \{ placeholder = "", render = true \} = \{\}\)[\s\S]*?return render \? setStreamingThinkingText\(streamThinkingRawText \|\| placeholder\) : true;/, "incremental thinking sync should only report success after setting visible thinking text");
1995
1995
  assert.doesNotMatch(app, /text \|\| placeholder \|\| streamThinkingBubble/, "partial-message thinking sync should not clear an existing thinking card when a partial carries no visible thinking text");
1996
1996
  assert.match(app, /update\.type === "thinking_start" \|\| update\.type === "thinking_delta"\) \{\s+syncStreamingThinkingFromUpdate\(event, update, \{ render: false \}\);\s+if \(thinkingOutputVisible && streamThinkingRawText\) thinkingStreamRenderScheduler\.request\(\{ complete: false \}\);/, "live thinking deltas should require visible raw thinking text before scheduling a card render");
@@ -1998,7 +1998,7 @@ assert.match(app, /function thinkingDeltaText\(update\) \{[\s\S]*?return visible
1998
1998
  assert.match(app, /const THINKING_VISIBILITY_STORAGE_KEY = "pi-webui-thinking-visible"/, "thinking visibility should persist in browser storage");
1999
1999
  assert.match(app, /function setThinkingOutputVisible\(visible[\s\S]*renderAllMessages\(\{ preserveScroll: true \}\)/, "thinking visibility changes should immediately re-render the transcript");
2000
2000
  assert.match(app, /function assistantStreamingMessage\(event\)/, "live streaming should read the authoritative partial assistant message from RPC events like the TUI");
2001
- assert.match(app, /function syncStreamingThinkingFromUpdate\(event, update[\s\S]*?update\.type === "thinking_end"\) \{[\s\S]*?const fallback = streamingThinkingTextFallback\(event\);[\s\S]*?setStreamThinkingRawText\(fallback, \{ reconcile: true \}\);[\s\S]*?return render \? setStreamingThinkingText\(streamThinkingRawText \|\| placeholder, \{ complete: true \}\) : true;/, "live thinking end should replace deltas with the final partial-message thinking content");
2001
+ assert.match(app, /function syncStreamingThinkingFromUpdate\(event, update[\s\S]*?update\.type === "thinking_end"\) \{[\s\S]*?typeof update\.content === "string"[\s\S]*?setStreamThinkingRawText\(snapshot, \{ reconcile: true \}\);[\s\S]*?setStreamingThinkingText\(streamThinkingRawText, \{ complete: true \}\)/, "live thinking end should respect explicit content, including an empty correction");
2002
2002
  assert.match(app, /function setStreamRawText\(text, \{ reason = "snapshot" \} = \{\}\)[\s\S]*?streamRawText = nextText;[\s\S]*?ensureStreamDerivedOutputState\(\)\.replace\(nextText, \{ reason \}\);/, "live assistant text should synchronize from partial messages through a cache-aware setter");
2003
2003
  assert.match(app, /const TODO_PROGRESS_LINE_REGEX = /, "frontend should recognize live todo progress lines that will be moved into the todo widget");
2004
2004
  assert.match(app, /function stripTodoProgressLines\(text, \{ streaming = false \} = \{\}\)/, "live Assistant output should strip todo-progress lines before rendering final-output text");
@@ -2015,7 +2015,7 @@ assert.match(app, /function handleMessageUpdate\(event\)[\s\S]*?assistantStreamR
2015
2015
  assert.match(app, /const assistantStreamRenderScheduler = createLatestWinsRenderScheduler\(\{\s+render: \(options\) => \{\s+renderStreamingAssistantText\(options\);/, "the assistant stream scheduler should render through the transcript-only sink");
2016
2016
  assert.match(app, /streamToolCallSeen = true;\n\s+suppressStreamingAssistantTextBeforeToolCall\(\);/, "tool-call starts should remove pending assistant text from the live transcript");
2017
2017
  assert.match(app, /function renderStreamingToolCallCard\(\{ scroll = false \} = \{\}\)[\s\S]*?appendMessage\(message, \{ streaming: true, itemKey:[\s\S]*?transcriptRenderer\.ownSurface\(streamToolCallText[\s\S]*?transcriptRenderer\.updateTextSurface\(\{[\s\S]*?text: displayText/, "live tool-call cards should render and update their stable semantic arguments surface in place");
2018
- assert.match(app, /update\.type === "toolcall_delta"[\s\S]*?updateStreamingToolCallFromEvent\(event, \{ appendDelta: true \}\)/, "tool-call deltas should update visible streamed arguments through the transcript-only sink");
2018
+ assert.match(app, /applyToolCallUpdate: \(event\) => \{[\s\S]*?streamToolCalls\.ingest\(event\)[\s\S]*?updateStreamingToolCallFromState\(call\)/, "tool-call deltas should reconstruct indexed state before updating the transcript-only sink");
2019
2019
  assert.match(app, /case "tool_execution_start":[\s\S]*?removeStreamingToolCallCard\(\)[\s\S]*?handleToolExecutionStart\(event\)/, "the streamed tool-call argument card should be removed when the real tool execution card starts");
2020
2020
  assert.doesNotMatch(app, /Preparing tool call:/, "tool-call streaming should no longer show only the static preparing placeholder");
2021
2021
  assert.match(app, /const created = appendMessage\(\{ role: "assistant", title: "final output"/, "live Assistant cards should be created only for final output text without a noisy Assistant label");
@@ -68,7 +68,7 @@ assert.match(server, /STATIC_PUBLIC_FILE_EXTENSIONS[\s\S]*"\.mjs"/, "the server
68
68
  assert.match(serviceWorker, /"\/issue-wizard-state\.mjs"/, "the PWA shell must keep caching the pure wizard module");
69
69
  assert.match(serviceWorker, /"\/issue-bot-client\.mjs"/, "the PWA shell must cache the browser client module");
70
70
  // Intent preserved: changing the public startup graph advances the PWA cache identity.
71
- assert.match(serviceWorker, /pi-webui-pwa-v154/, "the PWA cache name must change with browser wiring updates");
71
+ assert.match(serviceWorker, /pi-webui-pwa-v155/, "the PWA cache name must change with browser wiring updates");
72
72
  assert.match(packageJson, /node --check public\/issue-wizard-state\.mjs/, "the package check must keep syntax-checking the pure wizard module");
73
73
  assert.match(packageJson, /node --check public\/issue-bot-client\.mjs/, "the package check must syntax-check the browser client module");
74
74
 
@@ -60,8 +60,8 @@ assert.match(css, /\.optional-feature-title \{[\s\S]*?flex-direction: column;[\s
60
60
  assert.match(readme, /\+.*initial system prompt[\s\S]*?\+\.\.\..*session is running[\s\S]*?-.*no measured system-prompt text/i, "README should explain the symbols in user language");
61
61
  assert.match(technical, /prompt-impact indicators[\s\S]*?tool schemas and ordinary user or tool messages are not counted/i, "technical reference should state the measurement boundary");
62
62
  assert.match(development, /reports\/pi-default-system-prompt-evaluation\.md[\s\S]*?promptImpact/, "contributor guide should identify the evidence source and catalog field");
63
- assert.match(html, /styles\.css\?v=152/, "indicator styles should advance the stylesheet revision");
64
- assert.match(html, /app\.js\?v=183/, "indicator rendering should advance the app revision");
65
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "browser asset changes should advance the PWA cache identity");
63
+ assert.match(html, /styles\.css\?v=154/, "indicator styles should advance the stylesheet revision");
64
+ assert.match(html, /app\.js\?v=184/, "indicator rendering should advance the app revision");
65
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v155"/, "browser asset changes should advance the PWA cache identity");
66
66
 
67
67
  console.log("optional-feature-prompt-impact-static.test.mjs passed");
@@ -271,8 +271,8 @@ assert.match(
271
271
 
272
272
  // --- Coherent browser asset revisions --------------------------------------
273
273
 
274
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "changed browser assets should advance the PWA cache identity");
275
- assert.match(html, /styles\.css\?v=152/, "the page should request the updated layout stylesheet revision");
276
- assert.match(html, /data-app-src="\/app\.js\?v=183"/, "the boot loader should request the updated app module revision");
274
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v155"/, "changed browser assets should advance the PWA cache identity");
275
+ assert.match(html, /styles\.css\?v=154/, "the page should request the updated layout stylesheet revision");
276
+ assert.match(html, /data-app-src="\/app\.js\?v=184"/, "the boot loader should request the updated app module revision");
277
277
 
278
278
  console.log("persistent-ui-layout-static.test.mjs passed");
@@ -19,8 +19,8 @@ const resizePromptInput = app.slice(resizeStart, resizeEnd);
19
19
  assert.match(css, /#promptInput \{[\s\S]*--prompt-input-block-chrome: calc\(1\.8rem \+ 2px\);[\s\S]*max-height: calc\(6lh \+ var\(--prompt-input-block-chrome\)\);[\s\S]*overflow-y: auto;[\s\S]*overscroll-behavior-y: contain;/, "the prompt should show six complete lines before native vertical scrolling begins");
20
20
  assert.match(resizePromptInput, /input\.style\.height = "auto";[\s\S]*borderTopWidth[\s\S]*borderBottomWidth[\s\S]*naturalHeight = input\.scrollHeight \+ borderBlock[\s\S]*isCapped \? "auto" : "hidden"/, "auto-resizing should include the textarea borders and enable vertical scrolling only after the six-line cap");
21
21
  assert.doesNotMatch(resizePromptInput, /input\.style\.overflowY = "auto";/, "auto-resizing must not force a scrollbar below the six-line cap");
22
- assert.match(html, /styles\.css\?v=152/, "the page should request the six-line prompt stylesheet revision");
23
- assert.match(html, /app\.js\?v=183/, "the page should request the current app revision");
24
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "the PWA cache identity should advance with the prompt scroll assets");
22
+ assert.match(html, /styles\.css\?v=154/, "the page should request the six-line prompt stylesheet revision");
23
+ assert.match(html, /app\.js\?v=184/, "the page should request the current app revision");
24
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v155"/, "the PWA cache identity should advance with the prompt scroll assets");
25
25
 
26
26
  console.log("prompt-input-vertical-scroll-static.test.mjs passed");
@@ -504,8 +504,8 @@ assert.match(css, /@media \(max-width: 720px\), \(max-device-width: 720px\), \(p
504
504
  assert.match(css, /\.questionnaire-options button\s*\{\s*min-height:\s*3\.35rem/, "mobile questionnaire targets must exceed the 44px floor");
505
505
  assert.match(css, /@media \(prefers-reduced-motion: reduce\)\s*\{[\s\S]*?\*, \*::before, \*::after[\s\S]*?transition-duration:\s*1ms !important/, "global reduced-motion rules must cover questionnaire transitions");
506
506
 
507
- assert.match(html, /styles\.css\?v=152/, "questionnaire CSS needs the current stylesheet revision");
508
- assert.match(html, /app\.js\?v=183/, "questionnaire behavior needs the current app revision");
509
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "questionnaire public assets need a coherent PWA cache revision");
507
+ assert.match(html, /styles\.css\?v=154/, "questionnaire CSS needs the current stylesheet revision");
508
+ assert.match(html, /app\.js\?v=184/, "questionnaire behavior needs the current app revision");
509
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v155"/, "questionnaire public assets need a coherent PWA cache revision");
510
510
 
511
511
  console.log("questionnaire-dialog.test.mjs passed");
@@ -57,10 +57,10 @@ assert.match(css, /\.sampling-parameter-control\.unsupported:hover:not\(\.sampli
57
57
  assert.match(css, /\.sampling-parameter-control\.unsupported:focus-visible:not\(\.sampling-tooltip-dismissed\) > \.sampling-parameter-unsupported-tooltip/, "keyboard focus should reveal dismissible unsupported reasons");
58
58
  assert.match(css, /\.sampling-parameter-unsupported-tooltip\.sampling-tooltip-below/, "bounded placement should support flipping below top-edge rows");
59
59
  assert.match(css, /pointer-events: auto;/, "a visible unsupported tooltip should remain pointer-hoverable");
60
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "native-control assets should advance the cache identity");
60
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v155"/, "native-control assets should advance the cache identity");
61
61
  assert.match(serviceWorker, /"\/sampling-parameter-controls\.mjs"/, "the pure sampling module should be part of the offline app shell");
62
- assert.match(html, /styles\.css\?v=152/, "the changed stylesheet should have a new revision");
63
- assert.match(html, /app\.js\?v=183/, "the changed app module should have a new revision");
62
+ assert.match(html, /styles\.css\?v=154/, "the changed stylesheet should have a new revision");
63
+ assert.match(html, /app\.js\?v=184/, "the changed app module should have a new revision");
64
64
 
65
65
  // --- Browser state behavior -------------------------------------------------
66
66
 
@@ -27,8 +27,8 @@ assert.doesNotMatch(layout, /sectionHeightMin|sectionHeightMax|validateSectionHe
27
27
  assert.match(app, /const UI_LAYOUT_SIDE_PANEL_FIELDS = \["placement", "sectionLayout", "collapsedSectionIds", "hiddenSectionIds", "collapsedPanels", "panelWidths"\];/, "the browser durable layout field list should omit section heights");
28
28
  assert.match(app, /function clearRemovedSidePanelSectionHeightState\(\)[\s\S]*localStorage\.removeItem\(REMOVED_SIDE_PANEL_SECTION_HEIGHT_STORAGE_KEY\)[\s\S]*record\.field === "sidePanel" && record\.subfield === "sectionHeights"/, "startup should remove the retired cache and pending mutations");
29
29
  assert.match(app, /clearRemovedSidePanelSectionHeightState\(\);\s*restoreDurableUiLayoutPendingJournal\(\);/, "retired height state should be cleared before pending layout restoration");
30
- assert.match(html, /styles\.css\?v=152/, "removing section resize styles should advance the stylesheet revision");
31
- assert.match(html, /app\.js\?v=183/, "removing section resize behavior should advance the app revision");
32
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "removing browser assets should advance the PWA cache identity");
30
+ assert.match(html, /styles\.css\?v=154/, "removing section resize styles should advance the stylesheet revision");
31
+ assert.match(html, /app\.js\?v=184/, "removing section resize behavior should advance the app revision");
32
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v155"/, "removing browser assets should advance the PWA cache identity");
33
33
 
34
34
  console.log("side-panel-section-height-removal-static.test.mjs passed");
@@ -56,9 +56,11 @@ assert.equal(DEFAULT_STREAM_PENDING_ENTRY_LIMIT, 128);
56
56
  assert.equal(DEFAULT_STREAM_PENDING_BYTE_LIMIT, 256 * 1024);
57
57
  assert.equal(
58
58
  reconcileTranscriptThinkingSnapshot("first\n\nsecond\n\nthird\n\nfourth", "first\n\nsecond\n\nthird"),
59
- "first\n\nsecond\n\nthird\n\nfourth",
60
- "a regressive final thinking snapshot must not remove an already-rendered tail",
59
+ "first\n\nsecond\n\nthird",
60
+ "a final thinking snapshot must remove a discarded streamed tail",
61
61
  );
62
+ assert.equal(reconcileTranscriptThinkingSnapshot("draft", ""), "", "explicit empty thinking clears the draft");
63
+ assert.equal(reconcileTranscriptThinkingSnapshot("draft", undefined), "draft", "missing snapshots retain the draft");
62
64
  assert.equal(reconcileTranscriptThinkingSnapshot("short", "shorter complete"), "shorter complete", "a longer compatible final snapshot should win");
63
65
  assert.equal(reconcileTranscriptThinkingSnapshot("draft reasoning", "provider correction"), "provider correction", "divergent provider corrections must remain authoritative");
64
66
 
@@ -136,8 +136,8 @@ assert.doesNotMatch(styles, /\.chat > \.message:first-of-type \{ margin-top:\s*a
136
136
  assert.match(appendOptimisticUserPrompt, /renderAllMessages\(\);[\s\S]*?scrollChatToBottom\(\{ force:\s*true \}\);/, "submitting a prompt should explicitly resume bottom-follow for the new turn");
137
137
  assert.doesNotMatch(appendOptimisticUserPrompt, /if \(autoFollowChat \|\| isChatNearBottom\(\)\)/, "a paused reader position should not leave a newly submitted turn off-screen");
138
138
  assert.match(app, /import \{[^}]*reconcileTranscriptThinkingSnapshot[^}]*\} from "\.\/stream-output-controller\.mjs";/, "the browser should import the tested thinking-snapshot reconciler");
139
- assert.match(setStreamThinkingRawText, /reconcile\s*\?\s*reconcileTranscriptThinkingSnapshot\(streamThinkingRawText, snapshot\)/, "thinking state should support prefix-safe snapshot reconciliation");
140
- assert.match(syncStreamingThinkingFromUpdate, /update\.type === "thinking_end"[\s\S]*?setStreamThinkingRawText\(delta, \{ reconcile: true \}\)[\s\S]*?setStreamThinkingRawText\(fallback, \{ reconcile: true \}\)/, "thinking_end snapshots and fallbacks must not cut off an already-rendered compatible tail");
139
+ assert.match(setStreamThinkingRawText, /reconcile\s*\?\s*reconcileTranscriptThinkingSnapshot\(streamThinkingRawText, snapshot\)/, "thinking state should use authoritative snapshot reconciliation");
140
+ assert.match(syncStreamingThinkingFromUpdate, /update\.type === "thinking_end"[\s\S]*?typeof update\.content === "string"[\s\S]*?setStreamThinkingRawText\(snapshot, \{ reconcile: true \}\)/, "thinking_end must apply explicit shortened or empty content rather than preserving discarded tails");
141
141
 
142
142
  futureInvariant("theory #1: message_update streaming hot path must not call immediate scroll/layout work", () => {
143
143
  assert.doesNotMatch(handleMessageUpdate, /scrollChatToBottom\s*\(/, "handleMessageUpdate should schedule/coalesce follow-scroll instead of calling scrollChatToBottom() directly");
@@ -28,7 +28,7 @@ assert.match(app, /const SUBAGENT_ASYNC_WIDGET_KEY = "subagent-async"[\s\S]*case
28
28
  assert.match(app, /for \(const \[key, value\] of widgets\)[\s\S]*if \(key === SUBAGENT_ASYNC_WIDGET_KEY\) continue;/, "stale cached async-status widgets should remain hidden defensively");
29
29
  assert.match(css, /\.subagent-source-badge[\s\S]*text-overflow: ellipsis[\s\S]*@media \(max-width: 720px\)/, "source badges should remain compact and responsive");
30
30
  assert.match(html, /Managed and registered Pi agent runs[\s\S]*External agents/, "help should explain managed, registered, and external groups");
31
- assert.match(html, /styles\.css\?v=152[\s\S]*app\.js\?v=183/, "browser assets should use the current subagent-observability revisions");
32
- assert.match(worker, /pi-webui-pwa-v154/, "PWA cache identity should advance with subagent widget suppression");
31
+ assert.match(html, /styles\.css\?v=154[\s\S]*app\.js\?v=184/, "browser assets should use the current subagent-observability revisions");
32
+ assert.match(worker, /pi-webui-pwa-v155/, "PWA cache identity should advance with subagent widget suppression");
33
33
 
34
34
  console.log("subagent-observability-static.test.mjs passed");
@@ -60,9 +60,9 @@ assert.match(css, /\.markdown-code \.syntax-comment \{[^}]*font-style: italic;/,
60
60
 
61
61
  // --- Offline/PWA startup closure and coherent revisions ---
62
62
  assert.match(serviceWorker, /"\/syntax-highlight\.mjs",/, "the eagerly imported tokenizer must be part of the offline app shell");
63
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "adding a startup module should advance the PWA cache identity");
64
- assert.match(html, /styles\.css\?v=152/, "new token styles should advance the stylesheet revision");
65
- assert.match(html, /data-app-src="\/app\.js\?v=183"/, "new renderer wiring should advance the app module revision");
63
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v155"/, "adding a startup module should advance the PWA cache identity");
64
+ assert.match(html, /styles\.css\?v=154/, "new token styles should advance the stylesheet revision");
65
+ assert.match(html, /data-app-src="\/app\.js\?v=184"/, "new renderer wiring should advance the app module revision");
66
66
  assert.match(pkg, /node --check public\/syntax-highlight\.mjs/, "the package check should syntax-check the startup-critical tokenizer");
67
67
 
68
68
  const appShell = serviceWorker.slice(serviceWorker.indexOf("const APP_SHELL"), serviceWorker.indexOf("];", serviceWorker.indexOf("const APP_SHELL")));
@@ -34,7 +34,7 @@ assert.match(html, /role="alert" hidden>[\s\S]*Replace this exact target\?/, "ov
34
34
 
35
35
  assert.match(app, /from "\.\/theme-contract\.mjs"/, "frontend should consume the shared browser-safe theme contract");
36
36
  assert.match(serviceWorker, /"\/theme-contract\.mjs"/, "the PWA app shell should cache the startup-critical theme contract");
37
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v154"/, "adding the theme contract to the startup graph should advance the PWA cache identity");
37
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v155"/, "adding the theme contract to the startup graph should advance the PWA cache identity");
38
38
  assert.match(pkg, /node --check public\/theme-contract\.mjs/, "the package check should syntax-check the startup-critical theme contract");
39
39
  assert.match(app, /function themeDraftFromCatalog\(theme, name = theme\?\.name\)[\s\S]*colors: cloneThemeDraft\(theme\?\.colors \|\| \{\}\)/, "catalog metadata should be projected into a schema-only editable draft");
40
40
  assert.match(app, /for \(const \{ name, label \} of group\.tokens\)/, "visual controls should render from the exact shared token inventory");