@firstpick/pi-package-webui 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +236 -24
  2. package/bin/pi-webui-launcher.mjs +23 -12
  3. package/bin/pi-webui.mjs +493 -65
  4. package/lib/agent-run-adapters.mjs +500 -0
  5. package/lib/agent-run-protocol.mjs +262 -0
  6. package/lib/agent-run-registry.mjs +339 -0
  7. package/lib/app-runner-terminal.mjs +40 -0
  8. package/lib/git-workflow-preferences.mjs +11 -4
  9. package/lib/trust-boundaries.mjs +2 -0
  10. package/lib/ui-layout-settings.mjs +172 -28
  11. package/lib/update/package-layout.mjs +50 -0
  12. package/lib/update/plan.mjs +11 -0
  13. package/package.json +2 -2
  14. package/public/app.js +1376 -337
  15. package/public/index.html +113 -68
  16. package/public/service-worker.js +1 -1
  17. package/public/styles.css +371 -93
  18. package/tests/agent-run-adapters.test.mjs +217 -0
  19. package/tests/agent-run-launcher.test.mjs +41 -0
  20. package/tests/agent-run-protocol.test.mjs +82 -0
  21. package/tests/agent-run-registry.test.mjs +102 -0
  22. package/tests/app-runner-terminal-static.test.mjs +28 -0
  23. package/tests/app-runner-terminal.test.mjs +65 -0
  24. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  25. package/tests/browser/control-deck-side-panels.spec.mjs +354 -0
  26. package/tests/browser/controls-layout.spec.mjs +122 -0
  27. package/tests/browser/file-tree-git-ignored.spec.mjs +113 -0
  28. package/tests/browser/interaction-continuity.spec.mjs +159 -0
  29. package/tests/browser/mobile-foundation.spec.mjs +26 -0
  30. package/tests/browser/model-search-focus.spec.mjs +96 -0
  31. package/tests/browser/optimistic-prompt.spec.mjs +22 -0
  32. package/tests/browser/persistent-ui-layout.spec.mjs +224 -66
  33. package/tests/browser/subagent-observability.spec.mjs +87 -0
  34. package/tests/chat-scroll-intent-static.test.mjs +1 -1
  35. package/tests/codex-fast-mode-static.test.mjs +2 -2
  36. package/tests/component-update-api-static.test.mjs +2 -1
  37. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  38. package/tests/control-deck-component-updates-static.test.mjs +2 -0
  39. package/tests/control-deck-side-panels-static.test.mjs +68 -0
  40. package/tests/controls-layout-static.test.mjs +22 -0
  41. package/tests/fast-mode-client-static.test.mjs +1 -1
  42. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  43. package/tests/file-tree-git-ignored-static.test.mjs +152 -0
  44. package/tests/file-tree-search-layout-static.test.mjs +2 -1
  45. package/tests/fixtures/fake-pi.mjs +43 -7
  46. package/tests/footer-provider-usage-visual-static.test.mjs +10 -8
  47. package/tests/git-workflow-preferences.test.mjs +55 -6
  48. package/tests/http-endpoints-harness.test.mjs +173 -14
  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 +18 -5
  54. package/tests/open-issue-wizard-static.test.mjs +2 -2
  55. package/tests/persistent-ui-layout-static.test.mjs +13 -13
  56. package/tests/questionnaire-dialog.test.mjs +3 -3
  57. package/tests/remote-auth-settings-harness.test.mjs +1 -1
  58. package/tests/session-sampling-ui-static.test.mjs +3 -3
  59. package/tests/side-panel-context-menu-static.test.mjs +1 -1
  60. package/tests/side-panel-resize-static.test.mjs +26 -16
  61. package/tests/side-panel-section-height-removal-static.test.mjs +4 -4
  62. package/tests/side-panel-section-reorder-static.test.mjs +16 -70
  63. package/tests/subagent-gate-visibility.test.mjs +2 -1
  64. package/tests/subagent-launch-slots.test.mjs +1 -1
  65. package/tests/subagent-observability-static.test.mjs +32 -0
  66. package/tests/subagent-reliability-integration.test.mjs +161 -0
  67. package/tests/subagents-helper.test.mjs +344 -4
  68. package/tests/terminal-tabs-resize-static.test.mjs +35 -0
  69. package/tests/theme-customizer-static.test.mjs +1 -1
  70. package/tests/ui-layout-settings.test.mjs +104 -32
  71. package/tests/update-api-harness.test.mjs +24 -10
  72. package/tests/update-package-layout.test.mjs +38 -0
  73. package/tests/update-plan.test.mjs +11 -1
  74. package/tests/webui-settings-locking.test.mjs +33 -3
  75. package/webui-rpc-helper.mjs +417 -28
@@ -179,7 +179,7 @@ try {
179
179
  const disableAuth = await request("/api/remote-auth/settings", { method: "POST", body: { enabled: false } });
180
180
  assert.equal(disableAuth.status, 200);
181
181
  const savedAfterDisable = JSON.parse(await readFile(settingsFile, "utf8"));
182
- assert.equal(savedAfterDisable.version, 6, "Web UI settings should retain the current private settings envelope version");
182
+ assert.equal(savedAfterDisable.version, 7, "Web UI settings should retain the current private settings envelope version");
183
183
  assert.equal(savedAfterDisable.remoteAuthEnabled, false, "disabling Remote PIN auth should persist the off preference");
184
184
  assert.equal(savedAfterDisable.gitWorkflow?.generation?.modelId, "fake-model", "Remote PIN updates should preserve guided Git preferences");
185
185
 
@@ -57,10 +57,10 @@ assert.match(css, /\.sampling-parameter-control\.unsupported:hover:not\(\.sampli
57
57
  assert.match(css, /\.sampling-parameter-control\.unsupported:focus-visible:not\(\.sampling-tooltip-dismissed\) > \.sampling-parameter-unsupported-tooltip/, "keyboard focus should reveal dismissible unsupported reasons");
58
58
  assert.match(css, /\.sampling-parameter-unsupported-tooltip\.sampling-tooltip-below/, "bounded placement should support flipping below top-edge rows");
59
59
  assert.match(css, /pointer-events: auto;/, "a visible unsupported tooltip should remain pointer-hoverable");
60
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v84"/, "native-control assets should advance the cache identity");
60
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v94"/, "native-control assets should advance the cache identity");
61
61
  assert.match(serviceWorker, /"\/sampling-parameter-controls\.mjs"/, "the pure sampling module should be part of the offline app shell");
62
- assert.match(html, /styles\.css\?v=107/, "the changed stylesheet should have a new revision");
63
- assert.match(html, /app\.js\?v=121/, "the changed app module should have a new revision");
62
+ assert.match(html, /styles\.css\?v=115/, "the changed stylesheet should have a new revision");
63
+ assert.match(html, /app\.js\?v=132/, "the changed app module should have a new revision");
64
64
 
65
65
  // --- Browser state behavior -------------------------------------------------
66
66
 
@@ -52,7 +52,7 @@ assert.match(
52
52
  );
53
53
  assert.match(
54
54
  app,
55
- /function bindSidePanelContextMenu\(\)[\s\S]*addEventListener\("contextmenu", showSidePanelContextMenu\)[\s\S]*event\.key !== "ContextMenu"[\s\S]*event\.shiftKey && event\.key === "F10"/,
55
+ /function bindSidePanelContextMenu\(\)[\s\S]*\[elements\.sidePanelLeft, elements\.sidePanel\][\s\S]*addEventListener\("contextmenu", showSidePanelContextMenu\)[\s\S]*event\.key !== "ContextMenu"[\s\S]*event\.shiftKey && event\.key === "F10"/,
56
56
  "the menu should support pointer and standard keyboard context-menu activation",
57
57
  );
58
58
  assert.match(
@@ -11,15 +11,20 @@ const app = fs.readFileSync(path.join(root, "public/app.js"), "utf8");
11
11
  const server = fs.readFileSync(path.join(root, "bin/pi-webui.mjs"), "utf8");
12
12
 
13
13
  test("Control Deck exposes an accessible resize separator", () => {
14
- assert.match(html, /id="sidePanelResizeHandle"[^>]*role="separator"[^>]*aria-orientation="vertical"[^>]*aria-label="Resize Control Deck width"[^>]*tabindex="0"/);
14
+ assert.match(html, /id="sidePanelResizeHandle"[^>]*role="separator"[^>]*aria-orientation="vertical"[^>]*aria-label="Resize right Control Deck width"[^>]*tabindex="0"/);
15
+ assert.match(html, /id="sidePanelLeftResizeHandle"[^>]*role="separator"[^>]*aria-orientation="vertical"[^>]*aria-label="Resize left Control Deck width"[^>]*tabindex="0"/);
15
16
  assert.match(css, /--side-panel-width:\s*384px/);
16
- assert.match(css, /\.side-panel-resize-handle[\s\S]*cursor:\s*col-resize[\s\S]*touch-action:\s*none/);
17
+ assert.match(css, /\.file-viewer-resize-handle,[\s\S]*\.side-panel-resize-handle,[\s\S]*\.terminal-tabs-resize-handle \{[\s\S]*width:\s*1\.35rem;[\s\S]*height:\s*5\.2rem;[\s\S]*cursor:\s*col-resize;[\s\S]*touch-action:\s*none;/, "the Control Deck handle must keep its 1.35rem hit target and pointer geometry");
18
+ assert.match(css, /\.side-panel-resize-handle::after \{[\s\S]*left:\s*50%;[\s\S]*width:\s*0\.8rem;[\s\S]*transform:\s*translateX\(-50%\);/, "the painted Control Deck pill should be 0.8rem wide and centered within the hit target");
19
+ assert.match(css, /\.side-panel-resize-handle:hover::after,[\s\S]*\.side-panel-resize-handle:focus-visible::after,[\s\S]*body\.side-panel-resizing \.side-panel-resize-handle::after \{[\s\S]*border-color:/, "hover, focus, and active resizing must style the narrow painted pill rather than the hit target");
20
+ assert.match(css, /\.side-panel-resize-handle-right \{[\s\S]*left:\s*-1\.175rem/);
21
+ assert.match(css, /\.side-panel-resize-handle-left \{[\s\S]*right:\s*-1\.175rem;[\s\S]*left:\s*auto/, "the left Control Deck handle must sit in the workspace-facing inter-column gap");
17
22
  });
18
23
 
19
24
  test("desktop layouts and Control Deck content follow the selected width", () => {
20
- assert.match(css, /\.layout \{[\s\S]*grid-template-columns:\s*minmax\(0, 1fr\) minmax\(20rem, var\(--side-panel-width\)\)/);
21
- assert.match(css, /body\.file-viewer-open \.layout \{[\s\S]*minmax\(24rem, var\(--file-viewer-width\)\) minmax\(20rem, var\(--side-panel-width\)\)/);
22
- assert.match(css, /body\.terminal-split-open\.file-viewer-open \.layout \{[\s\S]*minmax\(20rem, var\(--side-panel-width\)\)/);
25
+ assert.match(css, /\.layout \{[\s\S]*grid-template-columns:\s*minmax\(20rem, var\(--side-panel-left-width, 384px\)\) minmax\(0, 1fr\) minmax\(20rem, var\(--side-panel-right-width, var\(--side-panel-width\)\)\)/);
26
+ assert.match(css, /body\.control-deck-left \.layout[\s\S]*grid-template-columns:/);
27
+ assert.match(css, /body\.control-deck-both \.layout[\s\S]*grid-template-columns:/);
23
28
  assert.match(css, /\.side-panel \{[\s\S]*width:\s*100%;[\s\S]*min-width:\s*0/);
24
29
  });
25
30
 
@@ -27,25 +32,30 @@ test("Control Deck width is clamped, user-persisted, pointer-resizable, and keyb
27
32
  assert.match(app, /const SIDE_PANEL_WIDTH_STORAGE_KEY = "pi-webui-side-panel-width"/);
28
33
  assert.match(app, /const SIDE_PANEL_WIDTH_MAX_PX = 4096/);
29
34
  assert.match(app, /width >= SIDE_PANEL_WIDTH_MIN_PX && width <= SIDE_PANEL_WIDTH_MAX_PX/);
30
- assert.match(app, /function persistSidePanelWidth\(width\)[\s\S]*\/api\/interface-preferences[\s\S]*sidePanelWidth: rounded[\s\S]*scoped: false/);
35
+ assert.match(app, /function persistSidePanelWidth\(width, side = "right"\)[\s\S]*panelWidths[\s\S]*markDurableUiLayoutDirty\("sidePanel", "panelWidths"\)/);
31
36
  assert.match(app, /async function restoreSidePanelWidthPreference\(\)[\s\S]*\/api\/interface-preferences[\s\S]*response\.data\?\.preferences\?\.sidePanelWidth[\s\S]*cacheSidePanelWidth/);
32
37
  assert.match(server, /url\.pathname === "\/api\/interface-preferences" && req\.method === "GET"/);
33
38
  assert.match(server, /url\.pathname === "\/api\/interface-preferences" && req\.method === "PUT"/);
34
- assert.match(app, /function sidePanelMaxWidth\(\)[\s\S]*fileViewerVisible[\s\S]*splitOpen[\s\S]*primaryMinWidth[\s\S]*available/);
35
- assert.match(app, /function applySidePanelWidth\(width, \{ persist = false \} = \{\}\)[\s\S]*--side-panel-width[\s\S]*persistSidePanelWidth/);
36
- assert.match(app, /function beginSidePanelResize\(event\)[\s\S]*setPointerCapture[\s\S]*pointermove[\s\S]*pointercancel/);
37
- assert.match(app, /function updateSidePanelResize\(event\)[\s\S]*state\.startWidth \+ \(state\.startX - event\.clientX\)/);
39
+ assert.match(app, /function sidePanelMaxWidth\(side = "right"\)[\s\S]*fileViewerVisible[\s\S]*splitOpen[\s\S]*centralMinimum[\s\S]*otherPanelWidth[\s\S]*available/);
40
+ assert.match(app, /function applySidePanelWidth\(width, \{ persist = false, side = "right" \} = \{\}\)[\s\S]*--side-panel-left-width[\s\S]*--side-panel-right-width[\s\S]*if \(side === "right"\)[\s\S]*--side-panel-width[\s\S]*persistSidePanelWidth/);
41
+ assert.match(app, /function controlDeckSideResizeAvailable\(side = "right"\)[\s\S]*presentation === "left"[\s\S]*presentation === "both"[\s\S]*presentation === "right"/);
42
+ assert.match(app, /function beginSidePanelResize\(event, forcedSide = null\)[\s\S]*controlDeckSideResizeAvailable\(side\)[\s\S]*setPointerCapture[\s\S]*pointermove[\s\S]*pointercancel/);
43
+ assert.match(app, /function updateSidePanelResize\(event\)[\s\S]*state\.side === "left" \? event\.clientX - state\.startX : state\.startX - event\.clientX/);
44
+ assert.match(app, /function persistSidePanelWidth\(width, side = "right"\)[\s\S]*if \(side === "right"\) cacheSidePanelWidth\(rounded\)/, "left width must not overwrite the legacy right-width mirror");
45
+ assert.match(app, /sidePanel:\s*Boolean\(sidePanelSectionPointerDrag\?\.active \|\| sidePanelResizeState\)/, "active side-panel resize must fence durable reconciliation");
38
46
  assert.match(app, /function handleSidePanelResizeKeydown\(event\)[\s\S]*ArrowLeft[\s\S]*ArrowRight[\s\S]*Home[\s\S]*End/);
39
47
  assert.match(app, /elements\.sidePanelResizeHandle\?\.addEventListener\("pointerdown", beginSidePanelResize\);\nelements\.sidePanelResizeHandle\?\.addEventListener\("keydown", handleSidePanelResizeKeydown\);/);
48
+ assert.match(app, /elements\.sidePanelResizeHandleLeft\?\.addEventListener\("pointerdown", \(event\) => beginSidePanelResize\(event, "left"\)\);\nelements\.sidePanelResizeHandleLeft\?\.addEventListener\("keydown", handleSidePanelResizeKeydown\);/);
49
+ assert.match(app, /function reconcileControlDeckHosts\(\)[\s\S]*updateSidePanelResizeHandle\(currentSidePanelWidth\("left"\), "left"\)[\s\S]*updateSidePanelResizeHandle\(currentSidePanelWidth\("right"\), "right"\)/);
40
50
  });
41
51
 
42
52
  test("Control Deck resizing disables itself in overlay layouts and responds to viewport changes", () => {
43
- assert.match(app, /const resizeAvailable = !isSidePanelOverlayView\(\) && !document\.body\.classList\.contains\("side-panel-collapsed"\)/);
53
+ assert.match(app, /function controlDeckSideResizeAvailable\(side = "right"\)[\s\S]*presentation === "overlay"[\s\S]*presentation === "embedded"[\s\S]*collapsedPanels/);
44
54
  assert.match(css, /@media \(max-width: 1050px\)[\s\S]*\.file-viewer-resize-handle,[\s\S]*\.side-panel-resize-handle \{\s*display:\s*none/);
45
- assert.match(app, /window\.addEventListener\("resize", syncResizablePanelWidthsForViewport/);
46
- assert.match(app, /function syncSidePanelWidthForViewport\(\)[\s\S]*applySidePanelWidth\(readStoredSidePanelWidth\(\) \|\| currentSidePanelWidth\(\)\)/, "hard-reset startup reconciliation should preserve the durable width instead of freezing an in-progress CSS transition");
47
- assert.match(app, /function updateFileViewerUi\(\)[\s\S]*requestAnimationFrame\(syncResizablePanelWidthsForViewport\)/);
48
- assert.match(app, /function closeFileViewer\(\)[\s\S]*requestAnimationFrame\(syncResizablePanelWidthsForViewport\)/);
49
- assert.match(app, /function updateTerminalSplitUi\(\)[\s\S]*requestAnimationFrame\(syncResizablePanelWidthsForViewport\)/);
55
+ assert.match(app, /window\.addEventListener\("resize", scheduleControlDeckPresentationReconciliation/);
56
+ assert.match(app, /function syncSidePanelWidthForViewport\(\)[\s\S]*applySidePanelWidth\(controlDeckLayout\.panelWidths\?\.left[\s\S]*applySidePanelWidth\(controlDeckLayout\.panelWidths\?\.right/, "viewport reconciliation should preserve both durable widths instead of freezing an in-progress CSS transition");
57
+ assert.match(app, /function updateFileViewerUi\(\)[\s\S]*scheduleControlDeckPresentationReconciliation\(\)/);
58
+ assert.match(app, /function resetFileViewerUi\(\)[\s\S]*scheduleControlDeckPresentationReconciliation\(\)/);
59
+ assert.match(app, /function updateTerminalSplitUi\(\)[\s\S]*scheduleControlDeckPresentationReconciliation\(\)/);
50
60
  assert.match(app, /restoreSidePanelWidthPreference\(\);\nrestoreFileViewerWidthPreference\(\);/);
51
61
  });
@@ -24,11 +24,11 @@ for (const removedToken of [
24
24
  assert.doesNotMatch(css, new RegExp(removedToken), `${removedToken} should be absent from side-panel styles`);
25
25
  }
26
26
  assert.doesNotMatch(layout, /sectionHeightMin|sectionHeightMax|validateSectionHeights|sectionHeights/, "the durable layout schema should not expose section heights");
27
- assert.match(app, /const UI_LAYOUT_SIDE_PANEL_FIELDS = \["sectionOrder", "collapsedSectionIds", "hiddenSectionIds", "collapsed"\];/, "the browser durable layout field list should omit section heights");
27
+ assert.match(app, /const UI_LAYOUT_SIDE_PANEL_FIELDS = \["placement", "sectionLayout", "collapsedSectionIds", "hiddenSectionIds", "collapsedPanels", "panelWidths"\];/, "the browser durable layout field list should omit section heights");
28
28
  assert.match(app, /function clearRemovedSidePanelSectionHeightState\(\)[\s\S]*localStorage\.removeItem\(REMOVED_SIDE_PANEL_SECTION_HEIGHT_STORAGE_KEY\)[\s\S]*record\.field === "sidePanel" && record\.subfield === "sectionHeights"/, "startup should remove the retired cache and pending mutations");
29
29
  assert.match(app, /clearRemovedSidePanelSectionHeightState\(\);\s*restoreDurableUiLayoutPendingJournal\(\);/, "retired height state should be cleared before pending layout restoration");
30
- assert.match(html, /styles\.css\?v=107/, "removing section resize styles should advance the stylesheet revision");
31
- assert.match(html, /app\.js\?v=121/, "removing section resize behavior should advance the app revision");
32
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v84"/, "removing browser assets should advance the PWA cache identity");
30
+ assert.match(html, /styles\.css\?v=115/, "removing section resize styles should advance the stylesheet revision");
31
+ assert.match(html, /app\.js\?v=132/, "removing section resize behavior should advance the app revision");
32
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v94"/, "removing browser assets should advance the PWA cache identity");
33
33
 
34
34
  console.log("side-panel-section-height-removal-static.test.mjs passed");
@@ -4,78 +4,24 @@ import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
6
6
  const root = join(dirname(fileURLToPath(import.meta.url)), "..");
7
- const [html, app, css, serviceWorker] = await Promise.all([
7
+ const [html, app, css] = await Promise.all([
8
8
  readFile(join(root, "public", "index.html"), "utf8"),
9
9
  readFile(join(root, "public", "app.js"), "utf8"),
10
10
  readFile(join(root, "public", "styles.css"), "utf8"),
11
- readFile(join(root, "public", "service-worker.js"), "utf8"),
12
11
  ]);
13
-
14
- assert.match(
15
- app,
16
- /const SIDE_PANEL_SECTION_ORDER_STORAGE_KEY = "pi-webui-side-panel-section-order-v1";[\s\S]*const SIDE_PANEL_SECTION_POINTER_DRAG_THRESHOLD_PX = 6;/,
17
- "side-panel order should use versioned browser storage and the same six-pixel pointer threshold as model ordering",
18
- );
19
- assert.match(
20
- app,
21
- /function readStoredSidePanelSectionOrder\(\)[\s\S]*JSON\.parse\(localStorage\.getItem\(SIDE_PANEL_SECTION_ORDER_STORAGE_KEY\)[\s\S]*new Set\([\s\S]*function persistSidePanelSectionOrder\(\)[\s\S]*sidePanelSectionRecords\(\)\.map\(\(\{ id \}\) => id\)/,
22
- "stored order should be deduplicated and persist the complete current section order",
23
- );
24
- assert.match(
25
- app,
26
- /function restoreSidePanelSectionOrder\(\)[\s\S]*rank = new Map\([\s\S]*Number\.MAX_SAFE_INTEGER[\s\S]*parent\.append\(section\)/,
27
- "restore should rank known IDs while appending newly introduced sections in their existing order",
28
- );
29
- assert.match(
30
- app,
31
- /function isSidePanelSectionReorderingEnabled\(\) \{\n\s+return !isMobileView\(\) \|\| sidePanelSectionEditMode;[\s\S]*function moveSidePanelSectionRelative\(fromId, targetRecord, insertBefore\) \{\n\s+if \(!isSidePanelSectionReorderingEnabled\(\)\) return false;[\s\S]*parent\.insertBefore\(sourceRecord\.section, targetRecord\.section\)[\s\S]*targetRecord\.section\.nextSibling[\s\S]*persistSidePanelSectionOrder\(\)/,
32
- "desktop reordering should stay enabled while mobile reordering fails closed outside Edit mode",
33
- );
34
- assert.match(
35
- app,
36
- /function moveSidePanelSectionByOffset\(sectionId, offset\) \{\n\s+if \(!isSidePanelSectionReorderingEnabled\(\)\) return false;/,
37
- "keyboard reordering should follow the desktop-always/mobile-Edit gate",
38
- );
39
- assert.match(
40
- app,
41
- /function beginSidePanelSectionPointerDrag\(event, sectionId\) \{\n\s+if \(!isSidePanelSectionReorderingEnabled\(\) \|\| event\.button !== 0/,
42
- "pointer and touch dragging should follow the responsive reorder gate",
43
- );
44
- assert.match(
45
- app,
46
- /function updateSidePanelSectionPointerDrag\(event\)[\s\S]*Math\.hypot[\s\S]*SIDE_PANEL_SECTION_POINTER_DRAG_THRESHOLD_PX[\s\S]*sidePanelSectionToggleFromPoint[\s\S]*getBoundingClientRect\(\)[\s\S]*moveSidePanelSectionRelative/,
47
- "edit-mode pointer dragging should activate only after the threshold and use header midpoint placement",
48
- );
49
- assert.match(
50
- app,
51
- /function endSidePanelSectionPointerDrag\(event\)[\s\S]*sidePanelSectionSuppressClickUntil = Date\.now\(\) \+ 250[\s\S]*focus\(\{ preventScroll: true \}\)/,
52
- "a completed drag should suppress the accidental toggle click and restore focus",
53
- );
54
- assert.match(
55
- app,
56
- /function bindSidePanelSectionToggles\(\)[\s\S]*Date\.now\(\) < sidePanelSectionSuppressClickUntil[\s\S]*!isSidePanelSectionReorderingEnabled\(\) \|\| !event\.altKey[\s\S]*event\.key !== "ArrowUp"[\s\S]*moveSidePanelSectionByOffset[\s\S]*beginSidePanelSectionPointerDrag/,
57
- "section headers should retain click toggling while the responsive gate controls Alt+Arrow and pointer reordering",
58
- );
59
- assert.match(
60
- app,
61
- /restoreSidePanelSectionOrder\(\);\s*restoreSidePanelSectionVisibility\(\);\s*restoreSidePanelSectionState\(\);/,
62
- "saved order should restore before visibility and accordion state",
63
- );
64
- assert.match(
65
- app,
66
- /event\.key === SIDE_PANEL_SECTION_ORDER_STORAGE_KEY\) restoreSidePanelSectionOrder\(\)/,
67
- "other tabs should apply stored side-panel order changes",
68
- );
69
- assert.match(
70
- css,
71
- /\.side-panel-edit-button \{\n\s+display: none;[\s\S]*?\.side-panel\.section-edit-mode \.side-panel-section-toggle\[data-side-panel-section-toggle\] \{\n\s+cursor: grab;\n\s+touch-action: none;\n\s+user-select: none;\n\}[\s\S]*?@media \(max-width: 720px\), \(max-device-width: 720px\), \(pointer: coarse\) and \(hover: none\) \{[\s\S]*?\.side-panel-edit-button \{ display: inline-flex;[\s\S]*?\.side-panel\.section-edit-mode \.side-panel-section-toggle\[data-side-panel-section-toggle\] \{\n\s+border-color:[\s\S]*?box-shadow:[\s\S]*?\.side-panel\.section-edit-mode \.side-panel-section-label::before \{/,
72
- "desktop should keep drag capture without edit highlighting while mobile restores Edit and its visual affordance",
73
- );
74
- assert.match(html, /id="sidePanelEditButton"[^>]*aria-controls="sidePanel"[^>]*aria-pressed="false"[^>]*aria-label="Edit Control Deck section order"[\s\S]*side-panel-edit-button-label">Edit</, "mobile Control Deck should retain an accessible Edit toggle");
75
- assert.match(app, /function setSidePanelSectionEditMode\(enabled\)[\s\S]*const next = isMobileView\(\) && !!enabled;[\s\S]*classList\.toggle\("section-edit-mode", reorderingEnabled\)[\s\S]*aria-pressed[\s\S]*"Done" : "Edit"[\s\S]*aria-keyshortcuts/, "mobile Edit state and always-enabled desktop reorder affordances should stay synchronized");
76
- assert.match(app, /function setSidePanelCollapsed\(collapsed,[\s\S]*if \(collapsed\) setSidePanelSectionEditMode\(false\);/, "closing the Control Deck should leave transient edit mode");
77
- assert.match(html, /styles\.css\?v=107/, "changed side-panel styles should advance the stylesheet revision");
78
- assert.match(html, /app\.js\?v=121/, "changed side-panel behavior should advance the app revision");
79
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v84"/, "changed browser assets should advance the PWA cache identity");
80
-
12
+ assert.match(app, /const SIDE_PANEL_SECTION_ORDER_STORAGE_KEY = "pi-webui-side-panel-section-order-v1"/);
13
+ assert.match(app, /const SIDE_PANEL_SECTION_POINTER_DRAG_THRESHOLD_PX = 6/);
14
+ assert.match(app, /function controlDeckSectionRecords\(\)[\s\S]*document\.querySelectorAll\("\[data-side-panel-section\]"\)/);
15
+ assert.match(app, /function persistControlDeckSectionLayout\(\)[\s\S]*sectionLayout[\s\S]*markDurableUiLayoutDirty\("sidePanel", "sectionLayout"\)/);
16
+ assert.match(app, /function moveSidePanelSectionRelative\(fromId, targetRecord, insertBefore, targetSide = null\)[\s\S]*parent\.insertBefore\(sourceRecord\.section, targetRecord\.section\)/);
17
+ assert.match(app, /function moveSidePanelSectionToSide\(sectionId, side\)[\s\S]*effectiveControlDeckPresentation\(\) !== "both"/);
18
+ assert.match(app, /function updateSidePanelSectionPointerDrag\(event\)[\s\S]*Math\.hypot[\s\S]*SIDE_PANEL_SECTION_POINTER_DRAG_THRESHOLD_PX[\s\S]*data-control-deck-drop-target/);
19
+ assert.match(app, /\["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"\]/);
20
+ assert.match(app, /function setOnlySidePanelSectionExpanded[\s\S]*controlDeckSectionSide\(record\.id\) !== targetSide/);
21
+ assert.match(app, /function setSidePanelSectionEditMode\(enabled\)[\s\S]*const next = isMobileView\(\) && !!enabled/);
22
+ assert.match(html, /id="sidePanelEditButton"[^>]*aria-controls="sidePanel"[^>]*aria-pressed="false"/);
23
+ assert.match(html, /data-control-deck-drop-target="left"/);
24
+ assert.match(html, /data-control-deck-drop-target="right"/);
25
+ assert.match(css, /\.side-panel\.section-edit-mode \.side-panel-section-toggle\[data-side-panel-section-toggle\]/);
26
+ assert.match(css, /\.side-panel-section\.drag-over-before/);
81
27
  console.log("side-panel-section-reorder-static.test.mjs passed");
@@ -71,7 +71,8 @@ const [app, css, serviceWorker, server, pkgRaw] = await Promise.all([
71
71
  const pkg = JSON.parse(pkgRaw);
72
72
 
73
73
  assert.match(app, /from "\.\/subagent-gate-visibility\.mjs"/, "the browser should load the retry-gate visibility policy");
74
- assert.match(app, /function subagentTabsWithRunningAgents\(\)[\s\S]*latestSubagents\?\.updatedAt[\s\S]*visibleSubagentGates\(tab, dismissedSubagentGateKeys, now\)[\s\S]*ungatedSubagentRuns\(tab\)[\s\S]*displayRuns/, "the side panel should filter retry-gated runs while retaining the gate attempts as their only rows");
74
+ assert.match(app, /function subagentOverviewGroups[\s\S]*Number\(data\?\.version\) === 2[\s\S]*displayRuns: runs/, "the side panel should render canonical v2 runs without recounting gate references");
75
+ assert.match(app, /const gates = visibleSubagentGates\(tab, dismissedSubagentGateKeys, now\);[\s\S]*displayRuns: ungatedSubagentRuns\(tab\)/, "the v1 fallback should retain gate-owned run filtering");
75
76
  assert.match(app, /function renderSubagentGate\(tab, gate\)[\s\S]*subagentGateIsTerminal\(gate\)[\s\S]*Hide finished retry gate[\s\S]*dismissedSubagentGateKeys\.add\(key\)[\s\S]*renderSubagents\(\)[\s\S]*event\.detail === 0[\s\S]*focusTarget\?\.focus/, "terminal gate cards should expose an accessible hide button and preserve keyboard focus after rerendering");
76
77
  assert.match(app, /pruneDismissedSubagentGateKeys\(latestSubagents\?\.tabs, dismissedSubagentGateKeys\)/, "polling should prune stale dismissal keys");
77
78
  assert.match(css, /\.subagent-gate-actions[\s\S]*\.subagent-gate-close[\s\S]*min-width:\s*1\.45rem[\s\S]*background:\s*transparent[\s\S]*\.subagent-gate-close:hover,[\s\S]*\.subagent-gate-close:focus-visible/, "the close control should remain minimal, compact, and keyboard-visible");
@@ -125,7 +125,7 @@ try {
125
125
  await writeFile(settingsFile, `${JSON.stringify({ version: 4, unrelated: { preserve: true }, remoteAuthEnabled: true }, null, 2)}\n`, "utf8");
126
126
  await writeWebuiSettings({ subagentLaunchSlots: config }, settingsFile);
127
127
  const persisted = JSON.parse(await readFile(settingsFile, "utf8"));
128
- assert.equal(persisted.version, 6, "persisted launch-slot settings must retain the current version-6 envelope");
128
+ assert.equal(persisted.version, 7, "persisted launch-slot settings must retain the current version-7 envelope");
129
129
  assert.deepEqual(persisted.unrelated, { preserve: true }, "launch-slot saves must preserve unrelated WebUI settings");
130
130
  assert.deepEqual((await readWebuiSettings(settingsFile)).subagentLaunchSlots.projects[projectKey].roles, defaultRoles);
131
131
 
@@ -0,0 +1,32 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFile } from "node:fs/promises";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
7
+ const [app, html, css, worker] = await Promise.all([
8
+ readFile(join(root, "public", "app.js"), "utf8"),
9
+ readFile(join(root, "public", "index.html"), "utf8"),
10
+ readFile(join(root, "public", "styles.css"), "utf8"),
11
+ readFile(join(root, "public", "service-worker.js"), "utf8"),
12
+ ]);
13
+
14
+ assert.match(app, /function subagentOverviewGroups[\s\S]*Number\(data\?\.version\) === 2[\s\S]*Array\.isArray\(data\?\.groups\)[\s\S]*Array\.isArray\(data\?\.tabs\)/, "browser should prefer v2 groups while retaining a v1 tabs fallback");
15
+ for (const label of ["SDK", "Pi RPC", "Pi JSON", "Pi print", "Pi session", "tmux", "pi-subagents", "scheduled", "gate", "workflow", "custom"]) assert.ok(app.includes(`"${label}"`), `launcher label ${label} should be present`);
16
+ for (const state of ["queued", "running", "stale", "lost", "done", "failed", "cancelled"]) {
17
+ assert.ok(app.includes(`"${state}"`), `lifecycle ${state} should be normalized`);
18
+ assert.match(css, new RegExp(`\\.subagent-state-dot\\.${state}`), `lifecycle ${state} should have a distinct CSS state`);
19
+ }
20
+ assert.match(app, /counts\?\.totalAgents[\s\S]*counts\?\.runningAgents[\s\S]*counts\?\.staleAgents/, "canonical retained-inclusive total and running/stale breakdown should drive status");
21
+ assert.match(app, /URLSearchParams\(\{ group: selection\.groupId, run: selection\.runId, agent: selection\.agentId \}\)/, "overlay should use the unified group/run/agent output query");
22
+ assert.match(app, /URLSearchParams\(\{ group: view\.groupId, run: view\.runId, agent: view\.agentId \}\)/, "view-only tab should use the unified group/run/agent output query");
23
+ assert.match(app, /subagentRunCanRefresh[\s\S]*subagentRunCanCancel[\s\S]*subagentRunCanDismiss/, "controls should be capability-aware");
24
+ assert.match(app, /function subagentRunIsAttachedProjection[\s\S]*source === "explicit-attach"[\s\S]*function subagentRunCanDismiss[\s\S]*provider === "webui-registry"/, "terminal registry rows should clear while stale explicit attaches remain manually detachable");
25
+ assert.match(app, /function finishedSubagentRunSelections[\s\S]*subagentRunIsTerminal\(run\) && subagentRunCanDismiss\(run\)/, "Auto-Clear should not immediately remove stale attached sessions");
26
+ assert.match(app, /agent\.unavailableReason[\s\S]*Output is unavailable for this registered agent/, "output views should show truthful unavailable evidence");
27
+ assert.match(css, /\.subagent-source-badge[\s\S]*text-overflow: ellipsis[\s\S]*@media \(max-width: 720px\)/, "source badges should remain compact and responsive");
28
+ assert.match(html, /Managed and registered Pi agent runs[\s\S]*External agents/, "help should explain managed, registered, and external groups");
29
+ assert.match(html, /styles\.css\?v=115[\s\S]*app\.js\?v=132/, "browser assets should use the WS-D revisions");
30
+ assert.match(worker, /pi-webui-pwa-v94/, "PWA cache identity should advance with WS-D browser assets");
31
+
32
+ console.log("subagent-observability-static.test.mjs passed");
@@ -0,0 +1,161 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFile } from "node:fs/promises";
3
+ import vm from "node:vm";
4
+ import { dirname, join } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+
7
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
8
+ const [server, app, helper] = await Promise.all([
9
+ readFile(join(root, "bin", "pi-webui.mjs"), "utf8").then((value) => value.replace(/\r\n/g, "\n")),
10
+ readFile(join(root, "public", "app.js"), "utf8").then((value) => value.replace(/\r\n/g, "\n")),
11
+ readFile(join(root, "webui-rpc-helper.mjs"), "utf8").then((value) => value.replace(/\r\n/g, "\n")),
12
+ ]);
13
+
14
+ function sourceBetween(text, start, end) {
15
+ const startIndex = text.indexOf(start);
16
+ const endIndex = text.indexOf(end, startIndex);
17
+ assert.ok(startIndex >= 0 && endIndex > startIndex, `expected source boundaries: ${start} -> ${end}`);
18
+ return text.slice(startIndex, endIndex);
19
+ }
20
+
21
+ const normalizationSource = sourceBetween(
22
+ server,
23
+ "function normalizeWebuiSubagentText(",
24
+ "\nfunction rememberWebuiSubagentsStatusEvent(",
25
+ );
26
+ const normalizationContext = {
27
+ WEBUI_SUBAGENT_RUN_LIMIT: 128,
28
+ WEBUI_SUBAGENT_AGENT_LIMIT: 256,
29
+ WEBUI_SUBAGENT_GATE_LIMIT: 32,
30
+ WEBUI_SUBAGENT_GATE_ATTEMPT_LIMIT: 100,
31
+ };
32
+ vm.runInNewContext(`${normalizationSource}\nthis.normalizePayload = normalizeWebuiSubagentPayload;`, normalizationContext);
33
+ const normalized = normalizationContext.normalizePayload({
34
+ version: 1,
35
+ available: true,
36
+ updatedAt: 100,
37
+ fleet: {
38
+ version: 1,
39
+ totalActive: 4,
40
+ omitted: 3,
41
+ entries: [{ key: "private-key", prompt: "private prompt", cwd: "C:/private" }],
42
+ privatePath: "C:/private",
43
+ },
44
+ privatePrompt: "do not expose",
45
+ runs: [{
46
+ id: "fleet:opaque",
47
+ source: "recovered",
48
+ provisional: true,
49
+ controllable: false,
50
+ status: "running",
51
+ startedAt: 10,
52
+ prompt: "private child prompt",
53
+ agents: [{ id: "fleet:opaque:agent", name: "Recovery scout", status: "running", model: "provider/model", thinking: "high", currentPath: "C:/private" }],
54
+ }],
55
+ });
56
+ assert.deepEqual(JSON.parse(JSON.stringify(normalized.fleet)), { version: 1, totalActive: 4, omitted: 3 }, "server should expose only bounded fleet aggregates");
57
+ const ordinary = normalizationContext.normalizePayload({
58
+ version: 1,
59
+ runs: [{ id: "run-ordinary", source: "async", status: "running", agents: [{ name: "worker", status: "running" }] }],
60
+ });
61
+ assert.equal(Object.hasOwn(ordinary.runs[0], "provisional"), false, "ordinary payload v1 rows should not gain recovery-only provisional metadata");
62
+ assert.equal(Object.hasOwn(ordinary.runs[0], "controllable"), false, "ordinary payload v1 rows should not gain recovery-only control metadata");
63
+ assert.deepEqual(JSON.parse(JSON.stringify(normalized.runs[0])), {
64
+ id: "fleet:opaque",
65
+ source: "recovered",
66
+ provisional: true,
67
+ controllable: false,
68
+ mode: "single",
69
+ status: "running",
70
+ startedAt: 10,
71
+ agents: [{
72
+ id: "fleet:opaque:agent",
73
+ name: "Recovery scout",
74
+ status: "running",
75
+ index: 0,
76
+ model: "provider/model",
77
+ thinking: "high",
78
+ nested: false,
79
+ }],
80
+ }, "server should preserve public recovery flags without leaking prompt, path, or raw fleet-entry fields");
81
+ assert.equal(normalizationContext.normalizePayload({ version: 1, fleet: { version: 1, totalActive: 1, omitted: 2 }, runs: [] }).fleet, null, "invalid aggregate counts should be discarded");
82
+
83
+ const canonicalProjectionSource = sourceBetween(
84
+ helper,
85
+ "function canonicalInstancesFromPublicRun(",
86
+ "\n /**\n * Canonical, deduplicated projection",
87
+ );
88
+ assert.match(canonicalProjectionSource, /Number\.isFinite\(run\.endedAt\) \? run\.endedAt : startedAt/, "a terminal run without endedAt should use one stable fallback timestamp");
89
+ assert.doesNotMatch(canonicalProjectionSource, /endedAt[^\n]*Date\.now\(\)/, "terminal projection timestamps must not change on every status poll");
90
+
91
+ const interactionSource = sourceBetween(
92
+ server,
93
+ "function webuiSubagentRunSupportsInteraction(",
94
+ "\nfunction restorableTabDescriptor(",
95
+ );
96
+ assert.match(interactionSource, /source !== "recovered"[\s\S]*provisional !== true[\s\S]*controllable !== false/, "server should treat every unsupported recovery signal as non-interactive");
97
+ assert.match(interactionSource, /requireInteractiveWebuiSubagentRun[\s\S]*!webuiSubagentRunSupportsInteraction\(run\)[\s\S]*webuiSubagentOutputData[\s\S]*requireInteractiveWebuiSubagentRun/, "output lookup should reject unsupported rows before helper dispatch");
98
+ assert.match(server, /\/api\/subagents\/cancel[\s\S]*rejectUnsupportedWebuiSubagentRun\(tab, body\.runId\)[\s\S]*\/api\/subagents\/dismiss[\s\S]*rejectUnsupportedWebuiSubagentRun\(tab, body\.runId\)/, "cancel and dismiss routes should reject unsupported recovered rows before helper dispatch");
99
+
100
+ const renderAgentSource = sourceBetween(app, "function renderSubagentAgent(", "\nfunction renderSubagentRun(");
101
+ assert.match(renderAgentSource, /make\(interactive \? "button" : "div"[\s\S]*metadata-only[\s\S]*if \(interactive\)[\s\S]*openSubagentOutput[\s\S]*output is unavailable from this provider/, "unsupported rows should use truthful non-button rendering with no output affordance");
102
+ const materializationSource = sourceBetween(app, "function materializeRetainedSubagentTerminalViews(", "\nfunction subagentTerminalViewGroups(");
103
+ assert.match(materializationSource, /subagentAgentStatus\(run\)[\s\S]*ensureSubagentTerminalView/, "only terminal open-capable rows should materialize retained terminal views");
104
+ assert.match(app, /function subagentRunCanCancel[\s\S]*capabilities\.cancel === true/, "canonical capability ownership should gate cancellation");
105
+ assert.match(app, /function subagentRunIsTerminal[\s\S]*\["done", "failed", "cancelled"\]/, "clear-finished should select only explicit terminal lifecycle states");
106
+ assert.match(app, /function subagentRunIsAttachedProjection[\s\S]*source === "explicit-attach"[\s\S]*\["stale", "lost"\]/, "stale explicit attached sessions should be manually detachable");
107
+ assert.match(app, /function subagentRunCanDismiss[\s\S]*subagentRunIsAttachedProjection\(run\)[\s\S]*provider === "webui-registry"/, "terminal registry projections and explicit attaches should expose the appropriate manual dismissal control");
108
+ assert.match(app, /function finishedSubagentRunSelections[\s\S]*subagentRunIsTerminal\(run\) && subagentRunCanDismiss\(run\)/, "auto-clear should remain limited to genuinely terminal rows");
109
+ assert.match(server, /function agentRunProjectionCanBeDismissed[\s\S]*origin === "explicit-attach"[\s\S]*dismissedAgentRunProjectionKeys\.has\(key\)[\s\S]*agentRunProjectionCanBeDismissed\(record\.instance\)[\s\S]*selection\.kind === "registry"[\s\S]*registrySelections[\s\S]*dismissAgentRunProjection\(candidate\.instance\)/, "registry dismissal should retain bounded tombstones only for terminal or explicit-attach WebUI projections");
110
+ const viewSyncSource = sourceBetween(app, "function syncSubagentTerminalViewsFromOverview(", "\nfunction materializeRetainedSubagentTerminalViews(");
111
+ assert.match(viewSyncSource, /run && !subagentRunCanOpen\(run,[\s\S]*subagentTerminalViews\.delete/, "a row that loses open capability should close an existing terminal output view");
112
+ assert.match(viewSyncSource, /run && !subagentRunCanOpen\(run,[\s\S]*subagentOverlaySelection = null/, "a row that loses open capability should close an existing output overlay");
113
+ assert.match(app, /async function openSubagentOverlay\(tab, run, agent\)[\s\S]*!subagentRunCanOpen\(run, agent\)/, "direct overlay entry should reject unsupported rows");
114
+ assert.match(app, /function subagentGateAttemptTarget\(tab, attempt\)[\s\S]*subagentRunCanOpen\(run, agent\)/, "retry-gate output entry should reject unsupported rows");
115
+
116
+ const refreshSource = sourceBetween(app, "async function refreshSubagents(", "\nfunction scheduleRefreshSubagents(");
117
+ let resolveFirst;
118
+ let resolveSecond;
119
+ let apiCalls = 0;
120
+ const firstResponse = new Promise((resolve) => { resolveFirst = resolve; });
121
+ const secondResponse = new Promise((resolve) => { resolveSecond = resolve; });
122
+ const refreshContext = {
123
+ subagentsRefreshPromise: null,
124
+ subagentsRefreshQueued: false,
125
+ subagentsLoading: false,
126
+ latestSubagents: null,
127
+ subagentsError: null,
128
+ dismissedSubagentGateKeys: new Set(),
129
+ subagentOverlaySelection: null,
130
+ activeTabId: "tab-a",
131
+ activeSubagentTerminalId: null,
132
+ subagentAutoClearEnabled: false,
133
+ renderSubagents() {},
134
+ pruneDismissedSubagentGateKeys() {},
135
+ syncSubagentTerminalViewsFromOverview() { return false; },
136
+ materializeRetainedSubagentTerminalViews() { return false; },
137
+ renderWidgets() {},
138
+ renderSubagentTerminalView() {},
139
+ scheduleSubagentTerminalRefresh() {},
140
+ renderTabs() {},
141
+ finishedSubagentRunSelections() { return []; },
142
+ async clearFinishedSubagentRuns() {},
143
+ api() {
144
+ apiCalls += 1;
145
+ return apiCalls === 1 ? firstResponse : secondResponse;
146
+ },
147
+ };
148
+ vm.runInNewContext(`${refreshSource}\nthis.runRefreshSubagents = refreshSubagents;`, refreshContext);
149
+ const initialRefresh = refreshContext.runRefreshSubagents();
150
+ const overlappingRefresh = refreshContext.runRefreshSubagents();
151
+ assert.equal(apiCalls, 1, "an overlapping refresh should coalesce while the first request is in flight");
152
+ resolveFirst({ data: { revision: "stale" } });
153
+ await new Promise((resolve) => setImmediate(resolve));
154
+ assert.equal(apiCalls, 2, "an overlapping request should guarantee one trailing authoritative refresh");
155
+ resolveSecond({ data: { revision: "authoritative" } });
156
+ await Promise.all([initialRefresh, overlappingRefresh]);
157
+ assert.equal(refreshContext.latestSubagents?.revision, "authoritative", "the trailing refresh should own final browser state");
158
+ assert.equal(refreshContext.subagentsLoading, false, "coalesced refresh should release its loading guard");
159
+ assert.equal(refreshContext.subagentsRefreshPromise, null, "coalesced refresh should clear its shared promise");
160
+
161
+ console.log("subagent-reliability-integration.test.mjs passed");