@firstpick/pi-package-webui 0.9.5 → 0.9.7

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 (82) hide show
  1. package/README.md +11 -5
  2. package/bin/pi-webui.mjs +457 -77
  3. package/lib/git-workflow-preferences.mjs +21 -1
  4. package/lib/optional-feature-catalog.mjs +1 -1
  5. package/lib/session-actions.mjs +20 -2
  6. package/lib/session-tree-event-targets.mjs +70 -0
  7. package/lib/subagent-launch-policy.mjs +375 -0
  8. package/lib/subagent-launch-slots.mjs +2 -1
  9. package/package.json +1 -1
  10. package/public/app.js +2539 -292
  11. package/public/index.html +87 -31
  12. package/public/service-worker.js +4 -1
  13. package/public/stream-derived-output.mjs +799 -0
  14. package/public/stream-markdown-tail.mjs +204 -0
  15. package/public/stream-output-controller.mjs +193 -51
  16. package/public/stream-render-scheduler.mjs +85 -0
  17. package/public/styles.css +501 -19
  18. package/public/transcript-renderer.mjs +73 -24
  19. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  20. package/tests/browser/composer-action-grid-reorder.spec.mjs +114 -31
  21. package/tests/browser/control-visibility.spec.mjs +141 -2
  22. package/tests/browser/events-tree-context-menu.spec.mjs +240 -0
  23. package/tests/browser/guided-git-fallback.spec.mjs +153 -0
  24. package/tests/browser/mobile-foundation.spec.mjs +28 -0
  25. package/tests/browser/stream-output-isolation.spec.mjs +308 -3
  26. package/tests/browser/user-noticeable-fixes.spec.mjs +204 -0
  27. package/tests/codex-fast-mode-static.test.mjs +2 -2
  28. package/tests/compact-sections-static.test.mjs +4 -0
  29. package/tests/composer-action-grid-reorder-static.test.mjs +8 -7
  30. package/tests/control-visibility-static.test.mjs +66 -3
  31. package/tests/controls-layout-static.test.mjs +3 -3
  32. package/tests/cwd-footer-reliability-static.test.mjs +1 -1
  33. package/tests/events-tree-context-menu-static.test.mjs +131 -0
  34. package/tests/fast-mode-client-static.test.mjs +5 -2
  35. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  36. package/tests/file-viewer-image-static.test.mjs +3 -3
  37. package/tests/fixtures/fake-pi.mjs +57 -10
  38. package/tests/fixtures/streaming-workloads.mjs +36 -0
  39. package/tests/footer-provider-usage-visual-static.test.mjs +15 -0
  40. package/tests/foreground-transcript-catch-up-static.test.mjs +7 -1
  41. package/tests/git-workflow-preferences.test.mjs +30 -1
  42. package/tests/guided-git-fallback-runtime.test.mjs +418 -0
  43. package/tests/guided-git-fallback-ui-static.test.mjs +60 -0
  44. package/tests/guided-git-message-reliability-static.test.mjs +8 -7
  45. package/tests/interaction-state-stability-static.test.mjs +3 -1
  46. package/tests/intercom-conversation-viewer-static.test.mjs +3 -3
  47. package/tests/intercom-conversations-http.test.mjs +16 -0
  48. package/tests/main-output-loading-static.test.mjs +3 -3
  49. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  50. package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
  51. package/tests/mobile-foundation-static.test.mjs +3 -3
  52. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  53. package/tests/mobile-static.test.mjs +80 -67
  54. package/tests/open-issue-wizard-static.test.mjs +1 -1
  55. package/tests/persistent-ui-layout-static.test.mjs +4 -4
  56. package/tests/prompt-input-vertical-scroll-static.test.mjs +26 -0
  57. package/tests/questionnaire-dialog.test.mjs +3 -3
  58. package/tests/remote-auth-settings-harness.test.mjs +23 -0
  59. package/tests/resource-defaults-helper.test.mjs +12 -0
  60. package/tests/runtime-error-visibility.test.mjs +3 -3
  61. package/tests/session-auth-harness.test.mjs +26 -1
  62. package/tests/session-sampling-helper.test.mjs +1 -0
  63. package/tests/session-sampling-ui-static.test.mjs +3 -3
  64. package/tests/session-tree-event-targets.test.mjs +106 -0
  65. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  66. package/tests/stream-derived-output.test.mjs +121 -0
  67. package/tests/stream-markdown-tail.test.mjs +218 -0
  68. package/tests/stream-output-controller.test.mjs +119 -4
  69. package/tests/stream-output-isolation-static.test.mjs +27 -6
  70. package/tests/stream-output-workloads.test.mjs +40 -3
  71. package/tests/stream-render-scheduler.test.mjs +115 -0
  72. package/tests/streaming-ui-coupling.test.mjs +1 -1
  73. package/tests/subagent-launch-policy.test.mjs +532 -0
  74. package/tests/subagent-observability-static.test.mjs +2 -2
  75. package/tests/subagents-helper.test.mjs +211 -1
  76. package/tests/syntax-highlighting-static.test.mjs +3 -3
  77. package/tests/tab-close-continuity-static.test.mjs +23 -0
  78. package/tests/theme-customizer-static.test.mjs +1 -1
  79. package/tests/thinking-format-parser.test.mjs +15 -0
  80. package/tests/todo-filter-static.test.mjs +148 -0
  81. package/tests/transcript-markdown-tail.test.mjs +137 -0
  82. package/webui-rpc-helper.mjs +220 -3
@@ -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=137/, "changed composer styles should advance the stylesheet revision");
61
+ assert.match(html, /app\.js\?v=166/, "changed composer behavior should advance the app revision");
62
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "changed browser assets should advance the PWA cache identity");
62
63
 
63
64
  console.log("composer-action-grid-reorder-static.test.mjs passed");
@@ -246,6 +246,69 @@ assert.match(
246
246
  "checked menu items should expose a visible check mark as well as aria-checked",
247
247
  );
248
248
 
249
+ // --- Catalog-driven setup dialog -----------------------------------------------
250
+
251
+ assert.equal(catalog.length, 24, "the approved visibility catalog should contain 24 entries");
252
+ assert.equal(groupLabels.length, 5, "the setup should retain the five approved groups");
253
+ assert.match(
254
+ html,
255
+ /<dialog id="controlVisibilitySetupDialog"[^>]*aria-labelledby="controlVisibilitySetupDialogTitle"[^>]*aria-describedby="controlVisibilitySetupDescription"[\s\S]*?<div id="controlVisibilitySetupBody"[^>]*><\/div>[\s\S]*?<button id="controlVisibilitySetupCloseButton"[^>]*type="button">Close<\/button>/,
256
+ "the setup should use a labelled native dialog with a generated body and explicit Close button",
257
+ );
258
+ assert.equal(
259
+ app.match(/controlVisibilityMenuAction\("open-setup", "Open setup"\)/g)?.length,
260
+ 2,
261
+ "both the direct and grouped visibility menus should offer Open setup",
262
+ );
263
+ assert.match(
264
+ app,
265
+ /function renderControlVisibilitySetupDialog\(\)[\s\S]*CONTROL_VISIBILITY_GROUP_LABELS\.map[\s\S]*CONTROL_VISIBILITY_CATALOG\.filter[\s\S]*checkbox\.dataset\.visibilitySetupId = entry\.id[\s\S]*body\.replaceChildren\(\.\.\.groups\)/,
266
+ "the five setup groups and their checkboxes should be generated from the canonical catalog",
267
+ );
268
+ assert.match(
269
+ app,
270
+ /controlVisibilitySetupBody\?\.addEventListener\("change"[\s\S]*CONTROL_VISIBILITY_REGISTRY\.get\(checkbox\.dataset\.visibilitySetupId\)[\s\S]*setControlVisibilityHidden\(entry\.id, !checkbox\.checked\)/,
271
+ "native setup checkbox changes should persist immediately through the existing setter",
272
+ );
273
+ assert.match(
274
+ app,
275
+ /function applyControlVisibility\(hiddenIdsOverride\)[\s\S]*refreshControlVisibilitySetupDialog\(\)/,
276
+ "normal visibility application should synchronize an open setup dialog",
277
+ );
278
+ assert.match(
279
+ app,
280
+ /controlVisibilitySetupShowAllButton\?\.addEventListener\("click"[\s\S]*showAllControls\(\)[\s\S]*refreshControlVisibilitySetupDialog\(\)[\s\S]*controlVisibilitySetupResetButton\?\.addEventListener\("click"[\s\S]*resetControlVisibilityDefaults\(\)[\s\S]*refreshControlVisibilitySetupDialog\(\)/,
281
+ "setup quick actions should retain the existing [] and null setters and refresh checkbox state",
282
+ );
283
+ assert.match(
284
+ app,
285
+ /if \(action === "open-setup"\) \{[\s\S]*closeVisibilityContextMenu\(\{ returnFocus: false \}\)[\s\S]*openControlVisibilitySetupDialog\(trigger\)/,
286
+ "Open setup should transfer the context-menu trigger to the dialog without intermediate focus restoration",
287
+ );
288
+ {
289
+ const restoreSetupFocus = app.match(/function restoreControlVisibilitySetupFocus\(\) \{[\s\S]*?^\}/m)?.[0] || "";
290
+ assert.match(
291
+ restoreSetupFocus,
292
+ /trigger\.isConnected[\s\S]*!trigger\.closest\?\.\("\[hidden\], \.webui-user-hidden"\)[\s\S]*if \(triggerSurvives\) trigger\.focus[\s\S]*else elements\.promptInput\?\.focus/,
293
+ "Close and Escape should restore a surviving opener or use the prompt fallback",
294
+ );
295
+ }
296
+ assert.match(
297
+ app,
298
+ /controlVisibilitySetupDialog\?\.addEventListener\("close", restoreControlVisibilitySetupFocus\)/,
299
+ "native dialog dismissal should share the setup focus-restoration path",
300
+ );
301
+ assert.match(
302
+ styles,
303
+ /\.control-visibility-setup-body \{[\s\S]*overflow: auto;[\s\S]*overscroll-behavior: contain;[\s\S]*@media \(max-width: 34rem\)[\s\S]*\.control-visibility-setup-grid \{ grid-template-columns: minmax\(0, 1fr\); \}[\s\S]*min-height: 44px;/,
304
+ "the generated catalog should scroll independently and retain usable narrow-screen controls",
305
+ );
306
+ assert.doesNotMatch(
307
+ app.match(/function renderControlVisibilitySetupDialog\(\)[\s\S]*?function refreshControlVisibilitySetupDialog/)?.[0] || "",
308
+ /send/i,
309
+ "the setup renderer should not introduce a Send-specific entry outside the catalog",
310
+ );
311
+
249
312
  // --- Keyboard-only recovery from Send ------------------------------------------
250
313
 
251
314
  assert.match(
@@ -285,10 +348,10 @@ assert.match(
285
348
 
286
349
  assert.match(
287
350
  serviceWorker,
288
- /const CACHE_NAME = "pi-webui-pwa-v115";/,
351
+ /const CACHE_NAME = "pi-webui-pwa-v132";/,
289
352
  "browser asset changes should advance the PWA cache identity",
290
353
  );
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");
354
+ assert.match(html, /styles\.css\?v=137/, "visibility styles should advance the stylesheet query revision");
355
+ assert.match(html, /data-app-src="\/app\.js\?v=166"/, "visibility behavior should advance the app query revision");
293
356
 
294
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=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=137/, "Controls stylesheet changes should advance the cache query");
19
+ assert.match(html, /app\.js\?v=166/, "Controls tooltip wiring should advance the app cache query");
20
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "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(
@@ -0,0 +1,131 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFile } from "node:fs/promises";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
7
+ const [html, app, styles, serviceWorker] = await Promise.all([
8
+ readFile(join(root, "public", "index.html"), "utf8"),
9
+ readFile(join(root, "public", "app.js"), "utf8"),
10
+ readFile(join(root, "public", "styles.css"), "utf8"),
11
+ readFile(join(root, "public", "service-worker.js"), "utf8"),
12
+ ]);
13
+
14
+ function functionSource(source, name) {
15
+ const start = source.indexOf(`function ${name}(`);
16
+ assert.ok(start >= 0, `${name} should exist`);
17
+ const next = source.slice(start + 1).match(/\n(?:async )?function [A-Za-z0-9_$]+\(/);
18
+ const end = next ? start + 1 + next.index : source.length;
19
+ return source.slice(start, end);
20
+ }
21
+
22
+ // Dedicated, labelled menu markup.
23
+ assert.match(html, /<div id="eventTreeContextMenu"[^>]*role="menu"[^>]*aria-labelledby="eventTreeContextMenuLabel"[^>]*hidden>/, "Events should own a labelled context menu");
24
+ assert.match(html, /id="eventDisplayDetailedAction"[^>]*role="menuitemradio"[^>]*aria-checked="true"[^>]*>Detailed<\/button>/, "the menu should expose Detailed as the default mode");
25
+ assert.match(html, /id="eventDisplayCompactAction"[^>]*role="menuitemradio"[^>]*aria-checked="false"[^>]*>Compact<\/button>/, "the menu should expose Compact mode");
26
+ assert.match(html, /role="separator"[\s\S]*id="eventTreeContextMenuAction"[^>]*role="menuitem"[^>]*>Tree…<\/button>[\s\S]*id="eventTreeContextMenuStatus"[^>]*role="status"/, "display choices should stay separate from Tree navigation and live feedback");
27
+ assert.match(html, /<label for="eventFilterSelect">Show<\/label>[\s\S]*id="eventFilterSelect"[\s\S]*value="all">All events<[\s\S]*value="errors">Errors \/ failures<[\s\S]*value="warnings">Warnings<[\s\S]*value="tools">Tool activity<[\s\S]*value="tree">Tree available</, "Events should expose the recommended native filter choices");
28
+ assert.match(html, /id="eventFilterStatus"[^>]*role="status"[^>]*aria-live="polite"[\s\S]*id="eventFilterEmpty"[^>]*hidden/, "the filter should expose live counts and an empty state");
29
+
30
+ const normalizeDisplaySource = functionSource(app, "normalizeEventDisplayMode");
31
+ assert.match(normalizeDisplaySource, /value === "compact" \? "compact" : "detailed"/, "unknown values should fall back to detailed mode");
32
+ assert.match(functionSource(app, "readStoredEventDisplayMode"), /localStorage\.getItem\(EVENT_DISPLAY_MODE_STORAGE_KEY\)/, "the display preference should restore from browser-local storage");
33
+ const setDisplaySource = functionSource(app, "setEventDisplayMode");
34
+ assert.match(setDisplaySource, /localStorage\.setItem\(EVENT_DISPLAY_MODE_STORAGE_KEY, eventDisplayMode\)/, "display choices should persist");
35
+ assert.match(functionSource(app, "syncEventDisplayModeUi"), /eventLog\.dataset\.displayMode = eventDisplayMode[\s\S]*eventDisplayDetailedAction[\s\S]*eventDisplayCompactAction/, "the current choice should update the log and radio menu state");
36
+
37
+ const normalizeFilterSource = functionSource(app, "normalizeEventFilter");
38
+ assert.match(normalizeFilterSource, /EVENT_FILTER_VALUES\.has\(value\) \? value : "all"/, "unknown filters should fall back to all events");
39
+ assert.match(functionSource(app, "readStoredEventFilter"), /localStorage\.getItem\(EVENT_FILTER_STORAGE_KEY\)/, "the event filter should restore from browser-local storage");
40
+ const filterMatchSource = functionSource(app, "eventRowMatchesFilter");
41
+ for (const contract of [
42
+ /filter === "errors"[\s\S]*eventLevel === "error"/,
43
+ /filter === "warnings"[\s\S]*eventLevel === "warn"/,
44
+ /filter === "tools"[\s\S]*eventToolPhase/,
45
+ /filter === "tree"[\s\S]*eventTreeAvailable === "true"/,
46
+ ]) assert.match(filterMatchSource, contract, "each visible filter should have an explicit row predicate");
47
+ const applyFilterSource = functionSource(app, "applyEventFilter");
48
+ assert.match(applyFilterSource, /line\.hidden = !matches[\s\S]*eventFilterStatus[\s\S]*eventFilterEmpty\.hidden/, "filtering should hide rows in place and update count and empty-state feedback");
49
+ const setFilterSource = functionSource(app, "setEventFilter");
50
+ assert.match(setFilterSource, /localStorage\.setItem\(EVENT_FILTER_STORAGE_KEY, eventFilter\)/, "filter choices should persist");
51
+ assert.match(app, /eventFilterSelect\?\.addEventListener\("change"[\s\S]*setEventFilter\(elements\.eventFilterSelect\.value\)/, "the native select should apply its selected filter");
52
+ assert.match(app, /event\.key === EVENT_FILTER_STORAGE_KEY[\s\S]*setEventFilter\(event\.newValue, \{ persist: false \}\)/, "filter changes should synchronize across same-origin tabs");
53
+
54
+ // Bounded event details: explicit target allowlist, status, duration, and shortened ID.
55
+ const targetSource = functionSource(app, "boundedToolEventTarget");
56
+ for (const toolName of ["read", "write", "edit", "grep", "find", "ls"]) {
57
+ assert.ok(app.includes(`["${toolName}", "path"]`), `${toolName} should be in the explicit path-target allowlist`);
58
+ }
59
+ assert.match(targetSource, /typeof value !== "string"/, "allowlisted details should accept only string fields");
60
+ assert.match(targetSource, /singleLine\.length > 96/, "allowlisted target text should be bounded");
61
+ assert.doesNotMatch(targetSource, /JSON\.stringify|\.result|\.output|Object\.values|Object\.entries/, "event details must not serialize arbitrary args or inspect output");
62
+ const detailsSource = functionSource(app, "toolLifecycleEventDetails");
63
+ for (const label of ["target", "status", "duration", "call"]) {
64
+ assert.ok(detailsSource.includes(`label: "${label}"`), `tool details should expose bounded ${label} metadata`);
65
+ }
66
+ assert.match(functionSource(app, "shortenedToolCallId"), /slice\(0, 7\)[\s\S]*slice\(-5\)/, "long call IDs should be visibly shortened");
67
+ const lifecycleArgumentsSource = functionSource(app, "toolLifecycleEventArguments");
68
+ assert.match(lifecycleArgumentsSource, /toolEventStartedAt\.set\(timerKey, \{ startedAt: occurredAt, target: boundedToolEventTarget\(event\) \}\)/, "start records should retain only timing and already bounded target text");
69
+ assert.doesNotMatch(lifecycleArgumentsSource, /args:|arguments:|invocation:|\.\.\.event|JSON\.stringify/, "start records must not retain raw tool arguments");
70
+ assert.match(lifecycleArgumentsSource, /toolLifecycleEventDetails[\s\S]*toolEventStartedAt\.delete/, "completion rows should consume and remove the matching bounded start record");
71
+ assert.match(detailsSource, /phase === "finish"[\s\S]*toolEventStartedAt\.get\(toolEventTimerKey\(event\)\)[\s\S]*boundedToolEventTarget\(event\) \|\| startRecord\?\.target/, "finish rows should reuse the matching bounded start target when completion args omit it");
72
+
73
+ // Every row exposes display choices; stable lifecycle rows alone expose Tree navigation.
74
+ const addEventSource = functionSource(app, "addEvent");
75
+ assert.match(addEventSource, /const toolLifecycle = \["start", "finish"\]\.includes\(toolEventPhase\)[\s\S]*stableToolCallId && toolLifecycle/, "only stable lifecycle rows should be Tree eligible");
76
+ assert.match(addEventSource, /line\.dataset\.eventLevel = String\(level[\s\S]*line\.dataset\.eventTreeAvailable = String\(!!treeEligible\)/, "rows should retain bounded filter metadata without copying payloads");
77
+ assert.match(addEventSource, /if \(toolLifecycle\) line\.dataset\.eventToolPhase = toolEventPhase/, "all tool lifecycle rows should remain visually identifiable in compact mode");
78
+ assert.match(addEventSource, /while \(elements\.eventLog\.children\.length > 120\)[\s\S]*applyEventFilter\(\)/, "new rows should apply the active filter after preserving the existing history bound");
79
+ assert.match(addEventSource, /setAttribute\("aria-keyshortcuts", "ContextMenu Shift\+F10"\)/, "every event row should expose keyboard display choices");
80
+ assert.match(addEventSource, /addEventListener\("click", \(\) => jumpToChatEvent\(line\)\)/, "event rows should preserve click-to-jump");
81
+ assert.match(
82
+ functionSource(app, "handleEvent"),
83
+ /case "tool_execution_start":[\s\S]*isIntercomTransportToolName\(event\.toolName\)[\s\S]*break;[\s\S]*toolLifecycleEventArguments\(event, "start"\)[\s\S]*case "tool_execution_end":[\s\S]*isIntercomTransportToolName\(event\.toolName\)[\s\S]*break;[\s\S]*toolLifecycleEventArguments\(event, "finish"\)/,
84
+ "hidden Intercom transport calls should still bypass event rows",
85
+ );
86
+
87
+ // Pointer and keyboard invocation, viewport clamping, focus, dismissal, and menu navigation.
88
+ assert.match(app, /eventLog\?\.addEventListener\("contextmenu"[\s\S]*closest\?\.\("\.event"\)[\s\S]*showEventTreeContextMenu\(event, line\)/, "every event row should support pointer display choices");
89
+ assert.match(app, /eventLog\?\.addEventListener\("keydown"[\s\S]*event\.key !== "ContextMenu"[\s\S]*event\.shiftKey && event\.key === "F10"[\s\S]*closest\?\.\("\.event"\)/, "every focused event row should support both keyboard invocations");
90
+ const showMenuSource = functionSource(app, "showEventTreeContextMenu");
91
+ assert.match(showMenuSource, /treeEligible = !!toolCallId[\s\S]*eventTreeContextMenuAction\.hidden = !treeEligible/, "Tree should appear only for eligible tool boundaries");
92
+ assert.match(showMenuSource, /window\.innerWidth - rect\.width[\s\S]*window\.innerHeight - rect\.height/, "the menu should clamp inside the viewport");
93
+ assert.match(showMenuSource, /eventDisplayCompactAction : elements\.eventDisplayDetailedAction[\s\S]*displayAction\?\.focus/, "the selected display choice should receive focus");
94
+ assert.match(functionSource(app, "closeOtherContextMenusForEventTree"), /closeFileContextMenu[\s\S]*closeGitPanelContextMenu[\s\S]*closeSidePanelContextMenu[\s\S]*closeVisibilityContextMenu[\s\S]*closeGitFooterContextMenu/, "opening Tree actions should close specialized context menus");
95
+ assert.match(app, /eventTreeContextMenu[^\n]*addEventListener\("keydown"[\s\S]*menuitemradio[\s\S]*"Escape"[\s\S]*"ArrowDown"[\s\S]*"ArrowUp"[\s\S]*"Home"[\s\S]*"End"/, "radio choices and Tree should share standard keyboard navigation");
96
+ assert.match(app, /eventTreeContextMenu && !elements\.eventTreeContextMenu\.hidden[\s\S]*event\.target\?\.closest\?\.\("\.event-tree-context-menu"\)[\s\S]*closeEventTreeContextMenu\(\)/, "outside pointer interaction should dismiss the menu");
97
+ assert.match(app, /window\.addEventListener\("resize", \(\) => closeEventTreeContextMenu\(\)/, "resize should dismiss the menu");
98
+ assert.match(app, /document\.addEventListener\("scroll"[\s\S]*closeEventTreeContextMenu\(\)/, "scroll should dismiss the menu");
99
+ assert.match(functionSource(app, "closeEventTreeContextMenu"), /trigger\?\.isConnected[\s\S]*trigger\.focus/, "closing should restore focus to a surviving event row");
100
+
101
+ // Action-time target resolution and exact no-summary navigation.
102
+ const targetEntrySource = functionSource(app, "eventTreeTargetEntryId");
103
+ assert.match(targetEntrySource, /data\?\.eventTargets/, "the action should use the minimal eventTargets contract");
104
+ assert.match(targetEntrySource, /state\.phase === "start" \? target\?\.startEntryId : target\?\.finishEntryId \|\| target\?\.startEntryId/, "start and finish boundaries should select the approved IDs");
105
+ assert.match(targetEntrySource, /nodes\.some\(\(node\) => node\?\.id === entryId\)/, "stale IDs should be rejected against current tree nodes");
106
+ const navigateSource = functionSource(app, "navigateEventTreeBoundary");
107
+ assert.match(navigateSource, /api\("\/api\/session-tree", \{ tabId: state\.tabContext\.tabId \}\)/, "targets should resolve from current session-tree data at action time");
108
+ assert.match(navigateSource, /appConfirm\(\{[\s\S]*Later entries stay in the tree[\s\S]*no automatic branch summary[\s\S]*Use \/tree to navigate back[\s\S]*danger: false/, "confirmation should explain branch effects and remain non-danger styled");
109
+ assert.match(navigateSource, /api\("\/api\/tree-navigate", \{[\s\S]*body: \{ entryId, summarize: false \}/, "acceptance should post the exact entry ID without summarization");
110
+ assert.ok(navigateSource.indexOf("if (!confirmed)") < navigateSource.indexOf('api("/api/tree-navigate"'), "cancel handling should return before any navigation POST");
111
+ const navigationPostIndex = navigateSource.indexOf('api("/api/tree-navigate"');
112
+ const postResponseSource = navigateSource.slice(navigationPostIndex);
113
+ assert.doesNotMatch(postResponseSource, /eventTreeContextMenuState !== state/, "post-confirmation response handling should not depend on menu visibility");
114
+ assert.match(postResponseSource, /if \(!isCurrentTabContext\(state\.tabContext\)\) return;[\s\S]*applyResponseTab\(result\)/, "successful responses should remain guarded by the originating tab generation");
115
+ assert.match(postResponseSource, /applyResponseTab\(result\)[\s\S]*title: "\/tree"[\s\S]*if \(eventTreeContextMenuState === state\) closeEventTreeContextMenu\(\)[\s\S]*await refreshAll\(state\.tabContext\)/, "success should apply response metadata, show /tree feedback, conditionally close the original menu, and refresh");
116
+ assert.match(navigateSource, /not available in the current persisted session tree[\s\S]*session was not changed/, "missing or stale targets should fail visibly without navigation");
117
+ assert.match(navigateSource, /state\.busy = true[\s\S]*action\.disabled = true[\s\S]*finally[\s\S]*action\.disabled = false/, "the action should preserve busy/error controls");
118
+
119
+ assert.match(styles, /\.event-filter-bar \{[\s\S]*grid-template-columns: auto minmax\(0, 1fr\) auto/, "the filter bar should keep its label, native select, and count aligned");
120
+ assert.match(styles, /\.event\[hidden\] \{ display: none; \}/, "filtered event rows should remain hidden despite the row display rule");
121
+ assert.match(styles, /\.event-details \{[\s\S]*flex-wrap: wrap/, "bounded details should wrap in detailed mode");
122
+ assert.match(styles, /\.event-log\[data-display-mode="compact"\] \.event-details \{ display: none; \}/, "compact mode should hide secondary metadata");
123
+ assert.match(styles, /\.event-log\[data-display-mode="compact"\] \.event\[data-event-tool-phase\][\s\S]*border-left:[\s\S]*\.event\[data-event-tool-phase="finish"\][\s\S]*border-left-color/, "compact tool events should retain visible lifecycle accents");
124
+ assert.match(styles, /\.event-tree-context-menu \{[\s\S]*max-width: calc\(100vw - 1rem\)/, "the dedicated menu should remain viewport bounded");
125
+
126
+ // Cache tuple for this browser-asset change.
127
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132";/, "the PWA cache identity should advance");
128
+ assert.match(html, /styles\.css\?v=137/, "compact-mode styles should advance the stylesheet revision");
129
+ assert.match(html, /data-app-src="\/app\.js\?v=166"/, "the app query revision should advance");
130
+
131
+ console.log("events-tree-context-menu-static.test.mjs passed");
@@ -47,6 +47,7 @@ const compactThinkingBubble = functionBody(app, "ensureCompactThinkingBubble");
47
47
  const compactToolShell = functionBody(app, "renderCompactToolShell");
48
48
  const clearCompactToolShells = functionBody(app, "clearCompactToolShells");
49
49
  const compactTranscript = functionBody(app, "renderCompactTranscriptBody");
50
+ const thinkingDisclosurePreviewText = functionBody(app, "thinkingDisclosurePreviewText");
50
51
  const compactThinkingDisclosureExpanded = functionBody(app, "compactThinkingDisclosureExpanded");
51
52
  const setCompactThinkingDisclosureExpanded = functionBody(app, "setCompactThinkingDisclosureExpanded");
52
53
  const clearCompactThinkingDisclosureState = functionBody(app, "clearCompactThinkingDisclosureState");
@@ -104,7 +105,9 @@ assert.match(appendTranscriptMessage, /compactTranscript && transcriptMessage\.r
104
105
  assert.match(compactThinkingSegments, /!thinkingOutputVisible\) return \[\][\s\S]*?message\?\.role === "thinking"[\s\S]*?assistantDisplayMessages\(message\)[\s\S]*?displayMessage\.role === "thinking"/, "fast mode should collect direct and embedded assistant thinking segments only when thinking output is enabled");
105
106
  assert.match(compactStoredTranscriptItems, /pendingThinking\.segments\.join\("\\n\\n"\)[\s\S]*?compactThinkingAggregate: true[\s\S]*?pendingThinking\.segments\.push\(\.\.\.thinkingSegments\)/, "thinking separated by tool calls should reconcile into one aggregate Markdown payload");
106
107
  assert.match(compactStoredTranscriptItems, /message\?\.role === "user"\) flushThinking\(\)[\s\S]*?message\?\.role === "assistant"\) flushThinking\(\)/, "aggregate thinking should stay bounded to one user turn and end before its final assistant output");
107
- assert.match(createMessageBubble, /compactThinkingAggregate = compactOutputActive\(\)[\s\S]*?message\.compactThinkingAggregate === true[\s\S]*?isCollapsibleOutput = compactThinkingAggregate[\s\S]*?defaultExpanded = message\.compactThinkingDefaultExpanded === true[\s\S]*?details\.open = compactThinkingDisclosureExpanded\(message\.compactThinkingKey, defaultExpanded\)[\s\S]*?setCompactThinkingDisclosureExpanded\(message\.compactThinkingKey, details\.open, defaultExpanded\)[\s\S]*?else if \(shouldOpenMessageCollapseByDefault/, "aggregate thinking should use a native disclosure with role-specific defaults and preserve explicit toggles across reconciliation");
108
+ assert.match(createMessageBubble, /compactThinkingAggregate = compactOutputActive\(\)[\s\S]*?message\.compactThinkingAggregate === true[\s\S]*?isCollapsibleOutput = compactThinkingAggregate[\s\S]*?defaultExpanded = message\.compactThinkingDefaultExpanded === true[\s\S]*?details\.open = compactThinkingDisclosureExpanded\(message\.compactThinkingKey, defaultExpanded\)[\s\S]*?setCompactThinkingDisclosureExpanded\(message\.compactThinkingKey, details\.open, defaultExpanded\)[\s\S]*?thinkingDisclosurePreviewText\(message\)[\s\S]*?else if \(shouldOpenMessageCollapseByDefault/, "thinking disclosures should preserve their defaults and use the cleaned preview helper");
109
+ assert.match(thinkingDisclosurePreviewText, /visibleThinkingText\(message\?\.thinking \|\| textFromContent\(message\?\.content\)\)[\s\S]*?speakableTextFromMarkdown\(raw\)\.slice\(0, Math\.max\(0, charLimit\)\)/, "collapsed thinking previews should strip Markdown before applying the length limit");
110
+ assert.match(styles, /\.thinking-disclosure > \.message-header \{[\s\S]*?display: grid;[\s\S]*?"role timestamp disclosure"[\s\S]*?"preview preview preview"[\s\S]*?\.thinking-disclosure > \.message-header::after \{ grid-area: disclosure; margin-left: 0; \}/, "collapsed thinking should keep the disclosure arrow in the top header row");
108
111
  assert.match(compactThinkingDisclosureExpanded, /compactThinkingDisclosureStateByTab\.get\(activeTabId \|\| "default"\)[\s\S]*?disclosureState\?\.has\(key\)[\s\S]*?!!defaultExpanded/, "aggregate disclosure state should be isolated per terminal tab and fall back to the role-specific default");
109
112
  assert.match(setCompactThinkingDisclosureExpanded, /expanded === defaultExpanded[\s\S]*?disclosureState\?\.delete\(key\)[\s\S]*?disclosureState = new Map\(\)[\s\S]*?disclosureState\.set\(key, !!expanded\)/, "aggregate disclosure state should store only explicit overrides from the role-specific default");
110
113
  assert.match(clearCompactThinkingDisclosureState, /disclosureState\?\.delete\(key\)[\s\S]*?compactThinkingDisclosureStateByTab\.delete\(tabId\)/, "stream resets should remove a live disclosure override without changing its expanded default");
@@ -156,7 +159,7 @@ assert.match(worker, /pi-webui-pwa-v\d+[\s\S]*?"\/fast-output-live\.mjs"/, "PWA
156
159
  assert.match(html, /<label for="fastOutputModeSelect">Compact mode \(Experimental\)<\/label>/, "the sidebar should mark compact mode as experimental");
157
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");
158
161
  // 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");
162
+ assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=166"/, "the guarded PWA entry point should cache-bust browser wiring");
160
163
  assert.match(JSON.parse(packageRaw).scripts.check, /node --check public\/fast-output-live\.mjs/, "package checks should parse the compact helper");
161
164
 
162
165
  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=137/, "integrated stylesheet changes should advance the cache query");
170
+ assert.match(html, /\/app\.js\?v=166/, "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-v132"/, "changed viewer assets should advance the PWA cache identity");
66
+ assert.match(html, /styles\.css\?v=137/, "changed image styles should advance the stylesheet revision");
67
+ assert.match(html, /app\.js\?v=166/, "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");