@firstpick/pi-package-webui 0.9.5 → 0.9.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 (61) hide show
  1. package/README.md +5 -3
  2. package/bin/pi-webui.mjs +90 -5
  3. package/lib/optional-feature-catalog.mjs +1 -1
  4. package/lib/session-actions.mjs +20 -2
  5. package/package.json +1 -1
  6. package/public/app.js +1823 -262
  7. package/public/index.html +51 -31
  8. package/public/service-worker.js +4 -1
  9. package/public/stream-derived-output.mjs +799 -0
  10. package/public/stream-markdown-tail.mjs +204 -0
  11. package/public/stream-output-controller.mjs +193 -51
  12. package/public/stream-render-scheduler.mjs +85 -0
  13. package/public/styles.css +249 -18
  14. package/public/transcript-renderer.mjs +73 -24
  15. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  16. package/tests/browser/composer-action-grid-reorder.spec.mjs +114 -31
  17. package/tests/browser/mobile-foundation.spec.mjs +28 -0
  18. package/tests/browser/stream-output-isolation.spec.mjs +308 -3
  19. package/tests/browser/user-noticeable-fixes.spec.mjs +204 -0
  20. package/tests/codex-fast-mode-static.test.mjs +2 -2
  21. package/tests/composer-action-grid-reorder-static.test.mjs +8 -7
  22. package/tests/control-visibility-static.test.mjs +3 -3
  23. package/tests/controls-layout-static.test.mjs +3 -3
  24. package/tests/cwd-footer-reliability-static.test.mjs +1 -1
  25. package/tests/fast-mode-client-static.test.mjs +1 -1
  26. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  27. package/tests/file-viewer-image-static.test.mjs +3 -3
  28. package/tests/fixtures/fake-pi.mjs +57 -10
  29. package/tests/fixtures/streaming-workloads.mjs +36 -0
  30. package/tests/footer-provider-usage-visual-static.test.mjs +15 -0
  31. package/tests/foreground-transcript-catch-up-static.test.mjs +7 -1
  32. package/tests/interaction-state-stability-static.test.mjs +3 -1
  33. package/tests/intercom-conversation-viewer-static.test.mjs +3 -3
  34. package/tests/intercom-conversations-http.test.mjs +16 -0
  35. package/tests/main-output-loading-static.test.mjs +3 -3
  36. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  37. package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
  38. package/tests/mobile-foundation-static.test.mjs +3 -3
  39. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  40. package/tests/mobile-static.test.mjs +74 -63
  41. package/tests/open-issue-wizard-static.test.mjs +1 -1
  42. package/tests/persistent-ui-layout-static.test.mjs +4 -4
  43. package/tests/prompt-input-vertical-scroll-static.test.mjs +26 -0
  44. package/tests/questionnaire-dialog.test.mjs +3 -3
  45. package/tests/runtime-error-visibility.test.mjs +3 -3
  46. package/tests/session-auth-harness.test.mjs +26 -1
  47. package/tests/session-sampling-ui-static.test.mjs +3 -3
  48. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  49. package/tests/stream-derived-output.test.mjs +121 -0
  50. package/tests/stream-markdown-tail.test.mjs +218 -0
  51. package/tests/stream-output-controller.test.mjs +119 -4
  52. package/tests/stream-output-isolation-static.test.mjs +27 -6
  53. package/tests/stream-output-workloads.test.mjs +40 -3
  54. package/tests/stream-render-scheduler.test.mjs +115 -0
  55. package/tests/streaming-ui-coupling.test.mjs +1 -1
  56. package/tests/subagent-observability-static.test.mjs +2 -2
  57. package/tests/syntax-highlighting-static.test.mjs +3 -3
  58. package/tests/theme-customizer-static.test.mjs +1 -1
  59. package/tests/thinking-format-parser.test.mjs +15 -0
  60. package/tests/todo-filter-static.test.mjs +148 -0
  61. package/tests/transcript-markdown-tail.test.mjs +137 -0
@@ -0,0 +1,204 @@
1
+ import { spawn } from "node:child_process";
2
+ import { createServer } from "node:net";
3
+ import { mkdtemp, rm } from "node:fs/promises";
4
+ import { tmpdir } from "node:os";
5
+ import { dirname, join } from "node:path";
6
+ import { setTimeout as delay } from "node:timers/promises";
7
+ import { fileURLToPath } from "node:url";
8
+ import assert from "node:assert/strict";
9
+ import { expect, test } from "@playwright/test";
10
+
11
+ // Browser coverage for plans/planned/webui-user-noticeable-improvements.md.
12
+
13
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
14
+ const serverScript = join(root, "bin", "pi-webui.mjs");
15
+ const fakePi = join(root, "tests", "fixtures", "fake-pi.mjs");
16
+
17
+ async function freePort() {
18
+ const server = createServer();
19
+ await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
20
+ const { port } = server.address();
21
+ await new Promise((resolve) => server.close(resolve));
22
+ return port;
23
+ }
24
+
25
+ let child;
26
+ let baseURL;
27
+ let tempRoot;
28
+ let output = "";
29
+
30
+ test.beforeAll(async () => {
31
+ const port = await freePort();
32
+ tempRoot = await mkdtemp(join(tmpdir(), "pi-webui-user-noticeable-"));
33
+ baseURL = `http://127.0.0.1:${port}`;
34
+ child = spawn(process.execPath, [serverScript, "--cwd", tempRoot, "--host", "127.0.0.1", "--port", String(port), "--pi", fakePi], {
35
+ stdio: ["ignore", "pipe", "pipe"],
36
+ env: {
37
+ ...process.env,
38
+ PI_WEBUI_RPC_SUPERVISOR: "0",
39
+ PI_CODING_AGENT_DIR: join(tempRoot, "agent"),
40
+ PI_WEBUI_SETTINGS_FILE: join(tempRoot, "settings.json"),
41
+ },
42
+ });
43
+ child.stdout.on("data", (chunk) => { output += String(chunk); });
44
+ child.stderr.on("data", (chunk) => { output += String(chunk); });
45
+ for (let attempt = 0; attempt < 80; attempt += 1) {
46
+ if (child.exitCode !== null) break;
47
+ try {
48
+ const response = await fetch(`${baseURL}/api/health`, { signal: AbortSignal.timeout(500) });
49
+ if (response.ok) return;
50
+ } catch {
51
+ // Wait for the local server and fake Pi fixture.
52
+ }
53
+ await delay(100);
54
+ }
55
+ throw new Error(`Pi Web UI did not start:\n${output}`);
56
+ });
57
+
58
+ test.afterAll(async () => {
59
+ child?.kill("SIGTERM");
60
+ if (child) await new Promise((resolve) => child.once("exit", resolve));
61
+ await rm(tempRoot, { recursive: true, force: true });
62
+ });
63
+
64
+ async function layoutMetrics(page) {
65
+ return page.evaluate(() => {
66
+ const workspace = document.querySelector(".workspace-column").getBoundingClientRect();
67
+ const prompt = document.querySelector("#promptInput").getBoundingClientRect();
68
+ return {
69
+ bodyClasses: document.body.className,
70
+ gridColumns: getComputedStyle(document.querySelector("main.layout")).gridTemplateColumns,
71
+ workspaceWidth: workspace.width,
72
+ promptWidth: prompt.width,
73
+ viewportWidth: window.innerWidth,
74
+ };
75
+ });
76
+ }
77
+
78
+ // P0-1: with the Control Deck collapsed in overlay presentation (phones, tablets, laptops <= 1050px)
79
+ // the workspace must take the full viewport width instead of collapsing to a few pixels.
80
+ for (const viewport of [{ width: 390, height: 844 }, { width: 820, height: 1180 }, { width: 1024, height: 700 }]) {
81
+ test(`overlay presentation keeps the workspace full-width at ${viewport.width}px`, async ({ page }) => {
82
+ await page.setViewportSize(viewport);
83
+ await page.goto(baseURL);
84
+ await expect(page.locator("#promptInput")).toBeVisible();
85
+ await expect.poll(async () => (await layoutMetrics(page)).bodyClasses).toContain("control-deck-overlay");
86
+ const metrics = await layoutMetrics(page);
87
+ assert.ok(metrics.bodyClasses.includes("side-panel-collapsed"), `overlay deck should start collapsed: ${metrics.bodyClasses}`);
88
+ assert.ok(metrics.workspaceWidth >= metrics.viewportWidth * 0.9, `workspace should fill the viewport: ${JSON.stringify(metrics)}`);
89
+ assert.ok(metrics.promptWidth >= metrics.viewportWidth * 0.6, `prompt should be usable: ${JSON.stringify(metrics)}`);
90
+ });
91
+ }
92
+
93
+ // P0-2: native selector dialogs (/model, /theme, /resume, …) — Enter in the filter selects the
94
+ // highlighted choice instead of closing the dialog; arrows move the highlight; the current
95
+ // choice is highlighted when unfiltered.
96
+ test("model selector supports Enter-to-select and arrow-key navigation from the filter box", async ({ page }) => {
97
+ await page.setViewportSize({ width: 1280, height: 800 });
98
+ const models = [
99
+ { provider: "fake", id: "fake-model", name: "Fake Model" },
100
+ { provider: "fake", id: "alpha-one", name: "Alpha One" },
101
+ { provider: "fake", id: "beta-two", name: "Beta Two" },
102
+ { provider: "other", id: "gamma-three", name: "Gamma Three" },
103
+ ];
104
+ await page.route("**/api/models*", async (route) => {
105
+ await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, data: { models } }) });
106
+ });
107
+ const setModelCalls = [];
108
+ await page.route(/\/api\/model(\?.*)?$/, async (route) => {
109
+ setModelCalls.push(route.request().postDataJSON());
110
+ await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, data: route.request().postDataJSON() }) });
111
+ });
112
+ await page.goto(baseURL);
113
+ await expect(page.locator("#promptInput")).toBeVisible();
114
+
115
+ await page.keyboard.press("Control+l");
116
+ const dialog = page.locator("#nativeCommandDialog");
117
+ await expect(dialog).toBeVisible();
118
+ const search = page.locator("#nativeCommandSearch");
119
+ await expect(search).toBeFocused();
120
+ await expect(page.locator("#nativeCommandBody .native-selector-item")).toHaveCount(4);
121
+ // The current model is highlighted before any filtering.
122
+ await expect(page.locator("#nativeCommandBody .native-selector-item.keyboard-active")).toContainText("fake/fake-model");
123
+
124
+ await page.keyboard.press("ArrowDown");
125
+ await expect(page.locator("#nativeCommandBody .native-selector-item.keyboard-active")).toContainText("fake/alpha-one");
126
+ await expect(search).toHaveAttribute("aria-activedescendant", /nativeSelectorItem-1/);
127
+ await page.keyboard.press("End");
128
+ await expect(page.locator("#nativeCommandBody .native-selector-item.keyboard-active")).toContainText("other/gamma-three");
129
+
130
+ await search.fill("beta");
131
+ await expect(page.locator("#nativeCommandBody .native-selector-item")).toHaveCount(1);
132
+ await expect(page.locator("#nativeCommandBody .native-selector-item.keyboard-active")).toContainText("fake/beta-two");
133
+ await page.keyboard.press("Enter");
134
+ await expect(dialog).toBeHidden();
135
+ assert.deepEqual(setModelCalls, [{ provider: "fake", modelId: "beta-two" }], "Enter should select the highlighted model");
136
+ });
137
+
138
+ // P0-3: Enter accepts the highlighted slash suggestion instead of sending the partial token;
139
+ // once the token equals the suggestion, Enter sends as usual.
140
+ test("Enter accepts the highlighted slash suggestion before sending", async ({ page }) => {
141
+ await page.setViewportSize({ width: 1280, height: 800 });
142
+ await page.goto(baseURL);
143
+ const prompt = page.locator("#promptInput");
144
+ await expect(prompt).toBeVisible();
145
+ await prompt.click();
146
+ await page.keyboard.type("/work");
147
+ const suggest = page.locator("#commandSuggest");
148
+ await expect(suggest).toBeVisible();
149
+ await expect(suggest.locator(".command-suggest-item").first()).toContainText("/workflow");
150
+ await expect(suggest.locator(".command-suggest-hint")).toContainText("Enter or Tab accept");
151
+ await page.keyboard.press("Enter");
152
+ await expect(prompt).toHaveValue("/workflow ");
153
+ await expect(suggest).toBeHidden();
154
+ // Nothing was sent: the transcript has no user message for the partial token.
155
+ await expect(page.locator("#chat")).not.toContainText("/work\n");
156
+ });
157
+
158
+ // P0-5: warnings/errors that used to land only in the collapsed Events log now surface as a
159
+ // non-blocking toast and increment an unread badge on the Events section header.
160
+ test("errors surface as a toast and an Events unread badge", async ({ page }) => {
161
+ await page.setViewportSize({ width: 1440, height: 900 });
162
+ await page.route(/\/api\/tabs(\?.*)?$/, async (route) => {
163
+ if (route.request().method() !== "POST") return route.fallback();
164
+ await route.fulfill({ status: 500, contentType: "application/json", body: JSON.stringify({ ok: false, error: "tab spawn exploded" }) });
165
+ });
166
+ await page.goto(baseURL);
167
+ await expect(page.locator("#promptInput")).toBeVisible();
168
+ await expect(page.locator("#eventsUnreadBadge")).toBeHidden();
169
+
170
+ // Palette → "New tab" fails server-side; previously this only wrote to the collapsed Events log.
171
+ await page.keyboard.press("Control+k");
172
+ await page.locator("#commandPaletteInput").fill("New tab");
173
+ await page.keyboard.press("Enter");
174
+ const toast = page.locator("#noticeToastStack .notice-toast.error");
175
+ await expect(toast.first()).toContainText("tab spawn exploded");
176
+ await expect(page.locator("#eventsUnreadBadge")).toBeVisible();
177
+ await expect(page.locator("#eventsUnreadBadge")).toHaveText("1");
178
+
179
+ // "Events" on the toast opens the Control Deck Events section and clears the unread badge.
180
+ await toast.first().locator(".notice-toast-events").click();
181
+ await expect(page.locator("#sidePanelSectionEvents")).toBeVisible();
182
+ await expect(page.locator("#eventsUnreadBadge")).toBeHidden();
183
+ await expect(page.locator("#eventLog .event.error").first()).toContainText("tab spawn exploded");
184
+ });
185
+
186
+ // P1-1: hover/focus-opened composer menus close on Escape even while the trigger keeps focus
187
+ // (previously the panel stayed visible because :focus-within re-opened it immediately).
188
+ test("Escape closes the composer options menu while its trigger keeps focus", async ({ page }) => {
189
+ await page.setViewportSize({ width: 1440, height: 900 });
190
+ await page.goto(baseURL);
191
+ await expect(page.locator("#promptInput")).toBeVisible();
192
+ const trigger = page.locator("#optionsMenuButton");
193
+ const panel = page.locator("#optionsMenu");
194
+ await trigger.click();
195
+ await expect(panel).toBeVisible();
196
+ await page.keyboard.press("Escape");
197
+ await expect(panel).toBeHidden();
198
+ await expect(trigger).toBeFocused();
199
+ // Explicit click reopens it.
200
+ await trigger.click();
201
+ await expect(panel).toBeVisible();
202
+ await page.keyboard.press("Escape");
203
+ await expect(panel).toBeHidden();
204
+ });
@@ -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-v115/, "PWA cache identity should be bumped for changed browser assets");
59
- assert.match(html, /data-app-src="\/app\.js\?v=150"/, "browser module URL should be cache-busted for Fast-mode wiring");
58
+ assert.match(serviceWorker, /pi-webui-pwa-v123/, "PWA cache identity should be bumped for changed browser assets");
59
+ assert.match(html, /data-app-src="\/app\.js\?v=157"/, "browser module URL should be cache-busted for Fast-mode wiring");
60
60
 
61
61
  console.log("codex-fast-mode-static.test.mjs passed");
@@ -30,14 +30,14 @@ assert.match(html, /id="composerActionOrderStatus"[^>]*role="status"[^>]*aria-li
30
30
 
31
31
  assert.match(
32
32
  css,
33
- /body\.composer-action-grid-enabled \.composer-row\s*\{[\s\S]*--composer-action-cell-min-width:\s*3\.2rem[\s\S]*display:\s*grid[\s\S]*grid-template-columns:\s*repeat\(auto-fill, minmax\(var\(--composer-action-cell-min-width\), 1fr\)\)[\s\S]*grid-auto-flow:\s*dense/,
34
- "the desktop composer should use wider dense responsive grid cells",
33
+ /body\.composer-action-grid-enabled \.composer-row\s*\{[\s\S]*--composer-action-cell-min-width:\s*3\.2rem[\s\S]*display:\s*grid[\s\S]*grid-template-columns:\s*repeat\(auto-fill, var\(--composer-action-cell-min-width\)\)[\s\S]*grid-auto-flow:\s*dense/,
34
+ "the desktop composer should use fixed-width dense grid cells",
35
35
  );
36
36
  assert.match(css, /grid-column:\s*var\(--composer-action-grid-column, auto\) \/ span var\(--composer-action-grid-span\)/, "actions should support explicit sparse grid columns");
37
37
  assert.match(css, /\[data-composer-action-span="2"\]\s*\{\s*--composer-action-grid-span:\s*2;/, "wide actions should span exactly two cells");
38
38
  assert.match(css, /body\.composer-action-grid-enabled \.composer-row \[data-composer-action-id\]\.composer-publish-menu:hover,[\s\S]*\.composer-publish-menu:focus-within,[\s\S]*\.composer-publish-menu\.open \{\s*z-index:\s*100;/, "open composer dropdowns should stack above prompt tags and neighboring grid controls");
39
39
  assert.match(css, /#newSessionButton\s*\{[\s\S]*display:\s*grid[\s\S]*place-items:\s*center[\s\S]*padding-inline:\s*0\.4rem[\s\S]*text-align:\s*center/, "New should center its label inside the one-cell button");
40
- assert.match(css, /composer-action-drag-active[\s\S]*composer-action-grid-guide:not\(\[hidden\]\)[\s\S]*position:\s*absolute[\s\S]*inset:\s*0[\s\S]*grid-template-columns:\s*repeat\(auto-fill, minmax\(var\(--composer-action-cell-min-width\), 1fr\)\)[\s\S]*gap:\s*0\.5rem/, "the drag-only guide should cover the complete composer row with the same responsive tracks");
40
+ assert.match(css, /composer-action-drag-active[\s\S]*composer-action-grid-guide:not\(\[hidden\]\)[\s\S]*position:\s*absolute[\s\S]*inset:\s*0[\s\S]*grid-template-columns:\s*repeat\(auto-fill, var\(--composer-action-cell-min-width\)\)[\s\S]*gap:\s*0\.5rem/, "the drag-only guide should cover the complete composer row with the same responsive tracks");
41
41
  assert.match(css, /\.composer-action-grid-cell\s*\{[\s\S]*min-width:\s*0[\s\S]*border:[\s\S]*background:/, "empty guide cells should render as full grid cells");
42
42
  assert.match(css, /composer-action-dragging[\s\S]*cursor:\s*grabbing[\s\S]*composer-action-drag-before[\s\S]*composer-action-drag-after/, "dragging and occupied drop targets should have visible affordances");
43
43
  assert.match(css, /composer-action-grid-cell-target[\s\S]*border-color:\s*var\(--ctp-teal\)/, "empty-cell drop targets should have a visible affordance");
@@ -48,7 +48,8 @@ assert.match(app, /function applyComposerActionOrder\(orderIds\)[\s\S]*knownIds[
48
48
  assert.match(app, /function showComposerActionGridGuide\(\)[\s\S]*composerActionGridColumnCount\(\)[\s\S]*top - groups\.at\(-1\) > 4[\s\S]*columnCount \* rowCount[\s\S]*composer-action-drag-active[\s\S]*function hideComposerActionGridGuide/, "dragging should materialize every full-row guide cell without splitting near-equal action tops into false rows");
49
49
  assert.match(app, /function composerActionGridColumnCount\(\)[\s\S]*--composer-action-cell-min-width[\s\S]*row\.clientWidth[\s\S]*Math\.floor\(\(availableWidth \+ gap\) \/ \(minWidth \+ gap\)\)/, "column counts should derive from the visible row width instead of overflow-created implicit tracks");
50
50
  assert.match(app, /function readStoredComposerActionLayout\(\)[\s\S]*COMPOSER_ACTION_LAYOUT_STORAGE_KEY[\s\S]*function composerActionSlotCanFit[\s\S]*function persistComposerActionSlotLayout[\s\S]*positions:\s*Object\.fromEntries/, "sparse cell positions should be validated and persisted independently from order");
51
- assert.match(app, /function remapComposerActionSlot\(record, slot, sourceColumns, targetColumns\)[\s\S]*relativeColumn[\s\S]*function nearestAvailableComposerActionSlot[\s\S]*function restoreComposerActionSlotLayout\(\)[\s\S]*stored\.columns === columns[\s\S]*remapComposerActionSlot/, "saved sparse positions should project into changed responsive grid widths instead of being cleared");
51
+ assert.match(app, /function projectComposerActionSlots\(entries, sourceColumns, targetColumns\)[\s\S]*continuesChunk[\s\S]*targetColumns - chunkWidth[\s\S]*lastTargetRow[\s\S]*projected\.set[\s\S]*function nearestAvailableComposerActionSlot[\s\S]*function restoreComposerActionSlotLayout\(\)[\s\S]*projectComposerActionSlots/, "saved sparse positions should project contiguous action groups without changing their visual order");
52
+ assert.doesNotMatch(app, /relativeColumn|remapComposerActionSlot/, "composer width changes must not proportionally or independently remap saved action columns");
52
53
  assert.doesNotMatch(app, /if \(!stored \|\| stored\.columns !== columns\)/, "column-count changes should not discard saved sparse positions");
53
54
  assert.match(app, /function captureComposerActionSlotLayout\(\)[\s\S]*composerActionGridGuide[\s\S]*function moveComposerActionToGridCell\(actionId, cell\)[\s\S]*composerActionSlotCanFit[\s\S]*composer-action-grid-cell-target/, "empty grid cells should capture and retain exact action slots");
54
55
  assert.match(app, /function composerActionRootFromPoint\(clientX, clientY\)[\s\S]*elementFromPoint[\s\S]*function updateComposerActionPointerDrag\(event\)[\s\S]*Math\.hypot[\s\S]*COMPOSER_ACTION_POINTER_DRAG_THRESHOLD_PX[\s\S]*showComposerActionGridGuide\(\)[\s\S]*captureComposerActionSlotLayout\(\)[\s\S]*composerActionGridCellFromPoint[\s\S]*moveComposerActionToGridCell/, "pointer dragging should activate after the threshold and distinguish occupied from empty grid cells");
@@ -56,8 +57,8 @@ assert.match(app, /function initializeComposerActionOrdering\(\)[\s\S]*MutationO
56
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");
57
58
  assert.match(app, /initializeComposerActionOrdering\(\);[\s\S]*restoreSidePanelSectionOrder\(\);/, "composer ordering should initialize during guarded app startup");
58
59
 
59
- assert.match(html, /styles\.css\?v=129/, "changed composer styles should advance the stylesheet revision");
60
- assert.match(html, /app\.js\?v=150/, "changed composer behavior should advance the app revision");
61
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v115"/, "changed browser assets should advance the PWA cache identity");
60
+ assert.match(html, /styles\.css\?v=132/, "changed composer styles should advance the stylesheet revision");
61
+ assert.match(html, /app\.js\?v=157/, "changed composer behavior should advance the app revision");
62
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v123"/, "changed browser assets should advance the PWA cache identity");
62
63
 
63
64
  console.log("composer-action-grid-reorder-static.test.mjs passed");
@@ -285,10 +285,10 @@ assert.match(
285
285
 
286
286
  assert.match(
287
287
  serviceWorker,
288
- /const CACHE_NAME = "pi-webui-pwa-v115";/,
288
+ /const CACHE_NAME = "pi-webui-pwa-v123";/,
289
289
  "browser asset changes should advance the PWA cache identity",
290
290
  );
291
- assert.match(html, /styles\.css\?v=129/, "visibility styles should advance the stylesheet query revision");
292
- assert.match(html, /data-app-src="\/app\.js\?v=150"/, "visibility behavior should advance the app query revision");
291
+ assert.match(html, /styles\.css\?v=132/, "visibility styles should advance the stylesheet query revision");
292
+ assert.match(html, /data-app-src="\/app\.js\?v=157"/, "visibility behavior should advance the app query revision");
293
293
 
294
294
  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=129/, "Controls stylesheet changes should advance the cache query");
19
- assert.match(html, /app\.js\?v=150/, "Controls tooltip wiring should advance the app cache query");
20
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v115"/, "Controls browser assets should advance the PWA cache identity");
18
+ assert.match(html, /styles\.css\?v=132/, "Controls stylesheet changes should advance the cache query");
19
+ assert.match(html, /app\.js\?v=157/, "Controls tooltip wiring should advance the app cache query");
20
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v123"/, "Controls browser assets should advance the PWA cache identity");
21
21
 
22
22
  console.log("controls-layout-static.test.mjs passed");
@@ -53,7 +53,7 @@ assert.match(
53
53
  );
54
54
  assert.match(
55
55
  app,
56
- /const validPayload = !!parseGitFooterWebuiPayloadRaw\(request\.statusText\);[\s\S]*?validPayload \? "ready" : "failed"/,
56
+ /const footerPayload = parseGitFooterWebuiPayloadRaw\(request\.statusText\);[\s\S]*?const validPayload = !!footerPayload;[\s\S]*?validPayload \? "ready" : "failed"/,
57
57
  "a later valid live payload should recover failed or waiting footer state",
58
58
  );
59
59
  assert.match(
@@ -156,7 +156,7 @@ assert.match(worker, /pi-webui-pwa-v\d+[\s\S]*?"\/fast-output-live\.mjs"/, "PWA
156
156
  assert.match(html, /<label for="fastOutputModeSelect">Compact mode \(Experimental\)<\/label>/, "the sidebar should mark compact mode as experimental");
157
157
  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");
158
158
  // Intent preserved: the guarded PWA entry point must advance whenever app wiring changes.
159
- assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=150"/, "the guarded PWA entry point should cache-bust browser wiring");
159
+ assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=157"/, "the guarded PWA entry point should cache-bust browser wiring");
160
160
  assert.match(JSON.parse(packageRaw).scripts.check, /node --check public\/fast-output-live\.mjs/, "package checks should parse the compact helper");
161
161
 
162
162
  const events = createFastModeOutputEvents();
@@ -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=129/, "integrated stylesheet changes should advance the cache query");
170
- assert.match(html, /\/app\.js\?v=150/, "integrated app changes should advance the cache query");
169
+ assert.match(html, /\/styles\.css\?v=132/, "integrated stylesheet changes should advance the cache query");
170
+ assert.match(html, /\/app\.js\?v=157/, "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-v115"/, "changed viewer assets should advance the PWA cache identity");
66
- assert.match(html, /styles\.css\?v=129/, "changed image styles should advance the stylesheet revision");
67
- assert.match(html, /app\.js\?v=150/, "changed image rendering should advance the app revision");
65
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v123"/, "changed viewer assets should advance the PWA cache identity");
66
+ assert.match(html, /styles\.css\?v=132/, "changed image styles should advance the stylesheet revision");
67
+ assert.match(html, /app\.js\?v=157/, "changed image rendering should advance the app revision");
68
68
 
69
69
  console.log("file viewer image static tests passed");
@@ -30,6 +30,7 @@ import {
30
30
  resolveSamplingParameterCapabilities,
31
31
  } from "../../lib/sampling-parameter-capabilities.mjs";
32
32
  import { validateSamplingParameterObject } from "../../public/sampling-parameter-controls.mjs";
33
+ import { longTranscriptMessages } from "./streaming-workloads.mjs";
33
34
 
34
35
  const sessionIndex = process.argv.indexOf("--session");
35
36
  const sessionFile = sessionIndex !== -1
@@ -119,6 +120,7 @@ let scriptedStreaming = false;
119
120
  let continuityRun = 0;
120
121
  let streamIsolationRun = 0;
121
122
  const pendingStreamIsolationRuns = new Map();
123
+ let streamIsolationLongTranscriptPopulated = false;
122
124
  let largeTranscriptEnabled = false;
123
125
  const fixtureSubagentRuns = [];
124
126
  const fixtureSubagentGates = [];
@@ -931,7 +933,13 @@ function handleFastModeFixturePrompt(command, base) {
931
933
  return true;
932
934
  }
933
935
 
934
- function streamIsolationTextDelta(index) {
936
+ function streamIsolationTextDelta(index, scenario = "standard") {
937
+ if (scenario === "long-transcript") {
938
+ const line = `const v${String(index).padStart(4, "0")} = ${index};\n`;
939
+ if (index === 0) return `\`\`\`js\n${line}`;
940
+ if (index === 999) return `${line}\`\`\`\nLONG-STREAM-TAIL`;
941
+ return line;
942
+ }
935
943
  const digit = String(index % 10);
936
944
  if (index === 0) return `ISOLATION-TEXT-BEGIN ${digit}`;
937
945
  if (index === 999) return `${digit} ISOLATION-TEXT-TAIL`;
@@ -942,11 +950,19 @@ function logStreamIsolationPhase(runId, mode, scenario, phase) {
942
950
  logJsonLine({ direction: "isolation-phase", isolationRunId: runId, isolationMode: mode, isolationScenario: scenario, isolationPhase: phase });
943
951
  }
944
952
 
953
+ function ensureStreamIsolationLongTranscript() {
954
+ if (streamIsolationLongTranscriptPopulated) return 1000;
955
+ for (const message of longTranscriptMessages(1000)) appendDynamicMessage(message);
956
+ streamIsolationLongTranscriptPopulated = true;
957
+ return 1000;
958
+ }
959
+
945
960
  function runStreamIsolationFixtureFlow(mode, scenario = "standard") {
946
961
  const runId = `stream-isolation-${mode}-${scenario}-${++streamIsolationRun}`;
962
+ const retainedMessageCount = scenario === "long-transcript" ? ensureStreamIsolationLongTranscript() : 0;
947
963
  const toolCallId = `${runId}-execution`;
948
964
  const streamedToolCallId = `${runId}-call`;
949
- const textDeltas = Array.from({ length: 1_000 }, (_, index) => streamIsolationTextDelta(index));
965
+ const textDeltas = Array.from({ length: 1_000 }, (_, index) => streamIsolationTextDelta(index, scenario));
950
966
  const finalText = textDeltas.join("");
951
967
  const thinkingText = "ISOLATION-THINKING-PATH";
952
968
  const toolCall = { type: "toolCall", id: streamedToolCallId, name: "read", arguments: { path: "isolation.txt" } };
@@ -993,7 +1009,30 @@ function runStreamIsolationFixtureFlow(mode, scenario = "standard") {
993
1009
  emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "thinking_end", delta: thinkingText } }, "raw"));
994
1010
  },
995
1011
  },
996
- {
1012
+ ];
1013
+
1014
+ if (scenario === "paced-pressure") {
1015
+ for (let start = 0; start < 1_000; start += 10) {
1016
+ const end = start + 10;
1017
+ steps.push({
1018
+ afterMs: start === 0 ? 100 : 8,
1019
+ run: () => {
1020
+ emitTextRange(start, end);
1021
+ if (end !== 1_000) return;
1022
+ // Alternating kinds intentionally defeat adjacent coalescing. The
1023
+ // final text_end snapshot remains authoritative, so this pressure
1024
+ // phase can exercise queue bounds without changing settled output.
1025
+ for (let pressureIndex = 0; pressureIndex < 260; pressureIndex += 1) {
1026
+ emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "thinking_delta", delta: "p" } }, "pressure"));
1027
+ emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "text_delta", contentIndex: 1, delta: "x" } }, "pressure"));
1028
+ }
1029
+ emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "text_end", contentIndex: 1, text: finalText } }, "raw"));
1030
+ logStreamIsolationPhase(runId, mode, scenario, "text-complete");
1031
+ },
1032
+ });
1033
+ }
1034
+ } else {
1035
+ steps.push({
997
1036
  afterMs: 100,
998
1037
  run: () => {
999
1038
  if (scenario === "abort") {
@@ -1004,8 +1043,8 @@ function runStreamIsolationFixtureFlow(mode, scenario = "standard") {
1004
1043
  logStreamIsolationPhase(runId, mode, scenario, "text-complete");
1005
1044
  }
1006
1045
  },
1007
- },
1008
- ];
1046
+ });
1047
+ }
1009
1048
 
1010
1049
  if (scenario === "abort") {
1011
1050
  // Keep a deterministic partial stream pending long enough for the browser
@@ -1057,7 +1096,10 @@ function runStreamIsolationFixtureFlow(mode, scenario = "standard") {
1057
1096
  }
1058
1097
  completionSteps.push(
1059
1098
  {
1060
- afterMs: 1_200,
1099
+ // Keep the expensive long-transcript stream live long enough for the
1100
+ // browser ledger and continuity assertions to sample it before the
1101
+ // authoritative settlement replaces the transient bubble.
1102
+ afterMs: scenario === "long-transcript" ? 15_000 : 1_200,
1061
1103
  run: () => {
1062
1104
  emitScriptedEvent(tagged({ type: "tool_execution_end", toolCallId, toolName: "read", isError: false, result: { content: [{ type: "text", text: "ISOLATION-TOOL-RESULT" }] } }, "post-burst"));
1063
1105
  logStreamIsolationPhase(runId, mode, scenario, "tool-complete");
@@ -1085,7 +1127,7 @@ function runStreamIsolationFixtureFlow(mode, scenario = "standard") {
1085
1127
  pendingStreamIsolationRuns.delete(runId);
1086
1128
  runScriptedSteps(scenario === "lifecycle" ? steps : [...steps, ...completionSteps]);
1087
1129
  });
1088
- return { runId, finalText };
1130
+ return { runId, finalText, retainedMessageCount };
1089
1131
  }
1090
1132
 
1091
1133
  function continueStreamIsolationFixture(runId) {
@@ -1097,12 +1139,17 @@ function continueStreamIsolationFixture(runId) {
1097
1139
 
1098
1140
  function handleStreamIsolationFixturePrompt(command, base) {
1099
1141
  if (!streamIsolationEnabled) return false;
1100
- const match = String(command.message || "").trim().match(/^fixture stream isolation (normal|compact)(?: (standard|abort|lifecycle))?$/);
1142
+ const message = String(command.message || "").trim();
1143
+ if (message === "fixture stream isolation populate long transcript") {
1144
+ respond({ ...base, data: { output: "stream isolation long transcript populated", retainedMessageCount: ensureStreamIsolationLongTranscript() } });
1145
+ return true;
1146
+ }
1147
+ const match = message.match(/^fixture stream isolation (normal|compact)(?: (standard|abort|lifecycle|background|long-transcript|paced-pressure))?$/);
1101
1148
  if (!match) return false;
1102
1149
  const mode = match[1];
1103
1150
  const scenario = match[2] || "standard";
1104
- const { runId, finalText } = runStreamIsolationFixtureFlow(mode, scenario);
1105
- respond({ ...base, data: { output: "stream isolation fixture accepted", runId, deltaCount: 1_000, mode, scenario, finalText } });
1151
+ const { runId, finalText, retainedMessageCount } = runStreamIsolationFixtureFlow(mode, scenario);
1152
+ respond({ ...base, data: { output: "stream isolation fixture accepted", runId, deltaCount: 1_000, retainedMessageCount, mode, scenario, finalText } });
1106
1153
  return true;
1107
1154
  }
1108
1155
 
@@ -120,6 +120,42 @@ export function overflowBurstEvents({ pairs = 200 } = {}) {
120
120
  return events;
121
121
  }
122
122
 
123
+ /**
124
+ * Hidden-tab workload. The browser suppresses these live events while hidden
125
+ * and uses `authoritativeText` when it returns to the foreground.
126
+ */
127
+ export function backgroundForegroundReconciliationScenario(deltaCount = 1000) {
128
+ const hiddenEvents = smallTextDeltaEvents(deltaCount).map((event, index) => ({
129
+ ...event,
130
+ baselineIndex: index,
131
+ }));
132
+ return {
133
+ hiddenEvents,
134
+ authoritativeText: concatenatedDeltaText(hiddenEvents),
135
+ };
136
+ }
137
+
138
+ /** Deterministic retained messages used by the long-transcript browser baseline. */
139
+ export function longTranscriptMessages(messageCount = 1000) {
140
+ return Array.from({ length: messageCount }, (_, index) => {
141
+ const role = index % 2 === 0 ? "user" : "assistant";
142
+ const text = `LONG-TRANSCRIPT-${String(index).padStart(4, "0")} ${WORD_POOL[index % WORD_POOL.length]} ${"x".repeat(80)}`;
143
+ return {
144
+ role,
145
+ content: role === "assistant" ? [{ type: "text", text }] : text,
146
+ timestamp: 10_000 + index,
147
+ };
148
+ });
149
+ }
150
+
151
+ /** Thousands of retained messages plus a simultaneous deterministic stream. */
152
+ export function longTranscriptActiveStreamScenario({ messageCount = 1000, deltaCount = 1000 } = {}) {
153
+ return {
154
+ retainedMessages: longTranscriptMessages(messageCount),
155
+ activeEvents: smallTextDeltaEvents(deltaCount),
156
+ };
157
+ }
158
+
123
159
  /** Concatenate every delta of one assistant-message-event type, in order. */
124
160
  export function concatenatedDeltaText(events, type = "text_delta") {
125
161
  let text = "";
@@ -21,6 +21,9 @@ const usageNormalization = normalizeChip.slice(normalizeChip.indexOf("if (value.
21
21
  const applyUsage = between(app, "function applyFooterUsageWindows", "const FOOTER_MIDDLE_TRUNCATION_END_CHARS");
22
22
  const shapeKey = between(app, "function gitFooterChipShapeKey", "function footerBranchPickerRenderKey");
23
23
  const inPlaceUpdate = between(app, "function updateGitFooterChipNodeValue", "let gitFooterRenderCache");
24
+ const providerUsageNormalization = between(app, "function normalizeFooterProviderUsageWindow", "function currentGitFooterCacheCwd");
25
+ const claudeUsageSync = between(app, "function claudeUsageWindowFromProvider", "function claudeUsageResetDate");
26
+ const claudeUsageRefresh = between(app, "async function refreshClaudeUsage", "function scheduleRefreshClaudeUsage");
24
27
 
25
28
  assert.match(parser, /x-codex-primary-window-minutes/, "Codex parser should read the primary window duration");
26
29
  assert.match(parser, /x-codex-secondary-window-minutes/, "Codex parser should read the secondary window duration");
@@ -31,8 +34,20 @@ assert.match(parser, /providerUsageWindows\(usage\)[\s\S]*\.map\(\(window\)/, "f
31
34
  assert.match(producer, /usageWindows\?:\s*\{\s*primaryPercent\?:\s*number;\s*secondaryPercent\?:\s*number;/s, "producer should type each usage window as independently optional");
32
35
  assert.match(producer, /providerUsage\.primary \? \{ primaryPercent: providerUsage\.primary\.usedPercent \}/, "Usage chip should publish an available primary percentage");
33
36
  assert.match(producer, /providerUsage\.secondary \? \{ secondaryPercent: providerUsage\.secondary\.usedPercent \}/, "Usage chip should publish an available secondary percentage");
37
+ assert.match(producer, /\.\.\.\(providerUsage \? \{ providerUsage \} : \{\}\)/, "footer payload should publish structured provider usage independently of Usage-chip visibility");
38
+ assert.match(producer, /latestProviderUsage = usage \? \{ \.\.\.usage, capturedAt: Date\.now\(\) \} : null;/, "provider-response capture should timestamp fresh usage snapshots");
34
39
  assert.match(app, /usage:\s*"Provider subscription usage\.[^"]*every available provider-reported rate window\./, "Usage tooltip should explain that partial provider windows remain visible");
35
40
 
41
+ assert.match(providerUsageNormalization, /value\.provider !== "anthropic" && value\.provider !== "openai-codex"/, "consumer should allow only supported provider-usage sources");
42
+ assert.match(providerUsageNormalization, /normalizeFooterProviderUsageWindow\(value\.primary\)[\s\S]*normalizeFooterProviderUsageWindow\(value\.secondary\)/, "consumer should normalize both structured provider windows without parsing display text");
43
+ assert.match(app, /const providerUsage = normalizeFooterProviderUsage\(parsed\.providerUsage\);[\s\S]*\{ providerUsage \}/, "footer payload parsing should retain normalized provider usage metadata");
44
+ assert.match(claudeUsageSync, /providerUsage\?\.provider !== "anthropic"[\s\S]*source: "git-footer-status-provider-headers"[\s\S]*windows/, "Claude Usage should consume the same live Anthropic header snapshot as the footer");
45
+ assert.match(claudeUsageSync, /capturedAt \+ resetAfterSeconds \* 1000/, "relative reset times should be anchored to provider capture time instead of drifting on each render");
46
+ assert.match(claudeUsageRefresh, /if \(!forceCli && syncClaudeUsageFromGitFooterPayload\(\)\) return;/, "scheduled Claude refreshes should prefer the live footer snapshot");
47
+ assert.match(app, /if \(footerPayload\) syncClaudeUsageFromGitFooterPayload\(footerPayload\);/, "incoming footer status should update the Claude Usage panel immediately");
48
+ assert.match(app, /function applyOptimisticGitFooterBranch[\s\S]*payload\.providerUsage \? \{ providerUsage: payload\.providerUsage \}/, "optimistic branch updates should preserve the provider snapshot used by Claude Usage");
49
+ assert.match(app, /refreshClaudeUsage\(\{ forceCli: true \}\)/, "the explicit Refresh usage button should retain the CLI fallback path");
50
+
36
51
  assert.match(usageNormalization, /value\.usageWindows\.primaryPercent/, "consumer should read structured primary metadata");
37
52
  assert.match(usageNormalization, /value\.usageWindows\.secondaryPercent/, "consumer should read structured secondary metadata");
38
53
  assert.match(usageNormalization, /Number\.isFinite\(primaryPercent\)\s*\|\|\s*Number\.isFinite\(secondaryPercent\)/, "consumer should accept either finite window value");
@@ -68,7 +68,7 @@ assert.match(
68
68
  assert.match(app, /case "webui_connected":[\s\S]*?resumedWithFreshSnapshot[\s\S]*?if \(!resumedWithFreshSnapshot\) scheduleForegroundReconcile/, "the deliberate reconnect must not immediately trigger a second full refresh");
69
69
  assert.match(app, /case "webui_supervisor_reconnected":[\s\S]*?foregroundReconnectSnapshotFreshUntil/, "initial supervisor replay must reuse the fresh foreground snapshot");
70
70
 
71
- const executeBeginCatchUp = new Function("eventSource", "streamOutputController", `
71
+ const executeBeginCatchUp = new Function("eventSource", "streamOutputController", "flushNormalStreamRenders", `
72
72
  let foregroundTranscriptCatchUpRequired = false;
73
73
  let backgroundReconnectSnapshotFresh = true;
74
74
  let eventStreamPausedForBackground = false;
@@ -77,10 +77,16 @@ const executeBeginCatchUp = new Function("eventSource", "streamOutputController"
77
77
  `);
78
78
  let closeCount = 0;
79
79
  let cancelCount = 0;
80
+ let normalRenderFlushCount = 0;
80
81
  const pausedState = executeBeginCatchUp(
81
82
  { close() { closeCount += 1; } },
82
83
  { cancel() { cancelCount += 1; } },
84
+ (reason) => {
85
+ assert.equal(reason, "visibility-hidden");
86
+ normalRenderFlushCount += 1;
87
+ },
83
88
  );
89
+ assert.equal(normalRenderFlushCount, 1, "backgrounding should flush pending normal formatting exactly once before pausing");
84
90
  assert.equal(cancelCount, 1, "backgrounding should cancel pending transcript work exactly once");
85
91
  assert.equal(closeCount, 1, "backgrounding should close the active EventSource exactly once");
86
92
  assert.equal(pausedState.eventSource, null, "the closed EventSource must be detached so no queued message handler remains current");
@@ -227,7 +227,9 @@ assert.match(updateTextSurface, /_transcriptTextNode[\s\S]*node\.appendData\(val
227
227
  // Stable committed blocks and a bounded mutable tail.
228
228
  assert.match(reconcileMarkdownSurface, /if \(boundary > state\.stableText\.length\)/, "committed blocks must never be re-rendered for append-only input");
229
229
  assert.match(reconcileMarkdownSurface, /for \(const node of state\.tailNodes\) node\.remove\(\)/, "only the mutable tail may be detached during streaming");
230
- assert.match(reconcileMarkdownSurface, /const diverged = !!state && !value\.startsWith\(state\.stableText\);[\s\S]*invalidateSelection: diverged/, "authoritative divergence must explicitly invalidate selection rather than silently rebuilding");
230
+ assert.match(reconcileMarkdownSurface, /const diverged = !!state && !value\.startsWith\(state\.value\);[\s\S]*invalidateSelection: diverged/, "authoritative divergence must compare the whole previous value and explicitly invalidate selection");
231
+ assert.match(reconcileMarkdownSurface, /canReuseLiveTail[\s\S]*appendLiveTail\(state\.tailNodes, state\.tailText, tail, boundaryInfo\)/, "open fences and bounded plain tails must append into their mounted live nodes");
232
+ assert.match(reconcileMarkdownSurface, /promotesMountedTail[\s\S]*ownBlocks\(state\.tailNodes[\s\S]*state\.tailNodes = \[\]/, "a newly stable mounted tail must be promoted without detaching its DOM");
231
233
 
232
234
  // Live settlement adoption.
233
235
  assert.match(authoritativeAssistantTextForAdoption, /if \(finalParts\.length !== 1\) return null;/, "multi-part settlement must not be fuzzy-adopted onto a single live surface");
@@ -95,9 +95,9 @@ assert.match(css, /\.composer-intercom-tag:hover,[\s\S]*\.composer-intercom-tag:
95
95
  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");
96
96
  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");
97
97
 
98
- assert.match(html, /\/styles\.css\?v=129/, "the stylesheet URL should advance for the bounded conversation tags");
99
- assert.match(html, /data-app-src="\/app\.js\?v=150"/, "the guarded app URL should advance for current browser wiring");
100
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v115"/, "the PWA cache identity should advance with browser assets");
98
+ assert.match(html, /\/styles\.css\?v=132/, "the stylesheet URL should advance for the bounded conversation tags");
99
+ assert.match(html, /data-app-src="\/app\.js\?v=157"/, "the guarded app URL should advance for current browser wiring");
100
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v123"/, "the PWA cache identity should advance with browser assets");
101
101
 
102
102
  assert.match(readme, /one compact tag per conversation appears beneath the composer/i, "the README should explain the user-visible entry point");
103
103
  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");