@firstpick/pi-package-webui 0.7.4 → 0.7.5

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.
@@ -0,0 +1,59 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFile } from "node:fs/promises";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
7
+ const app = await readFile(join(root, "public", "app.js"), "utf8");
8
+
9
+ function findFunctionBody(source, name) {
10
+ const signature = new RegExp(`function\\s+${name}\\s*\\(`, "m");
11
+ const match = signature.exec(source);
12
+ assert.ok(match, `${name} should be defined`);
13
+ let parenDepth = 0;
14
+ let openBrace = -1;
15
+ for (let index = match.index + match[0].length - 1; index < source.length; index += 1) {
16
+ const char = source[index];
17
+ if (char === "(") parenDepth += 1;
18
+ else if (char === ")") parenDepth -= 1;
19
+ else if (char === "{" && parenDepth === 0) {
20
+ openBrace = index;
21
+ break;
22
+ }
23
+ }
24
+ assert.notEqual(openBrace, -1, `${name} body should open`);
25
+ let depth = 0;
26
+ for (let index = openBrace; index < source.length; index += 1) {
27
+ const char = source[index];
28
+ if (char === "{") depth += 1;
29
+ else if (char === "}") {
30
+ depth -= 1;
31
+ if (depth === 0) return source.slice(openBrace + 1, index);
32
+ }
33
+ }
34
+ assert.fail(`${name} body should close`);
35
+ }
36
+
37
+ const touchStart = findFunctionBody(app, "noteChatTouchStart");
38
+ const awayIntent = findFunctionBody(app, "isChatScrollAwayIntent");
39
+ const noteIntent = findFunctionBody(app, "noteChatUserScrollIntent");
40
+ const syncAutoFollow = findFunctionBody(app, "syncAutoFollowFromChatScroll");
41
+ const updateLatest = findFunctionBody(app, "updateJumpToLatestButton");
42
+ const applyFollow = findFunctionBody(app, "applyChatFollowScroll");
43
+ const resumeFollow = findFunctionBody(app, "resumeChatAutoFollow");
44
+ const forceFollow = findFunctionBody(app, "scrollChatToBottom");
45
+
46
+ assert.match(awayIntent, /event\?\.type === "wheel"[\s\S]*event\.deltaY < 0/, "wheel-up should be recognized as intent to read earlier output");
47
+ assert.match(touchStart, /touches\?\.\[0\]\?\.clientY[\s\S]*chatLastTouchClientY/, "touch scrolling should capture its starting direction");
48
+ assert.match(awayIntent, /event\?\.type === "touchmove"[\s\S]*clientY > chatLastTouchClientY[\s\S]*return scrollAway/, "downward finger movement should pause follow while upward movement can resume at Latest");
49
+ assert.match(awayIntent, /"ArrowUp"[\s\S]*"Home"[\s\S]*"PageUp"/, "upward keyboard navigation should pause streaming follow");
50
+ assert.match(noteIntent, /autoFollowChat = false;[\s\S]*updateJumpToLatestButton\(\)/, "upward intent should pause follow and reveal Latest before the scroll event fires");
51
+ assert.match(syncAutoFollow, /^\s*const nearBottom[\s\S]*if \(isChatUserScrollAwayIntentActive\(\)\) \{\s*autoFollowChat = false;/, "the near-bottom threshold must not re-enable follow during active upward input");
52
+ assert.match(updateLatest, /hidden = autoFollowChat/, "Latest visibility should reflect paused follow even while still inside the near-bottom threshold");
53
+ assert.doesNotMatch(updateLatest, /isChatNearBottom/, "Latest must not remain hidden solely because the first upward movement is near the bottom");
54
+ assert.match(applyFollow, /if \(!autoFollowChat\)[\s\S]*return;/, "already queued streaming frames must honor the immediate follow pause");
55
+ assert.match(resumeFollow, /chatUserScrollAwayIntentUntil = 0;[\s\S]*autoFollowChat = true;/, "explicit resume should clear stale upward intent before following again");
56
+ assert.match(forceFollow, /if \(force\) resumeChatAutoFollow\(\)/, "Latest and other forced-bottom actions should use the explicit resume path");
57
+ assert.match(app, /addEventListener\("touchstart", noteChatTouchStart[\s\S]*addEventListener\("touchend", clearChatTouchIntent[\s\S]*addEventListener\("touchcancel", clearChatTouchIntent/, "touch direction tracking should be initialized and cleared for each gesture");
58
+
59
+ console.log("chat-scroll-intent-static.test.mjs passed");
@@ -0,0 +1,15 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFile } from "node:fs/promises";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
7
+ const app = await readFile(join(root, "public", "app.js"), "utf8");
8
+
9
+ assert.match(
10
+ app,
11
+ /renderContent\(body, message\.content, \{ markdown: message\.role === "assistant" \|\| message\.role === "custom" \}\)/,
12
+ "assistant and custom message output should render as Markdown",
13
+ );
14
+
15
+ console.log("custom message Markdown static check passed");
@@ -43,7 +43,23 @@ function functionBody(source, name) {
43
43
  const connectEvents = functionBody(app, "connectEvents");
44
44
  const compactUpdate = functionBody(app, "handleCompactMessageUpdate");
45
45
  const compactFlush = functionBody(app, "flushCompactLiveOutput");
46
+ const compactThinkingBubble = functionBody(app, "ensureCompactThinkingBubble");
46
47
  const compactToolShell = functionBody(app, "renderCompactToolShell");
48
+ const clearCompactToolShells = functionBody(app, "clearCompactToolShells");
49
+ const compactTranscript = functionBody(app, "renderCompactTranscriptBody");
50
+ const compactThinkingDisclosureExpanded = functionBody(app, "compactThinkingDisclosureExpanded");
51
+ const setCompactThinkingDisclosureExpanded = functionBody(app, "setCompactThinkingDisclosureExpanded");
52
+ const clearCompactThinkingDisclosureState = functionBody(app, "clearCompactThinkingDisclosureState");
53
+ const createMessageBubble = functionBody(app, "createMessageBubble");
54
+ const appendTranscriptMessage = functionBody(app, "appendTranscriptMessage");
55
+ const compactThinkingSegments = functionBody(app, "compactThinkingSegments");
56
+ const compactStoredTranscriptItems = functionBody(app, "compactStoredTranscriptItems");
57
+ const orderedTranscriptItems = functionBody(app, "orderedTranscriptItems");
58
+ const transcriptRenderEpoch = functionBody(app, "transcriptRenderEpoch");
59
+ const compactLiveStreamActive = functionBody(app, "compactLiveStreamRenderActive");
60
+ const restoreCompactStream = functionBody(app, "restoreCompactLiveOutputAfterChatRebuild");
61
+ const refreshMessages = functionBody(app, "refreshMessages");
62
+ const resetCompactLiveOutput = functionBody(app, "resetCompactLiveOutput");
47
63
  const resetStream = functionBody(app, "resetStreamBubble");
48
64
  const normalToCompact = functionBody(app, "transitionNormalLiveOutputToCompact");
49
65
  const compactToNormal = functionBody(app, "transitionCompactLiveOutputToNormal");
@@ -68,20 +84,50 @@ assert.doesNotMatch(compactUpdate, /event\.message|assistantMessageEvent\.partia
68
84
  assert.match(compactUpdate, /reduceFastOutputLiveEvent\(compactLiveState, event\)/, "compact deltas should use the pure reducer");
69
85
  assert.match(compactUpdate, /shouldConsumeFastOutputLiveEvent\(reduced\)/, "recognized compact empty end variants should be consumed instead of reaching normal handlers with stripped snapshots");
70
86
  assert.match(helper, /function shouldConsumeFastOutputLiveEvent\(reduction = \{\}\)[\s\S]*?"text-end"[\s\S]*?"thinking-end"[\s\S]*?"toolcall-end"/, "the reducer policy should consume only recognized compact end variants when no DOM state changes");
71
- assert.match(compactFlush, /\.textContent = compactLiveState\.text/, "compact text must render through a stable plain-text node");
72
- assert.match(compactFlush, /\.textContent = compactLiveState\.thinking/, "compact thinking must render through a stable plain-text node");
73
- assert.doesNotMatch(compactFlush, /renderStreamingMarkdown|renderThinkingMarkdown|renderToolExecution|normalizeToolExecution/, "compact flushing must not invoke live rich renderers");
87
+ assert.match(compactFlush, /\.textContent = compactLiveState\.text/, "compact assistant text must render through a stable plain-text node while streaming");
88
+ assert.match(compactThinkingBubble, /title: "thinking \(live\)"[\s\S]*?compactThinkingAggregate: true[\s\S]*?compactThinkingKey: "live"[\s\S]*?compactThinkingDefaultExpanded: true[\s\S]*?make\("div", "markdown-body thinking-text compact-live-thinking"\)/, "compact live thinking should use one expanded-by-default aggregate disclosure with a stable key and established Markdown styles");
89
+ assert.match(resetCompactLiveOutput, /clearCompactThinkingDisclosureState\("live"\)/, "a new compact stream should clear any explicit live override and restore its expanded default");
90
+ assert.match(compactFlush, /compactThinkingNode\?\._rawThinkingText !== compactLiveState\.thinking[\s\S]*?renderThinkingMarkdown\(compactThinkingNode, compactLiveState\.thinking\)/, "compact live thinking should preserve Markdown formatting");
91
+ assert.doesNotMatch(compactFlush, /compactThinkingNode\.textContent|renderStreamingMarkdown|renderToolExecution|normalizeToolExecution/, "compact thinking must not fall back to plain text or invoke rich tool renderers");
74
92
  assert.doesNotMatch(compactToolShell, /normalizeToolExecution|toolExecutionRenderSignature|renderToolExecution|handleToolExecutionUpdate|JSON\.stringify/, "compact tool shells must defer rich bodies and raw serialization");
75
93
  assert.match(app, /case "tool_execution_update":\s+if \(!compactOutputActive\(\)\) handleToolExecutionUpdate\(event\);/, "compact mode should not build intermediate rich tool updates");
76
94
  assert.match(app, /case "tool_execution_end":[\s\S]*?compactLiveScheduler\.flushNow\(\)[\s\S]*?renderCompactToolShell\(event, \{ complete: true \}\)[\s\S]*?finishCompactLiveOutput\(tabContext\)/, "compact tool completion should remain lightweight and request final reconciliation");
77
95
  assert.match(resetStream, /resetCompactLiveOutput\(\)/, "reset and tab changes should cancel compact pending work");
78
96
  assert.match(app, /case "message_end": \{\s+if \(compactOutputActive\(\)\) finishCompactLiveOutput\(tabContext\);/, "message ends should synchronously flush compact output before reconciliation");
79
97
  assert.match(app, /case "agent_end":\s+if \(compactOutputActive\(\)\) finishCompactLiveOutput\(tabContext\);/, "agent ends should synchronously flush compact output before reconciliation");
98
+ assert.match(compactTranscript, /message\.role !== "assistant"[\s\S]*?appendMarkdown\(body, output \|\| "_\[non-text output omitted in fast mode\]_"\)[\s\S]*?classList\.add\("compact-transcript-text"\)/, "reconciled fast-mode assistant output should preserve Markdown and explain omitted non-text output");
99
+ assert.doesNotMatch(compactTranscript, /appendText|renderToolExecution|normalizeToolExecution|JSON\.stringify|appendToolOutput|appendToolDiff|appendToolImages/, "fast-mode final output must not fall back to plain text or render tool details");
100
+ assert.match(createMessageBubble, /compactOutputActive\(\) && !streaming[\s\S]*?renderCompactTranscriptBody\(body, message\)/, "final transcript rendering should select the compact Markdown path only for acknowledged fast mode");
101
+ assert.match(appendTranscriptMessage, /compactTranscript && transcriptMessage\.role !== "assistant"/, "fast-mode assistant reconciliation should defer all thinking to the aggregate transcript item and retain only final output");
102
+ assert.match(compactThinkingSegments, /!thinkingOutputVisible\) return \[\][\s\S]*?message\?\.role === "thinking"[\s\S]*?assistantDisplayMessages\(message\)[\s\S]*?displayMessage\.role === "thinking"/, "fast mode should collect direct and embedded assistant thinking segments only when thinking output is enabled");
103
+ assert.match(compactStoredTranscriptItems, /pendingThinking\.segments\.join\("\\n\\n"\)[\s\S]*?compactThinkingAggregate: true[\s\S]*?pendingThinking\.segments\.push\(\.\.\.thinkingSegments\)/, "thinking separated by tool calls should reconcile into one aggregate Markdown payload");
104
+ assert.match(compactStoredTranscriptItems, /message\?\.role === "user"\) flushThinking\(\)[\s\S]*?message\?\.role === "assistant"\) flushThinking\(\)/, "aggregate thinking should stay bounded to one user turn and end before its final assistant output");
105
+ assert.match(createMessageBubble, /compactThinkingAggregate = compactOutputActive\(\)[\s\S]*?message\.compactThinkingAggregate === true[\s\S]*?isCollapsibleOutput = compactThinkingAggregate[\s\S]*?defaultExpanded = message\.compactThinkingDefaultExpanded === true[\s\S]*?details\.open = compactThinkingDisclosureExpanded\(message\.compactThinkingKey, defaultExpanded\)[\s\S]*?setCompactThinkingDisclosureExpanded\(message\.compactThinkingKey, details\.open, defaultExpanded\)[\s\S]*?else if \(shouldOpenMessageCollapseByDefault/, "aggregate thinking should use a native disclosure with role-specific defaults and preserve explicit toggles across reconciliation");
106
+ assert.match(compactThinkingDisclosureExpanded, /compactThinkingDisclosureStateByTab\.get\(activeTabId \|\| "default"\)[\s\S]*?disclosureState\?\.has\(key\)[\s\S]*?!!defaultExpanded/, "aggregate disclosure state should be isolated per terminal tab and fall back to the role-specific default");
107
+ assert.match(setCompactThinkingDisclosureExpanded, /expanded === defaultExpanded[\s\S]*?disclosureState\?\.delete\(key\)[\s\S]*?disclosureState = new Map\(\)[\s\S]*?disclosureState\.set\(key, !!expanded\)/, "aggregate disclosure state should store only explicit overrides from the role-specific default");
108
+ assert.match(clearCompactThinkingDisclosureState, /disclosureState\?\.delete\(key\)[\s\S]*?compactThinkingDisclosureStateByTab\.delete\(tabId\)/, "stream resets should remove a live disclosure override without changing its expanded default");
109
+ assert.match(compactStoredTranscriptItems, /compactThinkingKey: `turn:\$\{pendingThinking\.firstIndex\}`[\s\S]*?transcriptKey: `compact-thinking:\$\{pendingThinking\.firstIndex\}`/, "aggregate thinking should use a turn-stable disclosure and transcript key while later segments arrive");
110
+ assert.match(app, /workflowOverlayMinimizedByTab\.delete\(tabId\)[\s\S]*?compactThinkingDisclosureStateByTab\.delete\(tabId\)/, "closing a terminal tab should discard its aggregate thinking disclosure state");
111
+ assert.match(styles, /\.message\.compact-thinking-aggregate \{[\s\S]*?\.compact-thinking-disclosure[\s\S]*?border-top-color/, "aggregate thinking should render as one compact mauve disclosure box");
112
+ assert.match(orderedTranscriptItems, /compactOutputActive\(\) \? compactStoredTranscriptItems\(\) : \[\]/, "stored fast-mode transcript rows should come from the aggregate thinking projection");
113
+ assert.match(orderedTranscriptItems, /if \(!compactOutputActive\(\)\) latestMessages\.forEach/, "normal mode should retain the unchanged stored-message projection");
114
+ assert.match(orderedTranscriptItems, /if \(!compactOutputActive\(\)\) \{[\s\S]*?liveToolRuns\.entries\(\)/, "live tool-run reconciliation should not retain additional fast-mode tool rows");
115
+ assert.match(transcriptRenderEpoch, /compactOutputActive\(\) \? "compact" : "normal"/, "mode changes should invalidate the keyed transcript renderer");
116
+ assert.match(clearCompactToolShells, /removeCompactLiveBubble\(shell\?\.bubble\)[\s\S]*?compactToolShells\.clear\(\)/, "fast mode should remove previous transient tool shells from the DOM and registry");
117
+ assert.match(compactToolShell, /if \(!shell\) \{\s+clearCompactToolShells\(\)/, "a newly-started tool should replace the previous transient tool shell");
118
+ assert.match(compactToolShell, /shell\.status\.textContent = complete[\s\S]*?event\?\.isError \? "failed" : "done"[\s\S]*?: "running"/, "the current transient tool shell should expose only a non-duplicated status");
119
+ assert.match(styles, /\.message\.compact-tool-shell\s*\{[\s\S]*?display: grid[\s\S]*?grid-template-columns:[\s\S]*?padding: 0\.46rem 0\.62rem[\s\S]*?box-shadow: none/, "fast-mode tool activity should render as a compact horizontal row");
120
+ assert.match(styles, /\.compact-tool-shell \.compact-tool-status\s*\{[\s\S]*?display: inline-flex[\s\S]*?border-radius: 999px[\s\S]*?font-size: 0\.7rem[\s\S]*?text-transform: uppercase/, "the minimal tool status should remain visually distinct as a small pill");
121
+ assert.match(styles, /\.compact-tool-shell\.tool-running \.compact-tool-status[\s\S]*?\.compact-tool-shell\.tool-success \.compact-tool-status[\s\S]*?\.compact-tool-shell\.tool-error \.compact-tool-status/, "running, success, and failure tool states should have distinct visual tones");
122
+ assert.match(compactUpdate, /compactLiveState = reduced\.state;\s+clearCompactToolShells\(\)/, "new assistant or tool-call deltas should clear the preceding transient tool shell");
123
+ assert.match(compactLiveStreamActive, /messageOutputActive = streamMessageActive && Boolean\([\s\S]*?compactLiveState\.text[\s\S]*?compactLiveState\.thinking[\s\S]*?compactOutputActive\(\) && currentState\?\.isStreaming === true && Boolean\(compactToolShells\.size \|\| messageOutputActive\)/, "mid-stream reconciliation should preserve active compact message output or a current tool shell, but not completed final text");
124
+ assert.match(restoreCompactStream, /compactTextBubble = null[\s\S]*?compactThinkingBubble = null[\s\S]*?if \(streamMessageActive\) flushCompactLiveOutput\(\)[\s\S]*?compactToolShells\.values\(\)[\s\S]*?appendChatMessageBubble\(shell\.bubble\)/, "compact message state should be restored only while its message is active, while the current shell can survive between messages");
125
+ assert.match(refreshMessages, /preserveCompactStream = compactLiveStreamRenderActive\(\)[\s\S]*?!preserveCompactStream && !preserveNormalStream[\s\S]*?renderMessages\(latestMessages\)[\s\S]*?preserveCompactStream\) restoreCompactLiveOutputAfterChatRebuild\(\)/, "message refreshes must not reset active compact output before rebuilding the transcript");
80
126
 
81
127
  assert.match(app, /const SETTINGS_OUTPUT_MODE_OPTIONS = \[[\s\S]*?value: "normal"[\s\S]*?value: "compact-v1"/, "settings should offer normal and compact-v1 server defaults");
82
128
  assert.match(nativeSettingsDialog, /api\("\/api\/webui-output-mode", \{ scoped: false \}\)/, "opening settings should load output-mode metadata from the separate server API");
83
129
  assert.match(nativeSettingsDialog, /outputMode: nativeSettingSelect\("Output processing", outputModeMetadata\.persistedDefault, SETTINGS_OUTPUT_MODE_OPTIONS,[\s\S]*?\{ label: "server", tone: "startup" \}\)/, "Browser workflow should expose a server-badged output-processing selector");
84
- assert.match(nativeSettingsDialog, /Compact reduces local output-processing and live fidelity, restores rich final output, and does not change model inference or token generation\. Changes use server barriers without restarting Pi\./, "settings copy should bound compact mode to local output processing and preserve inference semantics");
130
+ assert.match(nativeSettingsDialog, /Fast mode preserves Markdown final output, keeps live thinking expanded, groups stored thinking in one collapsed disclosure per turn, shows only the current tool status transiently, and does not change model inference or token generation\. Changes use server barriers without restarting Pi\./, "settings copy should distinguish expanded live thinking from collapsed stored thinking without changing inference semantics");
85
131
  assert.match(nativeSettingsDialog, /nativeSettingsSection\("Browser workflow"[\s\S]*?controls\.outputMode/, "the output-mode selector should be placed in Browser workflow");
86
132
  assert.match(outputModeMetadataText, /Persisted default:[\s\S]*?Effective mode:[\s\S]*?Source:/, "settings should display persisted default plus effective mode and source");
87
133
  assert.match(outputModeMetadataText, /metadata\.overridden[\s\S]*?overrides the persisted setting/, "settings should display CLI/environment override state when it wins");
@@ -103,8 +149,10 @@ assert.match(app, /fastOutputModeSelect\?\.addEventListener\("change", \(\) => \
103
149
  assert.match(app, /refreshSidebarOutputMode\(\)\.catch[\s\S]*?initializeTabs\(\)/, "sidebar output mode should initialize with the WebUI");
104
150
 
105
151
  assert.match(helper, /FAST_OUTPUT_FLUSH_INTERVAL_MS = 100/, "the live scheduler should retain the exact 100 ms sustained-output bound");
106
- assert.match(worker, /pi-webui-pwa-v35[\s\S]*?"\/fast-output-live\.mjs"/, "PWA cache identity and app shell should include the compact helper");
107
- assert.match(html, /<script type="module" src="\/app\.js\?v=82"><\/script>/, "the PWA entry point should cache-bust browser wiring");
152
+ assert.match(worker, /pi-webui-pwa-v44[\s\S]*?"\/fast-output-live\.mjs"/, "PWA cache identity and app shell should include the compact helper");
153
+ assert.match(html, /<label for="fastOutputModeSelect">Fast mode \(Experimental\)<\/label>/, "the sidebar should mark fast mode as experimental");
154
+ assert.match(html, /Markdown final output; live thinking expanded; stored thinking grouped and collapsed/, "the sidebar should distinguish live and stored thinking defaults");
155
+ assert.match(html, /<script type="module" src="\/app\.js\?v=91"><\/script>/, "the PWA entry point should cache-bust browser wiring");
108
156
  assert.match(JSON.parse(packageRaw).scripts.check, /node --check public\/fast-output-live\.mjs/, "package checks should parse the compact helper");
109
157
 
110
158
  const events = createFastModeOutputEvents();
@@ -111,8 +111,8 @@ assert.match(
111
111
  );
112
112
  assert.match(
113
113
  css,
114
- /\.middle-truncate-start \{[\s\S]*?min-width:\s*6ch;[\s\S]*?text-overflow:\s*ellipsis[\s\S]*?\.middle-truncate-end \{[\s\S]*?flex:\s*0 0 auto/,
115
- "responsive styling should shrink the prefix while keeping the suffix fixed",
114
+ /\.middle-truncate-start \{[\s\S]*?flex:\s*0 1 auto;[\s\S]*?min-width:\s*6ch;[\s\S]*?text-overflow:\s*ellipsis[\s\S]*?\.middle-truncate-end \{[\s\S]*?flex:\s*0 0 auto/,
115
+ "responsive styling should keep split path parts contiguous until the prefix must shrink, then preserve the suffix",
116
116
  );
117
117
 
118
118
  console.log("footer-middle-truncation.test.mjs passed");
@@ -314,6 +314,65 @@ try {
314
314
  const tabId = tabList[0].id;
315
315
  assert.ok(tabId, "tab should have an id");
316
316
 
317
+ const initialUserLaunchSlots = await request("127.0.0.1", `/api/subagents/config?tab=${encodeURIComponent(tabId)}&scope=user`);
318
+ assert.equal(initialUserLaunchSlots.status, 200, `user launch-slot config should load: ${initialUserLaunchSlots.body?.error || ""}`);
319
+ assert.equal(initialUserLaunchSlots.body?.data?.reloadRequired, false);
320
+ assert.equal(initialUserLaunchSlots.body?.data?.roleMetadata?.length, 8, "launch-slot config should expose the documented builtin role metadata");
321
+ assert.deepEqual(initialUserLaunchSlots.body?.data?.roles?.reviewer, [{ id: "reviewer:base", model: null, thinking: null }], "launch-slot defaults should materialize a stable base slot");
322
+ assert.deepEqual(initialUserLaunchSlots.body?.data?.modelThinkingLevels?.["fake/fake-model"], ["off"], "the active tab model registry should drive supported thinking choices");
323
+
324
+ const userLaunchDraft = JSON.parse(JSON.stringify(initialUserLaunchSlots.body.data.roles));
325
+ userLaunchDraft.reviewer[0] = { id: "reviewer:base", model: "fake/fake-model", thinking: "off" };
326
+ userLaunchDraft.reviewer.push({ id: "reviewer-secondary", model: "fake/fake-model", thinking: "off" });
327
+ const savedUserLaunchSlots = await request("127.0.0.1", "/api/subagents/config", {
328
+ method: "POST",
329
+ body: { tab: tabId, scope: "user", revision: initialUserLaunchSlots.body.data.revision, roles: userLaunchDraft },
330
+ });
331
+ assert.equal(savedUserLaunchSlots.status, 200, `user launch-slot config should save: ${savedUserLaunchSlots.body?.error || ""}`);
332
+ assert.equal(savedUserLaunchSlots.body?.data?.saved, true);
333
+ assert.equal(savedUserLaunchSlots.body?.data?.changed, true);
334
+ assert.equal(savedUserLaunchSlots.body?.data?.reloadRequired, true, "a changed save must require active-tab reload before helper guidance changes");
335
+ assert.deepEqual(savedUserLaunchSlots.body?.data?.roles?.reviewer, userLaunchDraft.reviewer, "same-role launch slots must retain independent explicit model specs");
336
+ const persistedLaunchSlots = JSON.parse(await readFile(settingsFile, "utf8"));
337
+ assert.equal(persistedLaunchSlots.version, 5, "launch-slot persistence should upgrade the private WebUI settings envelope");
338
+ assert.deepEqual(persistedLaunchSlots.subagentLaunchSlots?.user?.roles?.reviewer, userLaunchDraft.reviewer);
339
+
340
+ const inheritedProjectLaunchSlots = await request("127.0.0.1", `/api/subagents/config?tab=${encodeURIComponent(tabId)}&scope=project`);
341
+ assert.equal(inheritedProjectLaunchSlots.status, 200);
342
+ assert.equal(inheritedProjectLaunchSlots.body?.data?.inherited, true, "project scope must inherit user launch slots until customized");
343
+ assert.deepEqual(inheritedProjectLaunchSlots.body?.data?.roles?.reviewer, userLaunchDraft.reviewer);
344
+ const projectLaunchDraft = JSON.parse(JSON.stringify(inheritedProjectLaunchSlots.body.data.roles));
345
+ projectLaunchDraft.reviewer[0] = { id: "reviewer:base", model: null, thinking: null };
346
+ const savedProjectLaunchSlots = await request("127.0.0.1", "/api/subagents/config", {
347
+ method: "POST",
348
+ body: { tab: tabId, scope: "project", revision: inheritedProjectLaunchSlots.body.data.revision, roles: projectLaunchDraft },
349
+ });
350
+ assert.equal(savedProjectLaunchSlots.status, 200);
351
+ assert.equal(savedProjectLaunchSlots.body?.data?.inherited, false, "saving project roles should create an explicit project entry");
352
+ assert.equal(savedProjectLaunchSlots.body?.data?.roles?.reviewer?.[0]?.model, null);
353
+ const resetProjectLaunchSlots = await request("127.0.0.1", "/api/subagents/config", {
354
+ method: "POST",
355
+ body: { tab: tabId, scope: "project", revision: savedProjectLaunchSlots.body.data.revision, inherit: true },
356
+ });
357
+ assert.equal(resetProjectLaunchSlots.status, 200);
358
+ assert.equal(resetProjectLaunchSlots.body?.data?.inherited, true, "project inherit reset should remove only the explicit project entry");
359
+ assert.deepEqual(resetProjectLaunchSlots.body?.data?.roles?.reviewer, userLaunchDraft.reviewer);
360
+
361
+ const settingsBeforeStaleLaunchSave = await readFile(settingsFile, "utf8");
362
+ const staleLaunchSave = await request("127.0.0.1", "/api/subagents/config", {
363
+ method: "POST",
364
+ body: { tab: tabId, scope: "user", revision: initialUserLaunchSlots.body.data.revision, roles: userLaunchDraft },
365
+ });
366
+ assert.equal(staleLaunchSave.status, 409, "stale launch-slot revisions must not overwrite current settings");
367
+ assert.equal(await readFile(settingsFile, "utf8"), settingsBeforeStaleLaunchSave, "a rejected stale launch-slot save must leave the settings file byte-for-byte unchanged");
368
+ const invalidLaunchDraft = JSON.parse(JSON.stringify(userLaunchDraft));
369
+ invalidLaunchDraft.reviewer[0].model = "fake/fake-model:high";
370
+ const invalidLaunchSave = await request("127.0.0.1", "/api/subagents/config", {
371
+ method: "POST",
372
+ body: { tab: tabId, scope: "user", revision: savedUserLaunchSlots.body.data.revision, roles: invalidLaunchDraft },
373
+ });
374
+ assert.equal(invalidLaunchSave.status, 400, "thinking-suffixed persisted model IDs must be rejected on save");
375
+
317
376
  const malformedInlineImage = await request("127.0.0.1", "/api/prompt", {
318
377
  method: "POST",
319
378
  body: { tab: tabId, message: "malformed inline image fixture", images: [{ type: "image", mimeType: "image/png", data: "137,80,78,71,13,10,26,10" }] },
@@ -1858,6 +1917,12 @@ try {
1858
1917
  });
1859
1918
  assert.equal(remoteFileSave.status, 403, "file saves must be localhost-only");
1860
1919
 
1920
+ const remoteLaunchSlotSave = await request(lan, "/api/subagents/config", {
1921
+ method: "POST",
1922
+ body: { tab: tabId, scope: "user", revision: "remote-request-must-not-read", roles: {} },
1923
+ });
1924
+ assert.equal(remoteLaunchSlotSave.status, 403, "launch-slot saves must be localhost-only before the request body is processed");
1925
+
1861
1926
  const remoteFileOpenDefault = await request(lan, "/api/files/open-default", {
1862
1927
  method: "POST",
1863
1928
  body: { tab: tabId, path: viewerRelative },
@@ -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,6 +249,9 @@ 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] || "";
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");
244
255
  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");
245
256
  assert.match(workflowModeButtonHtml, /data-tooltip="Workflow Mode:/, "Workflow Mode should retain its styled tooltip");
246
257
  assert.doesNotMatch(workflowModeButtonHtml, /\stitle=/, "Workflow Mode should not also expose a browser-native tooltip");
@@ -396,6 +407,8 @@ assert.match(css, /\.webui-dev-badge \{[\s\S]*?color:\s*var\(--ctp-yellow\)/, "W
396
407
  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
408
  assert.match(css, /\.side-panel-section:not\(\.collapsed\) \.side-panel-section-chevron/, "expanded side panel sections should rotate the chevron");
398
409
  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");
410
+ 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");
411
+ 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
412
  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
413
  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
414
  assert.match(css, /\.subagent-agent-row:hover,[\s\S]*\.subagent-agent-row:focus-visible/, "subagent rows should expose clickable hover and keyboard focus states");
@@ -704,7 +717,7 @@ assert.match(app, /function setOptionsMenuOpen\(open\)[\s\S]*scheduleMobileDropd
704
717
  assert.match(app, /function focusPromptInput\(\{ defer = false \} = \{\}\)/, "frontend should focus the prompt composer programmatically after tab/app startup");
705
718
  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
719
  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");
720
+ 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
721
  assert.match(app, /elements\.promptInput\.addEventListener\("focus", \(\) => \{\n\s+syncMobileChatToBottomForInput\(\);/, "focusing mobile input should scroll output to bottom");
709
722
  assert.match(app, /navigator\.serviceWorker\.register\("\/service-worker\.js"\)/, "PWA service worker should be registered by the app");
710
723
  assert.match(app, /function serverStartCommandText\(\)[\s\S]*return `pi-webui\$\{currentPortArg\(\)\}`/, "PWA/offline shell should build a pathless pi-webui recovery command");
@@ -778,6 +791,13 @@ assert.match(
778
791
  );
779
792
  assert.match(app, /function renderCodexUsage\(\)/, "frontend should render Codex usage buckets in the side panel");
780
793
  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");
794
+ 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");
795
+ assert.match(app, /function subagentLaunchSlotThinkingForModel\(model\)[\s\S]*modelThinkingLevels/, "launch-slot thinking choices should come from the selected model metadata");
796
+ 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");
797
+ 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");
798
+ 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");
799
+ const subagentOverviewRefreshSource = appFunctionSource("refreshSubagents", "scheduleRefreshSubagents");
800
+ assert.doesNotMatch(subagentOverviewRefreshSource, /subagentLaunchSlot/, "live subagent polling must not recreate or reset the launch-slot editor");
781
801
  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
802
  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
803
  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");
@@ -1036,12 +1056,15 @@ assert.match(app, /function renderWorkflowInspectorAgent\(agent, run\)[\s\S]*Pro
1036
1056
  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
1057
  assert.match(app, /confirmMessage && !window\.confirm\(confirmMessage\)/, "destructive WebUI Workflow actions should require browser confirmation");
1038
1058
  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");
1059
+ 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");
1060
+ 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");
1061
+ 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");
1062
+ assert.match(app, /workflowOverlayOpenButton\?\.addEventListener\("click", \(\) => setWorkflowOverlayMinimized\(false\)\)/, "the Workflow-button restore affordance should reopen the complete overlay");
1040
1063
  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
1064
  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
1065
  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
1066
  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");
1067
+ 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
1068
  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
1069
  assert.match(app, /terminal-tab-workflow-indicator[\s\S]*workflowRunningCountForTab/, "terminal tabs should display Workflow Mode or active-run badges");
1047
1070
  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");
@@ -1049,6 +1072,8 @@ assert.match(css, /\.workflow-inspector-widget\.minimized,[\s\S]*\.workflow-subp
1049
1072
  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
1073
  assert.match(css, /\.terminal-tab-workflow-indicator \{[\s\S]*color: var\(--ctp-mauve\)/, "inactive-tab Workflow badges should have a distinct accessible style");
1051
1074
  assert.match(css, /\.composer-workflow-mode-button\.active,[\s\S]*aria-pressed="true"/, "active Workflow Mode toggle should have persistent pressed styling");
1075
+ 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");
1076
+ 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
1077
  assert.match(css, /\.composer\.workflow-mode-active[\s\S]*body\.workflow-mode-active \.composer::before/, "active Workflow Mode should visibly accent the composer");
1053
1078
 
1054
1079
  // Workflow raw-script inspector: narrowly specialized, structurally read-only, and viewport-safe.
@@ -1587,6 +1612,7 @@ assert.match(serviceWorker, /fetchThenCache\(request\)\.catch\(/, "PWA service w
1587
1612
  assert.match(serviceWorker, /ignoreSearch: true/, "PWA service worker offline fallback should ignore ?v= cache busters");
1588
1613
  assert.match(serviceWorker, /self\.addEventListener\("notificationclick"/, "PWA service worker should focus Web UI when blocked-tab notifications are clicked");
1589
1614
  assert.match(serviceWorker, /event\.notification\.data\?\.url/, "blocked-tab notifications should carry a URL for service-worker click handling");
1615
+ assert.match(serviceWorker, /"\/subagent-launch-slot-state\.mjs"/, "PWA service worker should cache the launch-slot state module imported by the app shell");
1590
1616
  assert.match(serviceWorker, /"\/apple-touch-icon\.png"/, "PWA service worker should cache the apple touch icon");
1591
1617
  assert.match(serviceWorker, /"\/matrix-background\.webp"/, "PWA service worker should cache the Matrix background image");
1592
1618
  assert.match(serviceWorker, /"\/catppuccin-mocha-background\.png"/, "PWA service worker should cache the Catppuccin Mocha background image");
@@ -1766,6 +1792,7 @@ assert.match(server, /writeFile\(tmpFile, body\.content[\s\S]*?rename\(tmpFile,
1766
1792
  assert.match(server, /url\.pathname === "\/api\/themes" && req\.method === "GET"/, "server should expose GET /api/themes");
1767
1793
  assert.match(server, /readBundledThemes\(\)/, "server should read bundled theme JSON files for the browser");
1768
1794
  assert.match(server, /"apple-touch-icon\.png", "icon-192\.png"/, "server should serve the conventional apple touch icon path");
1795
+ 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
1796
  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
1797
  assert.match(server, /\["\.webmanifest", "application\/manifest\+json; charset=utf-8"\]/, "server should serve manifest with the correct MIME type");
1771
1798
  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");