@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.
@@ -0,0 +1,64 @@
1
+ function cloneSlot(slot = {}) {
2
+ return {
3
+ id: String(slot.id || ""),
4
+ model: typeof slot.model === "string" ? slot.model : null,
5
+ thinking: typeof slot.thinking === "string" ? slot.thinking : null,
6
+ };
7
+ }
8
+
9
+ export function cloneLaunchSlotRoles(roles = {}) {
10
+ return Object.fromEntries(Object.entries(roles || {}).map(([roleId, slots]) => [
11
+ roleId,
12
+ Array.isArray(slots) ? slots.map(cloneSlot) : [],
13
+ ]));
14
+ }
15
+
16
+ export function launchSlotRolesEqual(left, right) {
17
+ const leftRoles = Object.keys(left || {}).sort();
18
+ const rightRoles = Object.keys(right || {}).sort();
19
+ if (leftRoles.length !== rightRoles.length || leftRoles.some((roleId, index) => roleId !== rightRoles[index])) return false;
20
+ return leftRoles.every((roleId) => {
21
+ const leftSlots = Array.isArray(left?.[roleId]) ? left[roleId] : [];
22
+ const rightSlots = Array.isArray(right?.[roleId]) ? right[roleId] : [];
23
+ return leftSlots.length === rightSlots.length && leftSlots.every((slot, index) => (
24
+ slot?.id === rightSlots[index]?.id
25
+ && (slot?.model || null) === (rightSlots[index]?.model || null)
26
+ && (slot?.thinking || null) === (rightSlots[index]?.thinking || null)
27
+ ));
28
+ });
29
+ }
30
+
31
+ export function updateLaunchSlot(roles, roleId, slotId, patch = {}) {
32
+ const next = cloneLaunchSlotRoles(roles);
33
+ const slots = next[roleId];
34
+ const index = Array.isArray(slots) ? slots.findIndex((slot) => slot.id === slotId) : -1;
35
+ if (index < 0) return next;
36
+ const model = Object.hasOwn(patch, "model") ? (patch.model || null) : slots[index].model;
37
+ const thinking = model && Object.hasOwn(patch, "thinking") ? (patch.thinking || null) : model ? slots[index].thinking : null;
38
+ slots[index] = { ...slots[index], model, thinking };
39
+ return next;
40
+ }
41
+
42
+ export function addLaunchSlot(roles, roleId, sourceSlotId, { slotsPerRole = 8, totalSlots = 32, createId } = {}) {
43
+ const next = cloneLaunchSlotRoles(roles);
44
+ const slots = next[roleId];
45
+ if (!Array.isArray(slots) || slots.length >= slotsPerRole) return null;
46
+ const total = Object.values(next).reduce((count, value) => count + (Array.isArray(value) ? value.length : 0), 0);
47
+ if (total >= totalSlots) return null;
48
+ const source = slots.find((slot) => slot.id === sourceSlotId) || slots[slots.length - 1];
49
+ const id = typeof createId === "function" ? String(createId(roleId, slots) || "") : "";
50
+ if (!id || slots.some((slot) => slot.id === id)) return null;
51
+ const slot = { id, model: source?.model || null, thinking: source?.model ? source.thinking || null : null };
52
+ slots.push(slot);
53
+ return { roles: next, slot };
54
+ }
55
+
56
+ export function removeLaunchSlot(roles, roleId, slotId, baseSlotId = `${roleId}:base`) {
57
+ if (slotId === baseSlotId) return null;
58
+ const next = cloneLaunchSlotRoles(roles);
59
+ const slots = next[roleId];
60
+ const index = Array.isArray(slots) ? slots.findIndex((slot) => slot.id === slotId) : -1;
61
+ if (index < 0) return null;
62
+ const [removed] = slots.splice(index, 1);
63
+ return { roles: next, removed, focusSlotId: slots[Math.max(0, index - 1)]?.id || null };
64
+ }
@@ -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,111 @@
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 css = await readFile(join(root, "public", "styles.css"), "utf8");
8
+
9
+ function ruleBlock(selector, from = 0) {
10
+ const start = css.indexOf(`${selector} {`, from);
11
+ assert.notEqual(start, -1, `missing CSS rule: ${selector}`);
12
+ const end = css.indexOf("}", start);
13
+ assert.notEqual(end, -1, `unterminated CSS rule: ${selector}`);
14
+ return css.slice(start, end + 1);
15
+ }
16
+
17
+ function propertyValue(block, property) {
18
+ const match = block.match(new RegExp(`(?:^|\\n)\\s*${property.replace(/[.*+?^${}()|[\\]\\\\]/g, "\\$&")}:\\s*([^;]+);`));
19
+ assert.ok(match, `missing ${property} in CSS rule`);
20
+ return match[1].trim();
21
+ }
22
+
23
+ const compactStart = css.indexOf("/* Compact high-density surfaces:");
24
+ const responsiveStart = css.indexOf("@media (max-width: 1050px)");
25
+ assert.ok(compactStart >= 0 && responsiveStart > compactStart, "compact desktop overrides should stay before responsive rules so mobile adaptations win");
26
+
27
+ assert.match(
28
+ css,
29
+ /\/\* Compact high-density surfaces:[\s\S]*\.app-runner-widget \{[\s\S]*margin-block:\s*0\.18rem;[\s\S]*padding:\s*0\.52rem;[\s\S]*\.app-runner-live-widget \.release-npm-output-details\[open\] \.release-npm-terminal \{[\s\S]*height:\s*clamp\(8rem, 26dvh, 18rem\)/,
30
+ "App Runner should use compact widget chrome and a smaller live terminal",
31
+ );
32
+ assert.match(
33
+ css,
34
+ /\/\* Compact high-density surfaces:[\s\S]*\.subagent-launch-slots-summary \{[\s\S]*min-height:\s*2\.7rem;[\s\S]*\.subagents-box \{[\s\S]*padding:\s*0\.48rem;[\s\S]*\.subagent-tab-header \{[\s\S]*min-height:\s*36px;/,
35
+ "Subagents side-panel chrome should use the scoped compact density treatment",
36
+ );
37
+ assert.match(
38
+ css,
39
+ /\/\* Keep the Files tree visual language while giving Git its denser data-list rhythm\. \*\/[\s\S]*\.git-side-panel-folder-summary,[\s\S]*\.git-side-panel-file \{[\s\S]*min-height:\s*1\.55rem;[\s\S]*padding:\s*0\.08rem 0\.26rem;[\s\S]*border:\s*1px solid transparent;[\s\S]*border-radius:\s*0\.5rem;[\s\S]*\.git-side-panel-file:focus-visible \{[\s\S]*box-shadow:\s*inset 2px 0 0 var\(--ctp-blue\)/,
40
+ "Git changed-file rows should keep the Files tree visual language with denser spacing",
41
+ );
42
+ assert.match(
43
+ css,
44
+ /\/\* Compact high-density surfaces:[\s\S]*\.git-workflow-panel \{[\s\S]*gap:\s*0\.48rem;[\s\S]*max-height:\s*min\(28rem, 40dvh\);[\s\S]*padding:\s*0\.62rem;[\s\S]*\.git-workflow-output \{[\s\S]*min-height:\s*3\.5rem;/,
45
+ "Guided Git should use the scoped compact panel and output sizing",
46
+ );
47
+
48
+ const filesRow = ruleBlock(".file-tree-item");
49
+ const gitRows = ruleBlock(".git-side-panel-folder-summary,\n.git-side-panel-file", compactStart);
50
+ for (const property of ["color", "border-radius", "background"]) {
51
+ assert.equal(propertyValue(gitRows, property), propertyValue(filesRow, property), `Git and Files rows should share ${property}`);
52
+ }
53
+ assert.equal(propertyValue(gitRows, "min-height"), "1.55rem", "Git file rows should keep the compact data-list height");
54
+ assert.equal(propertyValue(gitRows, "padding"), "0.08rem 0.26rem", "Git file rows should keep their compact padding");
55
+ const gitTree = ruleBlock(".git-side-panel-tree", compactStart);
56
+ assert.equal(propertyValue(gitTree, "gap"), "0", "Git tree rows should not add inter-row gaps");
57
+ assert.equal(propertyValue(gitTree, "padding"), "0.14rem 0.18rem", "Git tree container padding should remain compact");
58
+ const denseGitRowsStart = css.indexOf("/* Keep the Files tree visual language", compactStart);
59
+ const genericDetailsStart = css.indexOf("\ndetails {\n margin: 0.5rem 0;");
60
+ assert.notEqual(genericDetailsStart, -1, "missing generic details card rule");
61
+ const genericDetails = ruleBlock("details", genericDetailsStart);
62
+ assert.equal(propertyValue(genericDetails, "padding"), "0.6rem", "generic details padding should remain explicit in the base stylesheet");
63
+ const gitFolderContainer = ruleBlock(".git-side-panel-folder", denseGitRowsStart);
64
+ assert.equal(propertyValue(gitFolderContainer, "margin"), "0", "Git directories should reset generic details margins");
65
+ assert.equal(propertyValue(gitFolderContainer, "padding"), "0", "Git directories should reset the generic details padding that creates inter-row gaps");
66
+ assert.equal(propertyValue(gitFolderContainer, "border"), "0", "Git directories should not inherit generic details borders");
67
+ assert.equal(propertyValue(gitFolderContainer, "border-radius"), "0", "Git directories should not retain generic details corner geometry");
68
+ assert.equal(propertyValue(gitFolderContainer, "background"), "transparent", "Git directories should not inherit generic details card backgrounds");
69
+ const gitFolderRow = ruleBlock(".git-side-panel-folder-summary", denseGitRowsStart);
70
+ assert.equal(propertyValue(gitFolderRow, "gap"), "0.18rem", "Git directory label spacing should remain compact");
71
+ assert.equal(propertyValue(gitFolderRow, "min-height"), "1.25rem", "Git directories should be denser than file rows");
72
+ assert.equal(propertyValue(gitFolderRow, "padding"), "0 0.2rem", "Git directories should remove vertical padding");
73
+ assert.equal(propertyValue(gitFolderRow, "line-height"), "1.1", "Git directory text should retain a compact readable line box");
74
+ const gitFolderChevron = ruleBlock(".git-side-panel-folder-chevron", denseGitRowsStart);
75
+ assert.equal(propertyValue(gitFolderChevron, "font-size"), "0.78rem", "Git directory chevrons should remain compact");
76
+ assert.equal(propertyValue(gitFolderChevron, "line-height"), "1", "Git directory chevrons should remain vertically centered");
77
+ const gitFolderBody = ruleBlock(".git-side-panel-folder-body", denseGitRowsStart);
78
+ assert.equal(propertyValue(gitFolderBody, "gap"), "0", "Nested Git entries should not add vertical gaps");
79
+ assert.equal(propertyValue(gitFolderBody, "margin"), "0 0 0 0.48rem", "Nested Git indentation should remain shallow");
80
+ assert.equal(propertyValue(gitFolderBody, "padding-left"), "0.24rem", "Nested guide padding should remain shallow");
81
+ assert.equal(propertyValue(filesRow, "border-color"), "transparent", "Files rows should start with a transparent border");
82
+ assert.equal(propertyValue(gitRows, "border"), "1px solid transparent", "Git rows should provide the same transparent one-pixel border geometry");
83
+ const filesHover = ruleBlock(".file-tree-item:hover,\n.file-tree-item:focus-visible");
84
+ const gitHover = ruleBlock(".git-side-panel-folder-summary:hover,\n.git-side-panel-folder-summary:focus-visible,\n.git-side-panel-file:hover,\n.git-side-panel-file:focus-visible", compactStart);
85
+ for (const property of ["border-color", "background", "box-shadow"]) {
86
+ assert.equal(propertyValue(gitHover, property), propertyValue(filesHover, property), `Git and Files rows should share hover/focus ${property}`);
87
+ }
88
+
89
+ const coarseStart = css.indexOf("@media (pointer: coarse)", compactStart);
90
+ const coarseEnd = css.indexOf("@media (prefers-reduced-motion: reduce)", coarseStart);
91
+ assert.ok(coarseStart > compactStart && coarseEnd > coarseStart, "coarse-pointer protections should follow compact desktop overrides");
92
+ const coarseBlock = css.slice(coarseStart, coarseEnd);
93
+ for (const selector of [
94
+ ".app-runner-output-controls .release-npm-action",
95
+ ".subagent-open-mode-field select",
96
+ ".subagent-launch-slots-summary",
97
+ ".subagent-tab-header",
98
+ ".git-side-panel-repository-toggle",
99
+ ".git-side-panel-tab",
100
+ ".git-side-panel-folder-summary",
101
+ ".git-side-panel-file",
102
+ "button.git-workflow-step",
103
+ ".git-workflow-message-input",
104
+ ]) {
105
+ assert.ok(coarseBlock.includes(selector), `${selector} should retain a coarse-pointer target floor`);
106
+ }
107
+ assert.match(coarseBlock, /min-height:\s*44px;/, "coarse-pointer compact controls should retain a 44px target floor");
108
+ const guidedGitTouchRule = css.indexOf("#gitWorkflowCancelButton { min-height: 44px; }");
109
+ assert.ok(guidedGitTouchRule > compactStart, "Guided Git action touch targets should override compact desktop sizing");
110
+
111
+ console.log("compact-sections-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 },