@firstpick/pi-package-webui 0.7.4 → 0.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -106,6 +106,10 @@ assert.match(html, /id="pathPickerCreateButton"[^>]*>Create directory<\/button>/
106
106
  assert.match(html, /id="pathPickerSearchInput"[^>]*type="search"[^>]*placeholder="Search current directory…"/, "cwd picker should expose a current-directory search box");
107
107
  assert.match(html, /id="pathPickerClearSearchButton"[^>]*hidden[^>]*>Clear<\/button>/, "cwd picker should expose a clear-search action");
108
108
  assert.match(app, /function fileTreeGitStatusForEntry\(entry = \{\}\) \{\s+return fileTreeState\.gitStatusByPath\.get\(normalizeFileTreePath\(entry\.path \|\| ""\)\) \|\| null;\s+\}/, "file tree rendering should use the refreshed Git-status snapshot instead of stale status embedded in cached entries");
109
+ assert.match(app, /function fileTreeExpander\(expanded = false\)[\s\S]*make\("span", "file-tree-expander", expanded \? "▾" : "▸"\)[\s\S]*aria-hidden/, "file tree arrows should be visual children rather than separate buttons");
110
+ assert.match(app, /function appendFileTreeEntry\(parent, entry, depth = 0\)[\s\S]*button\.append\([\s\S]*isDirectory \? fileTreeExpander\(expanded\)[\s\S]*file-tree-name[\s\S]*button\.addEventListener\("click"[\s\S]*toggleFileTreeDirectory\(path\)[\s\S]*item\.append\(button, fileTreeOverflowButton\(entry\)\)/, "each directory arrow and label should share one expansion button");
111
+ assert.match(app, /function appendFileSearchEntry\(parent, entry\)[\s\S]*button\.append\([\s\S]*isDirectory \? fileTreeExpander\(false\)[\s\S]*button\.addEventListener\("click"[\s\S]*revealFileTreeEntry\(entry\)[\s\S]*item\.append\(button, fileTreeOverflowButton\(entry\)\)/, "directory search results should also combine their arrow and label action");
112
+ assert.match(css, /\.file-tree-node \{[\s\S]*grid-template-columns: minmax\(0, 1fr\) auto[\s\S]*\.file-tree-item \{[\s\S]*grid-template-columns: auto auto minmax\(0, 1fr\) auto auto/, "file tree layout should reserve one row button plus the overflow action while keeping the arrow inside the row button");
109
113
  assert.match(app, /confirmLabel: activeAgentTabs\.length \? "Close and stop work" : count === 1 \? "Close tab" : "Close tabs"/, "single-tab confirmation should use singular close wording");
110
114
  assert.match(html, /data-side-panel-section="git"[\s\S]*class="side-panel-section-label">Git<[\s\S]*id="gitPanelCountBadge"[\s\S]*id="gitPanelGroups"[\s\S]*aria-label="Git repositories"[\s\S]*id="gitPanelContextMenu"[\s\S]*role="menu"/, "side panel should expose a collapsed, globally deduplicated Git repository list with a count and dedicated action menu");
111
115
  assert.match(app, /const GIT_PANEL_CACHE_MAX_AGE_MS = 5 \* 60 \* 1000/, "Git panel should use the approved five-minute page-local freshness window");
@@ -151,6 +155,10 @@ assert.match(html, /id="codexUsageBox"/, "side panel should expose Codex subscri
151
155
  assert.match(html, /data-side-panel-section="codex-usage"/, "Codex usage should live in a collapsible side-panel section");
152
156
  assert.match(html, /data-side-panel-section="subagents"[\s\S]*class="side-panel-section-label">Subagents<\/span>[\s\S]*id="subagentCountBadge"[\s\S]*class="subagents-help"[\s\S]*<code>subagent<\/code>[\s\S]*<code>subagent_gate<\/code>[\s\S]*bounded retries or a success quorum[\s\S]*id="subagentsBox"/, "side panel should explain ordinary delegation and retry-gate workflows with a live count");
153
157
  assert.match(html, /id="subagentOpenModeSelect"[\s\S]*<option value="overlay">Overlay<\/option>[\s\S]*<option value="tab">Tab \/ terminal<\/option>[\s\S]*id="subagentOpenModeStatus"/, "Subagents should offer a browser-persisted overlay or terminal-tab opening choice");
158
+ assert.match(html, /id="subagentLaunchSlots"[\s\S]*id="subagentLaunchSlotsTitle">Agent models<[\s\S]*id="subagentLaunchSlotScope"[\s\S]*<option value="user">User default<\/option>[\s\S]*<option value="project">This project<\/option>[\s\S]*id="subagentLaunchSlotRoles"[\s\S]*id="subagentLaunchSlotsSave"[\s\S]*Save agent models[\s\S]*id="subagentLaunchSlotsReload"[\s\S]*Reload active tab/, "Subagents should expose a separate scoped Agent models editor before the live monitor");
159
+ assert.match(html, /id="subagentLaunchSlotsInherit"[^>]*hidden[^>]*>Use user defaults<\/button>/, "project launch-slot overrides should expose an explicit inheritance reset");
160
+ assert.match(html, /id="subagentLaunchSlotScope"[^>]*aria-describedby="subagentLaunchSlotScopeStatus"/, "scope selection should use stable scope help rather than dynamic live status as its accessible description");
161
+ assert.match(html, /id="subagentLaunchSlotsAnnouncer"[^>]*aria-live="polite"[^>]*aria-atomic="true"/, "launch-slot additions and removals should have a dedicated live announcement");
154
162
  assert.match(html, /id="subagentTerminalView"[\s\S]*Subagent · view only[\s\S]*id="subagentTerminalTranscript"[\s\S]*id="subagentTerminalStatus"[^>]*aria-live="off"[\s\S]*id="subagentTerminalInput"[^>]*placeholder="View only — send messages from the parent terminal"[^>]*disabled[\s\S]*Use its parent terminal to interact with the run/, "dedicated subagent tabs should expose a view-only transcript, non-announcing routine status, and disabled input");
155
163
  assert.doesNotMatch(html, /id="subagentOverlayDialog"/, "subagent output should not use a blocking modal dialog");
156
164
  assert.match(html, /data-side-panel-section="session"[\s\S]*data-side-panel-section="subagents"[\s\S]*data-side-panel-section="queue"/, "Subagents should appear between Session and Queue in the side panel");
@@ -241,7 +249,11 @@ assert.ok(
241
249
  assert.match(html, /id="optionsConversationModeButton"[^>]*data-command="\/talk"[^>]*hidden[\s\S]*?<span>Start Conversation<\/span>/, "Options menu should include the feature-gated Natural Conversation toggle");
242
250
  assert.match(html, /id="conversationModeChip" class="composer-conversation-mode-chip"[\s\S]*hidden>Voice: off<\/button>/, "composer should expose a hidden-until-active conversation status chip");
243
251
  const workflowModeButtonHtml = html.match(/<button\s+id="workflowModeButton"[\s\S]*?<\/button>/)?.[0] || "";
244
- assert.match(workflowModeButtonHtml, /class="composer-workflow-mode-button"[\s\S]*aria-pressed="false"[\s\S]*hidden[\s\S]*<span>Workflow<\/span>/, "composer actions should expose a capability-gated Workflow Mode toggle");
252
+ const workflowOverlayOpenButtonHtml = html.match(/<button\s+id="workflowOverlayOpenButton"[\s\S]*?<\/button>/)?.[0] || "";
253
+ assert.match(html, /id="workflowModeControls" class="composer-publish-menu composer-workflow-mode-controls"[\s\S]*id="workflowOverlayOpenButton"[\s\S]*aria-controls="widgetArea"[\s\S]*id="workflowModeButton"/, "Workflow controls should group a restore affordance with the mode button like the app-runner helper control");
254
+ assert.doesNotMatch(workflowOverlayOpenButtonHtml, /\stitle=/, "Workflow overlay restore should not combine a browser-native tooltip with its styled tooltip");
255
+ assert.match(workflowModeButtonHtml, /class="composer-icon-button composer-workflow-mode-button"[\s\S]*aria-label="Enable Workflow Mode"[\s\S]*aria-pressed="false"[\s\S]*hidden[\s\S]*<svg class="composer-icon"[\s\S]*aria-hidden="true"/, "composer actions should expose a capability-gated, accessible Workflow Mode icon toggle");
256
+ assert.doesNotMatch(workflowModeButtonHtml, /<span>Workflow<\/span>/, "Workflow Mode should use the shared icon treatment instead of a text label");
245
257
  assert.match(workflowModeButtonHtml, /data-tooltip="Workflow Mode:/, "Workflow Mode should retain its styled tooltip");
246
258
  assert.doesNotMatch(workflowModeButtonHtml, /\stitle=/, "Workflow Mode should not also expose a browser-native tooltip");
247
259
  assert.match(html, /id="workflowModeChip" class="composer-workflow-mode-chip"[\s\S]*hidden>Workflow: on<\/button>/, "composer should expose a hidden-until-active Workflow Mode chip");
@@ -396,6 +408,8 @@ assert.match(css, /\.webui-dev-badge \{[\s\S]*?color:\s*var\(--ctp-yellow\)/, "W
396
408
  assert.match(css, /\.side-panel-section\.collapsed \.side-panel-section-content,\n\.side-panel-section-content\[hidden\] \{\n\s+display:\s*none;/, "collapsed side panel section content should be hidden");
397
409
  assert.match(css, /\.side-panel-section:not\(\.collapsed\) \.side-panel-section-chevron/, "expanded side panel sections should rotate the chevron");
398
410
  assert.match(css, /\.subagents-help \{[\s\S]*border-left:[\s\S]*font-size:\s*0\.7rem;[\s\S]*\.subagents-help code/, "subagent invocation guidance should render as a compact informational callout");
411
+ assert.match(css, /\.subagent-launch-slots \{[\s\S]*\.subagent-launch-slot-role \{[\s\S]*\.subagent-launch-slot-controls \{[\s\S]*grid-template-columns: repeat\(2, minmax\(0, 1fr\)\)/, "launch-slot cards should group role slots with paired model and thinking controls");
412
+ assert.match(css, /@media \(max-width: 720px\), \(max-device-width: 720px\), \(pointer: coarse\) and \(hover: none\) \{[\s\S]*min-height: 44px[\s\S]*\.subagent-launch-slot-scope,[\s\S]*\.subagent-launch-slot-row,[\s\S]*\.subagent-launch-slot-controls \{ grid-template-columns: minmax\(0, 1fr\); \}/, "launch-slot controls should stack with coarse-pointer touch targets");
399
413
  assert.match(css, /\.subagents-box\.has-items[\s\S]*\.subagent-tab-group[\s\S]*\.subagent-agent-row/, "running subagents should render as grouped terminal/session cards");
400
414
  assert.match(css, /\.subagent-gate-card[\s\S]*\.subagent-gate-status[\s\S]*\.subagent-gate-attempt[\s\S]*\.subagent-gate-attempt-error/, "retry gates should render quorum, attempt status, and failure details");
401
415
  assert.match(css, /\.subagent-agent-row:hover,[\s\S]*\.subagent-agent-row:focus-visible/, "subagent rows should expose clickable hover and keyboard focus states");
@@ -449,7 +463,8 @@ assert.match(css, /\.action-feedback-controls:hover,[\s\S]*?\.action-feedback-co
449
463
  assert.match(css, /\.action-feedback-controls:not\(:hover\):not\(:focus-within\) \.action-feedback-button/, "hidden action reactions should not expose button hit targets until the hover area is reached");
450
464
  assert.match(css, /\.action-feedback-button\.feedback-question\.active/, "question-mark reaction should have selected styling");
451
465
  assert.match(css, /\.composer-row button\[data-tooltip\]::after/, "composer button tooltips should be shared across Git, Steer, and Follow-up buttons");
452
- assert.match(css, /\.composer-row \.composer-workflow-mode-button\[data-tooltip\]::after \{\n\s+max-width:\s*min\(18rem, calc\(100vw - 2rem\)\);/, "Workflow Mode tooltip should stay narrow enough to remain inside the outer chat frame");
466
+ assert.match(css, /\.composer-row \.composer-workflow-mode-button\[data-tooltip\]::after \{[\s\S]*?left:\s*0;[\s\S]*?right:\s*auto;[\s\S]*?max-width:\s*min\(18rem, calc\(100vw - 2rem\)\);/, "Workflow Mode tooltip should open rightward and stay narrow enough to remain inside the outer chat frame");
467
+ assert.match(css, /\.composer-row \.composer-workflow-mode-button\[data-tooltip\]::before \{[\s\S]*?left:\s*50%;[\s\S]*?right:\s*auto;[\s\S]*?translate\(-50%, 0\.24rem\)/, "Workflow Mode tooltip arrow should stay centered on the icon while its panel opens rightward");
453
468
  assert.match(css, /\.composer-row \.composer-git-button\[data-tooltip\]::after \{[\s\S]*?left:\s*0;[\s\S]*?right:\s*auto;/, "Git workflow tooltip should open rightward so it is not clipped off the left edge");
454
469
  assert.match(css, /\.composer-row button\[data-tooltip\]\.tooltip-open::after/, "composer button tooltips should be triggerable from JS for empty mobile taps");
455
470
  assert.match(css, /\.composer-row button\[data-tooltip\]:hover,[\s\S]*?\.composer-input-row button\[data-tooltip\]\.tooltip-open \{\n\s+z-index:\s*40;/, "active composer tooltip triggers should stack above context tags and adjacent controls");
@@ -704,7 +719,7 @@ assert.match(app, /function setOptionsMenuOpen\(open\)[\s\S]*scheduleMobileDropd
704
719
  assert.match(app, /function focusPromptInput\(\{ defer = false \} = \{\}\)/, "frontend should focus the prompt composer programmatically after tab/app startup");
705
720
  assert.match(app, /async function switchTab\(tabId\)[\s\S]*?restoreActiveDraft\(\);\n\s+focusPromptInput\(\{ defer: true \}\);/, "switching to a newly opened tab should focus the prompt input immediately");
706
721
  assert.match(app, /async function initializeTabs\(\)[\s\S]*?restoreActiveDraft\(\);[\s\S]*if \(!loadedTabs\.length\)[\s\S]*focusPromptInput\(\{ defer: true \}\);/, "starting the Web UI should prompt for cwd when needed and focus active tabs");
707
- assert.match(app, /resizePromptInput\(\);\nrestoreFileViewerWidthPreference\(\);\nfocusPromptInput\(\{ defer: true \}\);\nrestoreStoredSkillUsage\(\);\nrestoreBusyPromptBehaviorSetting\(\);\nupdateComposerModeButtons\(\);/, "startup should restore browser preferences, request prompt focus, and restore skill tags before waiting for tab state refreshes");
722
+ assert.match(app, /resizePromptInput\(\);\nrestoreSidePanelWidthPreference\(\);\nrestoreFileViewerWidthPreference\(\);\nfocusPromptInput\(\{ defer: true \}\);\nrestoreStoredSkillUsage\(\);\nrestoreBusyPromptBehaviorSetting\(\);\nupdateComposerModeButtons\(\);/, "startup should restore resizable panel preferences, request prompt focus, and restore skill tags before waiting for tab state refreshes");
708
723
  assert.match(app, /elements\.promptInput\.addEventListener\("focus", \(\) => \{\n\s+syncMobileChatToBottomForInput\(\);/, "focusing mobile input should scroll output to bottom");
709
724
  assert.match(app, /navigator\.serviceWorker\.register\("\/service-worker\.js"\)/, "PWA service worker should be registered by the app");
710
725
  assert.match(app, /function serverStartCommandText\(\)[\s\S]*return `pi-webui\$\{currentPortArg\(\)\}`/, "PWA/offline shell should build a pathless pi-webui recovery command");
@@ -778,6 +793,13 @@ assert.match(
778
793
  );
779
794
  assert.match(app, /function renderCodexUsage\(\)/, "frontend should render Codex usage buckets in the side panel");
780
795
  assert.match(app, /function renderSubagents\(\)[\s\S]*subagentTabsWithRunningAgents\(\)[\s\S]*totalGates[\s\S]*renderSubagentTabGroup\(tab\)/, "frontend should group running subagents and retained retry gates by terminal and session");
796
+ assert.match(app, /from "\.\/subagent-launch-slot-state\.mjs"[\s\S]*function renderSubagentLaunchSlots\(\)[\s\S]*function loadSubagentLaunchSlotConfig\([\s\S]*\/api\/subagents\/config/, "launch-slot configuration should have its own browser state and API loader");
797
+ assert.match(app, /function subagentLaunchSlotThinkingForModel\(model\)[\s\S]*modelThinkingLevels/, "launch-slot thinking choices should come from the selected model metadata");
798
+ assert.match(app, /function renderSubagentLaunchSlotCard\(role, slots\)[\s\S]*Default \/ inherit[\s\S]*"Add slot"[\s\S]*Remove/, "role cards should render independent same-role slots and inheritance controls");
799
+ assert.match(app, /async function saveSubagentLaunchSlotConfig[\s\S]*scope: subagentLaunchSlotScope,[\s\S]*revision: subagentLaunchSlotConfig\.revision,[\s\S]*body\.roles = cloneLaunchSlotRoles[\s\S]*async function reloadActiveTabForSubagentLaunchSlots[\s\S]*sendPrompt\("prompt", "\/reload"/, "launch-slot saves should be revision checked and offer active-tab reload through the existing path");
800
+ assert.match(app, /const subagentLaunchSlotReloadTabs = new Set\(\)[\s\S]*subagentLaunchSlotReloadTabs\.add\(activeTabId\)[\s\S]*subagentLaunchSlotReloadTabs\.delete\(activeTabId\)/, "reload-required reminders should survive tab switches until that tab is actually reloaded");
801
+ const subagentOverviewRefreshSource = appFunctionSource("refreshSubagents", "scheduleRefreshSubagents");
802
+ assert.doesNotMatch(subagentOverviewRefreshSource, /subagentLaunchSlot/, "live subagent polling must not recreate or reset the launch-slot editor");
781
803
  assert.match(app, /function renderSubagentGateAttempt\(attempt\)[\s\S]*failureKind[\s\S]*function renderSubagentGate\(gate\)[\s\S]*qualifyingSuccesses/, "frontend should render failure-classified attempts and gate quorum");
782
804
  assert.match(helper, /async function enrichAsyncSubagentAgent\(run, agent, statusByDir\)[\s\S]*status\.json[\s\S]*agent\.model = subagentModel\(step\.model\)[\s\S]*agent\.thinking = subagentThinking\(step\.thinking\)/, "WebUI helper should enrich async children from effective lifecycle model and reasoning metadata");
783
805
  assert.match(helper, /SUBAGENT_GATE_UPDATE_EVENT[\s\S]*function publicSubagentGates\(\)[\s\S]*failureKind[\s\S]*gates = publicSubagentGates\(\)/, "WebUI helper should publish bounded retry-gate lifecycle data");
@@ -1026,6 +1048,9 @@ assert.match(app, /const WORKFLOW_MODE_RPC_WIDGET_KEY = "workflow-mode:rpc"[\s\S
1026
1048
  assert.match(app, /function workflowModeStateFromRpcPayload\(lines\)[\s\S]*payload\?\.type !== WORKFLOW_MODE_RPC_PAYLOAD_TYPE[\s\S]*normalizeWorkflowModeState/, "frontend should strictly validate structured Workflow Mode payloads");
1027
1049
  assert.match(app, /const workflowModeByTab = new Map\(\)/, "frontend should track Workflow Mode independently for each Pi tab");
1028
1050
  assert.match(app, /function renderWorkflowModeControls\(\)[\s\S]*workflow-mode-active[\s\S]*workflowModeButton[\s\S]*workflowModeChip/, "frontend should render toggle, active chip, and composer state from extension status");
1051
+ assert.match(app, /workflowModeButton\.toggleAttribute\("aria-busy", pending\)[\s\S]*pending\s*\? "Updating JavaScript Workflow Mode for this Pi tab\."/, "Workflow Mode icon should preserve pending-state feedback through busy semantics and its accessible tooltip");
1052
+ assert.match(app, /applyStyledTooltip\(elements\.workflowModeButton, tooltip, \{ ariaLabel: true, align: "start", floating: false \}\)/, "Workflow Mode should use only its composer pseudo-element tooltip instead of also binding the floating tooltip");
1053
+ assert.match(app, /function applyStyledTooltip\([\s\S]*if \(options\.floating !== false\) bindStyledTooltipEvents\(node\)/, "styled tooltip setup should allow controls with native scoped tooltip CSS to opt out of the floating tooltip layer");
1029
1054
  assert.match(app, /async function setWorkflowModeEnabled\(enabled\)[\s\S]*`\/\$\{commandName\} mode \$\{enabled \? "on" : "off"\}`/, "Workflow Mode toggle should send canonical extension commands rather than rewrite prompts locally");
1030
1055
  assert.match(app, /if \(statusKey === WORKFLOW_MODE_STATUS_KEY\) handleWorkflowModeStatus/, "Workflow Mode should synchronize from replayable extension setStatus events");
1031
1056
  assert.match(app, /if \(widgetKey === WORKFLOW_MODE_RPC_WIDGET_KEY\)[\s\S]*workflowModeStateFromRpcPayload\(request\.widgetLines\)[\s\S]*updateWorkflowModeForTab/, "Workflow Mode should consume structured replay state without rendering an opaque widget");
@@ -1036,19 +1061,25 @@ assert.match(app, /function renderWorkflowInspectorAgent\(agent, run\)[\s\S]*Pro
1036
1061
  assert.match(app, /canPause[\s\S]*`\/workflow pause \$\{run\.runId\}`[\s\S]*canAbort[\s\S]*`\/workflow abort \$\{run\.runId\}`[\s\S]*Save user[\s\S]*Save project[\s\S]*Raw workflow script/, "WebUI Workflow controls should send canonical extension commands and expose raw scripts");
1037
1062
  assert.match(app, /confirmMessage && !window\.confirm\(confirmMessage\)/, "destructive WebUI Workflow actions should require browser confirmation");
1038
1063
  assert.match(app, /const workflowInspectorByTab = new Map\(\)[\s\S]*workflowInspectorSelectionByTab = new Map\(\)[\s\S]*workflowInspectorMinimizedByTab = new Set\(\)/, "Workflow inspector run, selection, and minimized state should be per tab");
1039
- assert.match(app, /const workflowTerminalScrollByTab = new Map\(\);\s*const workflowSubprocessMinimizedByTab = new Set\(\);/, "Workflow subprocess minimize state should be isolated per browser tab");
1064
+ assert.match(app, /const workflowTerminalScrollByTab = new Map\(\);\s*const workflowSubprocessMinimizedByTab = new Set\(\);\s*const workflowOverlayMinimizedByTab = new Set\(\);/, "Workflow subprocess and complete-overlay minimize state should be isolated per browser tab");
1065
+ assert.match(app, /function setWorkflowOverlayMinimized\(minimized\)[\s\S]*workflowOverlayMinimizedByTab\.(?:add|delete)[\s\S]*renderWidgets\(\)[\s\S]*workflowOverlayOpenButton[\s\S]*workflow-overlay-close-button[\s\S]*focus\(\{ preventScroll: true \}\)/, "complete Workflow overlay minimize and restore should survive rerenders and move focus to the replacement control");
1066
+ assert.match(app, /function renderWidgets\(\)[\s\S]*if \(!workflowOverlayIsMinimized\(\)\)[\s\S]*attachWorkflowOverlayCloseButton\(workflowInspectorWidget \|\| workflowSubprocessWidget\)[\s\S]*renderWorkflowOverlayControls\(\)/, "the complete Workflow overlay should be omitted while minimized and expose one close control while open");
1067
+ assert.match(app, /workflowOverlayOpenButton\?\.addEventListener\("click", \(\) => setWorkflowOverlayMinimized\(false\)\)/, "the Workflow-button restore affordance should reopen the complete overlay");
1040
1068
  assert.match(app, /function workflowInspectorSetMinimized\(minimized\)[\s\S]*workflowInspectorMinimizedByTab\.(?:add|delete)[\s\S]*renderWidgets\(\)[\s\S]*requestAnimationFrame[\s\S]*workflow-inspector-minimize-button[\s\S]*focus\(\{ preventScroll: true \}\)/, "Workflow inspector minimize state should survive rerenders and restore focus to the replacement control");
1041
1069
  assert.match(app, /function renderWorkflowInspectorWidget\(\)[\s\S]*workflow-inspector-body[\s\S]*workflow-inspector-minimize-button[\s\S]*minimized \? "Restore" : "Minimize"[\s\S]*minimizeButton\.type = "button"[\s\S]*aria-controls[\s\S]*aria-expanded[\s\S]*aria-label[\s\S]*if \(minimized\) return node/, "Workflow inspector should expose an accessible minimize and restore disclosure control");
1042
1070
  assert.match(app, /function workflowSubprocessSetMinimized\(minimized\)[\s\S]*workflowSubprocessMinimizedByTab\.(?:add|delete)[\s\S]*renderWidgets\(\)[\s\S]*requestAnimationFrame[\s\S]*workflow-subprocess-minimize-button[\s\S]*focus\(\{ preventScroll: true \}\)/, "Workflow subprocess minimize state should survive live rerenders and restore focus to the replacement control");
1043
1071
  assert.match(app, /function renderWorkflowSubprocessWidget\(\)[\s\S]*workflow-subprocess-body[\s\S]*workflow-subprocess-minimize-button[\s\S]*minimized \? "Restore" : "Minimize"[\s\S]*minimizeButton\.type = "button"[\s\S]*aria-controls[\s\S]*aria-expanded[\s\S]*aria-label[\s\S]*node\.append\(header, body\);\s*if \(minimized\) return node;[\s\S]*body\.append\(outputDetails\)/, "Workflow subprocess output should expose an accessible minimize and restore disclosure control without rebuilding its terminal while minimized");
1044
- assert.match(app, /workflowInspectorMinimizedByTab\.delete\(tabId\)[\s\S]*workflowSubprocessMinimizedByTab\.delete\(tabId\)/, "closing a terminal tab should discard its Workflow inspector and subprocess minimize state");
1072
+ assert.match(app, /workflowInspectorMinimizedByTab\.delete\(tabId\)[\s\S]*workflowSubprocessMinimizedByTab\.delete\(tabId\)[\s\S]*workflowOverlayMinimizedByTab\.delete\(tabId\)/, "closing a terminal tab should discard its Workflow inspector, subprocess, and complete-overlay minimize state");
1045
1073
  assert.match(app, /handleInactiveTabEvent\(event\)[\s\S]*WORKFLOW_INSPECTOR_WIDGET_KEY[\s\S]*updateWorkflowInspectorForTab\(event\.tabId, inspector\)[\s\S]*renderTabs\(\)/, "inactive tabs should consume replayed Workflow inspector payloads for badges");
1046
1074
  assert.match(app, /terminal-tab-workflow-indicator[\s\S]*workflowRunningCountForTab/, "terminal tabs should display Workflow Mode or active-run badges");
1047
1075
  assert.match(css, /\.workflow-inspector-layout \{[\s\S]*grid-template-columns:[\s\S]*\.workflow-inspector-run-list[\s\S]*\.workflow-inspector-agent/, "Workflow inspector should have responsive run and agent layout styling");
1048
1076
  assert.match(css, /\.workflow-inspector-widget\.minimized,[\s\S]*\.workflow-subprocess-widget\.minimized \{[\s\S]*\.workflow-inspector-minimize-button,[\s\S]*\.workflow-subprocess-minimize-button/, "Workflow inspector and subprocess widgets should share visible minimized-state toggle styling");
1049
1077
  assert.match(css, /\.workflow-subprocess-widget\.minimized > \.release-npm-header \{[\s\S]*?padding-bottom:\s*0;[\s\S]*?border-bottom:\s*0;/, "minimized Workflow subprocess output should collapse its header divider and extra spacing");
1050
1078
  assert.match(css, /\.terminal-tab-workflow-indicator \{[\s\S]*color: var\(--ctp-mauve\)/, "inactive-tab Workflow badges should have a distinct accessible style");
1079
+ assert.match(css, /\.composer-workflow-mode-button \{[\s\S]*?min-width:\s*2\.9rem;/, "Workflow Mode icon should use the shared composer icon-button width");
1051
1080
  assert.match(css, /\.composer-workflow-mode-button\.active,[\s\S]*aria-pressed="true"/, "active Workflow Mode toggle should have persistent pressed styling");
1081
+ assert.match(css, /\.composer-workflow-mode-controls\.has-open-control \{[^}]*min-width:\s*1\.95rem;[^}]*min-height:\s*1\.95rem;/, "Workflow restore should retain an anchored box even if the Workflow Mode button is unavailable");
1082
+ assert.match(css, /\.composer-workflow-overlay-open-button \{[\s\S]*position:\s*absolute;[\s\S]*border-radius:\s*999px;[\s\S]*\.workflow-overlay-close-button \{/, "Workflow restore should use a visible helper badge and the complete overlay should expose a distinct close action");
1052
1083
  assert.match(css, /\.composer\.workflow-mode-active[\s\S]*body\.workflow-mode-active \.composer::before/, "active Workflow Mode should visibly accent the composer");
1053
1084
 
1054
1085
  // Workflow raw-script inspector: narrowly specialized, structurally read-only, and viewport-safe.
@@ -1587,6 +1618,7 @@ assert.match(serviceWorker, /fetchThenCache\(request\)\.catch\(/, "PWA service w
1587
1618
  assert.match(serviceWorker, /ignoreSearch: true/, "PWA service worker offline fallback should ignore ?v= cache busters");
1588
1619
  assert.match(serviceWorker, /self\.addEventListener\("notificationclick"/, "PWA service worker should focus Web UI when blocked-tab notifications are clicked");
1589
1620
  assert.match(serviceWorker, /event\.notification\.data\?\.url/, "blocked-tab notifications should carry a URL for service-worker click handling");
1621
+ assert.match(serviceWorker, /"\/subagent-launch-slot-state\.mjs"/, "PWA service worker should cache the launch-slot state module imported by the app shell");
1590
1622
  assert.match(serviceWorker, /"\/apple-touch-icon\.png"/, "PWA service worker should cache the apple touch icon");
1591
1623
  assert.match(serviceWorker, /"\/matrix-background\.webp"/, "PWA service worker should cache the Matrix background image");
1592
1624
  assert.match(serviceWorker, /"\/catppuccin-mocha-background\.png"/, "PWA service worker should cache the Catppuccin Mocha background image");
@@ -1766,6 +1798,7 @@ assert.match(server, /writeFile\(tmpFile, body\.content[\s\S]*?rename\(tmpFile,
1766
1798
  assert.match(server, /url\.pathname === "\/api\/themes" && req\.method === "GET"/, "server should expose GET /api/themes");
1767
1799
  assert.match(server, /readBundledThemes\(\)/, "server should read bundled theme JSON files for the browser");
1768
1800
  assert.match(server, /"apple-touch-icon\.png", "icon-192\.png"/, "server should serve the conventional apple touch icon path");
1801
+ assert.match(server, /"fast-output-live\.mjs", "subagent-launch-slot-state\.mjs", "voice-conversation\.mjs"/, "server should serve the launch-slot state module imported by the browser app");
1769
1802
  assert.match(server, /"catppuccin-mocha-background\.png", "matrix-background\.webp", "manifest\.webmanifest", "service-worker\.js"/, "server should serve theme background images as static assets");
1770
1803
  assert.match(server, /\["\.webmanifest", "application\/manifest\+json; charset=utf-8"\]/, "server should serve manifest with the correct MIME type");
1771
1804
  assert.match(server, /\["\.png", "image\/png"\]/, "server should serve PWA PNG icons with the correct MIME type");
@@ -0,0 +1,43 @@
1
+ import assert from "node:assert/strict";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import test from "node:test";
5
+ import { fileURLToPath } from "node:url";
6
+
7
+ const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
8
+ const html = fs.readFileSync(path.join(root, "public/index.html"), "utf8");
9
+ const css = fs.readFileSync(path.join(root, "public/styles.css"), "utf8");
10
+ const app = fs.readFileSync(path.join(root, "public/app.js"), "utf8");
11
+
12
+ test("Control Deck exposes an accessible resize separator", () => {
13
+ assert.match(html, /id="sidePanelResizeHandle"[^>]*role="separator"[^>]*aria-orientation="vertical"[^>]*aria-label="Resize Control Deck width"[^>]*tabindex="0"/);
14
+ assert.match(css, /--side-panel-width:\s*384px/);
15
+ assert.match(css, /\.side-panel-resize-handle[\s\S]*cursor:\s*col-resize[\s\S]*touch-action:\s*none/);
16
+ });
17
+
18
+ test("desktop layouts and Control Deck content follow the selected width", () => {
19
+ assert.match(css, /\.layout \{[\s\S]*grid-template-columns:\s*minmax\(0, 1fr\) minmax\(20rem, var\(--side-panel-width\)\)/);
20
+ assert.match(css, /body\.file-viewer-open \.layout \{[\s\S]*minmax\(24rem, var\(--file-viewer-width\)\) minmax\(20rem, var\(--side-panel-width\)\)/);
21
+ assert.match(css, /body\.terminal-split-open\.file-viewer-open \.layout \{[\s\S]*minmax\(20rem, var\(--side-panel-width\)\)/);
22
+ assert.match(css, /\.side-panel \{[\s\S]*width:\s*100%;[\s\S]*min-width:\s*0/);
23
+ });
24
+
25
+ test("Control Deck width is clamped, persisted, pointer-resizable, and keyboard-resizable", () => {
26
+ assert.match(app, /const SIDE_PANEL_WIDTH_STORAGE_KEY = "pi-webui-side-panel-width"/);
27
+ assert.match(app, /function sidePanelMaxWidth\(\)[\s\S]*fileViewerVisible[\s\S]*splitOpen[\s\S]*primaryMinWidth[\s\S]*available/);
28
+ assert.match(app, /function applySidePanelWidth\(width, \{ persist = false \} = \{\}\)[\s\S]*--side-panel-width[\s\S]*persistSidePanelWidth/);
29
+ assert.match(app, /function beginSidePanelResize\(event\)[\s\S]*setPointerCapture[\s\S]*pointermove[\s\S]*pointercancel/);
30
+ assert.match(app, /function updateSidePanelResize\(event\)[\s\S]*state\.startWidth \+ \(state\.startX - event\.clientX\)/);
31
+ assert.match(app, /function handleSidePanelResizeKeydown\(event\)[\s\S]*ArrowLeft[\s\S]*ArrowRight[\s\S]*Home[\s\S]*End/);
32
+ assert.match(app, /elements\.sidePanelResizeHandle\?\.addEventListener\("pointerdown", beginSidePanelResize\);\nelements\.sidePanelResizeHandle\?\.addEventListener\("keydown", handleSidePanelResizeKeydown\);/);
33
+ });
34
+
35
+ test("Control Deck resizing disables itself in overlay layouts and responds to viewport changes", () => {
36
+ assert.match(app, /const resizeAvailable = !isSidePanelOverlayView\(\) && !document\.body\.classList\.contains\("side-panel-collapsed"\)/);
37
+ assert.match(css, /@media \(max-width: 1050px\)[\s\S]*\.file-viewer-resize-handle,[\s\S]*\.side-panel-resize-handle \{\s*display:\s*none/);
38
+ assert.match(app, /window\.addEventListener\("resize", syncResizablePanelWidthsForViewport/);
39
+ assert.match(app, /function updateFileViewerUi\(\)[\s\S]*requestAnimationFrame\(syncResizablePanelWidthsForViewport\)/);
40
+ assert.match(app, /function closeFileViewer\(\)[\s\S]*requestAnimationFrame\(syncResizablePanelWidthsForViewport\)/);
41
+ assert.match(app, /function updateTerminalSplitUi\(\)[\s\S]*requestAnimationFrame\(syncResizablePanelWidthsForViewport\)/);
42
+ assert.match(app, /restoreSidePanelWidthPreference\(\);\nrestoreFileViewerWidthPreference\(\);/);
43
+ });
@@ -0,0 +1,36 @@
1
+ import assert from "node:assert/strict";
2
+ import {
3
+ addLaunchSlot,
4
+ cloneLaunchSlotRoles,
5
+ launchSlotRolesEqual,
6
+ removeLaunchSlot,
7
+ updateLaunchSlot,
8
+ } from "../public/subagent-launch-slot-state.mjs";
9
+
10
+ const initial = {
11
+ reviewer: [{ id: "reviewer:base", model: "anthropic/reviewer", thinking: "high" }],
12
+ worker: [{ id: "worker:base", model: null, thinking: null }],
13
+ };
14
+ const snapshot = cloneLaunchSlotRoles(initial);
15
+
16
+ const added = addLaunchSlot(initial, "reviewer", "reviewer:base", {
17
+ slotsPerRole: 8,
18
+ totalSlots: 32,
19
+ createId: () => "reviewer:slot-1",
20
+ });
21
+ assert.ok(added, "an available role capacity should create a slot");
22
+ assert.deepEqual(added.slot, { id: "reviewer:slot-1", model: "anthropic/reviewer", thinking: "high" }, "added slots should copy the source draft");
23
+ assert.equal(initial.reviewer.length, 1, "adding should not mutate the saved draft");
24
+ assert.equal(launchSlotRolesEqual(initial, added.roles), false, "a new slot should mark the draft dirty");
25
+
26
+ const changedModel = updateLaunchSlot(added.roles, "reviewer", "reviewer:slot-1", { model: null });
27
+ assert.deepEqual(changedModel.reviewer[1], { id: "reviewer:slot-1", model: null, thinking: null }, "inheriting a model should reset thinking inheritance");
28
+
29
+ const removed = removeLaunchSlot(added.roles, "reviewer", "reviewer:slot-1");
30
+ assert.ok(removed, "added slots should be removable");
31
+ assert.equal(removed.focusSlotId, "reviewer:base", "removal should return a sensible preceding focus target");
32
+ assert.equal(launchSlotRolesEqual(snapshot, removed.roles), true, "removing the added slot should restore a clean draft");
33
+ assert.equal(removeLaunchSlot(initial, "reviewer", "reviewer:base"), null, "base slots must remain non-removable");
34
+ assert.equal(addLaunchSlot(initial, "reviewer", "reviewer:base", { totalSlots: 2, createId: () => "reviewer:slot-2" }), null, "the total cap should prevent extra slots");
35
+
36
+ console.log("subagent-launch-slot-state.test.mjs passed");
@@ -0,0 +1,34 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFile } from "node:fs/promises";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
7
+ const [html, app, css, server, serviceWorker, pkg] = await Promise.all([
8
+ readFile(join(root, "public", "index.html"), "utf8"),
9
+ readFile(join(root, "public", "app.js"), "utf8"),
10
+ readFile(join(root, "public", "styles.css"), "utf8"),
11
+ readFile(join(root, "bin", "pi-webui.mjs"), "utf8"),
12
+ readFile(join(root, "public", "service-worker.js"), "utf8"),
13
+ readFile(join(root, "package.json"), "utf8"),
14
+ ]);
15
+
16
+ assert.match(html, /<details id="subagentLaunchSlots" class="subagent-launch-slots">[\s\S]*<summary class="subagent-launch-slots-summary">[\s\S]*id="subagentLaunchSlotsTitle">Agent models<[\s\S]*id="subagentLaunchSlotRoles"[\s\S]*id="subagentsStatus"[\s\S]*id="subagentsBox"/, "launch-slot configuration should be a native collapsible surface separate from the live monitor");
17
+ assert.doesNotMatch(html, /<details id="subagentLaunchSlots"[^>]*\sopen(?:\s|>)/, "Agent models should start collapsed to keep the Subagents panel compact");
18
+ assert.match(html, /id="subagentLaunchSlotScope"[^>]*aria-describedby="subagentLaunchSlotScopeStatus"/, "scope selection should use stable accessible help");
19
+ assert.match(html, /id="subagentLaunchSlotsAnnouncer"[^>]*aria-live="polite"[^>]*aria-atomic="true"/, "slot changes should be announced accessibly");
20
+ assert.match(app, /from "\.\/subagent-launch-slot-state\.mjs"/, "the browser should use the pure launch-slot state helper");
21
+ assert.match(app, /const subagentLaunchSlotReloadTabs = new Set\(\)[\s\S]*subagentLaunchSlotReloadTabs\.add\(activeTabId\)[\s\S]*subagentLaunchSlotReloadTabs\.delete\(activeTabId\)/, "reload reminders should be tracked per tab until reload");
22
+ assert.match(app, /subagentLaunchSlotsSummaryStatus\.textContent[\s\S]*"Unsaved changes"[\s\S]*"Saved · reload this tab"[\s\S]*subagentLaunchSlots\.open = true/, "the collapsed summary should surface state and reopen for errors or required reloads");
23
+ assert.doesNotMatch(app, /`(?:Model|Thinking) · \$\{slotLabel\}`/, "visible field labels should stay compact while aria-labels retain slot context");
24
+ assert.match(app, /api\(`\/api\/subagents\/config\?\$\{query\}`/, "the editor should load configuration through the tab-scoped API");
25
+ assert.match(app, /api\("\/api\/subagents\/config", \{ method: "POST", body, scoped: false \}\)/, "the editor should save through the localhost-scoped configuration API");
26
+ assert.match(css, /\.subagent-launch-slots \{[\s\S]*container: subagent-launch-slots \/ inline-size[\s\S]*@container subagent-launch-slots \(max-width: 30rem\)[\s\S]*\.subagent-launch-slot-controls \{ grid-template-columns: minmax\(0, 1fr\); \}/, "launch-slot controls should respond to the narrow side-panel container rather than only the viewport");
27
+ assert.match(css, /\.subagent-launch-slot-controls \{[\s\S]*grid-column: 1 \/ -1/, "model and thinking controls should own the full slot-row width before responsive stacking");
28
+ assert.match(css, /\.sr-only \{[\s\S]*clip-path: inset\(50%\)[\s\S]*white-space: nowrap/, "screen-reader announcements should stay visually hidden without leaving the accessibility tree");
29
+ assert.match(css, /\.subagent-launch-slot-remove \{[^}]*color: var\(--ctp-red\)/, "destructive slot removal should have a textual control and warning color");
30
+ assert.match(server, /"subagent-launch-slot-state\.mjs"/, "the pure browser module should be on the static allowlist");
31
+ assert.match(serviceWorker, /pi-webui-pwa-v44[\s\S]*"\/subagent-launch-slot-state\.mjs"/, "the refreshed PWA cache should include the browser module");
32
+ assert.match(pkg, /node --check public\/subagent-launch-slot-state\.mjs/, "package checks should syntax-check the browser state module");
33
+
34
+ console.log("subagent-launch-slots-static.test.mjs passed");
@@ -0,0 +1,143 @@
1
+ import assert from "node:assert/strict";
2
+ import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import path from "node:path";
5
+ import {
6
+ SUBAGENT_LAUNCH_SLOT_ROLE_CATALOG,
7
+ defaultSubagentLaunchSlotRoles,
8
+ formatSubagentLaunchSlotGuidance,
9
+ normalizeSubagentLaunchSlots,
10
+ resolveSubagentLaunchSlotProjectKey,
11
+ subagentLaunchSlotBaseId,
12
+ subagentLaunchSlotRevision,
13
+ subagentLaunchSlotScopeEntry,
14
+ validateSubagentLaunchSlotRoles,
15
+ } from "../lib/subagent-launch-slots.mjs";
16
+ import { readWebuiSettings, updateWebuiSettings, writeWebuiSettings } from "../lib/git-workflow-preferences.mjs";
17
+
18
+ function clone(value) {
19
+ return JSON.parse(JSON.stringify(value));
20
+ }
21
+
22
+ const defaultRoles = defaultSubagentLaunchSlotRoles();
23
+ assert.deepEqual(Object.keys(defaultRoles), SUBAGENT_LAUNCH_SLOT_ROLE_CATALOG.map((role) => role.id));
24
+ for (const role of SUBAGENT_LAUNCH_SLOT_ROLE_CATALOG) {
25
+ assert.deepEqual(defaultRoles[role.id], [{ id: subagentLaunchSlotBaseId(role.id), model: null, thinking: null }]);
26
+ }
27
+
28
+ const normalized = normalizeSubagentLaunchSlots({
29
+ user: {
30
+ roles: {
31
+ reviewer: [
32
+ { id: "reviewer-extra", model: "fake/reasoning", thinking: "high" },
33
+ { id: "reviewer:base", model: "fake/legacy:high", thinking: "high" },
34
+ { id: "reviewer-extra", model: "fake/reasoning", thinking: "high" },
35
+ { id: "unsafe id", model: "fake/reasoning", thinking: "high" },
36
+ ],
37
+ },
38
+ },
39
+ projects: {
40
+ relative: { roles: { reviewer: [{ id: "reviewer:base", model: "fake/reasoning", thinking: "high" }] } },
41
+ },
42
+ });
43
+ assert.equal(normalized.user.roles.reviewer[0].id, "reviewer:base", "normalization must materialize and order the stable base slot first");
44
+ assert.equal(normalized.user.roles.reviewer[0].model, null, "thinking-suffixed persisted model IDs must reset to inheritance");
45
+ assert.deepEqual(normalized.user.roles.reviewer.slice(1), [{ id: "reviewer-extra", model: "fake/reasoning", thinking: "high" }]);
46
+ assert.deepEqual(normalized.projects, {}, "unsafe project keys must be dropped without changing user defaults");
47
+ const overloadedRoles = defaultSubagentLaunchSlotRoles();
48
+ for (const role of SUBAGENT_LAUNCH_SLOT_ROLE_CATALOG) {
49
+ overloadedRoles[role.id].push(...Array.from({ length: 7 }, (_unused, index) => ({
50
+ id: `${role.id}-extra-${index}`,
51
+ model: null,
52
+ thinking: null,
53
+ })));
54
+ }
55
+ const boundedRoles = normalizeSubagentLaunchSlots({ user: { roles: overloadedRoles } }).user.roles;
56
+ assert.equal(Object.values(boundedRoles).flat().length, 32, "normalization must cap slots globally while retaining all role bases");
57
+ for (const role of SUBAGENT_LAUNCH_SLOT_ROLE_CATALOG) {
58
+ assert.equal(boundedRoles[role.id][0].id, subagentLaunchSlotBaseId(role.id), "global bounds must never displace a role base slot");
59
+ }
60
+
61
+ const availableModels = [
62
+ { provider: "fake", id: "reasoning", reasoning: true, thinkingLevelMap: { xhigh: "xhigh" } },
63
+ { provider: "fake", id: "basic", reasoning: false },
64
+ ];
65
+ const validRoles = clone(defaultRoles);
66
+ validRoles.reviewer[0] = { id: "reviewer:base", model: "fake/reasoning", thinking: "high" };
67
+ validRoles.reviewer.push({ id: "reviewer-extra", model: "fake/basic", thinking: "off" });
68
+ assert.deepEqual(validateSubagentLaunchSlotRoles(validRoles, availableModels).reviewer, validRoles.reviewer);
69
+ assert.throws(() => validateSubagentLaunchSlotRoles({ ...validRoles, unknown: [] }, availableModels), /Unknown subagent role/);
70
+ assert.throws(() => validateSubagentLaunchSlotRoles({ ...validRoles, reviewer: [{ id: "reviewer-extra", model: null, thinking: null }] }, availableModels), /base slot/);
71
+ assert.throws(() => validateSubagentLaunchSlotRoles({ ...validRoles, reviewer: [{ id: "reviewer:base", model: null, thinking: "high" }] }, availableModels), /cannot set thinking/);
72
+ assert.throws(() => validateSubagentLaunchSlotRoles({ ...validRoles, reviewer: [{ id: "reviewer:base", model: "fake/reasoning:high", thinking: "high" }] }, availableModels), /invalid model/);
73
+ assert.throws(() => validateSubagentLaunchSlotRoles({ ...validRoles, reviewer: [{ id: "reviewer:base", model: "fake/basic", thinking: "high" }] }, availableModels), /does not support/);
74
+
75
+ const projectRoot = await mkdtemp(path.join(tmpdir(), "pi-webui-launch-slots-project-"));
76
+ const nested = path.join(projectRoot, "nested", "child");
77
+ const settingsRoot = await mkdtemp(path.join(tmpdir(), "pi-webui-launch-slots-settings-"));
78
+ const settingsFile = path.join(settingsRoot, "settings.json");
79
+ try {
80
+ await mkdir(path.join(projectRoot, ".git"));
81
+ await mkdir(nested, { recursive: true });
82
+ const projectKey = await resolveSubagentLaunchSlotProjectKey(nested);
83
+ assert.equal(projectKey, projectRoot, "nested tab cwd must resolve to the nearest canonical repository root");
84
+ const markerlessProjectKey = await resolveSubagentLaunchSlotProjectKey(settingsRoot);
85
+ assert.equal(markerlessProjectKey, settingsRoot, "a markerless tab cwd must not collapse to the filesystem root");
86
+
87
+ const config = normalizeSubagentLaunchSlots({ user: { roles: validRoles } });
88
+ const inherited = subagentLaunchSlotScopeEntry(config, "project", projectKey);
89
+ assert.equal(inherited.inherited, true);
90
+ assert.deepEqual(inherited.entry.roles.reviewer, validRoles.reviewer);
91
+ const inheritedRevision = subagentLaunchSlotRevision(config, "project", projectKey);
92
+ config.projects[projectKey] = { roles: clone(defaultRoles) };
93
+ const explicit = subagentLaunchSlotScopeEntry(config, "project", projectKey);
94
+ assert.equal(explicit.inherited, false);
95
+ assert.notEqual(subagentLaunchSlotRevision(config, "project", projectKey), inheritedRevision, "project revisions must distinguish inheritance from an explicit project entry");
96
+
97
+ const guidance = formatSubagentLaunchSlotGuidance(inherited.entry.roles);
98
+ assert.match(guidance, /^## WebUI subagent launch slots/m);
99
+ assert.match(guidance, /reviewer slot 1: agent=reviewer model=fake\/reasoning:high/);
100
+ assert.match(guidance, /reviewer slot 2: agent=reviewer model=fake\/basic:off/);
101
+ const mixedGuidanceRoles = clone(defaultRoles);
102
+ mixedGuidanceRoles.reviewer.push({ id: "reviewer-explicit", model: "fake/reasoning", thinking: "high" });
103
+ const mixedGuidance = formatSubagentLaunchSlotGuidance(mixedGuidanceRoles);
104
+ assert.match(mixedGuidance, /reviewer slot 1: agent=reviewer model=<inherit; omit the model field>/, "mixed same-role guidance must retain inherited slots");
105
+ assert.match(mixedGuidance, /reviewer slot 2: agent=reviewer model=fake\/reasoning:high/);
106
+ assert.equal(formatSubagentLaunchSlotGuidance(defaultRoles), "", "guidance should be omitted when every slot inherits");
107
+
108
+ await writeFile(settingsFile, `${JSON.stringify({ version: 4, unrelated: { preserve: true }, remoteAuthEnabled: true }, null, 2)}\n`, "utf8");
109
+ await writeWebuiSettings({ subagentLaunchSlots: config }, settingsFile);
110
+ const persisted = JSON.parse(await readFile(settingsFile, "utf8"));
111
+ assert.equal(persisted.version, 5, "persisted launch-slot settings must use the version-5 envelope");
112
+ assert.deepEqual(persisted.unrelated, { preserve: true }, "launch-slot saves must preserve unrelated WebUI settings");
113
+ assert.deepEqual((await readWebuiSettings(settingsFile)).subagentLaunchSlots.projects[projectKey].roles, defaultRoles);
114
+
115
+ let releaseFirstUpdate;
116
+ let markFirstUpdateStarted;
117
+ const firstUpdateStarted = new Promise((resolve) => { markFirstUpdateStarted = resolve; });
118
+ const holdFirstUpdate = new Promise((resolve) => { releaseFirstUpdate = resolve; });
119
+ const firstUpdate = updateWebuiSettings(async () => {
120
+ markFirstUpdateStarted();
121
+ await holdFirstUpdate;
122
+ return { remoteAuthEnabled: false };
123
+ }, settingsFile);
124
+ await firstUpdateStarted;
125
+ let secondUpdateEntered = false;
126
+ const secondUpdate = updateWebuiSettings((current) => {
127
+ secondUpdateEntered = true;
128
+ assert.equal(current.remoteAuthEnabled, false, "serialized settings updates must observe the preceding completed write");
129
+ return { outputModeDefault: "compact-v1" };
130
+ }, settingsFile);
131
+ await new Promise((resolve) => setImmediate(resolve));
132
+ assert.equal(secondUpdateEntered, false, "same-file settings updates must not interleave between revision read and atomic write");
133
+ releaseFirstUpdate();
134
+ await Promise.all([firstUpdate, secondUpdate]);
135
+ const serialized = await readWebuiSettings(settingsFile);
136
+ assert.equal(serialized.remoteAuthEnabled, false);
137
+ assert.equal(serialized.outputModeDefault, "compact-v1");
138
+
139
+ console.log("subagent-launch-slots.test.mjs passed");
140
+ } finally {
141
+ await rm(projectRoot, { recursive: true, force: true });
142
+ await rm(settingsRoot, { recursive: true, force: true });
143
+ }
@@ -3,6 +3,7 @@ import { mkdtemp, rm, writeFile } from "node:fs/promises";
3
3
  import { tmpdir } from "node:os";
4
4
  import path from "node:path";
5
5
  import webuiRpcHelper from "../webui-rpc-helper.mjs";
6
+ import { defaultSubagentLaunchSlotRoles } from "../lib/subagent-launch-slots.mjs";
6
7
 
7
8
  class EventBus {
8
9
  constructor() {
@@ -50,6 +51,14 @@ const ctx = {
50
51
  sessionManager: {
51
52
  getBranch() { return []; },
52
53
  },
54
+ getSystemPromptOptions() {
55
+ return {
56
+ skills: [
57
+ { name: "repo-explorer", description: "Inspect repository context", filePath: "/tmp/repo-explorer/SKILL.md" },
58
+ { name: "code-security", description: "Review code security", filePath: "/tmp/code-security/SKILL.md" },
59
+ ],
60
+ };
61
+ },
53
62
  ui: {
54
63
  setStatus(key, text) {
55
64
  statuses.push({ key, text });
@@ -61,6 +70,15 @@ const ctx = {
61
70
  };
62
71
 
63
72
  const asyncRunDir = await mkdtemp(path.join(tmpdir(), "pi-webui-subagent-output-test-"));
73
+ const settingsFile = path.join(asyncRunDir, "webui-settings.json");
74
+ const initialLaunchRoles = defaultSubagentLaunchSlotRoles();
75
+ initialLaunchRoles.reviewer[0] = { id: "reviewer:base", model: "fake/reviewer", thinking: "high" };
76
+ await writeFile(settingsFile, `${JSON.stringify({
77
+ version: 5,
78
+ resourceDefaults: { tools: { enabledTools: null }, skills: { enabledSkills: ["repo-explorer"] } },
79
+ subagentLaunchSlots: { version: 1, user: { roles: initialLaunchRoles }, projects: {} },
80
+ }, null, 2)}\n`);
81
+ process.env.PI_WEBUI_SETTINGS_FILE = settingsFile;
64
82
  const asyncSessionFile = path.join(asyncRunDir, "reviewer-session.jsonl");
65
83
  await writeFile(asyncSessionFile, [
66
84
  JSON.stringify({ type: "message", timestamp: "2026-07-19T12:00:00.000Z", message: { role: "assistant", content: [{ type: "thinking", thinking: "Checking structured transcript extraction" }, { type: "text", text: "REVIEWER STREAM 1 OF 18" }, { type: "toolCall", id: "review-call", name: "bash", arguments: { command: "sleep 5" } }, { type: "text", text: "Review complete." }] } }),
@@ -76,19 +94,19 @@ await writeFile(asyncStatusFile, JSON.stringify({
76
94
  lastUpdate: Date.now(),
77
95
  steps: [
78
96
  { agent: "reviewer", status: "running", sessionFile: asyncSessionFile, recentOutput: [], currentTool: "bash", currentToolArgs: "sleep 5", model: "anthropic/claude-opus-4-8:high", thinking: "high" },
79
- { agent: "scout", status: "running", model: "openai-codex/gpt-5.6-sol", thinking: "high" },
97
+ { agent: "reviewer", status: "running", model: "openai-codex/gpt-5.6-sol", thinking: "high" },
80
98
  ],
81
99
  }));
82
100
 
83
101
  const statusText = `Active async runs: 2
84
102
 
85
- - run-a | running | active | parallel | 2/2 running | ~/repo
86
- 1. reviewer | running | tool read
87
- 2. scout | running | tool grep
103
+ - run-a | running | active | parallel [fresh] | 2/2 running | ~/repo
104
+ 1. reviewer [fresh] | running | tool read
105
+ 2. reviewer [fresh] | running | tool grep
88
106
 
89
- - run-b | running | active | chain | step 2/2 | ~/repo
90
- 1. planner | completed
91
- 2. [Implementation] Apply fixes (worker) | running | tool edit
107
+ - run-b | running | active | chain [mixed] | step 2/2 | ~/repo
108
+ 1. planner [fresh] | completed
109
+ 2. [Implementation] Apply fixes (worker) [fork] | running | tool edit
92
110
  ↳ nested-oracle [nested-1] running | tool grep`;
93
111
 
94
112
  webuiRpcHelper(pi);
@@ -106,6 +124,33 @@ const unsubscribeRpc = bus.on("subagents:rpc:v1:request", (request) => {
106
124
  });
107
125
 
108
126
  for (const handler of extensionHandlers.get("session_start") || []) await handler({ reason: "startup" }, ctx);
127
+ const beforeAgentStart = (extensionHandlers.get("before_agent_start") || [])[0];
128
+ assert.ok(beforeAgentStart, "helper should register before_agent_start guidance");
129
+ const promptWithSkills = [
130
+ "Base system prompt.",
131
+ "The following skills provide specialized capabilities:",
132
+ "<available_skills>",
133
+ " <skill>",
134
+ " <name>repo-explorer</name>",
135
+ " </skill>",
136
+ " <skill>",
137
+ " <name>code-security</name>",
138
+ " </skill>",
139
+ "</available_skills>",
140
+ ].join("\n");
141
+ const initialGuidance = await beforeAgentStart({ systemPrompt: promptWithSkills, systemPromptOptions: ctx.getSystemPromptOptions() });
142
+ assert.match(initialGuidance?.systemPrompt || "", /reviewer slot 1: agent=reviewer model=fake\/reviewer:high/, "session_start should cache effective launch-slot guidance");
143
+ assert.doesNotMatch(initialGuidance?.systemPrompt || "", /code-security/, "launch-slot guidance must compose with disabled-skill filtering");
144
+ const changedLaunchRoles = defaultSubagentLaunchSlotRoles();
145
+ changedLaunchRoles.reviewer[0] = { id: "reviewer:base", model: "fake/changed", thinking: "high" };
146
+ await writeFile(settingsFile, `${JSON.stringify({
147
+ version: 5,
148
+ resourceDefaults: { tools: { enabledTools: null }, skills: { enabledSkills: ["repo-explorer"] } },
149
+ subagentLaunchSlots: { version: 1, user: { roles: changedLaunchRoles }, projects: {} },
150
+ }, null, 2)}\n`);
151
+ const cachedGuidance = await beforeAgentStart({ systemPrompt: "Base system prompt.", systemPromptOptions: ctx.getSystemPromptOptions() });
152
+ assert.match(cachedGuidance?.systemPrompt || "", /fake\/reviewer:high/, "a settings save must not mutate the active helper snapshot");
153
+ assert.doesNotMatch(cachedGuidance?.systemPrompt || "", /fake\/changed:high/);
109
154
  for (let attempt = 0; attempt < 20 && !statuses.some((entry) => entry.text?.startsWith("PI_WEBUI_SUBAGENTS_V1 ") && entry.text.includes("run-a")); attempt++) {
110
155
  await new Promise((resolve) => setTimeout(resolve, 10));
111
156
  }
@@ -120,7 +165,8 @@ function latestPayload() {
120
165
  let payload = latestPayload();
121
166
  assert.equal(payload.available, true, "successful pi-subagents RPC should mark status available");
122
167
  assert.deepEqual(payload.runs.map((run) => run.id), ["run-a", "run-b"]);
123
- assert.deepEqual(payload.runs[0].agents.map((agent) => [agent.name, agent.currentTool]), [["reviewer", "read"], ["scout", "grep"]]);
168
+ assert.deepEqual(payload.runs.map((run) => run.mode), ["parallel", "chain"], "async overview should ignore fleet context badges when parsing run modes");
169
+ assert.deepEqual(payload.runs[0].agents.map((agent) => [agent.name, agent.currentTool]), [["reviewer", "read"], ["reviewer", "grep"]], "async overview should ignore fleet context badges while preserving same-role child indexes");
124
170
  assert.deepEqual(payload.runs[0].agents.map((agent) => [agent.model, agent.thinking]), [["anthropic/claude-opus-4-8:high", "high"], ["openai-codex/gpt-5.6-sol", "high"]], "async overview should publish effective lifecycle model and reasoning metadata");
125
171
  assert.deepEqual(payload.runs[1].agents.map((agent) => [agent.name, agent.nested]), [["worker", false], ["nested-oracle", true]]);
126
172
 
@@ -315,6 +361,7 @@ assert.equal(payload.runs.some((run) => run.source === "foreground"), false, "fo
315
361
 
316
362
  for (const handler of extensionHandlers.get("session_shutdown") || []) await handler({ reason: "quit" }, ctx);
317
363
  unsubscribeRpc();
364
+ delete process.env.PI_WEBUI_SETTINGS_FILE;
318
365
  await rm(asyncRunDir, { recursive: true, force: true });
319
366
 
320
367
  console.log("subagents-helper.test.mjs passed");