@firstpick/pi-package-webui 0.6.5 → 0.6.7

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.
@@ -79,6 +79,11 @@ const settingsFile = path.join(harnessSideEffectsRoot, "webui-settings.json");
79
79
  const openCommandLog = path.join(harnessSideEffectsRoot, "open-default.log");
80
80
  const openCommandScript = path.join(harnessSideEffectsRoot, "fake-open-default.mjs");
81
81
  const fakeOpenBinDir = path.join(harnessSideEffectsRoot, "bin");
82
+ const artifactRoot = path.join(harnessSideEffectsRoot, "artifacts"), artifactDir = path.join(artifactRoot, "fixture-document-artifact"), artifactManifest = path.join(artifactDir, "manifest.json"), artifactDownload = path.join(artifactDir, "document.docx"), artifactPage = path.join(artifactDir, "page-1.png"), artifactExpiresAt = new Date(Date.now() + 60 * 60 * 1000).toISOString();
83
+ await mkdir(artifactDir, { recursive: true });
84
+ await writeFile(artifactDownload, Buffer.from("fixture docx download bytes"));
85
+ await writeFile(artifactPage, Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]));
86
+ await writeFile(artifactManifest, JSON.stringify({ artifact: { schema: "pi.artifact/v1", kind: "document", id: "fixture-document-artifact", revisionId: "fixture-revision", title: "fixture.docx", mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", pageCount: 1, manifestPath: artifactManifest, downloadPath: artifactDownload, expiresAt: artifactExpiresAt }, sourcePath: "/private/source.docx", sourceSha256: "a".repeat(64), renderer: { engine: "fixture" }, pages: [{ pageNum: 1, width: 10, height: 20, outputPath: artifactPage }], warnings: [] }));
82
87
  await chmod(fakePi, 0o755);
83
88
  await mkdir(fakeOpenBinDir, { recursive: true });
84
89
  await writeFile(openCommandScript, `#!/usr/bin/env node\nimport { appendFile } from "node:fs/promises";\nawait appendFile(process.env.PI_WEBUI_OPEN_LOG, "custom-open\\t" + process.argv.slice(2).join("\\t") + "\\n", "utf8");\n`, "utf8");
@@ -123,6 +128,9 @@ const child = spawn(process.execPath, [serverScript, "--cwd", cwd, "--host", "0.
123
128
  PI_WEBUI_SETTINGS_FILE: settingsFile,
124
129
  ...(process.platform === "linux" ? {} : { PI_WEBUI_OPEN_COMMAND: openCommandScript }),
125
130
  PI_WEBUI_OPEN_LOG: openCommandLog,
131
+ PI_WEBUI_ARTIFACT_ROOTS: artifactRoot,
132
+ FAKE_PI_ARTIFACT_MANIFEST: artifactManifest,
133
+ FAKE_PI_ARTIFACT_DOWNLOAD: artifactDownload,
126
134
  FAKE_PI_VOICE_SCRIPTS: "1",
127
135
  PI_VOICE_STT_URL: `http://127.0.0.1:${voiceProviderPort}/stt`,
128
136
  PI_VOICE_TTS_URL: `http://127.0.0.1:${voiceProviderPort}/tts`,
@@ -217,6 +225,60 @@ try {
217
225
  const tabId = tabList[0].id;
218
226
  assert.ok(tabId, "tab should have an id");
219
227
 
228
+ const artifactFixture = await request("127.0.0.1", "/api/prompt", { method: "POST", body: { tab: tabId, message: "fixture document artifact" } });
229
+ assert.equal(artifactFixture.status, 200, "document artifact fixture should be accepted");
230
+ const artifactMessages = await request("127.0.0.1", `/api/messages?tab=${encodeURIComponent(tabId)}`);
231
+ const artifactToolResult = artifactMessages.body?.data?.messages?.findLast?.((message) => message?.role === "toolResult" && message?.toolName === "docx_render");
232
+ const publicArtifact = artifactToolResult?.details?.artifact;
233
+ assert.equal(publicArtifact?.schema, "pi.artifact/v1", "document artifact should survive transcript sanitization");
234
+ assert.ok(publicArtifact?.manifestUrl, "document artifact should receive a manifest URL");
235
+ assert.ok(publicArtifact?.downloadUrl, "document artifact should receive a download URL");
236
+ assert.equal(JSON.stringify(artifactToolResult).includes(harnessSideEffectsRoot), false, "browser transcript must not expose artifact host paths");
237
+ const artifactManifestResponse = await fetch(`http://127.0.0.1:${port}${publicArtifact.manifestUrl}`, { signal: AbortSignal.timeout(5_000) });
238
+ assert.equal(artifactManifestResponse.status, 200, "artifact manifest token should resolve for its tab");
239
+ const artifactManifestPayload = await artifactManifestResponse.json();
240
+ assert.equal(artifactManifestPayload.data.pages[0].pageNum, 1);
241
+ assert.equal(JSON.stringify(artifactManifestPayload).includes(harnessSideEffectsRoot), false, "artifact manifest response must not expose host paths");
242
+ const artifactPageResponse = await fetch(`http://127.0.0.1:${port}${artifactManifestPayload.data.pages[0].imageUrl}`, { signal: AbortSignal.timeout(5_000) });
243
+ assert.equal(artifactPageResponse.status, 200, "artifact page token should resolve");
244
+ assert.equal(artifactPageResponse.headers.get("content-type"), "image/png");
245
+ const artifactRangeResponse = await fetch(`http://127.0.0.1:${port}${publicArtifact.downloadUrl}`, { headers: { range: "bytes=0-6" }, signal: AbortSignal.timeout(5_000) });
246
+ assert.equal(artifactRangeResponse.status, 206, "artifact downloads should support bounded byte ranges");
247
+ assert.equal(artifactRangeResponse.headers.get("content-range"), `bytes 0-6/${(await stat(artifactDownload)).size}`);
248
+ const otherArtifactTab = await request("127.0.0.1", "/api/tabs", { method: "POST", body: { cwd, title: "artifact-isolation" } });
249
+ const wrongTabManifestUrl = new URL(publicArtifact.manifestUrl, `http://127.0.0.1:${port}`); wrongTabManifestUrl.searchParams.set("tab", otherArtifactTab.body?.data?.tab?.id);
250
+ assert.equal((await fetch(wrongTabManifestUrl, { signal: AbortSignal.timeout(5_000) })).status, 404, "artifact tokens must be tab-bound");
251
+ await request("127.0.0.1", `/api/tabs/${encodeURIComponent(otherArtifactTab.body?.data?.tab?.id)}`, { method: "DELETE" });
252
+ await request("127.0.0.1", "/api/prompt", { method: "POST", body: { tab: tabId, message: "fixture document artifact clear" } });
253
+
254
+ const subagentFixtureStart = await request("127.0.0.1", "/api/prompt", { method: "POST", body: { tab: tabId, message: "fixture subagents running" } });
255
+ assert.equal(subagentFixtureStart.status, 200, "subagent fixture status should be accepted");
256
+ let subagentsResponse;
257
+ for (let attempt = 0; attempt < 20; attempt++) {
258
+ subagentsResponse = await request("127.0.0.1", "/api/subagents");
259
+ if (subagentsResponse.body?.data?.totalAgents === 2) break;
260
+ await delay(50);
261
+ }
262
+ assert.equal(subagentsResponse?.status, 200, "subagent overview endpoint should respond");
263
+ assert.equal(subagentsResponse.body?.data?.totalAgents, 2, "subagent overview should count all running agents");
264
+ assert.equal(subagentsResponse.body?.data?.tabs?.[0]?.tabId, tabId, "subagent overview should group agents under their terminal tab");
265
+ assert.deepEqual(subagentsResponse.body?.data?.tabs?.[0]?.runs?.[0]?.agents?.map((agent) => agent.name), ["reviewer", "scout"], "subagent overview should preserve agent order within the session run");
266
+ const subagentOutputResponse = await request("127.0.0.1", `/api/subagents/output?tab=${encodeURIComponent(tabId)}&run=${encodeURIComponent("fixture-run")}&agent=${encodeURIComponent("fixture-run:0")}`);
267
+ assert.equal(subagentOutputResponse.status, 200, "running subagent output endpoint should respond");
268
+ assert.equal(subagentOutputResponse.body?.data?.agent?.name, "reviewer", "subagent output should target the selected child agent");
269
+ assert.deepEqual(subagentOutputResponse.body?.data?.agent?.recentOutput, ["Inspecting current implementation", "Waiting for the next tool result"], "subagent output should preserve bounded live output lines");
270
+ assert.equal(subagentOutputResponse.body?.data?.agent?.currentToolArgs, "README.md", "subagent output should include current tool state");
271
+ const unknownSubagentOutput = await request("127.0.0.1", `/api/subagents/output?tab=${encodeURIComponent(tabId)}&run=missing&agent=missing`);
272
+ assert.equal(unknownSubagentOutput.status, 404, "subagent output endpoint should reject untracked selections");
273
+ const subagentFixtureClear = await request("127.0.0.1", "/api/prompt", { method: "POST", body: { tab: tabId, message: "fixture subagents clear" } });
274
+ assert.equal(subagentFixtureClear.status, 200, "subagent fixture clear should be accepted");
275
+ for (let attempt = 0; attempt < 20; attempt++) {
276
+ subagentsResponse = await request("127.0.0.1", "/api/subagents");
277
+ if (subagentsResponse.body?.data?.totalAgents === 0) break;
278
+ await delay(50);
279
+ }
280
+ assert.equal(subagentsResponse.body?.data?.totalAgents, 0, "completed subagents should disappear from the running overview");
281
+
220
282
  const state = await request("127.0.0.1", `/api/state?tab=${encodeURIComponent(tabId)}`);
221
283
  assert.equal(state.status, 200);
222
284
  assert.equal(state.body?.data?.model?.provider, "fake", "state should come from the fake pi RPC");
@@ -0,0 +1,113 @@
1
+ import assert from "node:assert/strict";
2
+ import vm from "node:vm";
3
+ import { readFile } from "node:fs/promises";
4
+ import { dirname, join } from "node:path";
5
+ import { fileURLToPath, URL } from "node:url";
6
+
7
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
8
+ const app = await readFile(join(root, "public", "app.js"), "utf8");
9
+
10
+ function findFunctionSource(source, name) {
11
+ const signature = new RegExp(`function\\s+${name}\\s*\\(`, "m");
12
+ const match = signature.exec(source);
13
+ assert.ok(match, `${name} should be defined`);
14
+ let parenDepth = 0;
15
+ let openBrace = -1;
16
+ for (let index = match.index + match[0].length - 1; index < source.length; index += 1) {
17
+ const char = source[index];
18
+ if (char === "(") parenDepth += 1;
19
+ else if (char === ")") parenDepth -= 1;
20
+ else if (char === "{" && parenDepth === 0) {
21
+ openBrace = index;
22
+ break;
23
+ }
24
+ }
25
+ assert.notEqual(openBrace, -1, `${name} body should open`);
26
+ let depth = 0;
27
+ for (let index = openBrace; index < source.length; index += 1) {
28
+ const char = source[index];
29
+ if (char === "{") depth += 1;
30
+ else if (char === "}") {
31
+ depth -= 1;
32
+ if (depth === 0) return source.slice(match.index, index + 1);
33
+ }
34
+ }
35
+ assert.fail(`${name} body should close`);
36
+ }
37
+
38
+ const helperNames = [
39
+ "markdownFilePathFromHref",
40
+ "safeMarkdownLinkHref",
41
+ "normalizeMarkdownWorkspacePath",
42
+ "markdownWorkspaceFilePath",
43
+ ];
44
+ const context = { URL };
45
+ vm.runInNewContext(
46
+ `${helperNames.map((name) => findFunctionSource(app, name)).join("\n\n")}\nthis.markdownLinkHelpers = { ${helperNames.join(", ")} };`,
47
+ context,
48
+ );
49
+ const {
50
+ markdownFilePathFromHref,
51
+ safeMarkdownLinkHref,
52
+ markdownWorkspaceFilePath,
53
+ } = context.markdownLinkHelpers;
54
+
55
+ for (const href of [
56
+ "https://example.com/docs",
57
+ "mailto:dev@example.com",
58
+ "#details",
59
+ "docs/README.md",
60
+ "./docs/README.md",
61
+ "../README.md",
62
+ "/home/dev/project/README.md",
63
+ "C:/Users/dev/project/README.md",
64
+ String.raw`C:\Users\dev\project\README.md`,
65
+ "file:///C:/Users/dev/project/README.md",
66
+ ]) {
67
+ assert.equal(safeMarkdownLinkHref(href), href, `safe Markdown link should be accepted: ${href}`);
68
+ }
69
+
70
+ for (const href of [
71
+ "javascript:alert(1)",
72
+ "data:text/html,unsafe",
73
+ "vbscript:msgbox(1)",
74
+ "//example.com/unsafe",
75
+ String.raw`\\server\share\README.md`,
76
+ "file://server/share/README.md",
77
+ ]) {
78
+ assert.equal(safeMarkdownLinkHref(href), "", `unsafe or remote-file Markdown link should be rejected: ${href}`);
79
+ }
80
+
81
+ assert.equal(markdownFilePathFromHref("README.md#overview"), "README.md");
82
+ assert.equal(markdownFilePathFromHref("file:///C:/My%20Project/README.md#overview"), "C:/My Project/README.md");
83
+ assert.equal(markdownFilePathFromHref(String.raw`C:\My Project\README.md`), "C:/My Project/README.md");
84
+ assert.equal(markdownFilePathFromHref("https://example.com/README.md"), "");
85
+
86
+ assert.equal(
87
+ markdownWorkspaceFilePath("C:/Users/Dev/Project/docs/README.md", String.raw`c:\users\dev\project`),
88
+ "docs/README.md",
89
+ "Windows workspace matching should be case-insensitive",
90
+ );
91
+ assert.equal(
92
+ markdownWorkspaceFilePath("file:///C:/Users/Dev/Project/My%20Doc.md", "C:/Users/Dev/Project"),
93
+ "My Doc.md",
94
+ "file URLs should resolve to a workspace-relative path",
95
+ );
96
+ assert.equal(
97
+ markdownWorkspaceFilePath("/home/dev/project/docs/README.md", "/home/dev/project"),
98
+ "docs/README.md",
99
+ "POSIX absolute paths should resolve inside the workspace",
100
+ );
101
+ assert.equal(markdownWorkspaceFilePath("docs/../README.md", "/unused"), "README.md");
102
+ assert.equal(markdownWorkspaceFilePath("../README.md", "/unused", "docs/guides"), "docs/README.md");
103
+ assert.equal(markdownWorkspaceFilePath("../../secret.txt", "/unused", "docs"), "", "relative traversal outside the workspace should be rejected");
104
+ assert.equal(markdownWorkspaceFilePath("D:/secret.txt", "C:/Users/Dev/Project"), "", "absolute paths outside the workspace should be rejected");
105
+ assert.equal(markdownWorkspaceFilePath("/home/dev/other/secret.txt", "/home/dev/project"), "", "POSIX paths outside the workspace should be rejected");
106
+
107
+ const configureMarkdownLinkSource = findFunctionSource(app, "configureMarkdownLink");
108
+ assert.match(configureMarkdownLinkSource, /link\.dataset\.markdownFileHref = href/, "local Markdown links should retain their file target");
109
+ assert.match(configureMarkdownLinkSource, /markdownWorkspaceFilePath\(href, cwd, basePath\)/, "local Markdown links should be scoped to the active workspace");
110
+ assert.match(configureMarkdownLinkSource, /openFileInViewer\(workspacePath\)/, "local Markdown links should open in the WebUI file viewer");
111
+ assert.match(app, /configureMarkdownLink\(link, href\);/, "inline Markdown rendering should configure every accepted link");
112
+
113
+ console.log("markdown link tests passed");
@@ -28,8 +28,8 @@ const helper = await readFile(join(root, "webui-rpc-helper.mjs"), "utf8");
28
28
  const companionDependencies = {
29
29
  "@firstpick/pi-extension-bang-command-autocomplete": "^0.2.1",
30
30
  "@firstpick/pi-extension-btw": "^0.1.2",
31
- "@firstpick/pi-extension-fish-user-bash": "^0.2.0",
32
- "@firstpick/pi-extension-git-footer-status": "^0.3.6",
31
+ "@firstpick/pi-extension-fish-user-bash": "^0.2.1",
32
+ "@firstpick/pi-extension-git-footer-status": "^0.3.8",
33
33
  "@firstpick/pi-extension-release-aur": "^0.1.7",
34
34
  "@firstpick/pi-extension-release-npm": "^0.4.0",
35
35
  "@firstpick/pi-extension-safety-guard": "^0.2.3",
@@ -39,7 +39,7 @@ const companionDependencies = {
39
39
  "@firstpick/pi-extension-tools": "^0.1.6",
40
40
  "@firstpick/pi-extension-workflows": "^0.1.2",
41
41
  "@firstpick/pi-package-remote-webui": "^0.1.5",
42
- "@firstpick/pi-prompts-git-pr": "^0.1.2",
42
+ "@firstpick/pi-prompts-git-pr": "^0.1.3",
43
43
  "@firstpick/pi-themes-bundle": "^0.1.4",
44
44
  };
45
45
 
@@ -71,9 +71,14 @@ assert.match(html, /id="agentDoneNotificationsToggle"/, "side panel should expos
71
71
  assert.match(html, /id="agentDoneNotificationsStatus"/, "agent-done notifications toggle should expose status text");
72
72
  assert.match(html, /id="thinkingVisibilityToggle"/, "side panel should expose a thinking-output visibility toggle");
73
73
  assert.match(html, /id="thinkingVisibilityStatus"/, "thinking-output visibility toggle should expose status text");
74
+ assert.match(html, /<option value="xhigh">xhigh<\/option>\s*<option value="max">max<\/option>/, "side panel should expose Pi's max thinking effort after xhigh");
75
+ assert.match(app, /const SETTINGS_THINKING_OPTIONS = \["off", "minimal", "low", "medium", "high", "xhigh", "max"\]/, "native settings should expose every Pi thinking effort");
76
+ assert.match(app, /return levels\.length \? levels : \["off", "minimal", "low", "medium", "high", "xhigh", "max"\]/, "footer thinking picker fallback should include max effort");
77
+ assert.match(server, /const THINKING_LEVELS = \["off", "minimal", "low", "medium", "high", "xhigh", "max"\]/, "server should accept Pi's max thinking effort");
74
78
  assert.match(html, /id="terminalTabsLayoutSelect"[\s\S]*<option value="left">Left sidebar<\/option>/, "side panel controls should expose a terminal-tabs layout selector");
75
79
  assert.match(html, /id="terminalTabsLayoutStatus"/, "terminal-tabs layout selector should expose status text");
76
80
  assert.match(html, /id="nativeCommandDialog"/, "native slash selector UI should have a dedicated dialog");
81
+ assert.match(html, /id="optionsGitWorkflowSetupButton"[\s\S]*data-command="\/git-workflow-setup"[\s\S]*Guided Git Setup/, "Common Pi options should expose native Guided Git Setup");
77
82
  assert.match(html, /id="nativeCommandSearch"[^>]*type="search"/, "native slash selector dialog should expose a filter box");
78
83
  assert.match(html, /id="remoteQrDialog"[\s\S]*id="remoteQrBody"[\s\S]*id="remoteQrCopyButton"/, "remote WebUI should expose a dedicated QR popup dialog");
79
84
  assert.match(html, /id="commandPaletteCloseButton"[^>]*aria-label="Close command palette"[^>]*>Close<\/button>/, "command palette should expose a visible accessible close button");
@@ -86,6 +91,9 @@ assert.match(html, /class="optional-features-description[\s\S]*href="https:\/\/g
86
91
  assert.doesNotMatch(html, /id="btwOverlayDialog"/, "/btw should not use a blocking modal overlay");
87
92
  assert.match(html, /id="codexUsageBox"/, "side panel should expose Codex subscription usage status");
88
93
  assert.match(html, /data-side-panel-section="codex-usage"/, "Codex usage should live in a collapsible side-panel section");
94
+ assert.match(html, /data-side-panel-section="subagents"[\s\S]*class="side-panel-section-label">Subagents<\/span>[\s\S]*id="subagentCountBadge"[\s\S]*id="subagentsBox"/, "side panel should expose grouped running subagents with a live count");
95
+ assert.doesNotMatch(html, /id="subagentOverlayDialog"/, "subagent output should not use a blocking modal dialog");
96
+ 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");
89
97
  assert.match(html, /data-side-panel-section="queue"[\s\S]*id="createPromptListButton"[\s\S]*>Create prompt list<\/button>/, "Queue section should expose prompt-list creation");
90
98
  assert.match(html, /id="loadPromptListButton"[\s\S]*>Load List<\/button>[\s\S]*id="runLoadedPromptListButton"[^>]*disabled[^>]*>Run<\/button>/, "Queue section should expose load and run controls for saved prompt lists");
91
99
  assert.match(html, /id="promptListDialog"[\s\S]*id="promptListAddPromptButton"[\s\S]*\+ Add follow-up prompt/, "prompt-list dialog should add follow-up prompt rows");
@@ -151,6 +159,9 @@ assert.match(html, /id="nativeSkillsButton"[^>]*data-command="\/skills"[\s\S]*?<
151
159
  assert.match(html, /id="nativeToolsButton"[^>]*data-command="\/tools"[\s\S]*?<span>Tools Setup<\/span>/, "skills/tools command menu should include Tools Setup");
152
160
  assert.match(html, /id="appRunnerInfoButton"[\s\S]*?aria-controls="appRunnerInfoDialog"/, "detected app-runner controls should expose an explanation popup button");
153
161
  assert.match(html, /id="appRunnerMenuButton"[\s\S]*?aria-controls="appRunnerMenuPanel"/, "composer should expose a detected app-runner dropdown button");
162
+ for (const menuId of ["publishMenu", "nativeCommandMenu", "optionsMenu", "appRunnerMenuPanel"]) {
163
+ assert.match(html, new RegExp(`id="${menuId}"[^>]*class="[^"]*composer-auto-height-menu-panel`), `${menuId} should opt into content-height sizing without internal scrolling`);
164
+ }
154
165
  assert.ok(html.indexOf('id="optionsMenuButton"') < html.indexOf('id="appRunnerMenuButton"'), "app-runner dropdown should render to the right of the settings/options button");
155
166
  assert.match(html, /id="optionsRemoteButton"[^>]*data-command="\/remote"[^>]*hidden[\s\S]*?<span>Open Remote<\/span>/, "Options menu should include the Remote WebUI launcher by label");
156
167
  const optionsRemoteIndex = html.indexOf('id="optionsRemoteButton"');
@@ -274,6 +285,12 @@ assert.match(css, /\.webui-version-badge,\n\.webui-dev-badge \{[\s\S]*?border-ra
274
285
  assert.match(css, /\.webui-dev-badge \{[\s\S]*?color:\s*var\(--ctp-yellow\)/, "Web UI dev indicator should have distinct warning styling");
275
286
  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");
276
287
  assert.match(css, /\.side-panel-section:not\(\.collapsed\) \.side-panel-section-chevron/, "expanded side panel sections should rotate the chevron");
288
+ 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");
289
+ assert.match(css, /\.subagent-agent-row:hover,[\s\S]*\.subagent-agent-row:focus-visible/, "subagent rows should expose clickable hover and keyboard focus states");
290
+ assert.match(css, /\.subagent-overlay-widget[\s\S]*\.subagent-overlay-terminal[\s\S]*\.subagent-overlay-close-action/, "subagent output should reuse the non-blocking App Runner widget visual language");
291
+ assert.match(css, /\.subagent-output-waiting-dot[\s\S]*@keyframes subagent-output-waiting-pulse/, "subagent output should animate one transient ellipsis while waiting");
292
+ assert.doesNotMatch(css, /\.extension-dialog\.subagent-overlay-dialog/, "subagent output should not retain blocking dialog styles");
293
+ assert.match(css, /@keyframes subagent-running-pulse/, "running subagents should expose a live activity indicator");
277
294
  assert.match(css, /\.optional-feature-pill\.enabled/, "optional features should visually distinguish enabled state");
278
295
  assert.match(css, /\.todo-widget \{[\s\S]*?display:\s*grid/, "todo-progress widget should render as a styled checklist card");
279
296
  assert.match(css, /\.todo-widget-summary \{[\s\S]*?cursor:\s*pointer/, "todo-progress widget should expose a compact expandable summary");
@@ -320,10 +337,11 @@ assert.match(css, /\.composer-publish-menu:hover > \.composer-publish-button\[da
320
337
  assert.match(css, /\.composer-publish-menu-panel \{[\s\S]*?display:\s*none;[\s\S]*?flex-direction:\s*column/, "Publish workflow menu should hide when closed and expand like grouped tabs");
321
338
  assert.match(css, /\.composer-publish-menu:hover \.composer-publish-menu-panel,[\s\S]*?\.composer-publish-menu:focus-within \.composer-publish-menu-panel,[\s\S]*?\.composer-publish-menu\.open \.composer-publish-menu-panel \{\n\s+display:\s*flex;/, "Publish workflow menu should open on hover, focus, or explicit open state");
322
339
  assert.match(css, /\.composer-native-command-button \{[\s\S]*?color:\s*var\(--ctp-mauve\)/, "skills/tools command menu should have a distinct slash-command button style");
323
- assert.match(css, /\.composer-options-menu-panel \{[\s\S]*?max-height:\s*min\(calc\(var\(--visual-viewport-height, 100dvh\) - 2rem\), 48rem\)/, "Options menu should be tall enough for common commands without scrolling on normal viewports");
324
- assert.match(css, /\.composer-publish-menu-panel \{[\s\S]*?overscroll-behavior:\s*contain;[\s\S]*?-webkit-overflow-scrolling:\s*touch/, "dropdown panels should use contained momentum scrolling when their options overflow");
325
- assert.match(css, /\.composer-actions-panel > \.composer-publish-menu \.composer-publish-menu-panel \{[\s\S]*?max-height:\s*min\(var\(--mobile-dropdown-max-height, 34dvh\), calc\(var\(--visual-viewport-height, 100dvh\) - 2rem\)\)/, "mobile composer dropdowns should clamp to an in-viewport scroll height");
326
- assert.match(css, /\.composer-actions-panel > \.composer-options-menu \.composer-publish-menu-panel,\n\s+\.composer-actions-panel > \.composer-app-runner-menu \.composer-publish-menu-panel \{\n\s+inset-inline:\s*auto 0;/, "mobile Options and app-runner dropdowns should share the clamped scrollable popover placement");
340
+ assert.match(css, /\.composer-auto-height-menu-panel \{[\s\S]*?height:\s*auto;[\s\S]*?max-height:\s*none;[\s\S]*?overflow:\s*visible;[\s\S]*?overflow-y:\s*visible;/, "content-height composer menus should grow with their active commands without an internal scrollbar");
341
+ assert.match(css, /\.composer-publish-menu-panel \{[\s\S]*?overscroll-behavior:\s*contain;[\s\S]*?-webkit-overflow-scrolling:\s*touch/, "dropdown panels should default to contained momentum scrolling when their options overflow");
342
+ assert.match(css, /\.composer-actions-panel > \.composer-publish-menu \.composer-publish-menu-panel \{[\s\S]*?max-height:\s*min\(var\(--mobile-dropdown-max-height, 34dvh\), calc\(var\(--visual-viewport-height, 100dvh\) - 2rem\)\)/, "mobile composer dropdowns should default to an in-viewport scroll height");
343
+ assert.match(css, /\.composer-actions-panel > \.composer-options-menu \.composer-publish-menu-panel,\n\s+\.composer-actions-panel > \.composer-app-runner-menu \.composer-publish-menu-panel \{\n\s+inset-inline:\s*auto 0;/, "mobile Options and app-runner dropdowns should share right-aligned popover placement");
344
+ assert.match(css, /\.composer-actions-panel > \.composer-publish-menu \.composer-auto-height-menu-panel \{[\s\S]*?height:\s*auto;[\s\S]*?max-height:\s*none;[\s\S]*?overflow:\s*visible;[\s\S]*?overflow-y:\s*visible;/, "mobile content-height menus should grow with their active commands without an internal scrollbar");
327
345
  assert.match(css, /\.composer-native-command-menu-item \{[\s\S]*?color:\s*var\(--ctp-mauve\)/, "skills/tools command menu items should be styled separately from publish actions");
328
346
  assert.match(css, /\.composer-actions-panel > \.composer-publish-menu[\s\S]*?grid-column: span 1/, "Publish and command menu buttons should fit beside Git workflow in mobile actions");
329
347
  assert.match(css, /\.composer-actions-panel[\s\S]*?bottom:\s*calc\(100% \+ 0\.42rem\)/, "mobile composer actions should open as an above-composer sheet");
@@ -488,7 +506,7 @@ assert.match(app, /const hadNetworkStatus = networkStatusLoaded;[\s\S]*if \(!had
488
506
  assert.match(app, /remoteAuthToggle: \$\("#remoteAuthToggle"\)/, "Remote WebUI controls should bind the remote PIN auth toggle");
489
507
  assert.match(html, /id="networkControlField"[^>]*hidden/, "Remote WebUI browser controls should be hidden until the optional package is loaded and enabled");
490
508
  assert.match(app, /remoteWebuiCommand\(enable \? "authOn" : "authOff"/, "remote PIN auth toggle should dispatch through the Remote WebUI package command");
491
- assert.match(server, /function webuiSettingsFile\(\)[\s\S]*pi-webui[\s\S]*settings\.json/, "server should persist Web UI settings under a pi-webui settings file");
509
+ assert.match(server, /webuiSettingsFile,[\s\S]*from "\.\.\/lib\/git-workflow-preferences\.mjs"/, "server should use the shared Pi Web UI settings persistence module");
492
510
  assert.match(server, /let persistedRemoteAuthEnabled = await readPersistedRemoteAuthEnabled\(\)/, "server should load the saved Remote PIN auth preference before startup");
493
511
  assert.match(server, /if \(remoteAuthStartupEnabled\(\)\) enableRemoteAuth\(remoteAuthStartupReason\(\)\)/, "saved Remote PIN auth preference should enable auth on startup");
494
512
  assert.match(server, /await saveRemoteAuthPreference\(true\)/, "enabling Remote PIN auth should persist the on preference");
@@ -510,7 +528,7 @@ assert.match(server, /cwdExplicit: false/, "server should track whether startup
510
528
  assert.match(server, /return options\.cwdExplicit \? \[await createTab\(\)\] : \[\]/, "server should wait for UI cwd selection when no --cwd is supplied");
511
529
  assert.match(server, /async function resolvedPiCliScript\(\)[\s\S]*require\.resolve\.paths\(PI_CODING_AGENT_PACKAGE\)[\s\S]*nodeModulesRoot[\s\S]*dist[\s\S]*cli\.js/, "server should resolve the bundled Pi CLI through Node resolution roots so hoisted global installs can spawn RPC tabs");
512
530
  assert.match(server, /const bundledCli = await resolvedPiCliScript\(\)/, "standalone server should prefer the resolved Pi CLI script before falling back to PATH pi");
513
- assert.match(server, /if \(options\.piBinExplicit\) \{\n\s+const command = await resolvePiCommand\(updateArgs\)/, "explicit --pi JavaScript launchers should also work for update commands");
531
+ assert.match(server, /if \(options\.piBinExplicit\) \{\n\s+resolveCommand = \(args\) => resolvePiCommand\(args\)/, "explicit --pi JavaScript launchers should also work for capability checks and update commands");
514
532
  assert.match(app, /serverActionSelect\.addEventListener\("change", updateServerActionButton\)/, "Server action dropdown should control the guarded run button");
515
533
  assert.match(app, /runServerActionButton\.addEventListener\("click"[\s\S]*runSelectedServerAction/, "Server action run button should execute the selected action");
516
534
  assert.match(app, /api\("\/api\/restart", \{ method: "POST", scoped: false \}\)/, "Restart Server action should call the unscoped restart endpoint");
@@ -520,14 +538,15 @@ assert.match(app, /api\("\/api\/shutdown", \{ method: "POST", scoped: false \}\)
520
538
  assert.match(server, /url\.pathname === "\/api\/restart" && req\.method === "POST"/, "server should expose restart endpoint");
521
539
  assert.match(server, /PI_WEBUI_RESTORE_TABS: JSON\.stringify\(restorableTabs \|\| \[\]\)/, "server restart should preserve restorable tab metadata");
522
540
  assert.match(server, /if \(webuiDevServer\) env\.PI_WEBUI_DEV = "1";/, "server restart should explicitly preserve dev mode");
523
- assert.match(server, /const updateArgs = all \? \["update", "--all"\] : \["update"\]/, "server update should use pi update by default and pi update --all for package-inclusive updates");
524
- assert.match(server, /async function resolveUpdateTasks\(\{ all = false \} = \{\}\)[\s\S]*if \(!all\) return uniqueUpdateTasks\(\[piTask\]\)[\s\S]*currentWebuiPackageUpdateTask\(\)[\s\S]*agentPackageRootUpdateTask\(\)[\s\S]*projectPackageRootUpdateTasks\(\)[\s\S]*npmGlobalPackageRootUpdateTask\(\)[\s\S]*bunGlobalPackageRootUpdateTask\(\)/, "server all-update should run pi update plus detected local/global Pi package root tasks");
541
+ assert.match(server, /async function piUpdateCommandSupportsAll\(command\)[\s\S]*runCommand\(command\.command, command\.args \|\| \[\][\s\S]*piUpdateHelpSupportsAll/, "server should check the selected Pi executable's update help");
542
+ assert.match(server, /const supportsAll = all && await piUpdateCommandSupportsAll\(await resolveCommand\(\["update", "--help"\]\)\)[\s\S]*piUpdateCommandSteps\(\{ all, supportsAll \}\)/, "server should prefer --all only when the capability check succeeds");
543
+ assert.match(server, /async function resolveUpdateTasks\(\{ all = false \} = \{\}\)[\s\S]*const piTasks = await resolvePiUpdateCommands\(\{ all \}\)[\s\S]*if \(!all\) return uniqueUpdateTasks\(piTasks\)[\s\S]*currentWebuiPackageUpdateTask\(\)[\s\S]*agentPackageRootUpdateTask\(\)[\s\S]*projectPackageRootUpdateTasks\(\)[\s\S]*npmGlobalPackageRootUpdateTask\(\)[\s\S]*bunGlobalPackageRootUpdateTask\(\)/, "server all-update should run the selected Pi plan plus detected local/global Pi package root tasks");
525
544
  assert.match(server, /const UPDATE_PACKAGE_NAMES = \[\.\.\.new Set\(\[[\s\S]*WEBUI_CONTROLLED_PACKAGES[\s\S]*OPTIONAL_FEATURE_PACKAGES\.values\(\)/, "package-inclusive updates should include Web UI controlled Optional Feature packages");
526
- assert.match(app, /const command = all \? "pi update --all" : "pi update"/, "frontend update confirmation should describe self-only and all update commands");
545
+ assert.match(app, /const commandText = all \? '"pi update --all" when supported, otherwise "pi update --self" followed by "pi update --extensions"' : '"pi update --self"'/, "frontend update confirmation should describe capability selection and fallback");
527
546
  assert.match(app, /Optional Features, and detected Pi package roots/, "frontend all-update confirmation should describe optional-feature and detected-root coverage");
528
547
  assert.match(app, /api\(all \? "\/api\/update\?all=1" : "\/api\/update"/, "frontend all update should call the explicit all-mode endpoint");
529
- assert.match(html, /<option value="update-all">Update Pi \+ Packages &amp; Restart<\/option>/, "side panel should expose pi update --all as a separate server action");
530
- assert.match(readme, /`pi update` for Pi-only updates[\s\S]*`pi update --all` plus detected Web UI\/Optional Feature package-root updates/, "README should document self-only and expanded all update modes");
548
+ assert.match(html, /<option value="update-all">Update Pi \+ Packages &amp; Restart<\/option>/, "side panel should expose package-inclusive updates as a separate server action");
549
+ assert.match(readme, /first checks the selected Pi executable's `pi update --help`[\s\S]*uses `pi update --all` when advertised[\s\S]*otherwise falls back/, "README should document the checked preferred and fallback update modes");
531
550
  assert.match(server, /async function closeNetworkAccess\(\)/, "server should expose a local-only rebind helper for closing network access");
532
551
  assert.match(server, /url\.pathname === "\/api\/network\/close" && req\.method === "POST"/, "server should route network close requests");
533
552
  assert.match(server, /server\.closeAllConnections\?\.\(\)/, "network rebind should force-close long-lived clients so close-to-localhost can complete");
@@ -542,7 +561,7 @@ assert.match(app, /function setOptionsMenuOpen\(open\)[\s\S]*scheduleMobileDropd
542
561
  assert.match(app, /function focusPromptInput\(\{ defer = false \} = \{\}\)/, "frontend should focus the prompt composer programmatically after tab/app startup");
543
562
  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");
544
563
  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");
545
- assert.match(app, /resizePromptInput\(\);\nfocusPromptInput\(\{ defer: true \}\);\nrestoreStoredSkillUsage\(\);\nrestoreBusyPromptBehaviorSetting\(\);\nupdateComposerModeButtons\(\);/, "startup should request prompt focus and restore skill tags before waiting for tab state refreshes");
564
+ 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");
546
565
  assert.match(app, /elements\.promptInput\.addEventListener\("focus", \(\) => \{\n\s+syncMobileChatToBottomForInput\(\);/, "focusing mobile input should scroll output to bottom");
547
566
  assert.match(app, /navigator\.serviceWorker\.register\("\/service-worker\.js"\)/, "PWA service worker should be registered by the app");
548
567
  assert.match(app, /function serverStartCommandText\(\)[\s\S]*return `pi-webui\$\{currentPortArg\(\)\}`/, "PWA/offline shell should build a pathless pi-webui recovery command");
@@ -615,6 +634,23 @@ assert.match(
615
634
  "side-panel section toggles should expand at most one section at a time",
616
635
  );
617
636
  assert.match(app, /function renderCodexUsage\(\)/, "frontend should render Codex usage buckets in the side panel");
637
+ assert.match(app, /function renderSubagents\(\)[\s\S]*subagentTabsWithRunningAgents\(\)[\s\S]*renderSubagentTabGroup\(tab\)/, "frontend should group running subagents by terminal and session");
638
+ assert.match(app, /function openSubagentOverlay\(tab, run, agent\)[\s\S]*activeTabId !== tab\.tabId[\s\S]*await switchTab\(tab\.tabId\)[\s\S]*renderWidgets\(\)/, "clicking an agent should switch to its owning tab before rendering the live widget");
639
+ assert.match(app, /function renderWidgets\(\)[\s\S]*renderAppRunnerWidget\(\)[\s\S]*renderSubagentOverlayWidget\(\)/, "subagent output should render in the shared non-blocking top widget area after App Runner");
640
+ assert.doesNotMatch(app, /subagentOverlayDialog\.showModal|elements\.subagentOverlayDialog/, "subagent output should not open or depend on a modal dialog");
641
+ assert.match(app, /api\(`\/api\/subagents\/output\?\$\{query\}`, \{ scoped: false \}\)/, "subagent overlay should fetch selected live output from the owning tab");
642
+ assert.match(app, /SUBAGENT_OVERLAY_REFRESH_MS = 1000/, "subagent overlay should poll selected live output at a fast cadence");
643
+ assert.match(app, /function appendSubagentOutputWaitingIndicator\(parent\)[\s\S]*subagent-output-waiting-dot[\s\S]*if \(running && agent\.currentTool\) appendSubagentOutputWaitingIndicator\(terminal\)/, "subagent widget should render one replaceable waiting animation instead of transcript spam");
644
+ assert.match(app, /api\("\/api\/subagents", \{ scoped: false \}\)/, "frontend should refresh the cross-tab subagent overview");
645
+ assert.match(app, /SUBAGENTS_ACTIVE_REFRESH_MS = 1500/, "running subagents should receive a fast live refresh cadence");
646
+ assert.match(server, /url\.pathname === "\/api\/subagents" && req\.method === "GET"[\s\S]*webuiSubagentsData\(\)/, "server should expose a cross-tab running-subagent endpoint");
647
+ assert.match(server, /url\.pathname === "\/api\/subagents\/output" && req\.method === "GET"[\s\S]*webuiSubagentOutputData\(tab, runId, agentId\)/, "server should expose selected running subagent output only through its owning tab");
648
+ assert.match(server, /rememberWebuiSubagentsStatusEvent\(tab, event\)/, "server should ingest the helper's structured subagent status without forwarding internal JSON to the browser footer");
649
+ assert.match(helper, /SUBAGENT_RPC_REQUEST_EVENT = "subagents:rpc:v1:request"/, "Web UI helper should use pi-subagents' stable status RPC");
650
+ assert.match(helper, /case "subagent-output":[\s\S]*subagentOutputSnapshot\(payload\)/, "Web UI helper should return bounded live state and recent output for the selected child agent");
651
+ assert.match(helper, /line\.trim\(\)\.toLowerCase\(\) === "\(no output\)"/, "subagent transcript extraction should suppress empty tool-result markers");
652
+ assert.match(helper, /SUBAGENT_ASYNC_STARTED_EVENT = "subagent:async-started"[\s\S]*SUBAGENT_ASYNC_COMPLETE_EVENT = "subagent:async-complete"/, "Web UI helper should track async subagent lifecycle events");
653
+ assert.match(helper, /pi\.on\("tool_execution_start"[\s\S]*event\.toolName !== "subagent"[\s\S]*pi\.on\("tool_execution_end"/, "Web UI helper should track foreground subagent executions");
618
654
  assert.match(app, /if \(normalized === "prolite"\) return "Usage";/, "Codex Prolite plan labels should display as Usage in the side panel");
619
655
  assert.match(app, /api\(`\/api\/codex-usage\$\{suffix\}`, \{ scoped: false \}\)/, "Codex usage should load through a server endpoint without browser credentials");
620
656
  assert.match(app, /restoreSidePanelSectionState\(\);\nbindSidePanelSectionToggles\(\);/, "side panel section state should restore before toggles are bound");
@@ -632,7 +668,7 @@ assert.match(app, /function footerPayloadWithLiveModel\(payload\)[\s\S]*?shortMo
632
668
  assert.match(app, /function footerContextDisplayWithAuto\(value, state = currentState\)[\s\S]*footerAutoCompactionEnabled\(state\)[\s\S]*`\$\{withoutAuto\} \(auto\)`/, "context displays should append the auto-compaction indicator when enabled");
633
669
  assert.match(app, /function footerPayloadWithLiveModel\(payload\)[\s\S]*const contextChip = \(chip\)[\s\S]*footerContextDisplayWithAuto\(chip\?\.value\)[\s\S]*if \(chip\?\.key === "context"\) return \[contextChip\(chip\)\]/, "git footer context chips should use live Web UI auto-compaction state");
634
670
  assert.match(app, /async function toggleFooterAutoCompaction\(tabContext = activeTabContext\(\)\)[\s\S]*currentState = \{ \.\.\.currentState, autoCompactionEnabled: enabled \}[\s\S]*api\("\/api\/auto-compaction", \{ method: "POST", body: \{ enabled \}, tabId: tabContext\.tabId \}\)/, "git footer context box should optimistically toggle auto-compaction through the Web UI API");
635
- assert.match(app, /function renderGitFooterPayload\(payload\)[\s\S]*classList\.remove\("statusbar-tui-footer"\)[\s\S]*classList\.add\("statusbar-git-footer"\)[\s\S]*payload\.main\.map\(renderGitFooterPayloadMetric\)[\s\S]*payload\.meta\.map/, "enabled git footer payload should use the styled extension chip renderer, not the default TUI line");
671
+ assert.match(app, /function renderGitFooterPayload\(payload\)[\s\S]*classList\.remove\("statusbar-tui-footer"\)[\s\S]*classList\.add\("statusbar-git-footer"\)[\s\S]*payload\.main\.map\(\(chip\) => renderGitFooterPayloadMetric\(chip, payload\)\)[\s\S]*payload\.meta\.map\(\(chip\) => renderGitFooterPayloadMeta\(chip, tab, payload\)\)/, "enabled git footer payload should use the styled extension chip renderer, not the default TUI line");
636
672
  assert.match(app, /function ensureFooterTooltipNode\(\)[\s\S]*footer-floating-tooltip[\s\S]*document\.body\.append\(footerTooltipNode\)/, "git footer tooltips should render into a single floating viewport-level node");
637
673
  const footerTooltipSource = app.match(/function applyFooterTooltip\(node, tooltip, options = \{\}\)[\s\S]*?\n}\n\nfunction footerMetric/)?.[0] || "";
638
674
  assert.ok(footerTooltipSource, "git footer tooltip application source should be inspectable");
@@ -641,10 +677,10 @@ assert.match(app, /const GIT_FOOTER_TOOLTIP_COPY = \{[\s\S]*tokens:[\s\S]*cache:
641
677
  assert.match(app, /function gitFooterPayloadTooltip\(chip, options = \{\}\)[\s\S]*GIT_FOOTER_TOOLTIP_COPY\[key\][\s\S]*`Current: \$\{value\}`/, "git footer tooltips should combine explanations with the current chip value");
642
678
  assert.match(app, /function isRedundantFooterTooltipTitle\(sourceTitle, chip, value\)[\s\S]*labels\.map\(\(label\) => `\$\{label\}: \$\{value\}`\)/, "git footer tooltips should suppress duplicate label/current title lines");
643
679
  assert.match(app, /function gitFooterTooltipAlign\(chip\)[\s\S]*\["tokens", "cwd"\][\s\S]*return "start";[\s\S]*\["model", "thinking"\][\s\S]*return "end";/, "git footer tooltip alignment should keep edge boxes readable");
644
- assert.match(app, /function renderGitFooterPayloadMetric\(chip\)[\s\S]*applyGitFooterContextToggleOptions\(chip, options\)[\s\S]*gitFooterPayloadTooltip\(chip, \{ action \}\)[\s\S]*footerMetric\(chip\.icon/, "git footer main payload chips should render as styled metrics with explanatory tooltips and context action support");
645
- assert.match(app, /function applyFooterChangedFilesDropdown\(node, chip\)[\s\S]*chip\?\.key !== "changes"[\s\S]*footer-changes-with-files[\s\S]*footer-changed-files-popover/, "git footer changes chip should render a changed-files hover popover when files are present");
680
+ assert.match(app, /function renderGitFooterPayloadMetric\(chip, payload\)[\s\S]*applyGitFooterContextToggleOptions\(chip, options\)[\s\S]*gitFooterPayloadTooltip\(chip, \{ action \}\)[\s\S]*footerMetric\(chip\.icon/, "git footer main payload chips should render as styled metrics with explanatory tooltips and context action support");
681
+ assert.match(app, /function applyFooterChangedFilesDropdown\(node, chip, payload\)[\s\S]*gitFooterPayloadVisible\(payload, "webui-changed-files-popover"\)[\s\S]*chip\?\.key !== "changes"[\s\S]*footer-changes-with-files[\s\S]*footer-changed-files-popover/, "git footer changes chip should render a changed-files hover popover when files are present");
646
682
  assert.match(app, /function insertChangedFilePathReference\(path\)[\s\S]*formatPathReference\(path\)[\s\S]*input\.focus\(\)/, "clicking changed files should insert an @path reference and focus the composer");
647
- assert.match(app, /function renderGitFooterPayloadMeta\(chip, tab\)[\s\S]*options\.title = gitFooterPayloadTooltip\(chip, \{ action \}\)[\s\S]*footerMeta\(chip\.label, chip\.value, footerMetaClassForPayload\(chip\), options\)[\s\S]*applyFooterChangedFilesDropdown\(node, chip\)/, "git footer meta payload chips should render as styled metadata with explanatory tooltips and changes popovers");
683
+ assert.match(app, /function renderGitFooterPayloadMeta\(chip, tab, payload\)[\s\S]*options\.title = gitFooterPayloadTooltip\(chip, \{ action \}\)[\s\S]*footerMeta\(chip\.label, chip\.value, footerMetaClassForPayload\(chip\), options\)[\s\S]*applyFooterChangedFilesDropdown\(node, chip, payload\)/, "git footer meta payload chips should render as styled metadata with explanatory tooltips and changes popovers");
648
684
  assert.match(app, /chip\.key === "git"[\s\S]*setFooterBranchPickerOpen\(!footerBranchPickerOpen\)[\s\S]*Worktree actions are the safe default for parallel work/, "git branch footer chip should open the worktree-aware branch picker");
649
685
  assert.match(app, /chip\.key === "worktree"[\s\S]*setFooterBranchPickerOpen\(!footerBranchPickerOpen\)[\s\S]*Click to manage branch worktrees/, "worktree footer chip should open the branch worktree picker");
650
686
  assert.match(app, /function footerPayloadWithLiveModel\(payload\)[\s\S]*const worktreeLabel = gitWorkspaceBadgeLabel\(workspace\)[\s\S]*key: "worktree"/, "git footer payload should inject a live worktree chip from tab metadata");
@@ -794,7 +830,7 @@ assert.match(app, /const gitWorkflowsByTab = new Map\(\)/, "guided git workflow
794
830
  assert.match(app, /function bindGitWorkflowToActiveTab\(\) \{\n\s+gitWorkflow = gitWorkflowForTab\(activeTabId\) \|\| createGitWorkflowState\(\);/, "guided git workflow should render only the active terminal tab's workflow state");
795
831
  assert.match(app, /function setGitWorkflow\(patch, \{ tabId = activeTabId \} = \{\}\)[\s\S]*if \(tabId === activeTabId\) \{[\s\S]*renderGitWorkflow\(\);/, "guided git workflow should not render inactive terminal workflows globally");
796
832
  assert.match(html, /id="gitPrDialog"[\s\S]*id="gitPrTitleInput"[\s\S]*id="gitPrBodyEditor"[\s\S]*id="gitPrCreateButton"/, "guided git workflow should expose a PR review dialog with title and body editing");
797
- assert.match(app, /addGitWorkflowAction\("Create PR worktree", \(\) => createGitPrBranch\(\), "primary", false, GIT_WORKFLOW_CREATE_PR_TOOLTIP\)/, "guided git workflow should offer a Create PR worktree action after message generation");
833
+ assert.match(app, /addGitWorkflowAction\("Create PR worktree", \(\) => createGitPrBranch\(\), deliveryMode === "pr-worktree" \? "primary" : "", false, GIT_WORKFLOW_CREATE_PR_TOOLTIP\)/, "guided git workflow should offer and preference-highlight a Create PR worktree action after message generation");
798
834
  assert.match(app, /const GIT_WORKFLOW_CREATE_PR_TOOLTIP = \[[\s\S]*"Create PR worktree:"[\s\S]*"1\. Ask Pi to generate a type\/feature-name branch from staged changes\."[\s\S]*"4\. Create or open a Git worktree for that branch instead of switching this checkout\."[\s\S]*"7\. Push and Create PR will push upstream, run \/pr, let you review, then run gh pr create\."/, "Create PR worktree should have an up-to-date step-by-step tooltip");
799
835
  assert.match(app, /const GIT_WORKFLOW_MANUAL_BRANCH_TOOLTIP = \[[\s\S]*"Manual PR worktree:"[\s\S]*"1\. Skip agent branch-name generation\."[\s\S]*"4\. Create or open a Git worktree for that branch instead of switching this checkout\."[\s\S]*"7\. Push and Create PR will push upstream, run \/pr, let you review, then run gh pr create\."/, "Manual worktree should have an up-to-date step-by-step tooltip");
800
836
  assert.match(app, /addGitWorkflowAction\("Manual worktree", \(\) => createGitPrBranchManually\(\), "", false, GIT_WORKFLOW_MANUAL_BRANCH_TOOLTIP\)/, "Manual worktree should render with its tooltip");
@@ -812,7 +848,13 @@ assert.match(app, /async function createGitPrBranchWithSuggestion\([\s\S]*prompt
812
848
  assert.match(app, /function syncGitWorkflowWorktreeTabs\(result\)[\s\S]*Array\.isArray\(result\?\.tabs\)[\s\S]*applyTabMetadata\(result\.tab\)/, "guided git workflow should merge worktree tab metadata returned by the branch endpoint");
813
849
  assert.match(app, /const targetTabId = result\.tab\?\.id[\s\S]*setGitWorkflow\(nextState, \{ tabId: targetTabId \}\)[\s\S]*switchTab\(targetTabId\)/, "guided git workflow should transfer PR state to the opened worktree tab");
814
850
  assert.match(app, /addGitWorkflowAction\("Push and Create PR", \(\) => pushAndCreatePrGitWorkflow\(\), "primary", false\)/, "guided git workflow should replace push with Push and Create PR in PR mode");
815
- assert.match(app, /async function runGitPrPrompt\(tabId = gitWorkflowActionTabId\(\), \{ prefixOutput = "" \} = \{\}\)[\s\S]*body: \{ message: "\/pr" \}/, "guided git workflow should generate PR descriptions with /pr");
851
+ assert.match(app, /async function runGitPrPrompt\(tabId = gitWorkflowActionTabId\(\), \{ prefixOutput = "" \} = \{\}\)[\s\S]*\/api\/git-workflow\/generate"[\s\S]*kind: "pr"/, "guided git workflow should generate PR descriptions with the configured generation profile");
852
+ assert.match(app, /async function runGitMessagePrompt\([\s\S]*\/api\/git-workflow\/generate"[\s\S]*kind: "commit"/, "guided git workflow should generate commit messages with the configured model and effort");
853
+ assert.match(app, /async function runGitBranchNamePrompt\([\s\S]*\/api\/git-workflow\/generate"[\s\S]*kind: "branch"/, "guided git workflow should generate branch names with the configured model and effort");
854
+ assert.match(app, /async function acceptCurrentGitStaging\([\s\S]*summary\?\.staged[\s\S]*No staged files are available/, "review staging should require a non-empty current staged set");
855
+ assert.match(app, /Pre-commit verification reminder[\s\S]*Continue with this commit/, "configured verification reminders should run before committing");
856
+ assert.match(server, /async function startGitWorkflowGeneration\([\s\S]*set_model[\s\S]*setThinkingLevelForTab[\s\S]*type: "prompt"/, "server should apply the configured generation profile before prompting Pi");
857
+ assert.match(server, /event\?\.type === "agent_settled"[\s\S]*restoreGitWorkflowGenerationProfile\(tab\)/, "server should restore the active tab model and effort after generation settles");
816
858
  assert.match(server, /case "\/api\/git-workflow\/branch-name":[\s\S]*readGitWorkflowBranchName\(cwd\)/, "server should expose generated branch-name file loading for the guided PR workflow");
817
859
  assert.match(server, /case "\/api\/git-workflow\/branch":[\s\S]*createGitWorkflowBranchWorktree\(tab, body\)/, "server should route guided PR branch creation through worktree tabs");
818
860
  assert.match(server, /async function createGitWorkflowBranchWorktree\(tab, body = \{\}\)[\s\S]*snapshotGitWorkflowBranchState\(root, tab\.cwd\)[\s\S]*applyGitWorkflowBranchStateToWorktree\(snapshot, worktreePath\)[\s\S]*openWorktreeResultForTab\(tab, createdResult/, "guided PR worktree creation should copy staged state before opening the worktree tab");
@@ -895,8 +937,8 @@ assert.match(app, /function thinkingFormatOpenMatch\(text\)[\s\S]*?CHANNEL_THINK
895
937
  assert.match(app, /function splitThinkingFormatText\(text, \{ streaming = false \} = \{\}\)[\s\S]*?thinkingFormatOpenMatch\(rest\)[\s\S]*?finalText: stripThinkingFormatOutputSeparator\(rest\)/, "tagged thinking output should split thinking text from final response text");
896
938
  assert.match(app, /function visibleThinkingText\(text\)[\s\S]*?trimmed === UNEXPOSED_THINKING_TEXT[\s\S]*?return "";/, "provider no-thinking placeholders should normalize to empty thinking output");
897
939
  assert.match(app, /if \(isThinkingPart\) \{[\s\S]*?visibleThinkingText\(assistantThinkingText\(part\)\)[\s\S]*?if \(thinking\) displayMessages\.push/, "assistant transcript splitting should skip empty or unexposed thinking parts");
898
- assert.match(app, /message\.role === "thinking"[\s\S]*?visibleThinkingText\(message\.thinking \|\| textFromContent\(message\.content\)\)[\s\S]*?if \(thinkingOutputVisible && thinkingText\) appendText\(body, thinkingText, "thinking-text"\);/, "thinking cards should suppress empty and provider no-thinking placeholder output");
899
- assert.match(app, /function showStreamingThinking\(initialText = ""\)[\s\S]*?if \(initialText && !streamThinking\.textContent\) streamThinking\.textContent = initialText;/, "live thinking should not create a visible placeholder card before content arrives");
940
+ assert.match(app, /message\.role === "thinking"[\s\S]*?visibleThinkingText\(message\.thinking \|\| textFromContent\(message\.content\)\)[\s\S]*?if \(thinkingOutputVisible && thinkingText\) appendThinkingMarkdown\(body, thinkingText\);/, "thinking cards should suppress empty and provider no-thinking placeholder output while rendering visible reasoning as markdown");
941
+ assert.match(app, /function showStreamingThinking\(initialText = ""\)[\s\S]*?if \(initialText && !streamThinking\.textContent\) renderThinkingMarkdown\(streamThinking, initialText\);/, "live thinking should not create a visible placeholder card before content arrives");
900
942
  assert.match(app, /function setStreamingThinkingText\(text\)[\s\S]*?const thinking = visibleThinkingText\(text\);[\s\S]*?if \(!thinkingOutputVisible \|\| !thinking\) return false;[\s\S]*?return true;/, "live thinking text setters should ignore empty text instead of clearing or flashing the card");
901
943
  assert.match(app, /function syncStreamingThinkingFromUpdate\(event, update, \{ placeholder = "" \} = \{\}\)[\s\S]*?return setStreamingThinkingText\(streamThinkingRawText \|\| placeholder\);/, "incremental thinking sync should only report success after setting visible thinking text");
902
944
  assert.doesNotMatch(app, /text \|\| placeholder \|\| streamThinkingBubble/, "partial-message thinking sync should not clear an existing thinking card when a partial carries no visible thinking text");
@@ -1036,6 +1078,11 @@ assert.match(app, /setBusyPromptBehavior\(controls\.busyBehavior\.select\.value\
1036
1078
  assert.match(app, /sendPromptFromModeButton\("steer", elements\.steerButton\)/, "Steer should show tooltip instead of silently doing nothing when input is empty");
1037
1079
  assert.match(app, /sendPromptFromModeButton\("follow-up", elements\.followUpButton\)/, "Follow-up should show tooltip instead of silently doing nothing when input is empty");
1038
1080
  assert.match(app, /async function sendBtwQuestion\(question,[\s\S]*?`\/btw \$\{cleanQuestion\}`[\s\S]*?await sendPrompt\("prompt", message, \{ targetTabId, throwOnError: true \}\)/, "/btw helper should send text as an ephemeral slash command");
1081
+ assert.match(app, /const btwWidgetDismissedIdsByTab = new Map\(\)/, "/btw dismissals should be scoped to terminal tabs");
1082
+ assert.match(app, /function currentBtwWidgetPayload\(\)[\s\S]*?payload\.id === btwWidgetDismissedIdsByTab\.get\(activeTabId\)/, "/btw rendering should honor the active tab's dismissed payload ID");
1083
+ assert.match(app, /function closeBtwOutputWidget\(\)[\s\S]*?btwWidgetDismissedIdsByTab\.set\(activeTabId, payload\.id\)/, "closing /btw should remember the dismissed payload ID for its tab");
1084
+ const resetActiveTabUiSource = app.slice(app.indexOf("function resetActiveTabUi()"), app.indexOf("function tabGroupStatusRank"));
1085
+ assert.doesNotMatch(resetActiveTabUiSource, /btwWidgetDismissedIdsByTab/, "switching tabs should not clear remembered /btw dismissals");
1039
1086
  assert.match(app, /async function sendBtwPromptFromButton\(\)[\s\S]*?if \(!question\) \{\n\s+openBtwComposerWidget\(\);/, "empty /btw button should open the side-question widget input");
1040
1087
  assert.match(app, /function renderBtwComposerForm\(\)[\s\S]*?form\.requestSubmit\(\)[\s\S]*?sendBtwQuestion\(question\)/, "/btw widget input should submit each message as a /btw trigger");
1041
1088
  assert.match(app, /function makeBtwTransferIcon\(\)[\s\S]*?class", "btw-transfer-icon"[\s\S]*?function transferBtwContextToMain\(button, \{ transferMode = "full" \} = \{\}\)[\s\S]*?`\/btw-transfer \$\{encoded\}`[\s\S]*?streamingBehavior: "steer"[\s\S]*?Summarize & Steer/, "/btw widget should expose full-context and summary transfer actions that send steering context during active runs");
@@ -1061,11 +1108,14 @@ for (const command of ["resume", "reload", "remote", "name", "clone", "settings"
1061
1108
  const id = command.replace(/^./, (letter) => letter.toUpperCase());
1062
1109
  assert.match(app, new RegExp(`options${id}Button\\.addEventListener\\("click", \\(\\) => runNativeCommandMenu\\("\\/${command}"\\)\\)`), `Options menu should launch /${command}`);
1063
1110
  }
1111
+ assert.match(app, /optionsGitWorkflowSetupButton\?\.addEventListener\("click", \(\) => runNativeCommandMenu\("\/git-workflow-setup"\)\)/, "Options menu should launch native Guided Git Setup");
1112
+ assert.match(extension, /registerCommand\("git-workflow-setup"[\s\S]*runGitWorkflowSetup/, "Pi extension should register the reusable /git-workflow-setup command");
1113
+ assert.match(app, /async function openNativeGitWorkflowSetupDialog\([\s\S]*\/api\/git-workflow\/preferences/, "Web UI should implement Guided Git Setup with the persisted preferences API");
1064
1114
  assert.match(app, /async function sendPrompt\(kind = "prompt", explicitMessage, \{ targetTabId = activeTabId, throwOnError = false, streamingBehavior \} = \{\}\)/, "prompt sending should accept direct messages that bypass the input field and optional target tab");
1065
1115
  assert.match(app, /const rawMessage = usesPromptInput \? elements\.promptInput\.value : explicitMessage/, "direct prompt sends should not read the input textarea");
1066
1116
  assert.match(app, /if \(usesPromptInput\) \{[\s\S]*?if \(targetStillActive\) \{[\s\S]*?elements\.promptInput\.value = "";/, "direct prompt sends should preserve the input textarea draft");
1067
1117
  assert.match(app, /make\("button", "command-item"\)[\s\S]*?sendPrompt\("prompt", `\/\$\{command\.name\}`\)/, "side-panel command clicks should send the slash command directly");
1068
- assert.match(app, /const NATIVE_SELECTOR_COMMANDS = new Set\(\["model", "settings", "theme", "fork", "clone", "name", "resume", "tree", "login", "logout", "scoped-models", "tools", "skills"\]\)/, "frontend should route native slash commands into selector UIs");
1118
+ assert.match(app, /const NATIVE_SELECTOR_COMMANDS = new Set\(\["model", "settings", "git-workflow-setup", "theme", "fork", "clone", "name", "resume", "tree", "login", "logout", "scoped-models", "tools", "skills"\]\)/, "frontend should route native slash commands, including Guided Git Setup, into selector UIs");
1069
1119
  assert.match(app, /async function handleNativeSlashSelectorCommand\(message/, "frontend should intercept exact native slash commands before prompt forwarding");
1070
1120
  assert.match(app, /kind === "prompt" && attachments\.length === 0 && await handleNativeSlashSelectorCommand/, "prompt sending should open native selector dialogs before marking a run active");
1071
1121
  assert.match(app, /function openNativeModelSelector\(\)[\s\S]*?nativeCommandApi\("\/api\/models"\)/, "native /model selector should load models through the active tab API");
@@ -129,7 +129,7 @@ for (const target of ["state", "tabs", "commands", "themes", "workspace"]) {
129
129
  }
130
130
 
131
131
  const slashCommands = nativeSlashCommandEntries(parity);
132
- assert.equal(slashCommands.length, 24);
132
+ assert.equal(slashCommands.length, 25);
133
133
  assert.equal(slashCommands[0].name, "settings");
134
134
  assert.equal(slashCommands.at(-1).name, "quit");
135
135
 
@@ -53,6 +53,7 @@ const slashSurfaces = parity.surfaces.filter((surface) => surface.kind === "slas
53
53
  const slashCommandNames = slashSurfaces.map((surface) => surface.command?.name).filter(Boolean);
54
54
  const requiredNativeCommands = [
55
55
  "settings",
56
+ "git-workflow-setup",
56
57
  "model",
57
58
  "theme",
58
59
  "scoped-models",
@@ -62,10 +62,51 @@ try {
62
62
  assert.equal(startupAuth.body?.data?.auth?.enabled, true, "saved Remote PIN auth setting should enable auth at next startup");
63
63
  assert.match(startupAuth.body?.data?.auth?.pin, /^\d{4}$/, "startup auth should generate a fresh PIN, not persist one");
64
64
 
65
+ const initialGitSetup = await request("/api/git-workflow/preferences");
66
+ assert.equal(initialGitSetup.status, 200);
67
+ assert.equal(initialGitSetup.body?.data?.configured, false, "guided Git should require first-time model setup");
68
+ assert.equal(initialGitSetup.body?.data?.preferences?.stagingPolicy, "review", "review/select should be the safe staging default");
69
+ assert.equal(initialGitSetup.body?.data?.models?.[0]?.id, "fake-model");
70
+
71
+ const unsupportedEffort = await request("/api/git-workflow/preferences", {
72
+ method: "POST",
73
+ body: { preferences: { generation: { provider: "fake", modelId: "fake-model", thinkingLevel: "low" } } },
74
+ });
75
+ assert.equal(unsupportedEffort.status, 400, "setup should reject effort levels unsupported by the selected model");
76
+
77
+ const invalidStagingPolicy = await request("/api/git-workflow/preferences", {
78
+ method: "POST",
79
+ body: { preferences: { generation: { provider: "fake", modelId: "fake-model", thinkingLevel: "off" }, stagingPolicy: "everything" } },
80
+ });
81
+ assert.equal(invalidStagingPolicy.status, 400, "setup should reject invalid preference choices instead of silently normalizing them");
82
+
83
+ const savedGitSetup = await request("/api/git-workflow/preferences", {
84
+ method: "POST",
85
+ body: {
86
+ preferences: {
87
+ generation: { provider: "fake", modelId: "fake-model", thinkingLevel: "off", unavailablePolicy: "ask" },
88
+ commit: { language: "de", defaultVariant: "long", scope: "required" },
89
+ stagingPolicy: "review",
90
+ deliveryMode: "ask",
91
+ verificationPolicy: "ask",
92
+ },
93
+ },
94
+ });
95
+ assert.equal(savedGitSetup.status, 200);
96
+ assert.equal(savedGitSetup.body?.data?.configured, true);
97
+ assert.equal(savedGitSetup.body?.data?.preferences?.commit?.language, "de");
98
+
99
+ const generation = await request("/api/git-workflow/generate", { method: "POST", body: { kind: "commit" } });
100
+ assert.equal(generation.status, 200);
101
+ assert.equal(generation.body?.data?.message, "/git-staged-msg de required");
102
+ assert.deepEqual(generation.body?.data?.generation, { provider: "fake", modelId: "fake-model", thinkingLevel: "off" });
103
+
65
104
  const disableAuth = await request("/api/remote-auth/settings", { method: "POST", body: { enabled: false } });
66
105
  assert.equal(disableAuth.status, 200);
67
106
  const savedAfterDisable = JSON.parse(await readFile(settingsFile, "utf8"));
107
+ assert.equal(savedAfterDisable.version, 2, "Web UI settings should migrate to the guided Git schema version");
68
108
  assert.equal(savedAfterDisable.remoteAuthEnabled, false, "disabling Remote PIN auth should persist the off preference");
109
+ assert.equal(savedAfterDisable.gitWorkflow?.generation?.modelId, "fake-model", "Remote PIN updates should preserve guided Git preferences");
69
110
 
70
111
  const enableAuth = await request("/api/remote-auth/settings", { method: "POST", body: { enabled: true } });
71
112
  assert.equal(enableAuth.status, 200);