@firstpick/pi-package-webui 0.9.7 → 0.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/DEVELOPMENT.md +882 -0
  2. package/README.md +8 -4
  3. package/TECHNICAL.md +415 -0
  4. package/bin/pi-webui.mjs +154 -26
  5. package/index.ts +2 -1
  6. package/lib/optional-feature-catalog.mjs +1 -1
  7. package/lib/windows-drive-roots.mjs +114 -0
  8. package/package.json +3 -1
  9. package/public/app.js +683 -115
  10. package/public/guided-git-command-state.mjs +175 -1
  11. package/public/index.html +17 -10
  12. package/public/service-worker.js +1 -1
  13. package/public/styles.css +146 -32
  14. package/public/transcript-renderer.mjs +62 -0
  15. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  16. package/tests/browser/footer-model-advanced-layout.spec.mjs +512 -0
  17. package/tests/browser/guided-git-extension-command.spec.mjs +180 -0
  18. package/tests/browser/guided-git-fallback.spec.mjs +68 -3
  19. package/tests/browser/interaction-continuity.spec.mjs +33 -0
  20. package/tests/browser/windows-drive-parent.spec.mjs +198 -0
  21. package/tests/codex-fast-mode-static.test.mjs +2 -2
  22. package/tests/compaction-static.test.mjs +1 -1
  23. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  24. package/tests/control-visibility-static.test.mjs +3 -3
  25. package/tests/controls-layout-static.test.mjs +3 -3
  26. package/tests/events-tree-context-menu-static.test.mjs +3 -3
  27. package/tests/fast-mode-client-static.test.mjs +1 -1
  28. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  29. package/tests/file-viewer-image-static.test.mjs +3 -3
  30. package/tests/fixtures/fake-pi.mjs +34 -3
  31. package/tests/git-footer-context-menu-static.test.mjs +103 -1
  32. package/tests/guided-git-activation-http.test.mjs +194 -0
  33. package/tests/guided-git-activation-static.test.mjs +80 -0
  34. package/tests/guided-git-activation.test.mjs +244 -0
  35. package/tests/guided-git-fallback-runtime.test.mjs +1 -0
  36. package/tests/guided-git-fallback-ui-static.test.mjs +2 -2
  37. package/tests/guided-git-message-reliability-static.test.mjs +2 -1
  38. package/tests/guided-git-optional-feature.test.mjs +31 -0
  39. package/tests/http-endpoints-harness.test.mjs +3 -0
  40. package/tests/interaction-state-stability-static.test.mjs +1 -1
  41. package/tests/intercom-conversation-viewer-static.test.mjs +3 -3
  42. package/tests/main-output-loading-static.test.mjs +11 -9
  43. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  44. package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
  45. package/tests/mobile-foundation-static.test.mjs +3 -3
  46. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  47. package/tests/mobile-static.test.mjs +85 -4
  48. package/tests/open-issue-wizard-static.test.mjs +1 -1
  49. package/tests/persistent-ui-layout-static.test.mjs +3 -3
  50. package/tests/prompt-input-vertical-scroll-static.test.mjs +6 -6
  51. package/tests/prompt-routing-input-clear-static.test.mjs +1 -1
  52. package/tests/questionnaire-dialog.test.mjs +3 -3
  53. package/tests/session-sampling-ui-static.test.mjs +3 -3
  54. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  55. package/tests/subagent-observability-static.test.mjs +2 -2
  56. package/tests/syntax-highlighting-static.test.mjs +3 -3
  57. package/tests/tab-close-continuity-static.test.mjs +2 -0
  58. package/tests/theme-customizer-static.test.mjs +1 -1
  59. package/tests/thinking-block-grouping.test.mjs +79 -0
  60. package/tests/windows-drive-cwd-picker-static.test.mjs +81 -0
  61. package/tests/windows-drive-roots.test.mjs +130 -0
@@ -0,0 +1,244 @@
1
+ import test from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import {
4
+ GUIDED_GIT_START_PAYLOAD_MAX_BYTES,
5
+ GUIDED_GIT_START_PAYLOAD_TYPE,
6
+ GUIDED_GIT_START_PAYLOAD_VERSION,
7
+ GUIDED_GIT_START_STATUS_KEY,
8
+ createGuidedGitActivationController,
9
+ createGuidedGitLaunchPermitController,
10
+ guidedGitLaunchBlockedReason,
11
+ guidedGitLaunchModeForTabCatalog,
12
+ guidedGitWorkflowCommandForTabCatalog,
13
+ parseGuidedGitStartPayload,
14
+ resolveCommandForTabCatalog,
15
+ resolveRpcSlashCommandForTabCatalog,
16
+ } from "../public/guided-git-command-state.mjs";
17
+
18
+ const ids = [
19
+ "11111111-1111-4111-8111-111111111111",
20
+ "22222222-2222-4222-8222-222222222222",
21
+ "33333333-3333-4333-8333-333333333333",
22
+ "44444444-4444-4444-8444-444444444444",
23
+ ];
24
+
25
+ function payload(requestId = ids[0], patch = {}) {
26
+ return JSON.stringify({
27
+ type: GUIDED_GIT_START_PAYLOAD_TYPE,
28
+ version: GUIDED_GIT_START_PAYLOAD_VERSION,
29
+ action: "start",
30
+ requestId,
31
+ ...patch,
32
+ });
33
+ }
34
+
35
+ function request(tabId, requestId = ids[0], patch = {}) {
36
+ return {
37
+ method: "setStatus",
38
+ statusKey: GUIDED_GIT_START_STATUS_KEY,
39
+ statusText: payload(requestId),
40
+ tabId,
41
+ ...patch,
42
+ };
43
+ }
44
+
45
+ test("Guided Git activation parser accepts only the exact bounded v1 payload", () => {
46
+ assert.deepEqual(parseGuidedGitStartPayload(payload()), {
47
+ type: GUIDED_GIT_START_PAYLOAD_TYPE,
48
+ version: 1,
49
+ action: "start",
50
+ requestId: ids[0],
51
+ });
52
+
53
+ for (const invalid of [
54
+ "",
55
+ "not json",
56
+ "[]",
57
+ JSON.stringify(null),
58
+ payload(ids[0], { type: "other" }),
59
+ payload(ids[0], { version: 2 }),
60
+ payload(ids[0], { action: "restart" }),
61
+ payload("not-a-uuid"),
62
+ payload(ids[0], { extra: true }),
63
+ "x".repeat(GUIDED_GIT_START_PAYLOAD_MAX_BYTES + 1),
64
+ ]) assert.equal(parseGuidedGitStartPayload(invalid), null, `rejected: ${invalid.slice(0, 80)}`);
65
+ });
66
+
67
+ test("browser-local launch permits correlate one exact envelope and remain bounded", async () => {
68
+ const originPermits = createGuidedGitLaunchPermitController({ maxTrackedTabs: 2, permitTtlMs: 50 });
69
+ const otherClientPermits = createGuidedGitLaunchPermitController({ maxTrackedTabs: 2, permitTtlMs: 50 });
70
+ const origin = createGuidedGitActivationController({ claimStart: (tabId, _payload, event, now) => originPermits.consume(tabId, event?.guidedGitLaunchId, now) });
71
+ const otherClient = createGuidedGitActivationController({ claimStart: (tabId, _payload, event, now) => otherClientPermits.consume(tabId, event?.guidedGitLaunchId, now) });
72
+ const starts = [];
73
+
74
+ assert.equal(originPermits.grant("tab-a", ids[1], 100), true);
75
+ assert.equal(otherClientPermits.grant("tab-a", ids[2], 100), true, "two browser clients may independently await server arbitration");
76
+ assert.equal(originPermits.grant("tab-a", ids[3], 101), false, "one browser cannot queue multiple permits for one tab");
77
+ const correlated = request("tab-a", ids[0], { guidedGitLaunchId: ids[1] });
78
+ assert.equal(otherClient.consume(correlated, async () => starts.push("other"), 102).status, "unclaimed", "a concurrent client cannot cross-claim another launch");
79
+ assert.equal(otherClientPermits.inspect().launchIdForTab("tab-a"), ids[2], "wrong envelopes do not consume orphan permits");
80
+ const claimed = origin.consume(correlated, async () => starts.push("origin"), 102);
81
+ assert.equal(claimed.status, "started");
82
+ await claimed.promise;
83
+ assert.deepEqual(starts, ["origin"]);
84
+ assert.equal(originPermits.inspect().hasPermit("tab-a"), false);
85
+ assert.equal(otherClient.consume(request("tab-a", ids[1]), async () => starts.push("missing"), 103).status, "unclaimed", "a missing launch envelope fails closed");
86
+ assert.equal(otherClient.consume(request("tab-a", ids[2], { guidedGitLaunchId: ids[3] }), async () => starts.push("wrong"), 104).status, "unclaimed", "a wrong launch envelope fails closed");
87
+
88
+ assert.equal(otherClientPermits.consume("tab-a", ids[2], 151), false, "expired permits fail closed");
89
+ assert.equal(originPermits.grant("tab-a", ids[0], 300), true);
90
+ assert.equal(originPermits.grant("tab-b", ids[1], 301), true);
91
+ assert.equal(originPermits.grant("tab-c", ids[2], 302), true);
92
+ assert.equal(originPermits.inspect().trackedTabs, 2);
93
+ assert.equal(originPermits.inspect().hasPermit("tab-a"), false, "oldest tab permit is evicted at the count bound");
94
+ originPermits.clearTab("tab-b");
95
+ assert.equal(originPermits.inspect().hasPermit("tab-b"), false);
96
+ });
97
+
98
+ test("Guided Git launch admission recognizes tab-local aliases and refuses every non-idle state", () => {
99
+ const catalog = {
100
+ raw: [{ name: "git-guided-workflow:2", source: "extension", invokeName: "git-guided-workflow:2", duplicateCount: 2 }],
101
+ available: [{ name: "git-guided-workflow", source: "extension", invokeName: "git-guided-workflow:2", duplicateNames: ["git-guided-workflow:2"], duplicateCount: 2 }],
102
+ };
103
+ assert.equal(guidedGitWorkflowCommandForTabCatalog(catalog, "/git-guided-workflow"), true);
104
+ assert.equal(guidedGitWorkflowCommandForTabCatalog(catalog, "/git-guided-workflow:2"), true);
105
+ assert.equal(guidedGitWorkflowCommandForTabCatalog(catalog, "/git-guided-workflow extra"), false);
106
+ assert.equal(guidedGitWorkflowCommandForTabCatalog(catalog, "/other"), false);
107
+ assert.equal(guidedGitLaunchBlockedReason(null, 0), "state-unavailable");
108
+ assert.equal(guidedGitLaunchBlockedReason({ isStreaming: true, isCompacting: false, pendingMessageCount: 0 }, 0), "streaming");
109
+ assert.equal(guidedGitLaunchBlockedReason({ isStreaming: false, isCompacting: true, pendingMessageCount: 0 }, 0), "compacting");
110
+ assert.equal(guidedGitLaunchBlockedReason({ isStreaming: false, isCompacting: false, pendingMessageCount: 1 }, 0), "pending");
111
+ assert.equal(guidedGitLaunchBlockedReason({ isStreaming: false, isCompacting: false, pendingMessageCount: 0 }, 1), "pending");
112
+ assert.equal(guidedGitLaunchBlockedReason({ isStreaming: false, isCompacting: false, pendingMessageCount: 0 }, 0), "");
113
+ });
114
+
115
+ test("activation controller ignores clear and replay, deduplicates per tab, and clears tab state", async () => {
116
+ const controller = createGuidedGitActivationController();
117
+ const starts = [];
118
+ const start = async (tabId) => { starts.push(tabId); };
119
+
120
+ assert.equal(controller.consume({ tabId: "tab-a", statusText: undefined }, start).status, "ignored");
121
+ assert.equal(controller.consume(request("tab-a", ids[0], { replayed: true }), start).status, "ignored");
122
+ const first = controller.consume(request("tab-a"), start, 100);
123
+ assert.equal(first.status, "started");
124
+ await first.promise;
125
+ assert.equal(controller.consume(request("tab-a"), start, 101).status, "duplicate");
126
+ const otherTab = controller.consume(request("tab-b"), start, 102);
127
+ assert.equal(otherTab.status, "started");
128
+ await otherTab.promise;
129
+ assert.deepEqual(starts, ["tab-a", "tab-b"]);
130
+
131
+ controller.clearTab("tab-a");
132
+ const afterClear = controller.consume(request("tab-a"), start, 103);
133
+ assert.equal(afterClear.status, "started");
134
+ await afterClear.promise;
135
+ assert.equal(controller.inspect().seenForTab("tab-a"), 1);
136
+ });
137
+
138
+ test("clearing a tab invalidates ownership held by an asynchronous start", async () => {
139
+ const controller = createGuidedGitActivationController();
140
+ let release;
141
+ const blocked = new Promise((resolve) => { release = resolve; });
142
+ let activationIsCurrent;
143
+ const promise = controller.run("tab-a", async (_tabId, isCurrent) => {
144
+ activationIsCurrent = isCurrent;
145
+ await blocked;
146
+ });
147
+ await Promise.resolve();
148
+ assert.equal(activationIsCurrent(), true);
149
+ controller.clearTab("tab-a");
150
+ assert.equal(activationIsCurrent(), false);
151
+ release();
152
+ await promise;
153
+ assert.equal(controller.inspect().inFlightTabs, 0);
154
+ });
155
+
156
+ test("activation controller folds rapid distinct starts and keeps dedupe storage bounded", async () => {
157
+ const controller = createGuidedGitActivationController({ maxSeenPerTab: 2, maxTrackedTabs: 2, seenTtlMs: 50 });
158
+ let release;
159
+ const blocked = new Promise((resolve) => { release = resolve; });
160
+ let starts = 0;
161
+ const start = async () => { starts += 1; await blocked; };
162
+
163
+ const first = controller.consume(request("tab-a", ids[0]), start, 100);
164
+ const folded = controller.consume(request("tab-a", ids[1]), start, 101);
165
+ assert.equal(first.status, "started");
166
+ assert.equal(folded.status, "folded");
167
+ assert.equal(first.promise, folded.promise);
168
+ await Promise.resolve();
169
+ assert.equal(starts, 1);
170
+ release();
171
+ await first.promise;
172
+
173
+ const third = controller.consume(request("tab-a", ids[2]), async () => {}, 102);
174
+ await third.promise;
175
+ assert.equal(controller.inspect().seenForTab("tab-a"), 2);
176
+ const evicted = controller.consume(request("tab-a", ids[0]), async () => {}, 103);
177
+ assert.equal(evicted.status, "started", "oldest per-tab request is evicted at the bound");
178
+ await evicted.promise;
179
+
180
+ await controller.consume(request("tab-b", ids[0]), async () => {}, 104).promise;
181
+ await controller.consume(request("tab-c", ids[0]), async () => {}, 105).promise;
182
+ assert.equal(controller.inspect().trackedTabs, 2);
183
+
184
+ const expired = controller.consume(request("tab-c", ids[0]), async () => {}, 200);
185
+ assert.equal(expired.status, "started", "expired request IDs may be accepted again");
186
+ await expired.promise;
187
+ });
188
+
189
+ test("originating tab stays authoritative across an active-tab switch", async () => {
190
+ const controller = createGuidedGitActivationController();
191
+ let activeTabId = "tab-a";
192
+ let release;
193
+ const blocked = new Promise((resolve) => { release = resolve; });
194
+ let startedTabId = "";
195
+ const start = controller.consume(request("tab-a"), async (tabId) => {
196
+ await blocked;
197
+ startedTabId = tabId;
198
+ });
199
+ activeTabId = "tab-b";
200
+ release();
201
+ await start.promise;
202
+ assert.equal(activeTabId, "tab-b");
203
+ assert.equal(startedTabId, "tab-a", "the transport envelope tab, not the active browser tab, owns activation");
204
+ });
205
+
206
+ test("RPC resolution falls back to extension aliases when native commands own the base names", () => {
207
+ const catalog = {
208
+ raw: [
209
+ { name: "skills", source: "native", invokeName: "skills" },
210
+ { name: "skills:1", source: "extension", invokeName: "skills:1" },
211
+ { name: "tools", source: "native", invokeName: "tools" },
212
+ { name: "tools:1", source: "extension", invokeName: "tools:1" },
213
+ ],
214
+ available: [
215
+ { name: "skills", source: "native", invokeName: "skills" },
216
+ { name: "skills:1", source: "extension", invokeName: "skills:1" },
217
+ { name: "tools", source: "native", invokeName: "tools" },
218
+ { name: "tools:1", source: "extension", invokeName: "tools:1" },
219
+ ],
220
+ };
221
+
222
+ assert.equal(resolveCommandForTabCatalog(catalog, "skills", { rpcOnly: true })?.name, "skills:1");
223
+ assert.equal(resolveCommandForTabCatalog(catalog, "tools", { rpcOnly: true })?.name, "tools:1");
224
+ assert.equal(resolveRpcSlashCommandForTabCatalog(catalog, "/skills"), "/skills:1");
225
+ assert.equal(resolveRpcSlashCommandForTabCatalog(catalog, "/tools list"), "/tools:1 list");
226
+ });
227
+
228
+ test("tab catalog resolves the duplicate-suffixed command and the exact fallback eligibility", () => {
229
+ const catalog = {
230
+ raw: [
231
+ { name: "git-guided-workflow:2", source: "extension", invokeName: "git-guided-workflow:2", duplicateCount: 2 },
232
+ { name: "git-staged-msg", source: "prompt" },
233
+ ],
234
+ available: [
235
+ { name: "git-guided-workflow", source: "extension", invokeName: "git-guided-workflow:2", duplicateNames: ["git-guided-workflow:2"], duplicateCount: 2 },
236
+ { name: "git-staged-msg", source: "prompt" },
237
+ ],
238
+ };
239
+ assert.equal(resolveCommandForTabCatalog(catalog, "git-guided-workflow", { rpcOnly: true })?.name, "git-guided-workflow:2");
240
+ assert.equal(guidedGitLaunchModeForTabCatalog(catalog), "extension");
241
+ assert.equal(guidedGitLaunchModeForTabCatalog({ raw: [{ name: "git-staged-msg", source: "prompt" }] }), "fallback");
242
+ assert.equal(guidedGitLaunchModeForTabCatalog({ raw: [] }), "unavailable");
243
+ assert.equal(guidedGitLaunchModeForTabCatalog(catalog, { disabled: true }), "disabled");
244
+ });
@@ -373,6 +373,7 @@ await runScenario("artifact-primary-then-fallback", async ({ request, readLog })
373
373
  await waitFor(async () => (await readLog()).some((entry) => entry.type === "set_model" && entry.modelId === "fallback"), "fallback should begin after primary artifacts");
374
374
  const intermediate = await request(`/api/git-workflow/message?generationId=${encodeURIComponent(generationId)}`);
375
375
  assert.equal(intermediate.body.data.ready, false, "failed-primary artifacts must remain pending while fallback runs");
376
+ assert.equal(intermediate.body.data.running, true, "the browser must be told that the correlated fallback generation is still active");
376
377
  await waitFor(async () => (await readLog()).some((entry) => entry.type === "set_model" && entry.modelId === "original"), "fallback artifact generation should settle");
377
378
  const final = await request(`/api/git-workflow/message?generationId=${encodeURIComponent(generationId)}`);
378
379
  assert.equal(final.body.data.ready, true);
@@ -54,7 +54,7 @@ assert.match(readme, /fallback model and its own reasoning effort[\s\S]*tries th
54
54
  assert.match(technical, /## Guided Git generation profiles[\s\S]*strict one-retry policy[\s\S]*model and reasoning effort are restored[\s\S]*dead Pi process cannot run the fallback/i, "technical reference should document configuration and operational limits");
55
55
  assert.match(development, /### Fallback browser\/runtime contract[\s\S]*fallbackUsed: true[\s\S]*webui_git_workflow_generation_fallback_started[\s\S]*never sends a retry/, "development guide should preserve the response/event and browser ownership contract");
56
56
 
57
- assert.match(html, /data-app-src="\/app\.js\?v=166"/, "the changed browser app should use the next query revision");
58
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132";/, "the PWA cache identity should advance with browser behavior");
57
+ assert.match(html, /data-app-src="\/app\.js\?v=175"/, "the changed browser app should use the next query revision");
58
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v142";/, "the PWA cache identity should advance with browser behavior");
59
59
 
60
60
  console.log("guided-git-fallback-ui-static.test.mjs passed");
@@ -15,7 +15,7 @@ assert.match(server, /async function createGitWorkflowMessageGeneration\(tab, ge
15
15
  assert.match(server, /generationId: record\.generationId/, "generation dispatch must return one server-owned correlation ID across every kind and both attempts");
16
16
  assert.match(server, /tab\.gitWorkflowArtifactGeneration = record\.artifactGeneration/, "the artifact generation record must be owned by the originating tab");
17
17
  assert.match(server, /case "\/api\/git-workflow\/message"[\s\S]*generationId[\s\S]*tab\?\.gitWorkflowArtifactGeneration/, "fresh message reads must resolve the correlated generation from the requested tab");
18
- assert.match(server, /readGitWorkflowMessages\(cwd, \{ generationId = "", generation = null \} = \{\}\)[\s\S]*generation\.cwd !== messageCwd[\s\S]*!generation\.terminal[\s\S]*!generation\.successful/, "message readiness must reject wrong identity, active attempts, and terminal failure");
18
+ assert.match(server, /readGitWorkflowMessages\(cwd, \{ generationId = "", generation = null \} = \{\}\)[\s\S]*generation\.cwd !== messageCwd[\s\S]*!generation\.terminal[\s\S]*running: true[\s\S]*!generation\.successful/, "message readiness must reject wrong identity and terminal failure while identifying an active attempt");
19
19
  assert.match(server, /gitMessageArtifactPairReadiness\(generation\.baseline, pair\)[\s\S]*GIT_WORKFLOW_MESSAGE_PAIR_SETTLE_MS[\s\S]*sameGitMessageArtifactPair\(pair, settledPair\)/, "the backend must require both changed artifacts and a stable settled pair");
20
20
  assert.doesNotMatch(app, /newestMtime \+ 10000 < currentWorkflow\.messageRequestedAt/, "freshness must not use the previous wall-clock/mtime tolerance");
21
21
 
@@ -25,6 +25,7 @@ assert.match(app, /function acceptGitWorkflowGenerationCorrelation[\s\S]*generat
25
25
  assert.match(app, /const loadKey = `\$\{expectedRunId\}:\$\{expectedGenerationId \|\| "preview"\}`[\s\S]*existing\?\.key === loadKey[\s\S]*return existing\.promise/, "duplicate timer/resume/agent_end wakeups must reuse one poll promise");
26
26
  assert.match(app, /gitWorkflowMessageLoadIsCurrent\(tabId, expectedRunId, expectedGenerationId\)/, "poll results must be guarded by tab, run, and generation identity");
27
27
  assert.match(app, /GIT_WORKFLOW_MESSAGE_POLL_TIMEOUT_MS = 30_000[\s\S]*GIT_WORKFLOW_MESSAGE_POLL_DELAYS_MS/, "fresh message polling must be adaptive and bounded");
28
+ assert.match(app, /message\.running === true\) deadline = Date\.now\(\) \+ GIT_WORKFLOW_MESSAGE_POLL_TIMEOUT_MS/, "an active fallback generation must renew the artifact-settle deadline instead of forcing manual preview");
28
29
  assert.match(app, /\?generationId=\$\{encodeURIComponent\(expectedGenerationId\)\}/, "fresh commit reads must send the correlation ID to the backend");
29
30
  assert.match(app, /branch-name\$\{query\}[\s\S]*pr-description\$\{query\}/, "fresh branch and PR reads must also send exact generation IDs");
30
31
  assert.match(app, /message\.ready === false[\s\S]*message\.expired[\s\S]*Regenerate/, "pending and expired generation states must remain actionable");
@@ -0,0 +1,31 @@
1
+ import test from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { readFile } from "node:fs/promises";
4
+ import { dirname, join } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { OPTIONAL_FEATURE_BY_ID, OPTIONAL_FEATURE_CATALOG } from "../lib/optional-feature-catalog.mjs";
7
+
8
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
9
+ const app = await readFile(join(root, "public", "app.js"), "utf8");
10
+ const extensionManifest = JSON.parse(await readFile(join(root, "..", "pi-extension-git-guided-workflow", "package.json"), "utf8"));
11
+
12
+ test("Optional Features installs the Guided Git extension that bundles its prompt companion", () => {
13
+ assert.deepEqual(OPTIONAL_FEATURE_BY_ID.get("gitWorkflow"), {
14
+ featureId: "gitWorkflow",
15
+ packageName: "@firstpick/pi-extension-git-guided-workflow",
16
+ expectedSpec: "^0.1.0",
17
+ });
18
+ assert.equal(OPTIONAL_FEATURE_BY_ID.has("gitGuidedWorkflow"), false, "one package install should own the complete Guided Git feature");
19
+ assert.equal(new Set(OPTIONAL_FEATURE_CATALOG.map(({ featureId }) => featureId)).size, OPTIONAL_FEATURE_CATALOG.length);
20
+ assert.equal(new Set(OPTIONAL_FEATURE_CATALOG.map(({ packageName }) => packageName)).size, OPTIONAL_FEATURE_CATALOG.length);
21
+
22
+ assert.equal(extensionManifest.dependencies?.["@firstpick/pi-prompts-git-pr"], "^0.1.6");
23
+ assert.deepEqual(extensionManifest.bundledDependencies, ["@firstpick/pi-prompts-git-pr"]);
24
+ assert.deepEqual(extensionManifest.pi?.prompts, ["./node_modules/@firstpick/pi-prompts-git-pr/prompts"]);
25
+
26
+ assert.match(app, /id: "gitWorkflow"[\s\S]*packageName: "@firstpick\/pi-extension-git-guided-workflow"[\s\S]*capabilityLabel: "\/git-guided-workflow"/u);
27
+ assert.match(app, /\["git-guided-workflow", "gitWorkflow"\][\s\S]*\["git-staged-msg", "gitWorkflow"\]/u);
28
+ assert.match(app, /optionalFeatureAvailability\.gitWorkflow = hasAvailableCommand\("git-guided-workflow"\) \|\| hasAvailableCommand\("git-staged-msg"\);/u);
29
+ assert.match(app, /case "git-workflow": return true;/u, "the browser-owned setup must not depend on a removed prompt command");
30
+ assert.match(app, /case "git-workflow": return openNativeGitWorkflowSetupDialog\(\);/u, "Setup must open the Guided Git workflow dialog");
31
+ });
@@ -1316,6 +1316,9 @@ try {
1316
1316
  const optionalFeatures = await request("127.0.0.1", "/api/optional-features");
1317
1317
  assert.equal(optionalFeatures.status, 200, "optional feature status should load");
1318
1318
  assert.equal(optionalFeatures.body?.data?.features?.length, 20, "the explicit server catalog should expose every allowlisted feature");
1319
+ const guidedGitFeature = optionalFeatures.body?.data?.features?.find((feature) => feature.featureId === "gitWorkflow");
1320
+ assert.equal(guidedGitFeature?.packageName, "@firstpick/pi-extension-git-guided-workflow", "Optional Features must install the extension that bundles the prompt companion");
1321
+ assert.equal(guidedGitFeature?.expectedSpec, "^0.1.0");
1319
1322
  const aurReviewFeature = optionalFeatures.body?.data?.features?.find((feature) => feature.featureId === "aurReview");
1320
1323
  assert.equal(aurReviewFeature?.expectedSpec, "^0.1.1", "status should expose the catalog-owned compatibility spec");
1321
1324
  assert.equal(aurReviewFeature?.installed, true, "workspace discovery should find the local pi-extension-aur-review sibling without an npm dependency");
@@ -186,7 +186,7 @@ const coordinatedTextPoint = functionBody("textPoint", renderer);
186
186
  const logMutation = functionBody("logMutation", renderer);
187
187
 
188
188
  // Coordinator import and initialization.
189
- assert.match(app, /import \{ createTranscriptRenderer \} from "\.\/transcript-renderer\.mjs";/, "app must import the transcript mutation coordinator module");
189
+ assert.match(app, /import \{ createTranscriptRenderer, groupConsecutiveThinkingItems, groupConsecutiveThinkingMessages \} from "\.\/transcript-renderer\.mjs";/, "app must import the transcript mutation coordinator and thinking-group helpers");
190
190
  assert.match(app, /const transcriptRenderer = createTranscriptRenderer\(\{[\s\S]*?chat: elements\.chat[\s\S]*?contextKey: \(\) => chatTextSelectionContextKey\(\)[\s\S]*?\}\);/, "the coordinator must be initialized once against #chat with the transcript context key");
191
191
  assert.doesNotMatch(renderer, /^\s*import\s/m, "the transcript renderer must stay dependency-free");
192
192
  assert.match(renderer, /export function createTranscriptRenderer\(/, "the coordinator must be the module's exported factory");
@@ -95,9 +95,9 @@ assert.match(css, /\.composer-intercom-tag:hover,[\s\S]*\.composer-intercom-tag:
95
95
  assert.match(css, /\.extension-dialog\.intercom-conversation-dialog \{[\s\S]*width: min\(76rem,[\s\S]*height: min\(54rem,/, "the viewer should use a large in-app modal");
96
96
  assert.match(css, /@media \(max-width: 720px\)[\s\S]*\.composer-intercom-tag \{ min-height: 44px;[\s\S]*\.extension-dialog\.intercom-conversation-dialog[\s\S]*width: calc\(100vw - 0\.7rem\)/, "tags and the dialog should remain reachable on narrow and coarse-pointer layouts");
97
97
 
98
- assert.match(html, /\/styles\.css\?v=137/, "the stylesheet URL should advance for the bounded conversation tags");
99
- assert.match(html, /data-app-src="\/app\.js\?v=166"/, "the guarded app URL should advance for current browser wiring");
100
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "the PWA cache identity should advance with browser assets");
98
+ assert.match(html, /\/styles\.css\?v=143/, "the stylesheet URL should advance for the bounded conversation tags");
99
+ assert.match(html, /data-app-src="\/app\.js\?v=175"/, "the guarded app URL should advance for current browser wiring");
100
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v142"/, "the PWA cache identity should advance with browser assets");
101
101
 
102
102
  assert.match(readme, /one compact tag per conversation appears beneath the composer/i, "the README should explain the user-visible entry point");
103
103
  assert.match(technical, /## Agent conversation viewer[\s\S]*Attachments, tool calls and results, thinking, stdout\/stderr, filesystem paths, raw session records/i, "the advanced guide should document privacy exclusions");
@@ -22,8 +22,8 @@ function sourceBetween(startMarker, endMarker, label) {
22
22
 
23
23
  assert.match(
24
24
  html,
25
- /id="mainOutputLoading" class="main-output-loading" role="status" aria-live="polite" aria-atomic="true" aria-controls="chat" hidden>[\s\S]*?main-output-loading-spinner[\s\S]*?Loading agent output…[\s\S]*?<div id="chat" class="chat" aria-live="polite" aria-busy="false">/,
26
- "the main output should own an inline, accessible loading status before the transcript",
25
+ /class="main-output-surface">[\s\S]*?id="mainOutputLoading" class="main-output-loading" role="status" aria-live="polite" aria-atomic="true" aria-controls="chat" hidden>[\s\S]*?main-output-loading-spinner[\s\S]*?Loading agent output…[\s\S]*?<div id="chat" class="chat" aria-live="polite" aria-busy="false">/,
26
+ "the main output surface should own an accessible loading status over the transcript",
27
27
  );
28
28
  assert.doesNotMatch(html, /<dialog[^>]+id="mainOutputLoading"/, "loading feedback must not use a popup dialog");
29
29
  assert.match(app, /mainOutputLoading: \$\("#mainOutputLoading"\)/, "the browser should bind the inline status element");
@@ -42,17 +42,19 @@ assert.match(refreshMessages, /const loadingRequest = beginMainOutputLoading\(ta
42
42
  assert.match(refreshMessages, /finally \{\s*finishMainOutputLoading\(loadingRequest\);\s*\}/, "success, failure, and stale responses should all clear their request token");
43
43
  assert.match(app, /activeTabId = nextTabId;\s*renderMainOutputLoading\(\);/, "tab changes should immediately reconcile stale and current request visibility");
44
44
 
45
- assert.match(css, /\.main-output-loading\[hidden\] \{ display: none !important; \}/, "hidden loading feedback should not consume layout space");
46
- assert.match(css, /\.main-output-loading \{[\s\S]*?pointer-events: none;[\s\S]*?font-size: var\(--text-xs\)/, "the inline status should remain compact and non-blocking");
45
+ assert.match(css, /\.main-output-loading\[hidden\] \{ display: none !important; \}/, "hidden loading feedback should not render");
46
+ assert.match(css, /\.main-output-surface \{[\s\S]*?position: relative;[\s\S]*?flex: 1 1 auto;[\s\S]*?min-height: 0;/, "the transcript and loading status should share one stable layout surface");
47
+ assert.match(css, /\.main-output-loading \{[\s\S]*?position: absolute;[\s\S]*?left: 50%;[\s\S]*?transform: translateX\(-50%\);[\s\S]*?pointer-events: none;/, "the loading status should overlay the transcript without changing its layout");
48
+ assert.match(css, /\.main-output-loading \{[\s\S]*?font-size: var\(--text-xs\)/, "the loading status should remain compact");
47
49
  assert.match(css, /\.main-output-loading-spinner \{[\s\S]*?animation: main-output-loading-spin 780ms linear infinite/, "the status should include a visible spinner animation");
48
50
  assert.match(css, /@keyframes main-output-loading-spin/, "the spinner should have a local animation contract");
49
51
  assert.match(css, /@media \(prefers-reduced-motion: reduce\)[\s\S]*?animation-duration: 1ms !important;[\s\S]*?animation-iteration-count: 1 !important;/, "the existing reduced-motion policy should stop repeated spinner motion");
50
- assert.match(css, /body\.terminal-tabs-left \.main-output-loading,[\s\S]*?body\.terminal-tabs-left \.chat \{ grid-row: 4; \}/, "sidebar tab placement should keep the status inside the transcript grid row");
51
- assert.match(css, /body\.subagent-terminal-active \.main-output-loading,/, "main-output loading feedback should stay hidden in the dedicated subagent view");
52
+ assert.match(css, /body\.terminal-tabs-left \.main-output-surface \{ grid-row: 4; \}/, "sidebar tab placement should keep the stable output surface in the transcript grid row");
53
+ assert.match(css, /body\.subagent-terminal-active \.main-output-surface,/, "the main output surface should stay hidden in the dedicated subagent view");
52
54
 
53
- assert.match(html, /styles\.css\?v=137/, "the stylesheet cache query should advance");
54
- assert.match(html, /app\.js\?v=166/, "the app cache query should advance");
55
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "the PWA cache identity should advance with browser assets");
55
+ assert.match(html, /styles\.css\?v=143/, "the stylesheet cache query should advance");
56
+ assert.match(html, /app\.js\?v=175/, "the app cache query should advance");
57
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v142"/, "the PWA cache identity should advance with browser assets");
56
58
  assert.match(readme, /Loading agent output/, "user documentation should describe the visible loading feedback");
57
59
  assert.match(development, /main output loading/i, "developer documentation should preserve the request-ownership contract");
58
60
 
@@ -16,9 +16,9 @@ assert.match(app, /import \{ installMiddleButtonDragScroll \} from "\.\/middle-b
16
16
  assert.match(app, /installMiddleButtonDragScroll\(\{[\s\S]*onDirection: \(\{ target, offsetY \}\)[\s\S]*noteChatUserScrollIntent\(\{ type: "middle-drag", deltaY: offsetY \}\)/, "chat auto-scroll direction should feed the existing follow/pause intent state");
17
17
  assert.match(app, /event\?\.type === "middle-drag"\) return event\.deltaY > 0;/, "moving below the press point should be recognized as intent to read later chat output");
18
18
  assert.match(css, /body\.middle-button-auto-scrolling,[\s\S]*cursor: all-scroll !important;[\s\S]*user-select: none !important;/, "active automatic scrolling should expose a directional-scroll affordance and suppress accidental selection");
19
- assert.match(html, /styles\.css\?v=137/, "changed drag-scroll styles should advance the stylesheet revision");
20
- assert.match(html, /app\.js\?v=166/, "changed drag-scroll wiring should advance the app revision");
21
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132";[\s\S]*"\/middle-button-drag-scroll\.mjs"/, "offline PWA installs should refresh and cache the new controller module");
19
+ assert.match(html, /styles\.css\?v=143/, "changed drag-scroll styles should advance the stylesheet revision");
20
+ assert.match(html, /app\.js\?v=175/, "changed drag-scroll wiring should advance the app revision");
21
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v142";[\s\S]*"\/middle-button-drag-scroll\.mjs"/, "offline PWA installs should refresh and cache the new controller module");
22
22
  assert.match(JSON.parse(packageJson).scripts.check, /node --check public\/middle-button-drag-scroll\.mjs/, "the package check should parse the startup-critical controller module");
23
23
 
24
24
  console.log("middle-button-drag-scroll-static.test.mjs passed");
@@ -47,9 +47,9 @@ assert.match(css, /html\[data-tablet-shell="v2"\] \.mobile-shell-nav[\s\S]*?widt
47
47
  assert.match(css, /html\[data-tablet-shell="v2"\] \.mobile-shell-surface[\s\S]*?width: min\(30rem, 72vw\)/, "tablet inspector must be a bounded right-side sheet");
48
48
  assert.match(css, /html\[data-tablet-shell="v2"\] \.file-viewer-pane[\s\S]*?position: fixed[\s\S]*?inset: 0/, "tablet files must default to full-screen replacement");
49
49
  assert.match(css, /and \(pointer: coarse\)[\s\S]*?min-height: 44px/, "coarse tablet pointers must retain the 44px target floor");
50
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "continuity/tablet assets need a coherent cache identity");
51
- assert.match(html, /styles\.css\?v=137/, "tablet CSS must have a coherent HTML revision");
52
- assert.match(html, /app\.js\?v=166/, "continuity app logic must have a coherent HTML revision");
50
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v142"/, "continuity/tablet assets need a coherent cache identity");
51
+ assert.match(html, /styles\.css\?v=143/, "tablet CSS must have a coherent HTML revision");
52
+ assert.match(html, /app\.js\?v=175/, "continuity app logic must have a coherent HTML revision");
53
53
  assert.match(technical, /tabletShell=v2[\s\S]*tabletShell=legacy/, "technical reference should document tablet preview and rollback");
54
54
 
55
55
  console.log("mobile-continuity-tablet-static.test.mjs passed");
@@ -37,9 +37,9 @@ assert.match(pkg.scripts.check, /node --check public\/transcript-renderer\.mjs/,
37
37
  assert.match(server, /STATIC_PUBLIC_FILE_EXTENSIONS[\s\S]*"\.mjs"/, "the server must serve typed startup modules from the public asset boundary");
38
38
  assert.match(serviceWorker, /"\/mobile-shell-state\.mjs"/, "the PWA shell must cache the new startup module");
39
39
  assert.match(serviceWorker, /"\/transcript-renderer\.mjs"/, "the PWA shell must cache the transcript startup module");
40
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "the cache identity must change with the startup graph");
41
- assert.match(html, /styles\.css\?v=137/, "the stylesheet revision must change with mobile/tablet CSS fixes");
42
- assert.match(html, /app\.js\?v=166/, "the app revision must change with continuity/tablet wiring");
40
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v142"/, "the cache identity must change with the startup graph");
41
+ assert.match(html, /styles\.css\?v=143/, "the stylesheet revision must change with mobile/tablet CSS fixes");
42
+ assert.match(html, /app\.js\?v=175/, "the app revision must change with continuity/tablet wiring");
43
43
  assert.match(serviceWorker, /const APP_SHELL_NETWORK_TIMEOUT_MS = 8_000;[\s\S]*?event\.waitUntil\([\s\S]*?cache\.put\(request, response\.clone\(\)\)[\s\S]*?return networkResponse;/, "runtime cache writes must extend the event lifetime without blocking bounded network responses");
44
44
  assert.match(serviceWorker, /MOBILE_NAVIGATION_MESSAGE_TYPE = "pi-webui:navigate:v1"/, "the service worker must use a versioned active-client navigation message");
45
45
  assert.match(serviceWorker, /client\.postMessage\(\{ type: MOBILE_NAVIGATION_MESSAGE_TYPE, target \}\)/, "existing clients must receive only a validated target message");
@@ -60,6 +60,6 @@ assert.match(css, /data-mobile-presentation="essential"/, "Essential presentatio
60
60
  assert.match(css, /html\[data-mobile-shell="v2"\] body\.mobile-keyboard-open \.widget-area,[\s\S]*?\.composer-actions-button \{ display: block !important; \}/, "v2 keyboard mode must keep run widgets and the actions entry available");
61
61
  assert.match(css, /@media \(prefers-reduced-motion: reduce\)/, "reduced-motion behavior is required");
62
62
  assert.match(css, /@media \(forced-colors: active\)/, "forced-color affordances are required");
63
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "browser asset changes need a coherent cache tuple");
63
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v142"/, "browser asset changes need a coherent cache tuple");
64
64
 
65
65
  console.log("mobile-phone-experience-static.test.mjs passed");
@@ -310,6 +310,22 @@ assert.equal(
310
310
  "side-panel section panels should be hidden by default",
311
311
  );
312
312
  assert.match(html, /id="jumpToLatestButton"/, "chat should expose a jump-to-latest control for non-forced streaming");
313
+ assert.match(
314
+ html,
315
+ /<div class="main-output-surface">[\s\S]*?<div id="chat"[\s\S]*?<\/div>\s*<button id="jumpToLatestButton"[\s\S]*?<\/button>\s*<\/div>\s*<div id="runIndicatorHost"/,
316
+ "jump-to-latest should overlay the output surface above the separate run indicator",
317
+ );
318
+ assert.match(
319
+ css,
320
+ /\.jump-to-latest-button \{[\s\S]*?position: absolute;[\s\S]*?z-index: 14;[\s\S]*?bottom: 0\.75rem;[\s\S]*?left: 50%;[\s\S]*?transform: translateX\(-50%\);/,
321
+ "jump-to-latest should stay centered in the top overlay layer without taking a layout row",
322
+ );
323
+ assert.match(
324
+ css,
325
+ /\.jump-to-latest-button:hover \{[\s\S]*?transform: translateX\(-50%\) translateY\(-1px\);[\s\S]*?\.jump-to-latest-button:active \{[\s\S]*?transform: translateX\(-50%\) translateY\(0\);/,
326
+ "jump-to-latest hover and press feedback should preserve horizontal centering",
327
+ );
328
+ assert.doesNotMatch(css, /terminal-tabs-left \.jump-to-latest-button \{ grid-row:/, "sidebar terminal layout should not assign the overlay its own row");
313
329
  assert.match(html, /id="stickyUserPromptButton"/, "chat should expose a fixed last-user-prompt jump control");
314
330
  assert.match(html, /id="feedbackTray"/, "chat should expose a queued action-feedback tray");
315
331
  assert.match(html, /id="sendFeedbackButton"/, "action feedback should be submittable after the agent finishes");
@@ -1269,7 +1285,7 @@ const clearFinishedContext = {
1269
1285
  async api(path, options) { clearFinishedCalls.push({ path, options }); },
1270
1286
  async refreshSubagents() { clearFinishedRefreshes += 1; },
1271
1287
  scheduleRefreshSubagents() {},
1272
- addEvent(message, level) { clearFinishedEvents.push({ message, level }); },
1288
+ addEvent(message, level, options = {}) { clearFinishedEvents.push({ message, level, options }); },
1273
1289
  };
1274
1290
  vm.runInNewContext(`${app.slice(clearFinishedSourceStart, clearFinishedSourceEnd)}\nthis.runClearFinishedSubagentRuns = clearFinishedSubagentRuns;`, clearFinishedContext);
1275
1291
  await clearFinishedContext.runClearFinishedSubagentRuns();
@@ -1280,10 +1296,73 @@ assert.deepEqual(JSON.parse(JSON.stringify(clearFinishedCalls)), [
1280
1296
  ], "clear-finished should call the existing dismiss endpoint only for visible terminal ordinary runs");
1281
1297
  assert.equal(clearFinishedRefreshes, 1, "clear-finished should refresh the overview once after all dismissals");
1282
1298
  assert.equal(clearFinishedContext.subagentsClearingFinished, false, "clear-finished should always release its in-flight guard");
1283
- assert.deepEqual(clearFinishedEvents, [{ message: "cleared 3 finished subagent runs", level: "info" }]);
1299
+ assert.deepEqual(clearFinishedEvents, [{ message: "cleared 3 finished subagent runs", level: "info", options: {} }]);
1284
1300
  clearFinishedContext.latestSubagents = { tabs: [{ tabId: "tab-c", runs: [{ id: "done-c", status: "done", source: "async" }] }] };
1285
1301
  await clearFinishedContext.runClearFinishedSubagentRuns({ automatic: true });
1286
- assert.deepEqual(clearFinishedEvents.at(-1), { message: "auto-cleared 1 finished subagent run", level: "info" }, "automatic clearing should identify its action without changing terminal-run selection semantics");
1302
+ assert.deepEqual(JSON.parse(JSON.stringify(clearFinishedEvents.at(-1))), {
1303
+ message: "auto-cleared",
1304
+ level: "info",
1305
+ options: {
1306
+ aggregateKey: "subagent-auto-clear",
1307
+ aggregateIncrement: 1,
1308
+ aggregateSingular: "finished subagent run",
1309
+ aggregatePlural: "finished subagent runs",
1310
+ },
1311
+ }, "automatic clearing should use one keyed event whose cleared-run counter can accumulate");
1312
+ const addEventSource = appFunctionSource("addEvent", "closeEventTreeContextMenu");
1313
+ assert.match(addEventSource, /eventAggregateKey === stableAggregateKey[\s\S]*eventAggregateCount[\s\S]*priorAggregate\?\.remove\(\)[\s\S]*eventLog\.prepend\(line\)/, "keyed events should replace their prior row, retain a cumulative count, and return to the top of the log");
1314
+ assert.match(addEventSource, /aggregateCount === 1 \? aggregateSingular : aggregatePlural/, "aggregate rows should keep singular and plural summaries accurate");
1315
+ const aggregateEventLog = {
1316
+ children: [],
1317
+ prepend(node) {
1318
+ node.parent = this;
1319
+ this.children.unshift(node);
1320
+ },
1321
+ get lastElementChild() { return this.children.at(-1) || null; },
1322
+ };
1323
+ function aggregateEventNode(_tag, className = "", text = "") {
1324
+ return {
1325
+ className,
1326
+ dataset: {},
1327
+ children: [],
1328
+ attributes: {},
1329
+ textContent: text,
1330
+ classList: { contains: (value) => className.split(/\s+/).includes(value) },
1331
+ append(...children) {
1332
+ this.children.push(...children);
1333
+ this.textContent += children.map((child) => child?.textContent || "").join("");
1334
+ },
1335
+ setAttribute(name, value) { this.attributes[name] = String(value); },
1336
+ addEventListener() {},
1337
+ remove() {
1338
+ if (!this.parent) return;
1339
+ this.parent.children = this.parent.children.filter((child) => child !== this);
1340
+ this.parent = null;
1341
+ },
1342
+ };
1343
+ }
1344
+ const aggregateEventContext = {
1345
+ elements: { eventLog: aggregateEventLog },
1346
+ make: aggregateEventNode,
1347
+ applyEventFilter() {},
1348
+ jumpToChatEvent() {},
1349
+ showNoticeToast() {},
1350
+ noteUnreadEvent() {},
1351
+ };
1352
+ vm.runInNewContext(`${addEventSource}\nthis.runAddEvent = addEvent;`, aggregateEventContext);
1353
+ const aggregateOptions = {
1354
+ aggregateKey: "subagent-auto-clear",
1355
+ aggregateIncrement: 1,
1356
+ aggregateSingular: "finished subagent run",
1357
+ aggregatePlural: "finished subagent runs",
1358
+ };
1359
+ aggregateEventContext.runAddEvent("auto-cleared", "info", aggregateOptions);
1360
+ aggregateEventContext.runAddEvent("unrelated event", "info");
1361
+ aggregateEventContext.runAddEvent("auto-cleared", "info", { ...aggregateOptions, aggregateIncrement: 2 });
1362
+ assert.equal(aggregateEventLog.children.length, 2, "repeated keyed events should occupy one row alongside unrelated events");
1363
+ assert.equal(aggregateEventLog.children[0].dataset.eventAggregateCount, "3", "the keyed row should accumulate the supplied run counts");
1364
+ assert.equal(aggregateEventLog.children[0].children[0].children[1].textContent, "auto-cleared 3 finished subagent runs", "the keyed row should show its current cumulative count");
1365
+ assert.equal(aggregateEventLog.children[1].children[0].children[1].textContent, "unrelated event", "updating a keyed row should not remove unrelated history");
1287
1366
  assert.match(app, /function materializeRetainedSubagentTerminalViews\(\)[\s\S]*subagentOverviewGroups\(\)[\s\S]*restoreKey = `\$\{tab\.tabId\}\\u0000\$\{tab\.sessionFile[\s\S]*tab\.displayRuns[\s\S]*\["queued", "running", "stale"\]\.includes\(subagentAgentStatus\(run\)\)[\s\S]*ensureSubagentTerminalView/, "terminal mode should materialize only ungated restored retained agent views once per parent session identity without touching overlay mode");
1288
1367
  assert.match(app, /from "\.\/subagent-launch-slot-state\.mjs"[\s\S]*function renderSubagentLaunchSlots\(\)[\s\S]*function loadSubagentLaunchSlotConfig\([\s\S]*\/api\/subagents\/config/, "launch-slot configuration should have its own browser state and API loader");
1289
1368
  assert.match(app, /function subagentLaunchSlotThinkingForModel\(model\)[\s\S]*modelThinkingLevels/, "launch-slot thinking choices should come from the selected model metadata");
@@ -1759,7 +1838,8 @@ assert.match(app, /if \(!isOptionalFeatureDetected\("todoProgressWidget"\)\) ret
1759
1838
  assert.match(app, /const releasePrompt = detectedReleasePrompt && isOptionalFeatureEnabled\(detectedReleasePrompt\.featureId\) \? detectedReleasePrompt : null/, "release confirmation dialogs should use specialized rendering only when their release optional feature is enabled");
1760
1839
  assert.match(app, /case "webui_tab_reloaded":[\s\S]*resetOptionalFeatureAvailability\(\)/, "optional feature state should reset when the RPC tab reloads resources");
1761
1840
  assert.match(app, /function runPublishWorkflow\(command\)[\s\S]*resolveAvailableCommandName\(commandName, \{ rpcOnly: true \}\)/, "publish workflow launch should guard on loaded slash commands, including duplicate-suffixed RPC command names");
1762
- assert.match(app, /if \(!isOptionalFeatureEnabled\("gitWorkflow"\)\)/, "guided git workflow should guard on enabled /git-staged-msg feature");
1841
+ assert.match(app, /function guidedGitPromptCompanionAvailable\(tabId\)[\s\S]*hasLoadedRpcCommand\("git-staged-msg", \{ tabId \}\)/, "guided Git must guard the full browser workflow on the originating tab's prompt companion");
1842
+ assert.match(app, /function launchGuidedGitWorkflow\(tabId = activeTabId\)[\s\S]*resolveAvailableCommandName\("git-guided-workflow", \{ tabId, rpcOnly: true \}\)/, "guided Git visible entry points should prefer the tab-local extension command");
1763
1843
  assert.doesNotMatch(html, /gitWorkflowProcessSelect/, "guided git workflow should not expose process selection as a dropdown");
1764
1844
  assert.match(app, /const GIT_WORKFLOW_PROCESSES = \[[\s\S]*value: "stage", label: "Stage"[\s\S]*value: "message", label: "Message"[\s\S]*value: "commit", label: "Commit"[\s\S]*value: "push", label: "Push"/, "guided git workflow should define Stage/Message/Commit/Push process buttons");
1765
1845
  assert.match(app, /function selectGitWorkflowProcess\(processValue, tabId = gitWorkflowActionTabId\(\)\)[\s\S]*process === "commit"[\s\S]*loadGitWorkflowMessage\(\{ requireFresh: false, runId, tabId \}\)/, "guided git workflow process buttons should jump to Commit by loading current generated message files");
@@ -2362,6 +2442,7 @@ assert.match(extension, /if \(openTabSources\.length > 0\) return mergeRestorabl
2362
2442
  assert.match(extension, /return mergeRestorableTabsFromStatusSources\(\[statusData\?\.restorableTabs, existing\.restorableTabs\], options\)/, "launcher should use restorableTabs only as a legacy fallback");
2363
2443
  assert.match(extension, /env\.PI_WEBUI_RESTORE_FILE = \(await createRestoreFile\(agentDir, restoreTabs\)\)\.file/, "launcher should pass restorable tabs through a private read-once file");
2364
2444
  assert.match(extension, /pi\.registerCommand\("webui-start"/, "extension should expose the canonical /webui-start command");
2445
+ assert.match(extension, /const child = spawn\(nodeExecutable, args, \{/, "/webui-start should use Node instead of treating a standalone Pi executable as a JavaScript runtime");
2365
2446
  assert.match(extension, /pi\.registerCommand\("webui-tree-navigate"/, "extension should expose the internal Web UI tree navigation command");
2366
2447
  assert.match(extension, /ctx\.navigateTree\(payload\.entryId/, "internal Web UI tree command should call the native session tree navigation API");
2367
2448
  assert.doesNotMatch(extension, /pi\.registerCommand\("start-webui"/, "extension should not expose the older /start-webui alias");
@@ -68,7 +68,7 @@ assert.match(server, /STATIC_PUBLIC_FILE_EXTENSIONS[\s\S]*"\.mjs"/, "the server
68
68
  assert.match(serviceWorker, /"\/issue-wizard-state\.mjs"/, "the PWA shell must keep caching the pure wizard module");
69
69
  assert.match(serviceWorker, /"\/issue-bot-client\.mjs"/, "the PWA shell must cache the browser client module");
70
70
  // Intent preserved: changing the public startup graph advances the PWA cache identity.
71
- assert.match(serviceWorker, /pi-webui-pwa-v132/, "the PWA cache name must change with browser wiring updates");
71
+ assert.match(serviceWorker, /pi-webui-pwa-v142/, "the PWA cache name must change with browser wiring updates");
72
72
  assert.match(packageJson, /node --check public\/issue-wizard-state\.mjs/, "the package check must keep syntax-checking the pure wizard module");
73
73
  assert.match(packageJson, /node --check public\/issue-bot-client\.mjs/, "the package check must syntax-check the browser client module");
74
74
 
@@ -271,8 +271,8 @@ assert.match(
271
271
 
272
272
  // --- Coherent browser asset revisions --------------------------------------
273
273
 
274
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "changed browser assets should advance the PWA cache identity");
275
- assert.match(html, /styles\.css\?v=137/, "the page should request the updated layout stylesheet revision");
276
- assert.match(html, /data-app-src="\/app\.js\?v=166"/, "the boot loader should request the updated app module revision");
274
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v142"/, "changed browser assets should advance the PWA cache identity");
275
+ assert.match(html, /styles\.css\?v=143/, "the page should request the updated layout stylesheet revision");
276
+ assert.match(html, /data-app-src="\/app\.js\?v=175"/, "the boot loader should request the updated app module revision");
277
277
 
278
278
  console.log("persistent-ui-layout-static.test.mjs passed");