@firstpick/pi-package-webui 0.9.3 → 0.9.4

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 (32) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/public/app.js +36 -4
  4. package/public/index.html +2 -2
  5. package/public/service-worker.js +1 -1
  6. package/public/styles.css +35 -4
  7. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  8. package/tests/browser/intercom-conversation-viewer.spec.mjs +2 -0
  9. package/tests/codex-fast-mode-static.test.mjs +2 -2
  10. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  11. package/tests/controls-layout-static.test.mjs +3 -3
  12. package/tests/fast-mode-client-static.test.mjs +1 -1
  13. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  14. package/tests/file-viewer-image-static.test.mjs +3 -3
  15. package/tests/intercom-conversation-viewer-static.test.mjs +5 -4
  16. package/tests/main-output-loading-static.test.mjs +3 -3
  17. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  18. package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
  19. package/tests/mobile-foundation-static.test.mjs +3 -3
  20. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  21. package/tests/mobile-static.test.mjs +3 -3
  22. package/tests/open-issue-wizard-static.test.mjs +1 -1
  23. package/tests/persistent-ui-layout-static.test.mjs +3 -3
  24. package/tests/questionnaire-dialog.test.mjs +3 -3
  25. package/tests/session-sampling-ui-static.test.mjs +3 -3
  26. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  27. package/tests/subagent-observability-static.test.mjs +4 -2
  28. package/tests/subagents-helper.test.mjs +109 -0
  29. package/tests/syntax-highlighting-static.test.mjs +3 -3
  30. package/tests/terminal-cwd-grouping-static.test.mjs +22 -0
  31. package/tests/theme-customizer-static.test.mjs +1 -1
  32. package/webui-rpc-helper.mjs +126 -5
package/README.md CHANGED
@@ -17,7 +17,7 @@ Pi Web UI keeps the normal Pi agent experience while giving you more room to man
17
17
 
18
18
  | Area | Highlights |
19
19
  | --- | --- |
20
- | **Sessions and workspaces** | Run several isolated Pi sessions, resume prior work, switch projects, preserve per-tab drafts, and create branch worktrees. |
20
+ | **Sessions and workspaces** | Run several isolated Pi sessions, resume prior work, switch projects, preserve per-tab drafts, add another tab directly from the tab strip, and create branch worktrees. |
21
21
  | **Live agent work** | Follow streaming Markdown with syntax highlighting for code blocks, thinking, tool output, queues, todo progress, managed agent runs, and direct agent-to-agent conversations without leaving the browser. |
22
22
  | **Models and controls** | Change models and thinking effort, manage scoped models, configure tools and skills, and use the command palette. |
23
23
  | **Files and prompts** | Upload or paste files and images, edit text attachments, use slash-command suggestions, browse project files, and reference project paths with `@`. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firstpick/pi-package-webui",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "description": "Pi Web UI companion package with a local browser UI CLI plus /webui-start and /webui-status commands.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/Firstp1ck/pi-coding-agent-forge/tree/main/pi-package-webui#readme",
package/public/app.js CHANGED
@@ -1222,6 +1222,7 @@ const WORKFLOW_WIDGET_PAYLOAD_PREFIX = "WORKFLOW_WEBUI_PAYLOAD ";
1222
1222
  const WORKFLOW_SUBPROCESS_PAYLOAD_TYPE = "firstpick.pi-extension-workflows.subprocess";
1223
1223
  const WORKFLOW_SUBPROCESS_PAYLOAD_VERSION = 1;
1224
1224
  const WORKFLOW_INSPECTOR_WIDGET_KEY = "workflow:rpc";
1225
+ const SUBAGENT_ASYNC_WIDGET_KEY = "subagent-async";
1225
1226
  const WORKFLOW_INSPECTOR_PAYLOAD_PREFIX = "WORKFLOW_RPC_PAYLOAD ";
1226
1227
  const WORKFLOW_INSPECTOR_PAYLOAD_TYPE = "firstpick.pi-extension-workflows.inspector";
1227
1228
  const WORKFLOW_INSPECTOR_PAYLOAD_VERSION = 1;
@@ -5762,7 +5763,7 @@ function bindTerminalTabDragAndDrop(element, { sourceTabId = "", target = null }
5762
5763
  element.draggable = true;
5763
5764
  element.dataset.dragTabId = sourceTabId;
5764
5765
  element.addEventListener("dragstart", (event) => {
5765
- if (event.target?.closest?.(".terminal-tab-close, .terminal-tab-actions, .terminal-tab-group-add")) {
5766
+ if (event.target?.closest?.(".terminal-tab-close, .terminal-tab-actions, .terminal-tab-cwd-add, .terminal-tab-group-add")) {
5766
5767
  event.preventDefault();
5767
5768
  return;
5768
5769
  }
@@ -16137,7 +16138,25 @@ function appendTerminalTabContent(button, { title, indicator, meta, count = null
16137
16138
  button.append(titleRow, make("span", "terminal-tab-meta", meta));
16138
16139
  }
16139
16140
 
16140
- function renderTerminalTab(tab) {
16141
+ function createTerminalTabCwdAddMenu(tab) {
16142
+ const cwdTitle = tabGroupTitle(tab?.cwd, "working directory");
16143
+ const menu = make("div", "terminal-tab-cwd-add-menu");
16144
+ menu.setAttribute("role", "group");
16145
+ menu.setAttribute("aria-label", `Actions for ${cwdTitle}`);
16146
+ const add = make("button", "terminal-tab-group-add terminal-tab-cwd-add", "+ Tab");
16147
+ add.type = "button";
16148
+ add.draggable = false;
16149
+ const addTooltip = `Add tab in ${cwdTitle}`;
16150
+ applyStyledTooltip(add, addTooltip, { ariaLabel: addTooltip, targetKey: `terminal-tab:${tab.id}:add` });
16151
+ add.addEventListener("click", (event) => {
16152
+ event.stopPropagation();
16153
+ void createTerminalTab(tab.cwd || currentDirectoryForNewTab(), { triggerButton: add });
16154
+ });
16155
+ menu.append(add);
16156
+ return menu;
16157
+ }
16158
+
16159
+ function renderTerminalTab(tab, { showCwdAdd = false } = {}) {
16141
16160
  const isActive = tab.id === activeTabId && !activeSubagentTerminalId;
16142
16161
  const indicator = tabIndicator(tab);
16143
16162
  const appRunnerRun = tabAppRunnerRunningRun(tab);
@@ -16146,7 +16165,7 @@ function renderTerminalTab(tab) {
16146
16165
  const conversationLabel = conversationModeActive ? `, natural conversation ${tabConversationMode(tab).uiState || "listening"}` : "";
16147
16166
  const workflowModeActive = tabWorkflowModeActive(tab);
16148
16167
  const workflowCount = workflowRunningCountForTab(tab.id);
16149
- const wrapper = make("div", `terminal-tab activity-${indicator.state}${isActive ? " active" : ""}${tab.running ? "" : " stopped"}${appRunnerRun ? " app-runner-running" : ""}${conversationModeActive ? " conversation-mode-running" : ""}${workflowModeActive ? " workflow-mode-running" : ""}${workflowCount ? " workflow-run-running" : ""}`);
16168
+ const wrapper = make("div", `terminal-tab${showCwdAdd ? " terminal-tab-cwd-add-host" : ""} activity-${indicator.state}${isActive ? " active" : ""}${tab.running ? "" : " stopped"}${appRunnerRun ? " app-runner-running" : ""}${conversationModeActive ? " conversation-mode-running" : ""}${workflowModeActive ? " workflow-mode-running" : ""}${workflowCount ? " workflow-run-running" : ""}`);
16150
16169
  wrapper.dataset.tabId = tab.id;
16151
16170
  bindTerminalTabDragAndDrop(wrapper, { sourceTabId: tab.id, target: { type: "tab", tabId: tab.id } });
16152
16171
  const button = make("button", "terminal-tab-button");
@@ -16159,6 +16178,7 @@ function renderTerminalTab(tab) {
16159
16178
  appendTerminalTabContent(button, { title: tab.title, indicator, meta: terminalTabMeta(tab, indicator), appRunnerRun, conversationModeActive, workflowModeActive, workflowCount });
16160
16179
  button.addEventListener("click", () => switchTab(tab.id));
16161
16180
  wrapper.append(button, createTerminalTabActions(tab));
16181
+ if (showCwdAdd) wrapper.append(createTerminalTabCwdAddMenu(tab));
16162
16182
 
16163
16183
  if (tabs.length > 1) {
16164
16184
  const close = make("button", "terminal-tab-close", "×");
@@ -16418,6 +16438,7 @@ function terminalTabControlKey(node) {
16418
16438
  if (node.classList.contains("terminal-tab-close")) return `terminal-tab:${tabId}:close`;
16419
16439
  if (node.classList.contains("terminal-tab-split-button")) return `terminal-tab:${tabId}:split`;
16420
16440
  if (node.classList.contains("terminal-tab-summary-button")) return `terminal-tab:${tabId}:summary`;
16441
+ if (node.classList.contains("terminal-tab-cwd-add")) return `terminal-tab:${tabId}:add`;
16421
16442
  if (node.classList.contains("terminal-tab-button")) return `terminal-tab:${tabId}:switch`;
16422
16443
  }
16423
16444
  const groupKey = node?.closest?.("[data-group-key]")?.dataset?.groupKey;
@@ -16456,7 +16477,8 @@ function renderTabs() {
16456
16477
  if (shouldRenderTerminalTabGroup(group, groups.length)) {
16457
16478
  elements.tabBar.append(renderTerminalTabGroup(group, groups.length));
16458
16479
  } else {
16459
- for (const tab of group.tabs) elements.tabBar.append(renderTerminalTab(tab));
16480
+ const showCwdAdd = groups.length > 1 && group.tabs.length === 1 && Boolean(group.cwd);
16481
+ for (const tab of group.tabs) elements.tabBar.append(renderTerminalTab(tab, { showCwdAdd }));
16460
16482
  }
16461
16483
  }
16462
16484
  for (const group of subagentGroups) {
@@ -30405,6 +30427,11 @@ function renderWidgets() {
30405
30427
  if (btwWidget) elements.widgetArea.append(btwWidget);
30406
30428
 
30407
30429
  for (const [key, value] of widgets) {
30430
+ // pi-subagents publishes this machine-readable status for native TUI
30431
+ // consumers. The dedicated Subagents UI already consumes the equivalent
30432
+ // structured RPC state, so exposing the raw payload here duplicates state
30433
+ // and leaks an internal protocol record into the main conversation surface.
30434
+ if (key === SUBAGENT_ASYNC_WIDGET_KEY) continue;
30408
30435
  const widgetFeatureId = optionalFeatureWidgetFeatureId(key);
30409
30436
  if (widgetFeatureId && !isOptionalFeatureEnabled(widgetFeatureId)) continue;
30410
30437
  if (widgetFeatureId === "workflows" && workflowOverlayIsMinimized()) continue;
@@ -44997,6 +45024,11 @@ function handleExtensionUiRequest(request) {
44997
45024
  case "setWidget": {
44998
45025
  const widgetKey = request.widgetKey || request.id;
44999
45026
  const requestTabId = request.tabId || activeTabId;
45027
+ if (widgetKey === SUBAGENT_ASYNC_WIDGET_KEY) {
45028
+ const changed = setWidgetForTab(requestTabId, widgetKey, { ...request, widgetLines: undefined });
45029
+ if (changed && requestTabId === activeTabId) renderWidgets();
45030
+ return;
45031
+ }
45000
45032
  if (widgetKey === WORKFLOW_MODE_RPC_WIDGET_KEY) {
45001
45033
  const modeState = workflowModeStateFromRpcPayload(request.widgetLines);
45002
45034
  if (modeState) updateWorkflowModeForTab(requestTabId, modeState, { render: requestTabId === activeTabId });
package/public/index.html CHANGED
@@ -12,7 +12,7 @@
12
12
  <link rel="manifest" href="/manifest.webmanifest" />
13
13
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
14
14
  <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
15
- <link rel="stylesheet" href="/styles.css?v=123" />
15
+ <link rel="stylesheet" href="/styles.css?v=126" />
16
16
  <script>
17
17
  // Public-only issue-bot runtime configuration. Keep disabled unless the gateway,
18
18
  // Turnstile site key, exact CORS origin, and private-report destination are approved.
@@ -1819,7 +1819,7 @@
1819
1819
  </form>
1820
1820
  </dialog>
1821
1821
 
1822
- <script id="webuiBootLoader" data-app-src="/app.js?v=146">
1822
+ <script id="webuiBootLoader" data-app-src="/app.js?v=148">
1823
1823
  (() => {
1824
1824
  "use strict";
1825
1825
 
@@ -1,4 +1,4 @@
1
- const CACHE_NAME = "pi-webui-pwa-v108";
1
+ const CACHE_NAME = "pi-webui-pwa-v112";
2
2
  const APP_SHELL = [
3
3
  "/",
4
4
  "/index.html",
package/public/styles.css CHANGED
@@ -4741,7 +4741,9 @@ button.subagent-gate-attempt:focus-visible {
4741
4741
  }
4742
4742
  .terminal-tabs.terminal-tabs-dense:has(.terminal-tab-group:hover),
4743
4743
  .terminal-tabs.terminal-tabs-dense:has(.terminal-tab-group:focus-within),
4744
- .terminal-tabs.terminal-tabs-dense:has(.terminal-tab-group.menu-open) {
4744
+ .terminal-tabs.terminal-tabs-dense:has(.terminal-tab-group.menu-open),
4745
+ .terminal-tabs.terminal-tabs-dense:has(.terminal-tab-cwd-add-host:hover),
4746
+ .terminal-tabs.terminal-tabs-dense:has(.terminal-tab-cwd-add-host:focus-within) {
4745
4747
  overflow: visible;
4746
4748
  }
4747
4749
  .terminal-tabs.terminal-tabs-dense .terminal-tab {
@@ -4755,6 +4757,8 @@ button.subagent-gate-attempt:focus-visible {
4755
4757
  .terminal-tabs-shell:has(.terminal-tab-group:hover),
4756
4758
  .terminal-tabs-shell:has(.terminal-tab-group:focus-within),
4757
4759
  .terminal-tabs-shell:has(.terminal-tab-group.menu-open),
4760
+ .terminal-tabs-shell:has(.terminal-tab-cwd-add-host:hover),
4761
+ .terminal-tabs-shell:has(.terminal-tab-cwd-add-host:focus-within),
4758
4762
  .terminal-tabs-shell:has(.terminal-new-tab-menu:hover),
4759
4763
  .terminal-tabs-shell:has(.terminal-new-tab-menu:focus-within),
4760
4764
  .terminal-tabs-shell:has(.terminal-new-tab-menu.open) {
@@ -4763,6 +4767,8 @@ button.subagent-gate-attempt:focus-visible {
4763
4767
  .terminal-tabs:has(.terminal-tab-group:hover),
4764
4768
  .terminal-tabs:has(.terminal-tab-group:focus-within),
4765
4769
  .terminal-tabs:has(.terminal-tab-group.menu-open),
4770
+ .terminal-tabs:has(.terminal-tab-cwd-add-host:hover),
4771
+ .terminal-tabs:has(.terminal-tab-cwd-add-host:focus-within),
4766
4772
  .terminal-tabs:has(.terminal-new-tab-menu:hover),
4767
4773
  .terminal-tabs:has(.terminal-new-tab-menu:focus-within),
4768
4774
  .terminal-tabs:has(.terminal-new-tab-menu.open) {
@@ -4898,6 +4904,31 @@ button.subagent-gate-attempt:focus-visible {
4898
4904
  .terminal-tab-group-item.activity-done {
4899
4905
  border-color: rgba(166, 227, 161, 0.52);
4900
4906
  }
4907
+ .terminal-tab-cwd-add-host {
4908
+ position: relative;
4909
+ z-index: 1;
4910
+ overflow: visible;
4911
+ isolation: isolate;
4912
+ }
4913
+ .terminal-tab-cwd-add-host:hover,
4914
+ .terminal-tab-cwd-add-host:focus-within {
4915
+ z-index: 100;
4916
+ }
4917
+ .terminal-tab-cwd-add-menu {
4918
+ position: absolute;
4919
+ z-index: 100;
4920
+ inset: 100% 0 auto 0;
4921
+ display: none;
4922
+ flex-direction: column;
4923
+ align-items: stretch;
4924
+ width: 100%;
4925
+ min-width: 0;
4926
+ padding-top: 0.38rem;
4927
+ }
4928
+ .terminal-tab-cwd-add-host:hover .terminal-tab-cwd-add-menu,
4929
+ .terminal-tab-cwd-add-host:focus-within .terminal-tab-cwd-add-menu {
4930
+ display: flex;
4931
+ }
4901
4932
  .terminal-tab-group-add {
4902
4933
  flex: 0 0 auto;
4903
4934
  width: 100%;
@@ -9440,11 +9471,11 @@ summary { cursor: pointer; color: var(--warning); }
9440
9471
  display: grid;
9441
9472
  grid-auto-flow: column;
9442
9473
  grid-auto-columns: minmax(0, 1fr);
9443
- flex: 1 1 12rem;
9474
+ flex: 0 1 17rem;
9444
9475
  align-items: center;
9445
9476
  gap: 0.28rem;
9446
9477
  min-width: 0;
9447
- max-width: 100%;
9478
+ max-width: min(17rem, 100%);
9448
9479
  padding-block: 0.12rem;
9449
9480
  }
9450
9481
  .composer-intercom-tags[hidden] { display: none !important; }
@@ -9507,7 +9538,7 @@ summary { cursor: pointer; color: var(--warning); }
9507
9538
  text-align: center;
9508
9539
  }
9509
9540
  @media (max-width: 720px), (max-device-width: 720px), (pointer: coarse) and (hover: none) {
9510
- .composer-intercom-tags { flex: 1 1 100%; min-width: 0; }
9541
+ .composer-intercom-tags { flex: 1 1 100%; min-width: 0; max-width: 100%; }
9511
9542
  .composer-intercom-tag { min-height: 44px; }
9512
9543
  }
9513
9544
  .composer-feature-category-tag {
@@ -65,7 +65,7 @@ function makeEnvironment({
65
65
  reload: new FakeElement(),
66
66
  copyStatus: new FakeElement(),
67
67
  };
68
- const styleLink = new FakeElement({ href: "http://127.0.0.1:31415/styles.css?v=123", sheet: stylesheetLoaded ? {} : null });
68
+ const styleLink = new FakeElement({ href: "http://127.0.0.1:31415/styles.css?v=126", sheet: stylesheetLoaded ? {} : null });
69
69
  const listeners = new Map();
70
70
  const timers = new Map();
71
71
  let timerId = 0;
@@ -84,7 +84,7 @@ function makeEnvironment({
84
84
  removeEventListener(name) { listeners.delete(name); },
85
85
  };
86
86
  const document = {
87
- currentScript: new FakeElement({ dataset: { appSrc: "/app.js?v=146" } }),
87
+ currentScript: new FakeElement({ dataset: { appSrc: "/app.js?v=148" } }),
88
88
  readyState: "complete",
89
89
  querySelector(selector) {
90
90
  return {
@@ -232,7 +232,7 @@ for (const moduleName of startupModuleNames) {
232
232
  assert.ok(serviceWorker.includes(`"/${moduleName}"`), `the PWA app shell should include every app.js startup module: ${moduleName}`);
233
233
  }
234
234
  assert.match(serviceWorker, /pi-webui-pwa-v\d+/, "the app-shell cache should retain a versioned identity");
235
- assert.ok(html.indexOf('id="webuiBootLoader"') < html.indexOf("/app.js?v=146"), "the inline loader should own app module startup");
235
+ assert.ok(html.indexOf('id="webuiBootLoader"') < html.indexOf("/app.js?v=148"), "the inline loader should own app module startup");
236
236
  assert.doesNotMatch(html, /<script type="module" src="\/app\.js/, "the app module should not bypass the guarded loader");
237
237
 
238
238
  console.log("boot-failure-diagnostics.test.mjs passed");
@@ -162,12 +162,14 @@ test("the 32-conversation dense grid stays contained and opens the correct trunc
162
162
  return {
163
163
  clientWidth: element.clientWidth,
164
164
  scrollWidth: element.scrollWidth,
165
+ rootFontSize: Number.parseFloat(getComputedStyle(document.documentElement).fontSize),
165
166
  widths: tagRects.map((rect) => rect.width),
166
167
  rowTops: [...new Set(tagRects.map((rect) => Math.round(rect.top)))],
167
168
  allContained: tagRects.every((rect) => rect.left >= containerRect.left - 0.5 && rect.right <= containerRect.right + 0.5),
168
169
  };
169
170
  });
170
171
  assert.ok(layout.allContained, "every desktop conversation tag should remain within the tag container");
172
+ assert.ok(layout.clientWidth <= (17 * layout.rootFontSize) + 0.5, `the desktop conversation tag group should stay within 17rem (${layout.clientWidth}px)`);
171
173
  assert.ok(layout.scrollWidth <= layout.clientWidth, `the desktop tag grid should not overflow horizontally (${layout.scrollWidth} > ${layout.clientWidth})`);
172
174
  assert.ok(Math.min(...layout.widths) >= 44, `every dense desktop target should be at least 44px wide (minimum ${Math.min(...layout.widths)})`);
173
175
  assert.ok(layout.rowTops.length > 1, "the 32-conversation desktop fixture should wrap into multiple rows");
@@ -55,7 +55,7 @@ assert.match(app, /statusKey === CODEX_FAST_MODE_STATUS_KEY[\s\S]*?applyCodexFas
55
55
  assert.match(technical, /## Normal and compact output[\s\S]*?select \*\*Compact\*\*[\s\S]*?`compact-v1`/, "technical reference should document Compact mode with the stable identifier");
56
56
  assert.match(development, /### Codex subscription Fast mode[\s\S]*?service_tier: "priority"[\s\S]*?1\.5× faster[\s\S]*?2× Standard credits[\s\S]*?2\.5×/, "development guide should document Fast-mode integration and cost semantics");
57
57
  // Intent preserved: browser-asset changes must advance the coherent cache tuple.
58
- assert.match(serviceWorker, /pi-webui-pwa-v108/, "PWA cache identity should be bumped for changed browser assets");
59
- assert.match(html, /data-app-src="\/app\.js\?v=146"/, "browser module URL should be cache-busted for Fast-mode wiring");
58
+ assert.match(serviceWorker, /pi-webui-pwa-v112/, "PWA cache identity should be bumped for changed browser assets");
59
+ assert.match(html, /data-app-src="\/app\.js\?v=148"/, "browser module URL should be cache-busted for Fast-mode wiring");
60
60
 
61
61
  console.log("codex-fast-mode-static.test.mjs passed");
@@ -56,8 +56,8 @@ assert.match(app, /function initializeComposerActionOrdering\(\)[\s\S]*MutationO
56
56
  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
57
  assert.match(app, /initializeComposerActionOrdering\(\);[\s\S]*restoreSidePanelSectionOrder\(\);/, "composer ordering should initialize during guarded app startup");
58
58
 
59
- assert.match(html, /styles\.css\?v=123/, "changed composer styles should advance the stylesheet revision");
60
- assert.match(html, /app\.js\?v=146/, "changed composer behavior should advance the app revision");
61
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "changed browser assets should advance the PWA cache identity");
59
+ assert.match(html, /styles\.css\?v=126/, "changed composer styles should advance the stylesheet revision");
60
+ assert.match(html, /app\.js\?v=148/, "changed composer behavior should advance the app revision");
61
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "changed browser assets should advance the PWA cache identity");
62
62
 
63
63
  console.log("composer-action-grid-reorder-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=123/, "Controls stylesheet changes should advance the cache query");
19
- assert.match(html, /app\.js\?v=146/, "Controls tooltip wiring should advance the app cache query");
20
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "Controls browser assets should advance the PWA cache identity");
18
+ assert.match(html, /styles\.css\?v=126/, "Controls stylesheet changes should advance the cache query");
19
+ assert.match(html, /app\.js\?v=148/, "Controls tooltip wiring should advance the app cache query");
20
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "Controls browser assets should advance the PWA cache identity");
21
21
 
22
22
  console.log("controls-layout-static.test.mjs passed");
@@ -156,7 +156,7 @@ assert.match(worker, /pi-webui-pwa-v\d+[\s\S]*?"\/fast-output-live\.mjs"/, "PWA
156
156
  assert.match(html, /<label for="fastOutputModeSelect">Compact mode \(Experimental\)<\/label>/, "the sidebar should mark compact mode as experimental");
157
157
  assert.match(html, /Lightweight browser rendering; Markdown final output; live thinking expanded; stored thinking grouped and collapsed/, "the sidebar should distinguish compact rendering from model inference");
158
158
  // Intent preserved: the guarded PWA entry point must advance whenever app wiring changes.
159
- assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=146"/, "the guarded PWA entry point should cache-bust browser wiring");
159
+ assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=148"/, "the guarded PWA entry point should cache-bust browser wiring");
160
160
  assert.match(JSON.parse(packageRaw).scripts.check, /node --check public\/fast-output-live\.mjs/, "package checks should parse the compact helper");
161
161
 
162
162
  const events = createFastModeOutputEvents();
@@ -166,7 +166,7 @@ assert.match(functionSource("closeTerminalTabs"), /clearFeatureDecisionStateForT
166
166
  assert.match(app, /case "webui_connected":[\s\S]*clearFeatureDecisionStateForTab\(connectedTabId, \{ render: true \}\)[\s\S]*scheduleForegroundReconcile\("event stream reconnect", 0\)/, "reconnect should clear local state before authoritative replay");
167
167
  assert.match(app, /statusKey === FEATURE_DECISION_OUTPUT_STATUS_KEY[\s\S]*handleFeatureDecisionOutputStatus[\s\S]*return;[\s\S]*statusKey === FEATURE_CATEGORY_STATUS_KEY[\s\S]*return;[\s\S]*statusEntries\.set/, "both feature statuses should be intercepted before generic footer storage while preserving category handling");
168
168
 
169
- assert.match(html, /\/styles\.css\?v=123/, "integrated stylesheet changes should advance the cache query");
170
- assert.match(html, /\/app\.js\?v=146/, "integrated app changes should advance the cache query");
169
+ assert.match(html, /\/styles\.css\?v=126/, "integrated stylesheet changes should advance the cache query");
170
+ assert.match(html, /\/app\.js\?v=148/, "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-v108"/, "changed viewer assets should advance the PWA cache identity");
66
- assert.match(html, /styles\.css\?v=123/, "changed image styles should advance the stylesheet revision");
67
- assert.match(html, /app\.js\?v=146/, "changed image rendering should advance the app revision");
65
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "changed viewer assets should advance the PWA cache identity");
66
+ assert.match(html, /styles\.css\?v=126/, "changed image styles should advance the stylesheet revision");
67
+ assert.match(html, /app\.js\?v=148/, "changed image rendering should advance the app revision");
68
68
 
69
69
  console.log("file viewer image static tests passed");
@@ -88,15 +88,16 @@ assert.match(functionSource("scheduleIntercomConversationDetailRefresh"), /INTER
88
88
  assert.match(functionSource("resetIntercomConversationDialog"), /intercomDetailRequestSerial \+= 1[\s\S]*clearTimeout\(intercomDetailRefreshTimer\)[\s\S]*intercomConversationDialogState = null/, "dialog close should invalidate requests, cancel polling, and clear selection state");
89
89
  assert.match(app, /elements\.intercomConversationDialog\?\.addEventListener\("close", resetIntercomConversationDialog\)/, "native Escape and close-button paths should share polling cleanup");
90
90
 
91
- assert.match(css, /\.composer-intercom-tags \{[\s\S]*display: grid;[\s\S]*grid-auto-columns: minmax\(0, 1fr\);[\s\S]*min-width: 0;/, "all conversation tags should share the available width without a horizontal scroller");
91
+ assert.match(css, /\.composer-intercom-tags \{[\s\S]*display: grid;[\s\S]*grid-auto-columns: minmax\(0, 1fr\);[\s\S]*flex: 0 1 17rem;[\s\S]*max-width: min\(17rem, 100%\);/, "conversation tags should share a compact bounded width without a horizontal scroller");
92
+ assert.match(css, /@media \(max-width: 720px\)[\s\S]*\.composer-intercom-tags \{ flex: 1 1 100%; min-width: 0; max-width: 100%; \}/, "conversation tags should regain the available row width on narrow and coarse-pointer layouts");
92
93
  assert.doesNotMatch(css, /\.composer-intercom-tags \{[^}]*overflow-x:\s*(?:auto|scroll)/, "the conversation tag group should not restore horizontal scrolling");
93
94
  assert.match(css, /\.composer-intercom-tag:hover,[\s\S]*\.composer-intercom-tag:focus-visible/, "tags should expose pointer and keyboard focus states");
94
95
  assert.match(css, /\.extension-dialog\.intercom-conversation-dialog \{[\s\S]*width: min\(76rem,[\s\S]*height: min\(54rem,/, "the viewer should use a large in-app modal");
95
96
  assert.match(css, /@media \(max-width: 720px\)[\s\S]*\.composer-intercom-tag \{ min-height: 44px;[\s\S]*\.extension-dialog\.intercom-conversation-dialog[\s\S]*width: calc\(100vw - 0\.7rem\)/, "tags and the dialog should remain reachable on narrow and coarse-pointer layouts");
96
97
 
97
- assert.match(html, /\/styles\.css\?v=123/, "the stylesheet URL should advance for the accepted viewer fixes");
98
- assert.match(html, /data-app-src="\/app\.js\?v=146"/, "the guarded app URL should advance for incremental viewer wiring");
99
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "the PWA cache identity should advance with browser assets");
98
+ assert.match(html, /\/styles\.css\?v=126/, "the stylesheet URL should advance for the bounded conversation tags");
99
+ assert.match(html, /data-app-src="\/app\.js\?v=148"/, "the guarded app URL should advance for current browser wiring");
100
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "the PWA cache identity should advance with browser assets");
100
101
 
101
102
  assert.match(readme, /one compact tag per conversation appears beneath the composer/i, "the README should explain the user-visible entry point");
102
103
  assert.match(technical, /## Agent conversation viewer[\s\S]*Attachments, tool calls and results, thinking, stdout\/stderr, filesystem paths, raw session records/i, "the advanced guide should document privacy exclusions");
@@ -50,9 +50,9 @@ assert.match(css, /@media \(prefers-reduced-motion: reduce\)[\s\S]*?animation-du
50
50
  assert.match(css, /body\.terminal-tabs-left \.main-output-loading,[\s\S]*?body\.terminal-tabs-left \.chat \{ grid-row: 4; \}/, "sidebar tab placement should keep the status inside the transcript grid row");
51
51
  assert.match(css, /body\.subagent-terminal-active \.main-output-loading,/, "main-output loading feedback should stay hidden in the dedicated subagent view");
52
52
 
53
- assert.match(html, /styles\.css\?v=123/, "the stylesheet cache query should advance");
54
- assert.match(html, /app\.js\?v=146/, "the app cache query should advance");
55
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "the PWA cache identity should advance with browser assets");
53
+ assert.match(html, /styles\.css\?v=126/, "the stylesheet cache query should advance");
54
+ assert.match(html, /app\.js\?v=148/, "the app cache query should advance");
55
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "the PWA cache identity should advance with browser assets");
56
56
  assert.match(readme, /Loading agent output/, "user documentation should describe the visible loading feedback");
57
57
  assert.match(development, /main output loading/i, "developer documentation should preserve the request-ownership contract");
58
58
 
@@ -16,9 +16,9 @@ assert.match(app, /import \{ installMiddleButtonDragScroll \} from "\.\/middle-b
16
16
  assert.match(app, /installMiddleButtonDragScroll\(\{[\s\S]*onDirection: \(\{ target, offsetY \}\)[\s\S]*noteChatUserScrollIntent\(\{ type: "middle-drag", deltaY: offsetY \}\)/, "chat auto-scroll direction should feed the existing follow/pause intent state");
17
17
  assert.match(app, /event\?\.type === "middle-drag"\) return event\.deltaY > 0;/, "moving below the press point should be recognized as intent to read later chat output");
18
18
  assert.match(css, /body\.middle-button-auto-scrolling,[\s\S]*cursor: all-scroll !important;[\s\S]*user-select: none !important;/, "active automatic scrolling should expose a directional-scroll affordance and suppress accidental selection");
19
- assert.match(html, /styles\.css\?v=123/, "changed drag-scroll styles should advance the stylesheet revision");
20
- assert.match(html, /app\.js\?v=146/, "changed drag-scroll wiring should advance the app revision");
21
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108";[\s\S]*"\/middle-button-drag-scroll\.mjs"/, "offline PWA installs should refresh and cache the new controller module");
19
+ assert.match(html, /styles\.css\?v=126/, "changed drag-scroll styles should advance the stylesheet revision");
20
+ assert.match(html, /app\.js\?v=148/, "changed drag-scroll wiring should advance the app revision");
21
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112";[\s\S]*"\/middle-button-drag-scroll\.mjs"/, "offline PWA installs should refresh and cache the new controller module");
22
22
  assert.match(JSON.parse(packageJson).scripts.check, /node --check public\/middle-button-drag-scroll\.mjs/, "the package check should parse the startup-critical controller module");
23
23
 
24
24
  console.log("middle-button-drag-scroll-static.test.mjs passed");
@@ -47,9 +47,9 @@ assert.match(css, /html\[data-tablet-shell="v2"\] \.mobile-shell-nav[\s\S]*?widt
47
47
  assert.match(css, /html\[data-tablet-shell="v2"\] \.mobile-shell-surface[\s\S]*?width: min\(30rem, 72vw\)/, "tablet inspector must be a bounded right-side sheet");
48
48
  assert.match(css, /html\[data-tablet-shell="v2"\] \.file-viewer-pane[\s\S]*?position: fixed[\s\S]*?inset: 0/, "tablet files must default to full-screen replacement");
49
49
  assert.match(css, /and \(pointer: coarse\)[\s\S]*?min-height: 44px/, "coarse tablet pointers must retain the 44px target floor");
50
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "continuity/tablet assets need a coherent cache identity");
51
- assert.match(html, /styles\.css\?v=123/, "tablet CSS must have a coherent HTML revision");
52
- assert.match(html, /app\.js\?v=146/, "continuity app logic must have a coherent HTML revision");
50
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "continuity/tablet assets need a coherent cache identity");
51
+ assert.match(html, /styles\.css\?v=126/, "tablet CSS must have a coherent HTML revision");
52
+ assert.match(html, /app\.js\?v=148/, "continuity app logic must have a coherent HTML revision");
53
53
  assert.match(technical, /tabletShell=v2[\s\S]*tabletShell=legacy/, "technical reference should document tablet preview and rollback");
54
54
 
55
55
  console.log("mobile-continuity-tablet-static.test.mjs passed");
@@ -37,9 +37,9 @@ assert.match(pkg.scripts.check, /node --check public\/transcript-renderer\.mjs/,
37
37
  assert.match(server, /STATIC_PUBLIC_FILE_EXTENSIONS[\s\S]*"\.mjs"/, "the server must serve typed startup modules from the public asset boundary");
38
38
  assert.match(serviceWorker, /"\/mobile-shell-state\.mjs"/, "the PWA shell must cache the new startup module");
39
39
  assert.match(serviceWorker, /"\/transcript-renderer\.mjs"/, "the PWA shell must cache the transcript startup module");
40
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "the cache identity must change with the startup graph");
41
- assert.match(html, /styles\.css\?v=123/, "the stylesheet revision must change with mobile/tablet CSS fixes");
42
- assert.match(html, /app\.js\?v=146/, "the app revision must change with continuity/tablet wiring");
40
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "the cache identity must change with the startup graph");
41
+ assert.match(html, /styles\.css\?v=126/, "the stylesheet revision must change with mobile/tablet CSS fixes");
42
+ assert.match(html, /app\.js\?v=148/, "the app revision must change with continuity/tablet wiring");
43
43
  assert.match(serviceWorker, /const APP_SHELL_NETWORK_TIMEOUT_MS = 8_000;[\s\S]*?event\.waitUntil\([\s\S]*?cache\.put\(request, response\.clone\(\)\)[\s\S]*?return networkResponse;/, "runtime cache writes must extend the event lifetime without blocking bounded network responses");
44
44
  assert.match(serviceWorker, /MOBILE_NAVIGATION_MESSAGE_TYPE = "pi-webui:navigate:v1"/, "the service worker must use a versioned active-client navigation message");
45
45
  assert.match(serviceWorker, /client\.postMessage\(\{ type: MOBILE_NAVIGATION_MESSAGE_TYPE, target \}\)/, "existing clients must receive only a validated target message");
@@ -60,6 +60,6 @@ assert.match(css, /data-mobile-presentation="essential"/, "Essential presentatio
60
60
  assert.match(css, /html\[data-mobile-shell="v2"\] body\.mobile-keyboard-open \.widget-area,[\s\S]*?\.composer-actions-button \{ display: block !important; \}/, "v2 keyboard mode must keep run widgets and the actions entry available");
61
61
  assert.match(css, /@media \(prefers-reduced-motion: reduce\)/, "reduced-motion behavior is required");
62
62
  assert.match(css, /@media \(forced-colors: active\)/, "forced-color affordances are required");
63
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "browser asset changes need a coherent cache tuple");
63
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "browser asset changes need a coherent cache tuple");
64
64
 
65
65
  console.log("mobile-phone-experience-static.test.mjs passed");
@@ -111,10 +111,10 @@ assert.match(html, /id="optionsSafetyGuardSetupButton"[\s\S]*data-command="\/saf
111
111
  assert.match(html, /id="optionsGitWorkflowSetupButton"[\s\S]*data-command="\/git-workflow-setup"[\s\S]*Guided Git Setup/, "Common Pi options should expose native Guided Git Setup");
112
112
  assert.match(app, /const NATIVE_SELECTOR_COMMANDS = new Set\(\[[^\]]*"summary"[^\]]*"summary-setup"[^\]]*"workflow-setup"[^\]]*\]\)/, "exact /summary, /summary-setup, and /workflow-setup should be browser-native selector commands");
113
113
  assert.match(app, /function createTerminalTabSessionSummaryButton\(tab\)[\s\S]*hasAvailableCommand\("summary", \{ tabId: tab\.id \}\)[\s\S]*setAttribute\("aria-busy"[\s\S]*openSessionSummaryForTab\(tab\.id, \{ focusReturnKey:/, "each terminal tab summary action should use that tab's command catalog, busy state, focus restoration, and direct target");
114
- assert.match(app, /function renderTerminalTab\(tab\)[\s\S]*createTerminalTabActions\(tab\)[\s\S]*function renderTerminalTabGroupItem\(tab, group\)[\s\S]*createTerminalTabActions\(tab\)/, "regular and grouped Pi terminal tabs should render shared per-tab split and summary actions");
114
+ assert.match(app, /function renderTerminalTab\(tab, \{ showCwdAdd = false \} = \{\}\)[\s\S]*createTerminalTabActions\(tab\)[\s\S]*function renderTerminalTabGroupItem\(tab, group\)[\s\S]*createTerminalTabActions\(tab\)/, "regular and grouped Pi terminal tabs should render shared per-tab split and summary actions");
115
115
  assert.match(app, /function createTerminalTabActions\(tab\)[\s\S]*createTerminalTabSplitButton\(tab\)[\s\S]*createTerminalTabSessionSummaryButton\(tab\)/, "each terminal action slot should place Split beside Summary");
116
116
  assert.match(app, /function terminalTabControlKey\(node\)[\s\S]*terminal-tab-split-button[\s\S]*terminal-tab:\$\{tabId\}:split[\s\S]*terminal-tab-summary-button[\s\S]*terminal-tab:\$\{tabId\}:summary/, "per-tab split and summary actions should retain stable focus continuity keys");
117
- assert.match(app, /\.terminal-tab-close, \.terminal-tab-actions, \.terminal-tab-group-add/, "per-tab actions should not initiate terminal-tab dragging");
117
+ assert.match(app, /\.terminal-tab-close, \.terminal-tab-actions, \.terminal-tab-cwd-add, \.terminal-tab-group-add/, "per-tab actions should not initiate terminal-tab dragging");
118
118
  assert.match(app, /function prefetchInactiveTabCommandCatalogs\(\)[\s\S]*refreshCommands\(activeTabContext\(tab\.id\)\)[\s\S]*function refreshTabs[\s\S]*prefetchInactiveTabCommandCatalogs\(\)/, "restored inactive tabs should fetch their own command catalogs without activation");
119
119
  assert.match(app, /const focusReturnKey = sessionSummaryOverlayFocusReturnKey[\s\S]*querySelectorAll\("button"\)[\s\S]*terminalTabControlKey\(node\) === focusReturnKey/, "summary overlay focus restoration should resolve rerendered per-tab controls by continuity key");
120
120
  assert.match(app, /sessionSummaryOverlayFocusReturnKey = focusReturnKey \|\| terminalTabControlKey\(sessionSummaryOverlayFocusReturn\)/, "summary overlay opening should preserve an explicit per-tab focus key or capture the active control key");
@@ -2181,7 +2181,7 @@ assert.match(app, /const totalTabCount = tabs\.length \+ subagentTerminalViews\.
2181
2181
  assert.match(app, /appendTerminalTabContent\(button, \{ title: activeTitle,[\s\S]*?count: groupTabs\.length,[^}]*\}\)/, "group buttons should show the active terminal name instead of only the cwd label");
2182
2182
  assert.match(app, /wrapper\.addEventListener\("pointerenter", \(\) => setOpenTerminalTabGroup\(group\.key\)\)/, "terminal tab groups should mark themselves open while hovered");
2183
2183
  assert.match(app, /if \(openTerminalTabGroupKey\) \{\n\s+scheduleRefreshTabs\(600\);/, "tab polling should defer full tab refreshes while a group menu is open");
2184
- assert.match(app, /function shouldRenderTerminalTabGroup\(group, groupCount\) \{\n\s+if \(group\.custom\) return group\.tabs\.length > 1;\n\s+return groupCount > 1 && group\.tabs\.length > 1 && Boolean\(group\.cwd\);\n\}/, "terminal tabs should always render custom groups while only collapsing cwd groups when multiple groups are available");
2184
+ assert.match(app, /function shouldRenderTerminalTabGroup\(group, groupCount\) \{\n\s+if \(group\.custom\) return group\.tabs\.length > 1;\n\s+return groupCount > 1 && group\.tabs\.length > 1 && Boolean\(group\.cwd\);\n\}/, "terminal tabs should always render custom groups while only collapsing multi-tab cwd groups when multiple groups are available");
2185
2185
  assert.match(app, /TERMINAL_CUSTOM_GROUPS_STORAGE_KEY/, "frontend should persist custom terminal tab groups in browser storage");
2186
2186
  assert.match(app, /function bindTerminalTabDragAndDrop\(/, "terminal tabs should bind drag-and-drop grouping behavior");
2187
2187
  assert.match(app, /function handleTerminalTabDrop\(sourceTabId, target\)[\s\S]*?createTerminalCustomGroup/, "dropping a terminal tab onto another tab or group should create or update a custom group");
@@ -68,7 +68,7 @@ assert.match(server, /STATIC_PUBLIC_FILE_EXTENSIONS[\s\S]*"\.mjs"/, "the server
68
68
  assert.match(serviceWorker, /"\/issue-wizard-state\.mjs"/, "the PWA shell must keep caching the pure wizard module");
69
69
  assert.match(serviceWorker, /"\/issue-bot-client\.mjs"/, "the PWA shell must cache the browser client module");
70
70
  // Intent preserved: changing the public startup graph advances the PWA cache identity.
71
- assert.match(serviceWorker, /pi-webui-pwa-v108/, "the PWA cache name must change with browser wiring updates");
71
+ assert.match(serviceWorker, /pi-webui-pwa-v112/, "the PWA cache name must change with browser wiring updates");
72
72
  assert.match(packageJson, /node --check public\/issue-wizard-state\.mjs/, "the package check must keep syntax-checking the pure wizard module");
73
73
  assert.match(packageJson, /node --check public\/issue-bot-client\.mjs/, "the package check must syntax-check the browser client module");
74
74
 
@@ -271,8 +271,8 @@ assert.match(
271
271
 
272
272
  // --- Coherent browser asset revisions --------------------------------------
273
273
 
274
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "changed browser assets should advance the PWA cache identity");
275
- assert.match(html, /styles\.css\?v=123/, "the page should request the updated layout stylesheet revision");
276
- assert.match(html, /data-app-src="\/app\.js\?v=146"/, "the boot loader should request the updated app module revision");
274
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "changed browser assets should advance the PWA cache identity");
275
+ assert.match(html, /styles\.css\?v=126/, "the page should request the updated layout stylesheet revision");
276
+ assert.match(html, /data-app-src="\/app\.js\?v=148"/, "the boot loader should request the updated app module revision");
277
277
 
278
278
  console.log("persistent-ui-layout-static.test.mjs passed");
@@ -504,8 +504,8 @@ assert.match(css, /@media \(max-width: 720px\), \(max-device-width: 720px\), \(p
504
504
  assert.match(css, /\.questionnaire-options button\s*\{\s*min-height:\s*3\.35rem/, "mobile questionnaire targets must exceed the 44px floor");
505
505
  assert.match(css, /@media \(prefers-reduced-motion: reduce\)\s*\{[\s\S]*?\*, \*::before, \*::after[\s\S]*?transition-duration:\s*1ms !important/, "global reduced-motion rules must cover questionnaire transitions");
506
506
 
507
- assert.match(html, /styles\.css\?v=123/, "questionnaire CSS needs the current stylesheet revision");
508
- assert.match(html, /app\.js\?v=146/, "questionnaire behavior needs the current app revision");
509
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "questionnaire public assets need a coherent PWA cache revision");
507
+ assert.match(html, /styles\.css\?v=126/, "questionnaire CSS needs the current stylesheet revision");
508
+ assert.match(html, /app\.js\?v=148/, "questionnaire behavior needs the current app revision");
509
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "questionnaire public assets need a coherent PWA cache revision");
510
510
 
511
511
  console.log("questionnaire-dialog.test.mjs passed");
@@ -57,10 +57,10 @@ assert.match(css, /\.sampling-parameter-control\.unsupported:hover:not\(\.sampli
57
57
  assert.match(css, /\.sampling-parameter-control\.unsupported:focus-visible:not\(\.sampling-tooltip-dismissed\) > \.sampling-parameter-unsupported-tooltip/, "keyboard focus should reveal dismissible unsupported reasons");
58
58
  assert.match(css, /\.sampling-parameter-unsupported-tooltip\.sampling-tooltip-below/, "bounded placement should support flipping below top-edge rows");
59
59
  assert.match(css, /pointer-events: auto;/, "a visible unsupported tooltip should remain pointer-hoverable");
60
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "native-control assets should advance the cache identity");
60
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "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=123/, "the changed stylesheet should have a new revision");
63
- assert.match(html, /app\.js\?v=146/, "the changed app module should have a new revision");
62
+ assert.match(html, /styles\.css\?v=126/, "the changed stylesheet should have a new revision");
63
+ assert.match(html, /app\.js\?v=148/, "the changed app module should have a new revision");
64
64
 
65
65
  // --- Browser state behavior -------------------------------------------------
66
66
 
@@ -27,8 +27,8 @@ assert.doesNotMatch(layout, /sectionHeightMin|sectionHeightMax|validateSectionHe
27
27
  assert.match(app, /const UI_LAYOUT_SIDE_PANEL_FIELDS = \["placement", "sectionLayout", "collapsedSectionIds", "hiddenSectionIds", "collapsedPanels", "panelWidths"\];/, "the browser durable layout field list should omit section heights");
28
28
  assert.match(app, /function clearRemovedSidePanelSectionHeightState\(\)[\s\S]*localStorage\.removeItem\(REMOVED_SIDE_PANEL_SECTION_HEIGHT_STORAGE_KEY\)[\s\S]*record\.field === "sidePanel" && record\.subfield === "sectionHeights"/, "startup should remove the retired cache and pending mutations");
29
29
  assert.match(app, /clearRemovedSidePanelSectionHeightState\(\);\s*restoreDurableUiLayoutPendingJournal\(\);/, "retired height state should be cleared before pending layout restoration");
30
- assert.match(html, /styles\.css\?v=123/, "removing section resize styles should advance the stylesheet revision");
31
- assert.match(html, /app\.js\?v=146/, "removing section resize behavior should advance the app revision");
32
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "removing browser assets should advance the PWA cache identity");
30
+ assert.match(html, /styles\.css\?v=126/, "removing section resize styles should advance the stylesheet revision");
31
+ assert.match(html, /app\.js\?v=148/, "removing section resize behavior should advance the app revision");
32
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "removing browser assets should advance the PWA cache identity");
33
33
 
34
34
  console.log("side-panel-section-height-removal-static.test.mjs passed");
@@ -24,9 +24,11 @@ assert.match(app, /subagentRunCanRefresh[\s\S]*subagentRunCanCancel[\s\S]*subage
24
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
25
  assert.match(app, /function finishedSubagentRunSelections[\s\S]*subagentRunIsTerminal\(run\) && subagentRunCanDismiss\(run\)/, "Auto-Clear should not immediately remove stale attached sessions");
26
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(app, /const SUBAGENT_ASYNC_WIDGET_KEY = "subagent-async"[\s\S]*case "setWidget":[\s\S]*widgetKey === SUBAGENT_ASYNC_WIDGET_KEY[\s\S]*widgetLines: undefined[\s\S]*return;/, "native async-status widget updates should be discarded before reaching the generic main-output renderer");
28
+ assert.match(app, /for \(const \[key, value\] of widgets\)[\s\S]*if \(key === SUBAGENT_ASYNC_WIDGET_KEY\) continue;/, "stale cached async-status widgets should remain hidden defensively");
27
29
  assert.match(css, /\.subagent-source-badge[\s\S]*text-overflow: ellipsis[\s\S]*@media \(max-width: 720px\)/, "source badges should remain compact and responsive");
28
30
  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=123[\s\S]*app\.js\?v=146/, "browser assets should use the WS-D revisions");
30
- assert.match(worker, /pi-webui-pwa-v108/, "PWA cache identity should advance with WS-D browser assets");
31
+ assert.match(html, /styles\.css\?v=126[\s\S]*app\.js\?v=148/, "browser assets should use the current subagent-observability revisions");
32
+ assert.match(worker, /pi-webui-pwa-v112/, "PWA cache identity should advance with subagent widget suppression");
31
33
 
32
34
  console.log("subagent-observability-static.test.mjs passed");
@@ -406,6 +406,115 @@ assert.ok(payload.runs.some((run) => run.id === workflowRunId), "pi-subagents po
406
406
 
407
407
  const helperCommand = registeredCommands.get("webui-helper");
408
408
  assert.ok(helperCommand?.handler, "Web UI helper command should be registered");
409
+
410
+ const warmingWorkflowRunId = "workflow-warming-up";
411
+ const warmingWorkflowDir = await mkdtemp(path.join(asyncRunDir, "workflow-warmup-"));
412
+ const warmingWorkflowSessionFile = path.join(warmingWorkflowDir, "worker-session.jsonl");
413
+ const warmingWorkflowStartedAt = Date.now() - 500;
414
+ await writeFile(path.join(warmingWorkflowDir, "status.json"), JSON.stringify({
415
+ runId: warmingWorkflowRunId,
416
+ mode: "workflow",
417
+ state: "running",
418
+ startedAt: warmingWorkflowStartedAt,
419
+ lastUpdate: Date.now(),
420
+ steps: [],
421
+ }));
422
+ bus.emit("subagent:async-started", {
423
+ id: warmingWorkflowRunId,
424
+ mode: "workflow",
425
+ asyncDir: warmingWorkflowDir,
426
+ workflowGraph: { nodes: [] },
427
+ });
428
+ const warmingWorkflowFleet = {
429
+ version: 1,
430
+ entries: [
431
+ { key: "fleet-reviewer-1", agent: "reviewer", startedAt: fleetStartedAt, tokens: { input: 0, output: 0, total: 0 } },
432
+ { key: "fleet-reviewer-2", agent: "reviewer", startedAt: fleetStartedAt + 1, tokens: { input: 0, output: 0, total: 0 } },
433
+ { key: "fleet-worker", agent: "worker", startedAt: fleetStartedAt + 2, tokens: { input: 0, output: 0, total: 0 } },
434
+ { key: "fleet-nested", agent: "nested-oracle", startedAt: fleetStartedAt + 3, tokens: { input: 0, output: 0, total: 0 } },
435
+ { key: "fleet-recovered", agent: "scout", role: "Recovery scout", model: "openai-codex/gpt-5.6-terra:xhigh", effort: "xhigh", startedAt: fleetStartedAt + 4, tokens: { input: 0, output: 0, total: 0 } },
436
+ { key: "fleet-warming-workflow", agent: "workflow", startedAt: warmingWorkflowStartedAt, tokens: { input: 0, output: 0, total: 0 } },
437
+ { key: "fleet-warming-worker", agent: "worker", model: "openai-codex/gpt-5.6-sol", effort: "high", startedAt: warmingWorkflowStartedAt + 1, tokens: { input: 0, output: 0, total: 0 } },
438
+ ],
439
+ totalActive: 7,
440
+ omitted: 0,
441
+ };
442
+ const pollWarmingWorkflow = async (text, asyncSnapshot) => {
443
+ subagentRpcReplyHook = (request) => {
444
+ if (request.method !== "status" || Object.keys(request.params || {}).length) return false;
445
+ subagentRpcReplyHook = null;
446
+ bus.emit(`subagents:rpc:v1:reply:${request.requestId}`, {
447
+ version: 1,
448
+ requestId: request.requestId,
449
+ method: request.method,
450
+ success: true,
451
+ data: { text, details: { mode: "single", results: [] }, fleet: warmingWorkflowFleet, ...(asyncSnapshot ? { asyncSnapshot } : {}) },
452
+ });
453
+ return true;
454
+ };
455
+ bus.emit("subagents:rpc:v1:ready", { version: 1 });
456
+ await new Promise((resolve) => setTimeout(resolve, 0));
457
+ };
458
+ const warmingHeaderOnlyStatus = `Active async runs: 1
459
+
460
+ - ${warmingWorkflowRunId} | running | active | workflow | steps 0 | ~/repo`;
461
+ await pollWarmingWorkflow(warmingHeaderOnlyStatus);
462
+ await pollWarmingWorkflow(warmingHeaderOnlyStatus);
463
+ payload = latestPayload();
464
+ assert.equal(payload.runs.some((run) => run.id === "fleet:fleet-warming-workflow"), false, "a known workflow controller must not become an empty recovered Workflow row while its first child locator is pending");
465
+ await writeFile(warmingWorkflowSessionFile, `${JSON.stringify({
466
+ type: "message",
467
+ timestamp: "2026-07-26T12:00:10.000Z",
468
+ message: { role: "assistant", content: [{ type: "text", text: "Workflow worker output is live." }] },
469
+ })}\n`);
470
+ await writeFile(path.join(warmingWorkflowDir, "status.json"), JSON.stringify({
471
+ runId: warmingWorkflowRunId,
472
+ mode: "workflow",
473
+ state: "running",
474
+ startedAt: warmingWorkflowStartedAt,
475
+ lastUpdate: Date.now(),
476
+ steps: [{ agent: "worker", status: "running", sessionFile: warmingWorkflowSessionFile, model: "openai-codex/gpt-5.6-sol", thinking: "high" }],
477
+ }));
478
+ await pollWarmingWorkflow("No active async runs.", {
479
+ kind: "pi-subagents.async-status-snapshot",
480
+ version: 1,
481
+ generatedAt: Date.now(),
482
+ runs: [{
483
+ id: warmingWorkflowRunId,
484
+ kind: "workflow",
485
+ label: "workflow",
486
+ state: "running",
487
+ startedAt: warmingWorkflowStartedAt,
488
+ updatedAt: Date.now(),
489
+ children: [{ id: "ws1-input-backend", kind: "step", label: "ws1-input-backend", state: "running" }],
490
+ }],
491
+ });
492
+ payload = latestPayload();
493
+ const warmingWorkflowRun = payload.runs.find((run) => run.id === warmingWorkflowRunId);
494
+ assert.deepEqual(warmingWorkflowRun && {
495
+ source: warmingWorkflowRun.source,
496
+ status: warmingWorkflowRun.status,
497
+ agents: warmingWorkflowRun.agents.map((agent) => [agent.name, agent.model, agent.thinking]),
498
+ }, {
499
+ source: "async",
500
+ status: "running",
501
+ agents: [["worker", "openai-codex/gpt-5.6-sol", "high"]],
502
+ }, "an active workflow header must keep the run alive until its first worker locator appears");
503
+ assert.equal(payload.runs.some((run) => run.id === "fleet:fleet-warming-worker"), false, "the real workflow worker must replace its temporary fleet placeholder");
504
+ const warmingWorkflowCanonical = latestCanonicalPayload().instances.find((instance) => instance.runId === warmingWorkflowRunId && instance.name === "worker");
505
+ assert.ok(warmingWorkflowCanonical, "the resolved workflow worker should publish a canonical output handle");
506
+ await helperCommand.handler(JSON.stringify({
507
+ requestId: "warming-workflow-live-output-test",
508
+ action: "subagent-output",
509
+ payload: { outputId: warmingWorkflowCanonical.outputRef.id },
510
+ }), ctx);
511
+ const warmingWorkflowOutput = helperResponse("warming-workflow-live-output-test");
512
+ assert.equal(warmingWorkflowOutput.ok, true);
513
+ assert.equal(warmingWorkflowOutput.data.source, "async");
514
+ assert.equal(warmingWorkflowOutput.data.agent.unavailable, undefined);
515
+ assert.deepEqual(warmingWorkflowOutput.data.agent.recentOutput, ["Workflow worker output is live."], "a newly resolved workflow worker should expose its live transcript instead of the recovered placeholder");
516
+ bus.emit("subagent:async-complete", { id: warmingWorkflowRunId });
517
+
409
518
  await helperCommand.handler(JSON.stringify({
410
519
  requestId: "recovered-subagent-output-test",
411
520
  action: "subagent-output",
@@ -60,9 +60,9 @@ assert.match(css, /\.markdown-code \.syntax-comment \{[^}]*font-style: italic;/,
60
60
 
61
61
  // --- Offline/PWA startup closure and coherent revisions ---
62
62
  assert.match(serviceWorker, /"\/syntax-highlight\.mjs",/, "the eagerly imported tokenizer must be part of the offline app shell");
63
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "adding a startup module should advance the PWA cache identity");
64
- assert.match(html, /styles\.css\?v=123/, "new token styles should advance the stylesheet revision");
65
- assert.match(html, /data-app-src="\/app\.js\?v=146"/, "new renderer wiring should advance the app module revision");
63
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "adding a startup module should advance the PWA cache identity");
64
+ assert.match(html, /styles\.css\?v=126/, "new token styles should advance the stylesheet revision");
65
+ assert.match(html, /data-app-src="\/app\.js\?v=148"/, "new renderer wiring should advance the app module revision");
66
66
  assert.match(pkg, /node --check public\/syntax-highlight\.mjs/, "the package check should syntax-check the startup-critical tokenizer");
67
67
 
68
68
  const appShell = serviceWorker.slice(serviceWorker.indexOf("const APP_SHELL"), serviceWorker.indexOf("];", serviceWorker.indexOf("const APP_SHELL")));
@@ -0,0 +1,22 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFileSync } from "node:fs";
3
+
4
+ const app = readFileSync(new URL("../public/app.js", import.meta.url), "utf8");
5
+ const styles = readFileSync(new URL("../public/styles.css", import.meta.url), "utf8");
6
+ const predicateSource = app.match(/function shouldRenderTerminalTabGroup\(group, groupCount\) \{([\s\S]*?)\n\}/)?.[1];
7
+ assert.ok(predicateSource, "terminal CWD grouping predicate should be present");
8
+
9
+ const shouldRenderTerminalTabGroup = new Function("group", "groupCount", predicateSource);
10
+ assert.equal(shouldRenderTerminalTabGroup({ custom: false, cwd: "/repo/one", tabs: [{}] }, 2), false, "a one-tab CWD should remain a normal tab instead of duplicating itself in a group dropdown");
11
+ assert.equal(shouldRenderTerminalTabGroup({ custom: false, cwd: "/repo/one", tabs: [{}, {}] }, 2), true, "a multi-tab CWD should retain its group dropdown");
12
+ assert.equal(shouldRenderTerminalTabGroup({ custom: false, cwd: "", tabs: [{}, {}] }, 2), false, "tabs without a CWD should remain ungrouped");
13
+ assert.equal(shouldRenderTerminalTabGroup({ custom: true, cwd: "", tabs: [{}] }, 2), false, "a one-tab custom group should remain ungrouped");
14
+ assert.equal(shouldRenderTerminalTabGroup({ custom: true, cwd: "", tabs: [{}, {}] }, 1), true, "multi-tab custom groups should retain their existing behavior");
15
+
16
+ assert.match(app, /function createTerminalTabCwdAddMenu\(tab\)[\s\S]*make\("div", "terminal-tab-cwd-add-menu"\)[\s\S]*make\("button", "terminal-tab-group-add terminal-tab-cwd-add", "\+ Tab"\)[\s\S]*createTerminalTab\(tab\.cwd \|\| currentDirectoryForNewTab\(\)/, "a singleton CWD should receive a below-tab + Tab menu using its directory");
17
+ assert.match(app, /const showCwdAdd = groups\.length > 1 && group\.tabs\.length === 1 && Boolean\(group\.cwd\);[\s\S]*renderTerminalTab\(tab, \{ showCwdAdd \}\)/, "the direct + Tab action should appear only for singleton CWDs when multiple CWD groups are open");
18
+ assert.match(app, /function renderTerminalTab\(tab, \{ showCwdAdd = false \} = \{\}\)[\s\S]*terminal-tab-cwd-add-host[\s\S]*if \(showCwdAdd\) wrapper\.append\(createTerminalTabCwdAddMenu\(tab\)\)/, "singleton CWDs should stay on the regular tab rendering path with a separate add-only menu");
19
+ assert.match(styles, /\.terminal-tab-cwd-add-menu \{[\s\S]*position:\s*absolute;[\s\S]*inset:\s*100% 0 auto 0;[\s\S]*display:\s*none;/, "the singleton + Tab menu should sit hidden directly below its tab");
20
+ assert.match(styles, /\.terminal-tab-cwd-add-host:hover \.terminal-tab-cwd-add-menu,\n\.terminal-tab-cwd-add-host:focus-within \.terminal-tab-cwd-add-menu \{\n\s+display:\s*flex;/, "hover or keyboard focus should reveal the singleton + Tab menu");
21
+
22
+ console.log("terminal-cwd-grouping-static.test.mjs passed");
@@ -34,7 +34,7 @@ assert.match(html, /role="alert" hidden>[\s\S]*Replace this exact target\?/, "ov
34
34
 
35
35
  assert.match(app, /from "\.\/theme-contract\.mjs"/, "frontend should consume the shared browser-safe theme contract");
36
36
  assert.match(serviceWorker, /"\/theme-contract\.mjs"/, "the PWA app shell should cache the startup-critical theme contract");
37
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "adding the theme contract to the startup graph should advance the PWA cache identity");
37
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "adding the theme contract to the startup graph should advance the PWA cache identity");
38
38
  assert.match(pkg, /node --check public\/theme-contract\.mjs/, "the package check should syntax-check the startup-critical theme contract");
39
39
  assert.match(app, /function themeDraftFromCatalog\(theme, name = theme\?\.name\)[\s\S]*colors: cloneThemeDraft\(theme\?\.colors \|\| \{\}\)/, "catalog metadata should be projected into a schema-only editable draft");
40
40
  assert.match(app, /for \(const \{ name, label \} of group\.tokens\)/, "visual controls should render from the exact shared token inventory");
@@ -55,6 +55,9 @@ const SUBAGENT_RPC_VERSION = 1;
55
55
  const SUBAGENT_RPC_REQUEST_EVENT = "subagents:rpc:v1:request";
56
56
  const SUBAGENT_RPC_READY_EVENT = "subagents:rpc:v1:ready";
57
57
  const SUBAGENT_RPC_REPLY_PREFIX = "subagents:rpc:v1:reply:";
58
+ const SUBAGENT_ASYNC_STATUS_SNAPSHOT_KIND = "pi-subagents.async-status-snapshot";
59
+ const SUBAGENT_ASYNC_STATUS_SNAPSHOT_VERSION = 1;
60
+ const SUBAGENT_ASYNC_STATUS_SNAPSHOT_RUN_LIMIT = 32;
58
61
  const SUBAGENT_ASYNC_STARTED_EVENT = "subagent:async-started";
59
62
  const SUBAGENT_ASYNC_COMPLETE_EVENT = "subagent:async-complete";
60
63
  const WORKFLOW_SUBAGENTS_EVENT = "firstpick:workflow-subagents:v1";
@@ -841,12 +844,13 @@ function parseSubagentStatusText(text, previousRuns = new Map()) {
841
844
  if (runMatch) {
842
845
  const id = subagentText(runMatch[1], 160);
843
846
  const segments = rawLine.split(" | ").map((part) => part.trim());
844
- const mode = segments.map((part) => part.match(/^(single|parallel|chain)\b/)?.[1]).find(Boolean);
847
+ const mode = segments.map((part) => part.match(/^(single|parallel|chain|workflow)\b/)?.[1]).find(Boolean);
845
848
  const previous = previousRuns.get(id);
846
849
  current = {
847
850
  id,
848
851
  source: "async",
849
852
  mode: subagentMode(mode, previous?.mode),
853
+ workflow: mode === "workflow" || previous?.workflow === true,
850
854
  status: runMatch[2].toLowerCase(),
851
855
  startedAt: previous?.startedAt || Date.now(),
852
856
  agents: [],
@@ -889,7 +893,40 @@ function parseSubagentStatusText(text, previousRuns = new Map()) {
889
893
  nested: /^\s{4,}\d+\./.test(rawLine),
890
894
  });
891
895
  }
892
- return runs.filter((run) => run.status === "running" && run.agents.length > 0);
896
+ // Keep active headers even before their first child step is persisted. Dynamic
897
+ // workflow runs can report a running header for several polls while their
898
+ // worker locator is still being written. Dropping that header makes absence
899
+ // reconciliation falsely finish the run, after which later worker details are
900
+ // deliberately ignored as stale and the UI is left with a fleet placeholder.
901
+ return runs.filter((run) => run.status === "running");
902
+ }
903
+
904
+ function parseAsyncSubagentSnapshot(value, previousRuns = new Map()) {
905
+ if (!value || typeof value !== "object"
906
+ || value.kind !== SUBAGENT_ASYNC_STATUS_SNAPSHOT_KIND
907
+ || value.version !== SUBAGENT_ASYNC_STATUS_SNAPSHOT_VERSION
908
+ || !Array.isArray(value.runs)) return [];
909
+ const runs = [];
910
+ const seen = new Set();
911
+ for (const candidate of value.runs.slice(0, SUBAGENT_ASYNC_STATUS_SNAPSHOT_RUN_LIMIT)) {
912
+ const id = subagentText(candidate?.id, 160);
913
+ if (!id || seen.has(id) || candidate?.state !== "running") continue;
914
+ seen.add(id);
915
+ const previous = previousRuns.get(id);
916
+ const workflow = candidate?.kind === "workflow" || previous?.workflow === true;
917
+ runs.push({
918
+ id,
919
+ source: "async",
920
+ mode: subagentMode(undefined, previous?.mode),
921
+ workflow,
922
+ status: "running",
923
+ startedAt: Number.isSafeInteger(candidate?.startedAt) && candidate.startedAt >= 0
924
+ ? candidate.startedAt
925
+ : Number.isFinite(previous?.startedAt) ? previous.startedAt : Date.now(),
926
+ agents: [],
927
+ });
928
+ }
929
+ return runs;
893
930
  }
894
931
 
895
932
  export default function webuiRpcHelper(pi) {
@@ -1543,9 +1580,79 @@ export default function webuiRpcHelper(pi) {
1543
1580
  if (sessionFile && path.isAbsolute(sessionFile) && path.extname(sessionFile) === ".jsonl") agent.sessionFile = path.normalize(sessionFile);
1544
1581
  }
1545
1582
 
1583
+ function subagentRunningAgentsFromStatus(run, status) {
1584
+ return (Array.isArray(status?.steps) ? status.steps : [])
1585
+ .slice(0, 128)
1586
+ .map((step, offset) => {
1587
+ if (step?.status !== "running") return undefined;
1588
+ const name = subagentAgentName(step.agent);
1589
+ if (!name) return undefined;
1590
+ const index = Number.isInteger(step.index) && step.index >= 0 ? step.index : offset;
1591
+ const sessionFile = subagentText(step.sessionFile, 4096);
1592
+ return {
1593
+ id: `${run.id}:step:${index}:${name}`,
1594
+ name,
1595
+ status: "running",
1596
+ index,
1597
+ currentTool: subagentText(step.currentTool, 120) || undefined,
1598
+ activityState: subagentText(step.activityState, 80) || undefined,
1599
+ currentPath: subagentText(step.currentPath, 1000) || undefined,
1600
+ turnCount: Number.isFinite(step.turnCount) ? step.turnCount : undefined,
1601
+ toolCount: Number.isFinite(step.toolCount) ? step.toolCount : undefined,
1602
+ tokens: Number.isFinite(step.tokens?.total) ? step.tokens.total : Number.isFinite(step.tokens) ? step.tokens : undefined,
1603
+ model: subagentModel(step.model) || undefined,
1604
+ thinking: subagentThinking(step.thinking) || subagentThinkingFromModel(step.model) || undefined,
1605
+ recentTools: subagentRecentTools(step.recentTools),
1606
+ recentOutput: subagentOutputLines(step.recentOutput),
1607
+ sessionFile: sessionFile && path.isAbsolute(sessionFile) && path.extname(sessionFile) === ".jsonl" ? path.normalize(sessionFile) : undefined,
1608
+ nested: false,
1609
+ };
1610
+ })
1611
+ .filter(Boolean);
1612
+ }
1613
+
1546
1614
  async function enrichAsyncSubagentRun(run) {
1547
1615
  const statusByDir = new Map();
1616
+ const agents = Array.isArray(run?.agents) ? run.agents : [];
1617
+ if (!agents.some((agent) => agent?.status === "running")) {
1618
+ const targetRunId = subagentText(run?.id, 160);
1619
+ let asyncDir = subagentText(run?.asyncDir, 4096);
1620
+ if (!asyncDir && targetRunId) {
1621
+ try {
1622
+ const data = await requestSubagentStatus({ id: targetRunId });
1623
+ asyncDir = subagentAsyncDirFromStatusText(data?.text);
1624
+ } catch {
1625
+ // The aggregate snapshot still keeps the run alive until a locator resolves.
1626
+ }
1627
+ }
1628
+ if (asyncDir) {
1629
+ run.asyncDir = asyncDir;
1630
+ let status = null;
1631
+ try {
1632
+ status = JSON.parse(readFileSync(path.join(asyncDir, "status.json"), "utf8"));
1633
+ } catch {
1634
+ // A status write can be briefly between atomic replacements.
1635
+ }
1636
+ if (status && (!status.runId || status.runId === targetRunId)) {
1637
+ statusByDir.set(asyncDir, status);
1638
+ run.workflow = status.mode === "workflow" || run.workflow === true;
1639
+ run.mode = subagentMode(status.mode, run.mode);
1640
+ if (!Number.isFinite(run.startedAt) && Number.isFinite(status.startedAt)) run.startedAt = status.startedAt;
1641
+ const discovered = subagentRunningAgentsFromStatus(run, status);
1642
+ if (discovered.length) {
1643
+ run.agents = [
1644
+ ...agents.filter((agent) => !discovered.some((candidate) => candidate.index === agent.index && candidate.name === agent.name)),
1645
+ ...discovered.map((agent) => ({
1646
+ ...agents.find((candidate) => candidate.index === agent.index && candidate.name === agent.name),
1647
+ ...agent,
1648
+ })),
1649
+ ];
1650
+ }
1651
+ }
1652
+ }
1653
+ }
1548
1654
  for (const agent of Array.isArray(run?.agents) ? run.agents : []) {
1655
+ if (agent?.status !== "running") continue;
1549
1656
  await enrichAsyncSubagentAgent(run, agent, statusByDir);
1550
1657
  }
1551
1658
  }
@@ -1742,9 +1849,16 @@ export default function webuiRpcHelper(pi) {
1742
1849
  const addSlots = (runs, priority) => {
1743
1850
  for (const run of runs) {
1744
1851
  if (run?.status !== "running") continue;
1852
+ const slotPriority = parsedIds.has(run.id) ? 0 : priority;
1853
+ // pi-subagents publishes one aggregate fleet entry named "workflow" for
1854
+ // each orchestration run. It is a controller, not a model-powered agent.
1855
+ // Claim it against the known workflow container so it cannot become an
1856
+ // empty recovered Workflow row beside the real child agent.
1857
+ if (run.workflow === true) slots.push({ run, identity: "workflow", priority: slotPriority, claimed: false });
1745
1858
  for (const agent of Array.isArray(run.agents) ? run.agents : []) {
1746
- if (agent?.status !== "running" || !subagentAgentName(agent.name)) continue;
1747
- slots.push({ run, agent, priority: parsedIds.has(run.id) ? 0 : priority, claimed: false });
1859
+ const identity = subagentAgentName(agent?.name);
1860
+ if (agent?.status !== "running" || !identity) continue;
1861
+ slots.push({ run, agent, identity, priority: slotPriority, claimed: false });
1748
1862
  }
1749
1863
  }
1750
1864
  };
@@ -1755,7 +1869,7 @@ export default function webuiRpcHelper(pi) {
1755
1869
  const matchedRunIds = new Set();
1756
1870
  const unmatched = [];
1757
1871
  for (const entry of fleet.entries) {
1758
- const slot = slots.find((candidate) => !candidate.claimed && candidate.agent.name === entry.agent);
1872
+ const slot = slots.find((candidate) => !candidate.claimed && candidate.identity === entry.agent);
1759
1873
  if (!slot) {
1760
1874
  unmatched.push(entry);
1761
1875
  continue;
@@ -1802,6 +1916,12 @@ export default function webuiRpcHelper(pi) {
1802
1916
  const data = await requestSubagentStatus();
1803
1917
  if (generation !== subagentPollGeneration || sequence <= subagentAppliedPollSequence) return;
1804
1918
  const parsedRuns = parseSubagentStatusText(data?.text, asyncSubagentRuns);
1919
+ const parsedRunIds = new Set(parsedRuns.map((run) => run.id));
1920
+ for (const run of parseAsyncSubagentSnapshot(data?.asyncSnapshot, asyncSubagentRuns)) {
1921
+ if (parsedRunIds.has(run.id)) continue;
1922
+ parsedRunIds.add(run.id);
1923
+ parsedRuns.push(run);
1924
+ }
1805
1925
  const nextRuns = [];
1806
1926
  for (const run of parsedRuns) {
1807
1927
  const previous = asyncSubagentRuns.get(run.id);
@@ -1908,6 +2028,7 @@ export default function webuiRpcHelper(pi) {
1908
2028
  id,
1909
2029
  source: "async",
1910
2030
  mode: subagentMode(info.mode, Array.isArray(info.chain) ? "chain" : "single"),
2031
+ workflow: info.mode === "workflow" || undefined,
1911
2032
  status: "running",
1912
2033
  startedAt: Date.now(),
1913
2034
  eventSeenAt: Date.now(),