@firstpick/pi-package-webui 0.6.9 → 0.7.0

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.
@@ -4,9 +4,11 @@
4
4
  import { createInterface } from "node:readline";
5
5
 
6
6
  const COMPACTION_TRIGGER = "__pi_webui_test_start_compaction__";
7
+ const ABORTED_COMPACTION_TRIGGER = "__pi_webui_test_start_aborted_compaction__";
7
8
 
8
9
  let isCompacting = false;
9
10
  let compactionTimer = null;
11
+ let compactionWillAbort = false;
10
12
  const received = [];
11
13
 
12
14
  function respond(payload) {
@@ -37,18 +39,21 @@ function statePayload() {
37
39
  function finishCompaction() {
38
40
  compactionTimer = null;
39
41
  isCompacting = false;
42
+ const aborted = compactionWillAbort;
43
+ compactionWillAbort = false;
40
44
  emit({
41
45
  type: "compaction_end",
42
46
  reason: "test",
43
- result: { summary: "fake compaction summary", tokensBefore: 1000, estimatedTokensAfter: 100 },
44
- aborted: false,
47
+ result: aborted ? null : { summary: "fake compaction summary", tokensBefore: 1000, estimatedTokensAfter: 100 },
48
+ aborted,
45
49
  willRetry: false,
46
50
  });
47
51
  }
48
52
 
49
- function startCompaction() {
53
+ function startCompaction({ aborted = false } = {}) {
50
54
  if (compactionTimer) clearTimeout(compactionTimer);
51
55
  isCompacting = true;
56
+ compactionWillAbort = aborted;
52
57
  emit({ type: "compaction_start", reason: "test" });
53
58
  compactionTimer = setTimeout(finishCompaction, 1500);
54
59
  }
@@ -91,8 +96,8 @@ rl.on("line", (line) => {
91
96
  return;
92
97
  case "prompt": {
93
98
  const message = String(command.message || "");
94
- if (message === COMPACTION_TRIGGER) {
95
- startCompaction();
99
+ if (message === COMPACTION_TRIGGER || message === ABORTED_COMPACTION_TRIGGER) {
100
+ startCompaction({ aborted: message === ABORTED_COMPACTION_TRIGGER });
96
101
  respond({ ...base, data: { compacting: true } });
97
102
  return;
98
103
  }
@@ -261,6 +261,26 @@ function handleWebuiHelperPrompt(command, base) {
261
261
  currentToolArgs: "README.md",
262
262
  recentTools: [{ tool: "grep", args: "Subagents", endMs: Date.now() - 200 }],
263
263
  recentOutput: ["Inspecting current implementation", "Waiting for the next tool result"],
264
+ transcript: [
265
+ {
266
+ role: "assistant",
267
+ timestamp: "2026-07-19T12:00:00.000Z",
268
+ content: [
269
+ { type: "thinking", thinking: "Checking the fixture transcript." },
270
+ { type: "text", text: "Inspecting current implementation" },
271
+ { type: "toolCall", id: "fixture-read", name: "read", arguments: { path: "README.md", offset: 1 } },
272
+ { type: "text", text: "Waiting for the next tool result" },
273
+ ],
274
+ },
275
+ {
276
+ role: "toolResult",
277
+ timestamp: "2026-07-19T12:00:01.000Z",
278
+ toolCallId: "fixture-read",
279
+ toolName: "read",
280
+ isError: false,
281
+ content: [{ type: "text", text: "# Fixture README" }],
282
+ },
283
+ ],
264
284
  turnCount: 2,
265
285
  toolCount: 3,
266
286
  tokens: 420,
@@ -285,6 +305,31 @@ function handleDocumentArtifactFixturePrompt(command, base) {
285
305
  return true;
286
306
  }
287
307
 
308
+ function handleTransportFixturePrompt(command, base) {
309
+ const message = String(command.message || "").trim();
310
+ if (message === "fixture stderr diagnostic") {
311
+ process.stderr.write("fixture Pi RPC stderr diagnostic\n");
312
+ respond({ ...base, data: { output: "fake stderr diagnostic emitted" } });
313
+ return true;
314
+ }
315
+ if (message === "fixture oversized jsonl") {
316
+ const bytes = Math.max(0, Math.min(64 * 1024 * 1024, Number.parseInt(process.env.FAKE_PI_OVERSIZED_JSONL_BYTES || "0", 10) || 0));
317
+ if (bytes === 0) {
318
+ respond({ ...base, success: false, error: "FAKE_PI_OVERSIZED_JSONL_BYTES must be configured" });
319
+ return true;
320
+ }
321
+ // Intentionally leave this physical JSONL line unterminated long enough
322
+ // for the server to switch into discard mode before sending a valid reply.
323
+ process.stdout.write("x".repeat(bytes));
324
+ setTimeout(() => {
325
+ process.stdout.write("\n");
326
+ respond({ ...base, data: { output: "fake oversized JSONL line discarded" } });
327
+ }, 50);
328
+ return true;
329
+ }
330
+ return false;
331
+ }
332
+
288
333
  function handleSubagentFixturePrompt(command, base) {
289
334
  const message = String(command.message || "").trim();
290
335
  if (message !== "fixture subagents running" && message !== "fixture subagents clear") return false;
@@ -447,6 +492,7 @@ rl.on("line", (line) => {
447
492
  }
448
493
  case "prompt":
449
494
  if (handleWebuiHelperPrompt(command, base)) return;
495
+ if (handleTransportFixturePrompt(command, base)) return;
450
496
  if (handleSubagentFixturePrompt(command, base)) return;
451
497
  if (handleDocumentArtifactFixturePrompt(command, base)) return;
452
498
  if (handleWorkflowFixturePrompt(command, base)) return;
@@ -0,0 +1,183 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFile } from "node:fs/promises";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import {
6
+ guidedGitReviewCanRequestStagedContent,
7
+ guidedGitReviewHasApprovedBinding,
8
+ guidedGitReviewProcessNavigationAllowed,
9
+ guidedGitReviewProcessSelectionPatch,
10
+ guidedGitReviewTransition,
11
+ guidedGitReviewWidgetRemovalTransition,
12
+ } from "../public/guided-git-review-state.mjs";
13
+ import { guidedGitReviewAvailableForTabCatalog, resolveRpcSlashCommandForTabCatalog } from "../public/guided-git-command-state.mjs";
14
+
15
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
16
+ const app = await readFile(join(root, "public", "app.js"), "utf8");
17
+ const fingerprint = "a".repeat(64);
18
+ const stagedContentHash = "c".repeat(64);
19
+ const repoRoot = "/workspace/repository";
20
+ const pendingPayload = {
21
+ scope: "staged",
22
+ origin: "guided-git",
23
+ repoRoot,
24
+ fingerprint,
25
+ stagedContentHash,
26
+ updatedAt: "2026-06-01T00:00:02.000Z",
27
+ decision: { state: "pending" },
28
+ };
29
+ const requestingWorkflow = {
30
+ active: true,
31
+ step: "reviewRequesting",
32
+ guidedReviewStatus: "requesting",
33
+ guidedReviewRequestedAt: Date.parse("2026-06-01T00:00:01.000Z"),
34
+ guidedReviewFingerprint: "",
35
+ guidedReviewRepoRoot: "",
36
+ guidedReviewStagedContentHash: "",
37
+ guidedReviewDeclinedStagedContentHash: "",
38
+ };
39
+ const pendingWorkflow = {
40
+ ...requestingWorkflow,
41
+ step: "review",
42
+ guidedReviewStatus: "pending",
43
+ guidedReviewRequired: true,
44
+ guidedReviewFingerprint: fingerprint,
45
+ guidedReviewRepoRoot: repoRoot,
46
+ guidedReviewStagedContentHash: stagedContentHash,
47
+ };
48
+
49
+ assert.equal(guidedGitReviewTransition(requestingWorkflow, pendingPayload), "pending", "only a fresh staged/guided-git pending payload may bind a request");
50
+ assert.equal(guidedGitReviewTransition(pendingWorkflow, { ...pendingPayload, decision: { state: "approved", decidedAt: "2026-06-01T00:00:03.000Z", reviewedFingerprint: fingerprint, reviewedStagedContentHash: stagedContentHash } }), "approved", "matching approval may advance the matching flow");
51
+ assert.equal(guidedGitReviewTransition(pendingWorkflow, { ...pendingPayload, decision: { state: "declined", decidedAt: "2026-06-01T00:00:03.000Z", reviewedFingerprint: fingerprint, reviewedStagedContentHash: stagedContentHash } }), "declined", "matching decline must reset the matching flow");
52
+ assert.equal(guidedGitReviewTransition(pendingWorkflow, { ...pendingPayload, decision: { state: "closed" } }), "closed", "a matching closed payload must return the pending flow to recovery without approval");
53
+ assert.equal(guidedGitReviewTransition(requestingWorkflow, { ...pendingPayload, decision: { state: "closed" } }), "closed", "a freshly requested review may close before its pending card is replayed");
54
+ assert.equal(guidedGitReviewTransition(pendingWorkflow, { ...pendingPayload, origin: "standalone", scope: "working-tree", decision: { state: "approved", decidedAt: "2026-06-01T00:00:03.000Z", reviewedFingerprint: fingerprint, reviewedStagedContentHash: stagedContentHash } }), "ignore", "standalone payloads cannot advance Guided Git");
55
+ assert.equal(guidedGitReviewTransition(pendingWorkflow, { ...pendingPayload, fingerprint: "b".repeat(64), decision: { state: "approved", decidedAt: "2026-06-01T00:00:03.000Z", reviewedFingerprint: "b".repeat(64), reviewedStagedContentHash: stagedContentHash } }), "ignore", "a stale/wrong review cannot advance Guided Git");
56
+ assert.equal(guidedGitReviewTransition(pendingWorkflow, { ...pendingPayload, decision: { state: "approved", decidedAt: "2026-06-01T00:00:03.000Z", reviewedFingerprint: fingerprint, reviewedStagedContentHash: "d".repeat(64) } }), "ignore", "approval must bind the exact staged-content hash");
57
+ assert.equal(guidedGitReviewTransition({ ...pendingWorkflow, active: false }, { ...pendingPayload, decision: { state: "approved", decidedAt: "2026-06-01T00:00:03.000Z", reviewedFingerprint: fingerprint, reviewedStagedContentHash: stagedContentHash } }), "ignore", "a payload for another tab's inactive flow cannot advance this tab");
58
+ assert.equal(guidedGitReviewWidgetRemovalTransition(pendingWorkflow), "closed", "clearing a matching pending widget is equivalent to close");
59
+ assert.equal(guidedGitReviewWidgetRemovalTransition({ ...pendingWorkflow, step: "add", guidedReviewStatus: "" }), "ignore", "a replayed widget removal cannot disturb a recovered staging flow");
60
+
61
+ const freshAvailableWorkflow = {
62
+ ...requestingWorkflow,
63
+ step: "add",
64
+ process: "stage",
65
+ guidedReviewRequired: true,
66
+ };
67
+ for (const process of ["message", "commit", "push"]) {
68
+ assert.equal(guidedGitReviewProcessNavigationAllowed(requestingWorkflow, process), false, `${process} navigation must be rejected while review request is outstanding`);
69
+ assert.equal(guidedGitReviewProcessNavigationAllowed(pendingWorkflow, process), false, `${process} navigation must be rejected while review is pending`);
70
+ assert.equal(guidedGitReviewProcessNavigationAllowed(freshAvailableWorkflow, process), false, `a fresh available-review flow must block ${process} before staging and approval`);
71
+ assert.equal(guidedGitReviewProcessSelectionPatch(freshAvailableWorkflow, process), null, `a fresh available-review flow must not transition to ${process}`);
72
+ }
73
+ assert.equal(guidedGitReviewProcessNavigationAllowed(pendingWorkflow, "stage"), true, "staging recovery remains available while review is pending");
74
+ assert.equal(guidedGitReviewProcessNavigationAllowed(pendingWorkflow, "review"), true, "review recovery remains available while review is pending");
75
+
76
+ const approvedWorkflow = {
77
+ ...pendingWorkflow,
78
+ step: "generate",
79
+ process: "message",
80
+ guidedReviewStatus: "approved",
81
+ guidedReviewRequired: false,
82
+ };
83
+ assert.equal(guidedGitReviewHasApprovedBinding(approvedWorkflow), true, "approval must carry the exact repo, fingerprint, and staged-content binding");
84
+ for (const process of ["message", "commit", "push"]) {
85
+ assert.equal(guidedGitReviewProcessNavigationAllowed(approvedWorkflow, process), true, `matching approval may navigate to ${process}`);
86
+ const patch = guidedGitReviewProcessSelectionPatch(approvedWorkflow, process);
87
+ assert.equal(patch?.guidedReviewStatus, "approved", `${process} navigation must preserve approval status`);
88
+ assert.equal(patch?.guidedReviewRepoRoot, repoRoot, `${process} navigation must preserve the approved repo root`);
89
+ assert.equal(patch?.guidedReviewFingerprint, fingerprint, `${process} navigation must preserve the approved fingerprint`);
90
+ assert.equal(patch?.guidedReviewStagedContentHash, stagedContentHash, `${process} navigation must preserve the approved staged-content hash`);
91
+ assert.equal(patch?.guidedReviewRequired, false, `${process} navigation must not convert matching approval to legacy state`);
92
+ }
93
+ for (const process of ["stage", "review"]) {
94
+ const patch = guidedGitReviewProcessSelectionPatch(approvedWorkflow, process);
95
+ assert.equal(patch?.guidedReviewRequired, true, `${process} must re-arm required review after approval`);
96
+ assert.equal(patch?.guidedReviewStatus, "", `${process} must clear prior approval status`);
97
+ assert.equal(patch?.guidedReviewRepoRoot, "", `${process} must clear prior repo binding`);
98
+ assert.equal(patch?.guidedReviewFingerprint, "", `${process} must clear prior fingerprint binding`);
99
+ assert.equal(patch?.guidedReviewStagedContentHash, "", `${process} must clear prior staged-content binding`);
100
+ const rearmedWorkflow = { ...approvedWorkflow, ...patch, step: process === "stage" ? "add" : "review", process };
101
+ for (const laterProcess of ["message", "commit", "push"]) {
102
+ assert.equal(guidedGitReviewProcessNavigationAllowed(rearmedWorkflow, laterProcess), false, `${laterProcess} must remain blocked after approval is cleared via ${process}`);
103
+ }
104
+ }
105
+
106
+ const legacyWorkflow = {
107
+ ...requestingWorkflow,
108
+ step: "add",
109
+ process: "stage",
110
+ guidedReviewRequired: false,
111
+ };
112
+ for (const process of ["message", "commit", "push"]) {
113
+ assert.equal(guidedGitReviewProcessNavigationAllowed(legacyWorkflow, process), true, `a flow started without aur-review retains legacy ${process} navigation`);
114
+ assert.equal(guidedGitReviewProcessSelectionPatch(legacyWorkflow, process)?.guidedReviewRequired, false, `legacy ${process} navigation must remain ungated`);
115
+ }
116
+
117
+ const recoveredWorkflow = {
118
+ ...pendingWorkflow,
119
+ step: "add",
120
+ process: "stage",
121
+ guidedReviewStatus: "",
122
+ guidedReviewFingerprint: "",
123
+ guidedReviewRepoRoot: "",
124
+ guidedReviewStagedContentHash: "",
125
+ guidedReviewDeclinedStagedContentHash: stagedContentHash,
126
+ guidedReviewRequired: true,
127
+ };
128
+ for (const process of ["message", "commit", "push"]) {
129
+ assert.equal(guidedGitReviewProcessNavigationAllowed(recoveredWorkflow, process), false, `${process} remains blocked after Stage/Review recovery`);
130
+ }
131
+ assert.equal(guidedGitReviewProcessNavigationAllowed(recoveredWorkflow, "stage"), true, "recovery stage remains available with durable requirement");
132
+ assert.equal(guidedGitReviewProcessNavigationAllowed(recoveredWorkflow, "review"), true, "recovery review remains available with durable requirement");
133
+ const rerequestedWorkflow = { ...pendingWorkflow, guidedReviewRequired: true };
134
+ assert.equal(guidedGitReviewTransition(rerequestedWorkflow, { ...pendingPayload, decision: { state: "approved", decidedAt: "2026-06-01T00:00:03.000Z", reviewedFingerprint: fingerprint, reviewedStagedContentHash: stagedContentHash } }), "approved", "a new matching approval advances the recovered review flow");
135
+ assert.equal(guidedGitReviewCanRequestStagedContent(recoveredWorkflow, stagedContentHash), false, "an unchanged declined staged hash must be rejected");
136
+ assert.equal(guidedGitReviewCanRequestStagedContent(recoveredWorkflow, "d".repeat(64)), true, "changed/restaged content may request a new review");
137
+
138
+ const catalogByTab = new Map();
139
+ const delay = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
140
+ await Promise.all([
141
+ (async () => { await delay(12); catalogByTab.set("tab-a", { raw: [{ name: "git-staged-msg", source: "extension" }], available: [{ name: "git-staged-msg", source: "extension" }] }); })(),
142
+ (async () => { await delay(1); catalogByTab.set("tab-b", { raw: [{ name: "aur-review:2", source: "extension" }], available: [{ name: "aur-review:2", invokeName: "aur-review:2", duplicateCount: 2, source: "extension" }] }); })(),
143
+ ]);
144
+ assert.equal(guidedGitReviewAvailableForTabCatalog(catalogByTab.get("tab-a")), false, "tab A cannot inherit tab B's review command after async tab switching");
145
+ assert.equal(resolveRpcSlashCommandForTabCatalog(catalogByTab.get("tab-a"), "/aur-review start --scope staged"), "/aur-review start --scope staged", "tab A cannot inherit tab B's alias");
146
+ assert.equal(guidedGitReviewAvailableForTabCatalog(catalogByTab.get("tab-b")), true, "tab B retains its own review command");
147
+ assert.equal(resolveRpcSlashCommandForTabCatalog(catalogByTab.get("tab-b"), "/aur-review start --scope staged"), "/aur-review:2 start --scope staged", "tab B resolves only its own alias");
148
+
149
+ const runGitAdd = app.slice(app.indexOf("async function runGitAdd"), app.indexOf("async function acceptCurrentGitStaging"));
150
+ const acceptStaging = app.slice(app.indexOf("async function acceptCurrentGitStaging"), app.indexOf("async function loadGitWorkflowDefaultCommitMessage"));
151
+ assert.match(runGitAdd, /guidedGitReviewAvailable\(tabId\) \|\| workflow\.guidedReviewRequired === true[\s\S]*await requestGuidedGitReview\(tabId, \{ output \}\)/s, "git add . must keep an already-required review gate fail-closed while preserving disabled-from-start fallback");
152
+ assert.match(acceptStaging, /guidedGitReviewAvailable\(tabId\) \|\| workflow\.guidedReviewRequired === true[\s\S]*await requestGuidedGitReview\(tabId, \{ output \}\)/s, "accepting a staged set must keep an already-required review gate fail-closed");
153
+ const reconcileReview = app.slice(app.indexOf("function reconcileGuidedGitReviewPayload"), app.indexOf("async function startGitWorkflow"));
154
+ assert.match(reconcileReview, /transition === "approved"[\s\S]*step: "generate"[\s\S]*guidedReviewDeclinedStagedContentHash: ""/s, "only approval advances to message generation and clears an older decline binding");
155
+ assert.match(reconcileReview, /transition === "pending"[\s\S]*guidedReviewDeclinedStagedContentHash[\s\S]*same staged content that was declined/s, "extension payload replay cannot retry an unchanged declined staged hash");
156
+ assert.match(reconcileReview, /transition === "closed"[\s\S]*resetGuidedGitReviewToStaging/s, "closed payloads must reset the matching flow to staging");
157
+ assert.match(reconcileReview, /function reconcileGuidedGitReviewWidgetRemoval[\s\S]*guidedGitReviewWidgetRemovalTransition[\s\S]*resetGuidedGitReviewToStaging/s, "matching widget removal must reset the gate rather than imply approval");
158
+ const resetReviewToStaging = app.slice(app.indexOf("function resetGuidedGitReviewToStaging"), app.indexOf("function reconcileGuidedGitReviewPayload"));
159
+ assert.match(resetReviewToStaging, /step: "add"[\s\S]*stage: false/s, "decline and close return the flow to staging and require restaging");
160
+ const workflowRender = app.slice(app.indexOf("function renderGitWorkflow"), app.indexOf("async function gitWorkflowRequest"));
161
+ assert.match(workflowRender, /item\.disabled = !!gitWorkflow\.busy \|\| !guidedGitReviewProcessNavigationAllowed\(gitWorkflow, process\.value\);/, "the UI must disable later process buttons while the review gate is active");
162
+ const processSelection = app.slice(app.indexOf("function selectGitWorkflowProcess"), app.indexOf("function gitWorkflowTitle"));
163
+ assert.match(processSelection, /const guidedReviewPatch = guidedGitReviewProcessSelectionPatch\(workflow, process\);[\s\S]*if \(!guidedReviewPatch\) return;[\s\S]*\.\.\.guidedReviewPatch/s, "process selection must use the tested patch that preserves approval or re-arms review");
164
+ assert.doesNotMatch(processSelection, /resetGuidedGitReviewPatch/, "process selection must not share a reset that drops an approved binding during later navigation");
165
+ const startWorkflow = app.slice(app.indexOf("async function startGitWorkflow"), app.indexOf("async function startGitInitWorkflow"));
166
+ assert.match(startWorkflow, /guidedReviewRequired: guidedGitReviewAvailable\(tabId\)/, "a fresh standard flow must require review when aur-review is available in its originating tab");
167
+ assert.match(app, /function guidedGitReviewAvailable\(tabId = activeTabId\)[\s\S]*commandCatalogForTab\(tabId\)/, "Guided Git availability must read the originating tab catalog");
168
+ assert.match(app, /resolveRpcSlashCommandMessage\(guidedGitReviewCommand\(\), \{ tabId \}\)/, "Guided Git review requests must resolve aliases from the originating tab catalog");
169
+ assert.match(app, /message = resolveRpcSlashCommandMessage\(message, \{ tabId: targetTabId \}\)/, "generic targeted slash-command dispatch must resolve aliases from its captured target tab");
170
+ for (const [name, action] of [["runGitMessagePrompt", "commit-message generation"], ["commitGitWorkflow", "commit"], ["createGitPrBranchWithSuggestion", "PR worktree creation"]]) {
171
+ const start = app.indexOf(`async function ${name}`);
172
+ const next = app.indexOf("\nasync function ", start + 1);
173
+ const source = app.slice(start, next === -1 ? undefined : next);
174
+ assert.match(source, /assertGuidedGitStagedContentBinding/, `${name} must recheck the approved staged-content hash at its action boundary`);
175
+ assert.match(source, /expectedStagedContentHash/, `${name} must send the approved staged-content hash to its gated endpoint`);
176
+ }
177
+ assert.match(app, /function requestGuidedGitReview[\s\S]*readGuidedGitStagedContent[\s\S]*git add \. produced no substantive staged changes[\s\S]*guideded|function requestGuidedGitReview[\s\S]*readGuidedGitStagedContent[\s\S]*git add \. produced no substantive staged changes/s, "manual-review requests must preflight no-staged content instead of waiting for a card");
178
+ assert.match(app, /guidedGitReviewUnavailableMessage[\s\S]*No message, commit, worktree, or push action was performed/, "a disappeared extension after a required gate must remain fail-closed with recovery guidance");
179
+ assert.match(app, /commandCatalogsByTab\.set\(tabContext\.tabId, catalog\)[\s\S]*if \(!isCurrentTabContext\(tabContext\)\) return;/, "async command refresh must cache inactive-tab results rather than discard or activate them");
180
+ assert.match(app, /widgetKey === AUR_REVIEW_RPC_WIDGET_KEY[\s\S]*else if \(!Array\.isArray\(request\.widgetLines\)\) reconcileGuidedGitReviewWidgetRemoval\(requestTabId\)/s, "active-tab widget clearing must reconcile a matching pending review");
181
+ assert.match(app, /AUR_REVIEW_RPC_WIDGET_KEY\)[\s\S]*else if \(!Array\.isArray\(event\.widgetLines\)\) reconcileGuidedGitReviewWidgetRemoval\(event\.tabId\)/s, "inactive-tab widget clearing must reconcile the owning tab only");
182
+ assert.match(app, /handleInactiveTabEvent[\s\S]*AUR_REVIEW_RPC_WIDGET_KEY[\s\S]*reconcileGuidedGitReviewPayload\(event\.tabId, payload\)/s, "tab-local review events must reconcile using their event tab id");
183
+ console.log("guided Git aur-review tests passed");
@@ -269,6 +269,21 @@ try {
269
269
  const rawVoiceModuleSize = (await stat(join(root, "public", "voice-conversation.mjs"))).size;
270
270
  assert.equal(voiceModuleBody.byteLength, rawVoiceModuleSize, "served voice-conversation.mjs should match the raw file byte-for-byte in size");
271
271
 
272
+ // app.js imports this pure Guided Git review gate at startup. Fetch it over
273
+ // the real server so an omitted static allowlist entry cannot 404 the UI.
274
+ const guidedGitReviewStateResponse = await fetch(`http://127.0.0.1:${port}/guided-git-review-state.mjs`, {
275
+ signal: AbortSignal.timeout(5_000),
276
+ });
277
+ assert.equal(guidedGitReviewStateResponse.status, 200, "guided-git-review-state.mjs must be served for the Guided Git review gate");
278
+ assert.match(guidedGitReviewStateResponse.headers.get("content-type") || "", /text\/javascript/, "guided-git-review-state.mjs should use a JavaScript MIME type");
279
+ assert.equal(await guidedGitReviewStateResponse.text(), await readFile(join(root, "public", "guided-git-review-state.mjs"), "utf8"), "served Guided Git review state must match the source module");
280
+ for (const moduleName of ["aur-review-payload.mjs", "guided-git-command-state.mjs"]) {
281
+ const response = await fetch(`http://127.0.0.1:${port}/${moduleName}`, { signal: AbortSignal.timeout(5_000) });
282
+ assert.equal(response.status, 200, `${moduleName} must be served for the Guided Git review gate`);
283
+ assert.match(response.headers.get("content-type") || "", /text\/javascript/, `${moduleName} should use a JavaScript MIME type`);
284
+ assert.equal(await response.text(), await readFile(join(root, "public", moduleName), "utf8"), `served ${moduleName} must match the source module`);
285
+ }
286
+
272
287
  const mermaidModuleResponse = await fetch(`http://127.0.0.1:${port}/vendor/mermaid/mermaid.esm.min.mjs`, {
273
288
  signal: AbortSignal.timeout(5_000),
274
289
  });
@@ -290,6 +305,12 @@ try {
290
305
  const tabId = tabList[0].id;
291
306
  assert.ok(tabId, "tab should have an id");
292
307
 
308
+ const optionalFeatures = await request("127.0.0.1", "/api/optional-features");
309
+ assert.equal(optionalFeatures.status, 200, "optional feature status should load");
310
+ const aurReviewFeature = optionalFeatures.body?.data?.features?.find((feature) => feature.featureId === "aurReview");
311
+ assert.equal(aurReviewFeature?.installed, true, "workspace discovery should find the local pi-extension-aur-review sibling without an npm dependency");
312
+ assert.equal(path.basename(aurReviewFeature?.installedRoot || ""), "pi-extension-aur-review", "aur-review discovery must validate the exact sibling manifest/name");
313
+
293
314
  const sessionToolsBefore = await request("127.0.0.1", `/api/tools?tab=${encodeURIComponent(tabId)}&scope=session`);
294
315
  assert.equal(sessionToolsBefore.status, 200);
295
316
  assert.equal(sessionToolsBefore.body?.data?.scope, "session");
@@ -409,6 +430,25 @@ try {
409
430
  assert.equal(subagentOutputResponse.body?.data?.agent?.name, "reviewer", "subagent output should target the selected child agent");
410
431
  assert.deepEqual(subagentOutputResponse.body?.data?.agent?.recentOutput, ["Inspecting current implementation", "Waiting for the next tool result"], "subagent output should preserve bounded live output lines");
411
432
  assert.equal(subagentOutputResponse.body?.data?.agent?.currentToolArgs, "README.md", "subagent output should include current tool state");
433
+ assert.deepEqual(subagentOutputResponse.body?.data?.agent?.transcript, [
434
+ {
435
+ role: "assistant",
436
+ timestamp: "2026-07-19T12:00:00.000Z",
437
+ content: [
438
+ { type: "thinking", thinking: "Checking the fixture transcript." },
439
+ { type: "text", text: "Inspecting current implementation" },
440
+ { type: "toolCall", id: "fixture-read", name: "read", arguments: "{\"path\":\"README.md\",\"offset\":1}" },
441
+ { type: "text", text: "Waiting for the next tool result" },
442
+ ],
443
+ },
444
+ {
445
+ role: "toolResult",
446
+ timestamp: "2026-07-19T12:00:01.000Z",
447
+ toolCallId: "fixture-read",
448
+ toolName: "read",
449
+ content: [{ type: "text", text: "# Fixture README" }],
450
+ },
451
+ ], "subagent output endpoint should preserve normalized structured transcript roles, order, IDs, and tool metadata");
412
452
  const unknownSubagentOutput = await request("127.0.0.1", `/api/subagents/output?tab=${encodeURIComponent(tabId)}&run=missing&agent=missing`);
413
453
  assert.equal(unknownSubagentOutput.status, 404, "subagent output endpoint should reject untracked selections");
414
454
  const subagentFixtureClear = await request("127.0.0.1", "/api/prompt", { method: "POST", body: { tab: tabId, message: "fixture subagents clear" } });
@@ -1055,6 +1095,58 @@ try {
1055
1095
  const closeGitActionTabs = await request("127.0.0.1", "/api/tabs/close", { method: "POST", body: { ids: [stagingTab, truncationTab, mergeTab, abortTab, rebaseTab, bisectTab, stashTab, undoTab] }, timeoutMs: 10_000 });
1056
1096
  assert.equal(closeGitActionTabs.status, 200, "git action fixture tabs should close");
1057
1097
  await rmWithRetry(gitFixturesRoot);
1098
+
1099
+ // AUR-review paths are repo-root-relative even when a tab starts in a
1100
+ // subdirectory. The dedicated read-only route must not reuse cwd-scoped
1101
+ // workspace file access.
1102
+ const reportRepo = await mkdtemp(path.join(tmpdir(), "pi-webui-aur-report-"));
1103
+ let reportTabId = "";
1104
+ try {
1105
+ const reportSubdir = path.join(reportRepo, "subdir");
1106
+ const reportPath = path.join(reportRepo, "reports", "audit.md");
1107
+ const oversizedReportPath = path.join(reportRepo, "reports", "oversized.md");
1108
+ await mkdir(reportSubdir, { recursive: true });
1109
+ await mkdir(path.dirname(reportPath), { recursive: true });
1110
+ runGitFixture(["init", "-b", "main"], reportRepo, "report fixture should initialize");
1111
+ await writeFile(reportPath, "# Audit report\n\nCanonical repo-root report.\n", "utf8");
1112
+ const reportTab = await request("127.0.0.1", "/api/tabs", { method: "POST", body: { cwd: reportSubdir, title: "aur-report-subdir" } });
1113
+ assert.equal(reportTab.status, 201, `subdirectory report tab should open: ${reportTab.body?.error || ""}`);
1114
+ reportTabId = reportTab.body?.data?.tab?.id || "";
1115
+ assert.ok(reportTabId, "subdirectory report tab should have an id");
1116
+ const reportRequestPath = (reportFile, repoRoot = reportRepo) => `/api/aur-review/report-content?tab=${encodeURIComponent(reportTabId)}&path=${encodeURIComponent(reportFile)}&repoRoot=${encodeURIComponent(repoRoot)}`;
1117
+
1118
+ const cwdScopedMiss = await request("127.0.0.1", `/api/files/content?tab=${encodeURIComponent(reportTabId)}&path=${encodeURIComponent("reports/audit.md")}`);
1119
+ assert.equal(cwdScopedMiss.status, 404, "generic workspace file access must remain scoped to the tab subdirectory");
1120
+ const openedReport = await request("127.0.0.1", reportRequestPath("reports/audit.md"));
1121
+ assert.equal(openedReport.status, 200, `repo-root report should open from a subdirectory tab: ${openedReport.body?.error || ""}`);
1122
+ assert.equal(openedReport.body?.data?.root, reportRepo, "report endpoint should return the canonical Git root");
1123
+ assert.equal(openedReport.body?.data?.path, "reports/audit.md", "report endpoint should retain the repo-relative report path");
1124
+ assert.equal(openedReport.body?.data?.content, "# Audit report\n\nCanonical repo-root report.\n");
1125
+ assert.equal(openedReport.body?.data?.language, "markdown", "repo-root reports should use the existing Markdown viewer metadata");
1126
+
1127
+ const wrongRoot = await request("127.0.0.1", reportRequestPath("reports/audit.md", reportSubdir));
1128
+ assert.equal(wrongRoot.status, 403, "report endpoint must require the payload repoRoot to equal the canonical Git root");
1129
+ const traversal = await request("127.0.0.1", reportRequestPath("../reports/audit.md"));
1130
+ assert.equal(traversal.status, 400, "report endpoint must reject traversal paths");
1131
+ const absolute = await request("127.0.0.1", reportRequestPath(reportPath));
1132
+ assert.equal(absolute.status, 400, "report endpoint must reject absolute report paths");
1133
+ const nonRegular = await request("127.0.0.1", reportRequestPath("reports"));
1134
+ assert.equal(nonRegular.status, 400, "report endpoint must reject non-regular paths");
1135
+ await writeFile(oversizedReportPath, Buffer.alloc(2 * 1024 * 1024 + 1, 0x61));
1136
+ const oversized = await request("127.0.0.1", reportRequestPath("reports/oversized.md"));
1137
+ assert.equal(oversized.status, 413, "report endpoint must reject oversized reports before returning content");
1138
+ try {
1139
+ await symlink(reportPath, path.join(reportRepo, "reports", "audit-link.md"));
1140
+ const symlinked = await request("127.0.0.1", reportRequestPath("reports/audit-link.md"));
1141
+ assert.equal(symlinked.status, 403, "report endpoint must reject symlinked reports even when their targets stay in the repository");
1142
+ } catch (error) {
1143
+ if (!["EPERM", "EACCES", "EINVAL", "ENOTSUP"].includes(error?.code)) throw error;
1144
+ console.log(`http-endpoints-harness: symlink unavailable (${error.code}); skipping report symlink check`);
1145
+ }
1146
+ } finally {
1147
+ if (reportTabId) await request("127.0.0.1", "/api/tabs/close", { method: "POST", body: { ids: [reportTabId] }, timeoutMs: 10_000 });
1148
+ await rmWithRetry(reportRepo);
1149
+ }
1058
1150
  } else {
1059
1151
  console.log("http-endpoints-harness: git not available; skipping git init workflow endpoint checks");
1060
1152
  }
@@ -1,5 +1,6 @@
1
1
  import assert from "node:assert/strict";
2
2
  import { readFile } from "node:fs/promises";
3
+ import vm from "node:vm";
3
4
  import { dirname, join } from "node:path";
4
5
  import { fileURLToPath } from "node:url";
5
6
 
@@ -26,6 +27,13 @@ const manifest = JSON.parse(manifestRaw);
26
27
  const lock = JSON.parse(await readFile(join(root, "package-lock.json"), "utf8"));
27
28
  const helper = await readFile(join(root, "webui-rpc-helper.mjs"), "utf8");
28
29
  const codexAuth = await readFile(join(root, "lib", "codex-usage-auth.mjs"), "utf8");
30
+
31
+ function appFunctionSource(name, nextName) {
32
+ const start = app.indexOf(`function ${name}(`);
33
+ const end = app.indexOf(`\nfunction ${nextName}(`, start);
34
+ assert.ok(start >= 0 && end > start, `${name} should remain a standalone frontend helper`);
35
+ return app.slice(start, end);
36
+ }
29
37
  const nativeExportPayload = await readFile(join(root, "lib", "native-export-payload.mjs"), "utf8");
30
38
  const companionDependencies = {
31
39
  "@firstpick/pi-extension-bang-command-autocomplete": "^0.2.1",
@@ -60,6 +68,7 @@ assert.match(html, /id="newTabWorktreeButton" class="terminal-new-tab-menu-item
60
68
  assert.match(html, /id="closeAllTabsButton"[\s\S]*?>Close all Tabs<\/button>/, "tab header should expose a top-right close-all tabs action");
61
69
  assert.match(html, /id="sidePanelBackdrop"/, "mobile side panel needs an overlay/backdrop close target");
62
70
  assert.match(html, /<div class="side-panel-heading">[\s\S]*<strong class="side-panel-title">Control Deck<\/strong>[\s\S]*<div class="side-panel-version-row"[\s\S]*<button id="piVersionButton"[\s\S]*aria-controls="piReleaseNotesDialog"[\s\S]*<button id="webuiVersionButton"[\s\S]*aria-controls="confirmationDialog"[\s\S]*id="webuiDevBadge"/, "Control Deck header should keep its title separate from an aligned version and build row");
71
+ assert.match(html, /<div class="side-panel-brand-row">[\s\S]*<span class="side-panel-kicker">Pi Web UI<\/span>[\s\S]*<a class="sponsor-link" href="https:\/\/github\.com\/sponsors\/Firstp1ck" target="_blank" rel="noopener noreferrer" aria-label="Sponsor Firstp1ck on GitHub"[^>]*>♡<\/a>/, "Control Deck brand should expose a subtle, accessible sponsor link beside the Pi Web UI name");
63
72
  assert.match(html, /<dialog id="piReleaseNotesDialog"[\s\S]*id="piReleaseNotesTitle"[\s\S]*id="piReleaseNotesStatus"[\s\S]*id="piReleaseNotesBody"[\s\S]*id="piReleaseNotesGithubLink"/, "Pi release notes should use a dedicated accessible dialog");
64
73
  assert.doesNotMatch(html, /Safer option|confirmationAlternative/, "shared confirmation dialogs should not render a safer-option row");
65
74
  assert.doesNotMatch(app, /confirmationAlternative|\balternative:\s*options\.alternative/, "confirmation logic should not populate a removed safer-option row");
@@ -328,6 +337,8 @@ assert.match(css, /\.session-detail-value\.truncate[\s\S]*?text-overflow:\s*elli
328
337
  assert.match(css, /\.server-restart-panel \{[\s\S]*?z-index:\s*62/, "server restart overlay should render above the offline shell");
329
338
  assert.match(css, /@keyframes server-restart-spin/, "server restart overlay should show a loading spinner");
330
339
  assert.match(css, /\.side-panel-version-row \{[\s\S]*?display:\s*flex[\s\S]*?align-items:\s*center[\s\S]*?flex-wrap:\s*wrap/, "Control Deck versions and build status should use a dedicated responsive row");
340
+ assert.match(css, /\.side-panel-brand-row \{[\s\S]*?display:\s*flex[\s\S]*?align-items:\s*center[\s\S]*?\.sponsor-link \{[\s\S]*?text-decoration:\s*none/, "Sponsor heart should sit inline with the Pi Web UI brand and remain visually subtle");
341
+ assert.match(css, /\.sponsor-link:hover,[\s\S]*?\.sponsor-link:focus-visible/, "Sponsor heart should expose visible hover and keyboard focus states");
331
342
  assert.match(css, /\.pi-version-button,\n\.webui-version-button,\n\.webui-dev-badge \{[\s\S]*?border-radius:\s*999px/, "Pi and Web UI version buttons plus the dev indicator should render as compact title controls");
332
343
  assert.match(css, /\.webui-version-button:hover,[\s\S]*?\.webui-version-button:focus-visible/, "Web UI version button should expose visible hover and keyboard focus states");
333
344
  assert.match(css, /\.pi-version-button:hover,[\s\S]*?\.pi-version-button:focus-visible/, "Pi version button should expose visible hover and keyboard focus states");
@@ -704,21 +715,60 @@ assert.match(
704
715
  assert.match(app, /function renderCodexUsage\(\)/, "frontend should render Codex usage buckets in the side panel");
705
716
  assert.match(app, /function renderSubagents\(\)[\s\S]*subagentTabsWithRunningAgents\(\)[\s\S]*renderSubagentTabGroup\(tab\)/, "frontend should group running subagents by terminal and session");
706
717
  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");
707
- 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");
718
+ assert.match(app, /function renderWidgets\(\)[\s\S]*renderAppRunnerWidget\(\)[\s\S]*renderSubagentOverlayWidgetSafely\(\)/, "subagent output should render in the shared non-blocking top widget area after App Runner");
708
719
  assert.doesNotMatch(app, /subagentOverlayDialog\.showModal|elements\.subagentOverlayDialog/, "subagent output should not open or depend on a modal dialog");
709
720
  assert.match(app, /api\(`\/api\/subagents\/output\?\$\{query\}`, \{ scoped: false \}\)/, "subagent overlay should fetch selected live output from the owning tab");
710
721
  assert.match(app, /SUBAGENT_OVERLAY_REFRESH_MS = 1000/, "subagent overlay should poll selected live output at a fast cadence");
711
722
  assert.match(app, /function createMessageBubble\(message,[\s\S]*renderContent\(body, message\.content, \{ markdown: message\.role === "assistant" \}\)[\s\S]*function appendMessage\(message, options = \{\}\)[\s\S]*createMessageBubble\(message, options\)/, "main transcript output should use the reusable message bubble renderer");
712
- assert.match(app, /function renderSubagentOverlayWidget\(\)[\s\S]*createMessageBubble\(\{[\s\S]*role: "assistant"[\s\S]*content: shownText[\s\S]*\}, \{ streaming: running, transient: true \}\)[\s\S]*subagent-overlay-message/, "subagent output should use the same assistant Markdown message renderer as the main transcript");
713
- assert.match(app, /function appendSubagentOutputWaitingIndicator\(parent\)[\s\S]*message runIndicator run-indicator-message streaming subagent-output-waiting[\s\S]*subagent-output-waiting-dot[\s\S]*if \(running && agent\.currentTool\) appendSubagentOutputWaitingIndicator\(output\)/, "subagent widget should render one main-transcript-style waiting indicator instead of transcript spam");
723
+ const subagentTranscriptMessagesSource = appFunctionSource("subagentOverlayTranscriptMessages", "subagentOverlayToolArguments");
724
+ assert.ok(subagentTranscriptMessagesSource.includes("message.role === \"assistant\" || message.role === \"toolResult\""), "subagent overlays should retain structured assistant and tool-result entries");
725
+ const subagentToolArgumentsSource = appFunctionSource("subagentOverlayToolArguments", "subagentOverlayTranscriptDisplayMessages");
726
+ assert.ok(subagentToolArgumentsSource.includes("JSON.parse(value)"), "structured tool arguments should be restored for specialized tool renderers");
727
+ const subagentDisplaySource = appFunctionSource("subagentOverlayTranscriptDisplayMessages", "subagentOverlayTranscriptOutputLines");
728
+ assert.ok(subagentDisplaySource.includes("const toolResults = buildToolResultMap(messages);"), "subagent rendering should pair calls with the shared result lookup");
729
+ assert.ok(subagentDisplaySource.includes("role: \"toolExecution\""), "paired subagent calls should use main-transcript toolExecution cards");
730
+ assert.ok(subagentDisplaySource.includes("const result = toolResults.get(displayMessage.toolCallId) || null;") && subagentDisplaySource.includes(" result,"), "incomplete subagent tool calls should remain pending tool cards");
731
+ assert.ok(subagentDisplaySource.includes("if (pairedToolCallIds.has(toolResultCallId(message))) continue;"), "paired tool results should not render as duplicate generic cards");
732
+ const subagentAppendSource = appFunctionSource("appendSubagentOverlayTranscript", "subagentOverlayStateFacts");
733
+ assert.ok(subagentAppendSource.includes("subagentOverlayTranscriptDisplayMessages(messages)"), "subagent bubbles should use the paired structured display sequence");
734
+ assert.ok(subagentAppendSource.includes("createMessageBubble(displayMessage, { transient: true })"), "subagent bubbles should reuse the main message renderer");
735
+ const thinkingVisibilitySource = appFunctionSource("setThinkingOutputVisible", "applyToolOutputExpansionToDom");
736
+ assert.ok(thinkingVisibilitySource.includes("if (subagentOverlaySelection?.tabId === activeTabId) renderWidgets();"), "changing thinking visibility should rerender an open subagent transcript, including finished agents");
737
+ const subagentCopySource = appFunctionSource("subagentOverlayTranscriptOutputLines", "subagentOverlayOutputLines");
738
+ assert.ok(subagentCopySource.includes("messageCopyText(message)"), "global subagent copy should derive from the same structured bubble messages");
739
+ const subagentOutputSource = appFunctionSource("subagentOverlayOutputLines", "subagentOverlayOutputText");
740
+ assert.ok(subagentOutputSource.includes("if (transcriptMessages.length) return subagentOverlayTranscriptOutputLines(data);"), "global subagent copy should prefer structured transcript content over flattened recent output");
741
+ const subagentEmptySource = appFunctionSource("subagentOverlayEmptyTranscriptText", "appendSubagentOutputWaitingIndicator");
742
+ assert.ok(subagentEmptySource.includes("No visible output was captured."), "hidden or non-renderable structured output should have explicit fallback text");
743
+ const subagentRenderErrorSource = appFunctionSource("renderSubagentOverlayErrorWidget", "renderSubagentOverlayWidgetSafely");
744
+ assert.ok(subagentRenderErrorSource.includes("Subagent output unavailable"), "a failed subagent renderer should show a minimal recoverable widget");
745
+ assert.ok(subagentRenderErrorSource.includes("appRunnerActionButton(\"Close\", closeSubagentOverlay"), "the recoverable subagent renderer error widget should provide a Close action");
746
+ assert.doesNotMatch(subagentRenderErrorSource, /addEvent\(/, "renderer failures should not create repeated event-log entries while a refresh retries");
747
+ const subagentSafeRenderSource = appFunctionSource("renderSubagentOverlayWidgetSafely", "renderSubagentOverlayWidget");
748
+ assert.match(subagentSafeRenderSource, /try \{[\s\S]*renderSubagentOverlayWidget\(\)[\s\S]*\} catch \{[\s\S]*renderSubagentOverlayErrorWidget\(\)/, "subagent renderer exceptions should be isolated from the shared widget render pass");
749
+ const rendererFallbackSentinel = {};
750
+ const rendererContainmentResult = vm.runInNewContext(`${subagentSafeRenderSource}\nrenderSubagentOverlayWidgetSafely();`, {
751
+ renderSubagentOverlayWidget() { throw new Error("fixture renderer failure"); },
752
+ renderSubagentOverlayErrorWidget() { return rendererFallbackSentinel; },
753
+ });
754
+ assert.equal(rendererContainmentResult, rendererFallbackSentinel, "subagent renderer failures should return the recoverable fallback widget");
755
+ const subagentWidgetSource = appFunctionSource("renderSubagentOverlayWidget", "scheduleSubagentOverlayRefresh");
756
+ assert.ok(subagentWidgetSource.includes("const visibleFallbackText = !hasStructuredTranscript ? fallbackText : emptyTranscriptFallback;"), "the widget should render a fallback instead of leaving structured-but-hidden output blank");
757
+ assert.ok(subagentWidgetSource.includes("if (visibleFallbackText) {"), "the widget should append the nonblank fallback bubble");
758
+ assert.ok(subagentWidgetSource.includes("if (running && (agent.currentTool || (hasStructuredTranscript && renderedTranscriptMessages === 0))) appendSubagentOutputWaitingIndicator(output);"), "subagent widgets should retain one waiting indicator while structured output is hidden or a tool is running");
714
759
  assert.match(app, /api\("\/api\/subagents", \{ scoped: false \}\)/, "frontend should refresh the cross-tab subagent overview");
715
760
  assert.match(app, /SUBAGENTS_ACTIVE_REFRESH_MS = 1500/, "running subagents should receive a fast live refresh cadence");
716
761
  assert.match(server, /url\.pathname === "\/api\/subagents" && req\.method === "GET"[\s\S]*webuiSubagentsData\(\)/, "server should expose a cross-tab running-subagent endpoint");
717
762
  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");
718
763
  assert.match(server, /rememberWebuiSubagentsStatusEvent\(tab, event\)/, "server should ingest the helper's structured subagent status without forwarding internal JSON to the browser footer");
764
+ assert.match(server, /PI_RPC_JSONL_LINE_MAX_BYTES = 32 \* 1024 \* 1024/, "Pi RPC JSONL parsing should use an explicit line-size limit with inline-image headroom");
765
+ assert.match(server, /function ensureStderrMirrorErrorHandler\(stream\)[\s\S]*stream\.on\("error"/, "Pi stderr mirroring should contain asynchronous closed-sink failures");
766
+ assert.match(server, /type: "pi_stdout_line_too_large"[\s\S]*discardingOversizedLine/, "oversized unterminated Pi RPC lines should be discarded until their newline");
719
767
  assert.match(helper, /SUBAGENT_RPC_REQUEST_EVENT = "subagents:rpc:v1:request"/, "Web UI helper should use pi-subagents' stable status RPC");
720
768
  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");
769
+ assert.match(helper, /function subagentTranscriptOutput\(sessionFile\)[\s\S]*const empty = \{ recentOutput: \[\], transcript: \[\] \}[\s\S]*transcript: subagentTranscriptMessages\(boundedCandidates\)/, "subagent transcript extraction should return bounded structured entries alongside recentOutput");
721
770
  assert.match(helper, /line\.trim\(\)\.toLowerCase\(\) === "\(no output\)"/, "subagent transcript extraction should suppress empty tool-result markers");
771
+ assert.match(server, /function normalizeWebuiSubagentTranscript\(value\)[\s\S]*remainingParts = WEBUI_SUBAGENT_OUTPUT_LINE_LIMIT[\s\S]*const transcript = normalizeWebuiSubagentTranscript\(rawAgent\.transcript\)/, "server output normalization should preserve the structured transcript under the existing line limit");
722
772
  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");
723
773
  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");
724
774
  assert.match(app, /if \(normalized === "prolite"\) return "Usage";/, "Codex Prolite plan labels should display as Usage in the side panel");
@@ -904,7 +954,7 @@ assert.match(app, /window\.addEventListener\("storage"[\s\S]*OPTIONAL_FEATURES_S
904
954
  assert.match(app, /if \(key === "pi-remote-webui"\) return "remoteWebui"/, "optional feature handling should recognize Remote WebUI widget events without rendering them as overlays");
905
955
  assert.match(app, /REMOTE_WEBUI_CONTROLS_PAYLOAD_TYPE = "firstpick\.pi-package-remote-webui\.controls"/, "Remote WebUI package should announce browser controls through a package-owned status payload");
906
956
  assert.match(app, /function combineIdenticalDuplicateCommands\(commands\)[\s\S]*duplicateGroups[\s\S]*duplicateCount: group\.length/, "identical duplicate RPC commands should be combined into one visible command entry");
907
- assert.match(app, /if \(kind === "prompt" && attachments\.length === 0\) message = resolveRpcSlashCommandMessage\(message\)/, "manual slash prompts should resolve combined duplicate command aliases before reaching Pi RPC");
957
+ assert.match(app, /if \(kind === "prompt" && attachments\.length === 0\) message = resolveRpcSlashCommandMessage\(message, \{ tabId: targetTabId \}\)/, "manual targeted slash prompts should resolve combined duplicate command aliases from their captured target tab before reaching Pi RPC");
908
958
  assert.match(app, /if \(!isOptionalFeatureEnabled\("todoProgressWidget"\)\) return String\(text \|\| ""\)/, "todo progress line stripping should only run when the todo feature is detected and enabled");
909
959
  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");
910
960
  assert.match(app, /case "webui_tab_reloaded":[\s\S]*resetOptionalFeatureAvailability\(\)/, "optional feature state should reset when the RPC tab reloads resources");
@@ -939,7 +989,7 @@ assert.match(css, /\.git-workflow-message-input-row \{[\s\S]*flex:\s*1 1 100%/,
939
989
  assert.match(css, /\.git-workflow-actions button\[data-tooltip\]::after \{[\s\S]*content:\s*attr\(data-tooltip\)[\s\S]*white-space:\s*pre-line/, "guided git workflow action tooltips should render multiline step lists");
940
990
  assert.match(app, /function gitBranchNamePromptMessage\(\)[\s\S]*hasAvailableCommand\("git-branch-name"\)[\s\S]*return "\/git-branch-name"/, "guided git workflow should ask the agent to generate PR branch names when the prompt is available");
941
991
  assert.match(app, /async function loadGitWorkflowBranchName\([\s\S]*gitWorkflowRequest\("\/api\/git-workflow\/branch-name"/, "guided git workflow should load generated agent branch names before branch creation");
942
- assert.match(app, /async function createGitPrBranchWithSuggestion\([\s\S]*prompt\("New PR branch worktree name[\s\S]*gitWorkflowRequest\("\/api\/git-workflow\/branch", \{ body: \{ branch, sessionMode: "fork-current", openTab: true \}/, "guided git workflow should confirm an agent-suggested branch before opening its worktree");
992
+ assert.match(app, /async function createGitPrBranchWithSuggestion\([\s\S]*prompt\("New PR branch worktree name[\s\S]*assertGuidedGitStagedContentBinding\(tabId, "PR worktree creation"\)[\s\S]*gitWorkflowRequest\("\/api\/git-workflow\/branch", \{ body: \{ branch, sessionMode: "fork-current", openTab: true, [\s\S]*expectedStagedContentHash/, "guided git workflow should confirm an agent-suggested branch and verify approved staged content before opening its worktree");
943
993
  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");
944
994
  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");
945
995
  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");
@@ -954,7 +1004,7 @@ assert.match(server, /async function startGitWorkflowGeneration\([\s\S]*set_mode
954
1004
  assert.match(server, /event\?\.type === "agent_settled"[\s\S]*restoreGitWorkflowGenerationProfile\(tab\)/, "server should restore the active tab model and effort after generation settles");
955
1005
  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");
956
1006
  assert.match(server, /case "\/api\/git-workflow\/branch":[\s\S]*createGitWorkflowBranchWorktree\(tab, body\)/, "server should route guided PR branch creation through worktree tabs");
957
- 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");
1007
+ assert.match(server, /async function createGitWorkflowBranchWorktree\(tab, body = \{\}\)[\s\S]*expectedStagedContentHashFromBody\(body\)[\s\S]*snapshotGitWorkflowBranchState\(root, tab\.cwd, expectedStagedContentHash\)[\s\S]*applyGitWorkflowBranchStateToWorktree\(snapshot, worktreePath\)[\s\S]*openWorktreeResultForTab\(tab, createdResult/, "guided PR worktree creation should verify and copy exact staged state before opening the worktree tab");
958
1008
  assert.match(server, /case "\/api\/git-workflow\/create-pr":[\s\S]*runGitHubWorkflowCommand\(\["pr", "create"/, "server should create PRs with the GitHub CLI after confirmation");
959
1009
  assert.doesNotMatch(app, /gitWorkflowVisibleTabId|Workflow belongs to/, "guided git workflow should not pin or show workflows outside their owning terminal tab");
960
1010
  assert.match(app, /function renderReleaseNpmOutputWidget\(\)/, "release-npm live output should use a specialized Web UI renderer");
@@ -1601,6 +1651,9 @@ for (const [name, range] of Object.entries(companionDependencies)) {
1601
1651
  }
1602
1652
  assert.equal(pkg.bundledDependencies, undefined, "webui optional companion packages should not be bundled into the tarball");
1603
1653
  assert.equal(pkg.optionalDependencies?.["@firstpick/pi-package-natural-conversation"], undefined, "webui package should not optionally depend on the standalone Natural Conversation package");
1654
+ assert.equal(pkg.optionalDependencies?.["@firstpick/pi-extension-aur-review"], undefined, "webui package should not reference the unpublished aur-review extension");
1655
+ assert.equal(lock.packages?.["node_modules/@firstpick/pi-extension-aur-review"], undefined, "package lock should not retain an unpublished aur-review tarball");
1656
+ assert.ok(!pkg.pi?.extensions?.some((entry) => String(entry).includes("pi-extension-aur-review")), "webui Pi manifest should not bundle the unpublished aur-review path");
1604
1657
  assert.ok(!pkg.pi?.extensions?.some((entry) => String(entry).includes("pi-package-natural-conversation")), "webui Pi manifest should not load Natural Conversation directly; /talk must come from the standalone package");
1605
1658
  assert.ok(pkg.pi?.extensions?.includes("./index.ts"), "webui Pi manifest should load its own extension");
1606
1659
  for (const extensionPath of [