@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,180 @@
1
+ import assert from "node:assert/strict";
2
+ import { spawn, spawnSync } from "node:child_process";
3
+ import { createServer } from "node:net";
4
+ import { mkdtemp, rm, writeFile } from "node:fs/promises";
5
+ import { tmpdir } from "node:os";
6
+ import { dirname, join } from "node:path";
7
+ import { setTimeout as delay } from "node:timers/promises";
8
+ import { fileURLToPath } from "node:url";
9
+ import { expect, test } from "@playwright/test";
10
+
11
+ test.describe.configure({ mode: "serial" });
12
+
13
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
14
+ const serverScript = join(root, "bin", "pi-webui.mjs");
15
+ const fakePi = join(root, "tests", "fixtures", "fake-pi.mjs");
16
+
17
+ async function freePort() {
18
+ const server = createServer();
19
+ await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
20
+ const { port } = server.address();
21
+ await new Promise((resolve) => server.close(resolve));
22
+ return port;
23
+ }
24
+
25
+ let child;
26
+ let baseURL;
27
+ let tempRoot;
28
+ let output = "";
29
+
30
+ async function waitForServer() {
31
+ for (let attempt = 0; attempt < 100; attempt += 1) {
32
+ if (child.exitCode !== null) break;
33
+ try {
34
+ const response = await fetch(`${baseURL}/api/health`, { signal: AbortSignal.timeout(500) });
35
+ if (response.ok) return;
36
+ } catch {}
37
+ await delay(100);
38
+ }
39
+ throw new Error(`Pi Web UI did not start:\n${output}`);
40
+ }
41
+
42
+ test.beforeAll(async () => {
43
+ const port = await freePort();
44
+ tempRoot = await mkdtemp(join(tmpdir(), "pi-webui-guided-git-extension-"));
45
+ assert.equal(spawnSync("git", ["init", "--quiet"], { cwd: tempRoot }).status, 0);
46
+ await writeFile(join(tempRoot, "fixture.txt"), "guided git extension fixture\n", "utf8");
47
+ const settingsFile = join(tempRoot, "settings.json");
48
+ await writeFile(settingsFile, `${JSON.stringify({
49
+ version: 8,
50
+ gitWorkflow: {
51
+ reviewProcessEnabled: false,
52
+ stagingPolicy: "all",
53
+ generation: {
54
+ provider: "fake",
55
+ modelId: "fake-model",
56
+ thinkingLevel: "off",
57
+ unavailablePolicy: "ask",
58
+ fallback: { provider: "", modelId: "", thinkingLevel: "off" },
59
+ },
60
+ },
61
+ }, null, 2)}\n`, "utf8");
62
+ baseURL = `http://127.0.0.1:${port}`;
63
+ child = spawn(process.execPath, [serverScript, "--cwd", tempRoot, "--host", "127.0.0.1", "--port", String(port), "--pi", fakePi], {
64
+ stdio: ["ignore", "pipe", "pipe"],
65
+ env: {
66
+ ...process.env,
67
+ PI_WEBUI_RPC_SUPERVISOR: "0",
68
+ PI_CODING_AGENT_DIR: join(tempRoot, "agent"),
69
+ PI_WEBUI_SETTINGS_FILE: settingsFile,
70
+ FAKE_PI_GUIDED_GIT_ACTIVATION: "1",
71
+ FAKE_PI_GUIDED_GIT_ACTIVATION_DELAY_MS: "150",
72
+ },
73
+ });
74
+ child.stdout.on("data", (chunk) => { output += String(chunk); });
75
+ child.stderr.on("data", (chunk) => { output += String(chunk); });
76
+ await waitForServer();
77
+ });
78
+
79
+ test.afterAll(async () => {
80
+ if (child?.exitCode === null) child.kill("SIGTERM");
81
+ if (child?.exitCode === null) await new Promise((resolve) => child.once("exit", resolve));
82
+ await rm(tempRoot, { recursive: true, force: true });
83
+ });
84
+
85
+ test("typing /git-guided-workflow opens the originating tab workflow exactly once", async ({ page }) => {
86
+ let preferenceLoads = 0;
87
+ page.on("request", (request) => {
88
+ if (new URL(request.url()).pathname === "/api/git-workflow/preferences") preferenceLoads += 1;
89
+ });
90
+ await page.goto(baseURL);
91
+ const button = page.locator("#gitWorkflowButton");
92
+ await expect(button).toBeVisible();
93
+ await expect(button).toBeEnabled();
94
+
95
+ const prompt = page.locator("#promptInput");
96
+ await prompt.fill("/git-guided-workflow");
97
+ await prompt.press("Enter");
98
+
99
+ await expect(page.locator("#gitWorkflowPanel")).toBeVisible();
100
+ await expect(page.locator("#gitWorkflowKicker")).toHaveText("Git workflow");
101
+ await expect(prompt).toHaveValue("");
102
+ await delay(200);
103
+ assert.equal(preferenceLoads, 1, "one typed extension command must start one browser workflow");
104
+ });
105
+
106
+ test("one browser command starts Guided Git only in its originating client", async ({ browser }) => {
107
+ const context = await browser.newContext();
108
+ const origin = await context.newPage();
109
+ const observer = await context.newPage();
110
+ let originPreferenceLoads = 0;
111
+ let observerPreferenceLoads = 0;
112
+ origin.on("request", (request) => {
113
+ if (new URL(request.url()).pathname === "/api/git-workflow/preferences") originPreferenceLoads += 1;
114
+ });
115
+ observer.on("request", (request) => {
116
+ if (new URL(request.url()).pathname === "/api/git-workflow/preferences") observerPreferenceLoads += 1;
117
+ });
118
+ await origin.goto(baseURL);
119
+ await observer.goto(baseURL);
120
+ await expect(origin.locator("#gitWorkflowButton")).toBeEnabled();
121
+ await expect(observer.locator("#gitWorkflowButton")).toBeEnabled();
122
+
123
+ await origin.locator("#promptInput").fill("/git-guided-workflow");
124
+ await origin.locator("#promptInput").press("Enter");
125
+
126
+ await expect(origin.locator("#gitWorkflowPanel")).toBeVisible();
127
+ await delay(250);
128
+ await expect(observer.locator("#gitWorkflowPanel")).toBeHidden();
129
+ assert.equal(originPreferenceLoads, 1, "the initiating browser owns the activation");
130
+ assert.equal(observerPreferenceLoads, 0, "another browser attached to the same Pi tab must ignore the broadcast");
131
+ await context.close();
132
+ });
133
+
134
+ test("two initiating clients cannot cross-claim one pending Guided Git activation", async ({ browser }) => {
135
+ const context = await browser.newContext();
136
+ const first = await context.newPage();
137
+ const second = await context.newPage();
138
+ let preferenceLoads = 0;
139
+ for (const page of [first, second]) {
140
+ page.on("request", (request) => {
141
+ if (new URL(request.url()).pathname === "/api/git-workflow/preferences") preferenceLoads += 1;
142
+ });
143
+ await page.goto(baseURL);
144
+ await expect(page.locator("#gitWorkflowButton")).toBeEnabled();
145
+ await page.locator("#promptInput").fill("/git-guided-workflow");
146
+ }
147
+
148
+ await Promise.all([
149
+ first.locator("#promptInput").press("Enter"),
150
+ second.locator("#promptInput").press("Enter"),
151
+ ]);
152
+ await expect.poll(async () => Number(await first.locator("#gitWorkflowPanel").isVisible()) + Number(await second.locator("#gitWorkflowPanel").isVisible())).toBe(1);
153
+ await delay(250);
154
+ assert.equal(preferenceLoads, 1, "server arbitration and envelope correlation must produce one aggregate start");
155
+ await context.close();
156
+ });
157
+
158
+ test("Guided Git button dispatch preserves the existing composer draft and attachment", async ({ page }) => {
159
+ const promptMessages = [];
160
+ page.on("request", (request) => {
161
+ if (new URL(request.url()).pathname !== "/api/prompt" || request.method() !== "POST") return;
162
+ const data = request.postDataJSON();
163
+ promptMessages.push(data?.message);
164
+ });
165
+ await page.goto(baseURL);
166
+ const prompt = page.locator("#promptInput");
167
+ await prompt.fill("keep this draft");
168
+ await page.locator("#attachmentInput").setInputFiles({
169
+ name: "keep.txt",
170
+ mimeType: "text/plain",
171
+ buffer: Buffer.from("keep this attachment\n"),
172
+ });
173
+ await expect(page.locator(".attachment-pill-name")).toHaveText("keep.txt");
174
+
175
+ await page.locator("#gitWorkflowButton").click();
176
+ await expect(page.locator("#gitWorkflowPanel")).toBeVisible();
177
+ await expect(prompt).toHaveValue("keep this draft");
178
+ await expect(page.locator(".attachment-pill-name")).toHaveText("keep.txt");
179
+ assert.equal(promptMessages.filter((message) => /^\/git-guided-workflow(?::\d+)?$/u.test(String(message || ""))).length, 1);
180
+ });
@@ -8,6 +8,8 @@ import { setTimeout as delay } from "node:timers/promises";
8
8
  import { fileURLToPath } from "node:url";
9
9
  import { expect, test } from "@playwright/test";
10
10
 
11
+ test.describe.configure({ mode: "serial" });
12
+
11
13
  const root = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
12
14
  const serverScript = join(root, "bin", "pi-webui.mjs");
13
15
 
@@ -44,13 +46,39 @@ test.beforeAll(async () => {
44
46
  const fakePi = join(tempRoot, "fake-pi.mjs");
45
47
  const logFile = join(tempRoot, "rpc.jsonl");
46
48
  await writeFile(fakePi, `#!/usr/bin/env node
47
- import { appendFileSync } from "node:fs";
49
+ import { appendFileSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
50
+ import { join } from "node:path";
48
51
  import { createInterface } from "node:readline";
49
52
  const logFile = process.env.GUIDED_GIT_BROWSER_LOG;
53
+ const fallbackSuccessFlag = process.env.GUIDED_GIT_BROWSER_FALLBACK_SUCCESS;
54
+ const artifactRoot = process.env.GUIDED_GIT_BROWSER_ARTIFACT_ROOT;
50
55
  let model = { provider: "fake", id: "original" };
51
56
  let thinkingLevel = "high";
52
57
  function send(value) { process.stdout.write(JSON.stringify(value) + "\\n"); }
53
58
  function log(value) { appendFileSync(logFile, JSON.stringify(value) + "\\n"); }
59
+ function fallbackSuccessEnabled() { return existsSync(fallbackSuccessFlag); }
60
+ function event(value) { send(value); }
61
+ function assistantFailure() { return { role: "assistant", stopReason: "error", content: [{ type: "text", text: "fixture failure" }] }; }
62
+ function writeCommitArtifacts() {
63
+ const directory = join(artifactRoot, "dev", "COMMIT");
64
+ mkdirSync(directory, { recursive: true });
65
+ writeFileSync(join(directory, "staged-commit-short.txt"), "fallback short\\n");
66
+ writeFileSync(join(directory, "staged-commit-long.txt"), "fallback long\\n");
67
+ }
68
+ function settle({ failed = false, wait = 20 } = {}) {
69
+ setTimeout(() => {
70
+ event({ type: "agent_start" });
71
+ if (failed) {
72
+ const message = assistantFailure();
73
+ event({ type: "message_end", message });
74
+ event({ type: "agent_end", willRetry: false, messages: [message] });
75
+ } else {
76
+ event({ type: "message_end", message: { role: "assistant", content: [{ type: "text", text: "fixture success" }] } });
77
+ event({ type: "agent_end" });
78
+ }
79
+ event({ type: "agent_settled" });
80
+ }, wait);
81
+ }
54
82
  const models = [
55
83
  { provider: "fake", id: "original", name: "Original", reasoning: true },
56
84
  { provider: "fake", id: "primary", name: "Primary", reasoning: true },
@@ -69,10 +97,12 @@ createInterface({ input: process.stdin }).on("line", (line) => {
69
97
  { name: "pr", source: "extension", description: "Generate PR text" },
70
98
  ] } });
71
99
  else if (command.type === "get_messages") send({ ...response, data: { messages: [] } });
72
- else if (command.type === "set_model" && command.modelId === "primary") send({ ...response, success: false, error: "SECRET primary failure at /private/provider.mjs:12" });
100
+ else if (command.type === "set_model" && command.modelId === "primary" && !fallbackSuccessEnabled()) send({ ...response, success: false, error: "SECRET primary failure at /private/provider.mjs:12" });
73
101
  else if (command.type === "set_model") { model = { provider: command.provider, id: command.modelId }; send({ ...response, data: model }); }
74
102
  else if (command.type === "set_thinking_level") { thinkingLevel = command.level; send({ ...response, data: { level: thinkingLevel } }); }
75
- else if (command.type === "prompt" && model.id === "fallback") send({ ...response, success: false, error: "SECRET fallback failure at /private/provider.mjs:44" });
103
+ else if (command.type === "prompt" && model.id === "primary" && fallbackSuccessEnabled()) { send({ ...response, data: {} }); settle({ failed: true }); }
104
+ else if (command.type === "prompt" && model.id === "fallback" && !fallbackSuccessEnabled()) send({ ...response, success: false, error: "SECRET fallback failure at /private/provider.mjs:44" });
105
+ else if (command.type === "prompt" && model.id === "fallback") { send({ ...response, data: {} }); setTimeout(writeCommitArtifacts, 450); settle({ wait: 600 }); }
76
106
  else send({ ...response, data: {} });
77
107
  });
78
108
  `, "utf8");
@@ -103,6 +133,8 @@ createInterface({ input: process.stdin }).on("line", (line) => {
103
133
  PI_CODING_AGENT_DIR: join(tempRoot, "agent"),
104
134
  PI_WEBUI_SETTINGS_FILE: settingsFile,
105
135
  GUIDED_GIT_BROWSER_LOG: logFile,
136
+ GUIDED_GIT_BROWSER_FALLBACK_SUCCESS: join(tempRoot, "fallback-success"),
137
+ GUIDED_GIT_BROWSER_ARTIFACT_ROOT: tempRoot,
106
138
  },
107
139
  });
108
140
  child.stdout.on("data", (chunk) => { output += String(chunk); });
@@ -151,3 +183,36 @@ test("pre-response fallback lifecycle survives correlation and remains browser-o
151
183
  const entries = (await log).trim().split("\n").filter(Boolean).map((line) => JSON.parse(line));
152
184
  assert.equal(entries.filter((entry) => entry.type === "prompt" && entry.activeModel === "fallback").length, 1, "the browser must not dispatch another fallback prompt");
153
185
  });
186
+
187
+ test("a slow successful fallback opens the generated message preview automatically", async ({ page }) => {
188
+ await writeFile(join(tempRoot, "fallback-success"), "enabled\n", "utf8");
189
+ await page.route("**/app.js?v=*", async (route) => {
190
+ const response = await route.fetch();
191
+ const source = await response.text();
192
+ assert.match(source, /GIT_WORKFLOW_MESSAGE_POLL_TIMEOUT_MS = 30_000/);
193
+ await route.fulfill({ response, body: source.replace("GIT_WORKFLOW_MESSAGE_POLL_TIMEOUT_MS = 30_000", "GIT_WORKFLOW_MESSAGE_POLL_TIMEOUT_MS = 100") });
194
+ });
195
+ await page.route("**/api/commands?*", async (route) => {
196
+ await route.fulfill({
197
+ status: 200,
198
+ contentType: "application/json",
199
+ body: JSON.stringify({ ok: true, data: { commands: [
200
+ { name: "git-staged-msg", source: "extension", description: "Generate commit messages" },
201
+ { name: "git-branch-name", source: "extension", description: "Generate branch names" },
202
+ { name: "pr", source: "extension", description: "Generate PR text" },
203
+ ] } }),
204
+ });
205
+ });
206
+ await page.goto(baseURL);
207
+ await page.locator("#gitWorkflowButton").click();
208
+
209
+ const panel = page.locator("#gitWorkflowPanel");
210
+ await panel.getByRole("button", { name: "Run git add ." }).click();
211
+ await panel.getByRole("button", { name: "Generate commit message" }).click();
212
+
213
+ const outputText = page.locator("#gitWorkflowOutput");
214
+ await expect(outputText).toContainText("fallback short");
215
+ await expect(outputText).toContainText("fallback long");
216
+ await expect(panel.getByRole("button", { name: "Commit short (default)", exact: true })).toBeVisible();
217
+ await expect(outputText).not.toContainText("Preview current message files");
218
+ });
@@ -234,10 +234,14 @@ test("main output shows non-blocking inline feedback while transcript data loads
234
234
  await expect(chat).toHaveAttribute("aria-busy", "true");
235
235
  await expect(page.locator("#promptInput")).toBeEnabled();
236
236
  assert.equal(await page.evaluate(() => document.querySelectorAll("dialog:modal").length), 0, "loading feedback should not open a popup");
237
+ const loadingChatBounds = await chat.boundingBox();
238
+ assert.ok(loadingChatBounds, "the transcript should have measurable bounds while loading");
237
239
 
238
240
  releaseMessages();
239
241
  await expect(loading).toBeHidden();
240
242
  await expect(chat).toHaveAttribute("aria-busy", "false");
243
+ const settledChatBounds = await chat.boundingBox();
244
+ assert.deepEqual(settledChatBounds, loadingChatBounds, "showing or hiding loading feedback must not move or resize the transcript");
241
245
  } finally {
242
246
  releaseMessages?.();
243
247
  await page.unroute(messagesPattern);
@@ -301,6 +305,35 @@ test("only hidden pages disconnect live events and resume from one authoritative
301
305
  assert.ok(Date.now() - resumedAt < 4_000, "the bounded snapshot resume should complete without replaying the hidden stream duration");
302
306
  });
303
307
 
308
+ test("the main input shows six lines before vertical scrolling", async ({ page }) => {
309
+ await page.setViewportSize({ width: 1280, height: 800 });
310
+ await page.goto(baseURL);
311
+
312
+ const promptInput = page.locator("#promptInput");
313
+ await promptInput.fill(Array.from({ length: 6 }, (_, index) => `line ${index + 1}`).join("\n"));
314
+ const sixLines = await promptInput.evaluate((node) => {
315
+ const style = getComputedStyle(node);
316
+ return {
317
+ clientHeight: node.clientHeight,
318
+ scrollHeight: node.scrollHeight,
319
+ renderedHeight: node.getBoundingClientRect().height,
320
+ lineHeight: style.lineHeight,
321
+ maxHeight: style.maxHeight,
322
+ paddingBlock: `${style.paddingTop} + ${style.paddingBottom}`,
323
+ };
324
+ });
325
+ assert.ok(sixLines.scrollHeight <= sixLines.clientHeight + 1, `six lines overflowed: ${JSON.stringify(sixLines)}`);
326
+
327
+ await promptInput.fill(Array.from({ length: 7 }, (_, index) => `line ${index + 1}`).join("\n"));
328
+ const sevenLines = await promptInput.evaluate((node) => ({
329
+ clientHeight: node.clientHeight,
330
+ scrollHeight: node.scrollHeight,
331
+ renderedHeight: node.getBoundingClientRect().height,
332
+ }));
333
+ assert.ok(sevenLines.scrollHeight > sevenLines.clientHeight + 1, "the seventh line should overflow the six-line input height");
334
+ assert.ok(Math.abs(sevenLines.renderedHeight - sixLines.renderedHeight) <= 1, "the prompt should stop growing after six lines");
335
+ });
336
+
304
337
  test("autosizing the main input does not move settled agent output", async ({ page }) => {
305
338
  await page.setViewportSize({ width: 1280, height: 800 });
306
339
  await page.goto(baseURL);
@@ -0,0 +1,198 @@
1
+ import { spawn } from "node:child_process";
2
+ import { createServer } from "node:net";
3
+ import { mkdtemp, rm } from "node:fs/promises";
4
+ import { tmpdir } from "node:os";
5
+ import { dirname, join } from "node:path";
6
+ import { setTimeout as delay } from "node:timers/promises";
7
+ import { fileURLToPath } from "node:url";
8
+ import assert from "node:assert/strict";
9
+ import AxeBuilder from "@axe-core/playwright";
10
+ import { expect, test } from "@playwright/test";
11
+
12
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
13
+ const serverScript = join(root, "bin", "pi-webui.mjs");
14
+ const fakePi = join(root, "tests", "fixtures", "fake-pi.mjs");
15
+ const WINDOWS_DRIVES_PICKER_PATH = "::pi-webui-windows-drives::";
16
+
17
+ async function freePort() {
18
+ const server = createServer();
19
+ await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
20
+ const { port } = server.address();
21
+ await new Promise((resolve) => server.close(resolve));
22
+ return port;
23
+ }
24
+
25
+ let child;
26
+ let baseURL;
27
+ let tempRoot;
28
+ let output = "";
29
+
30
+ test.beforeAll(async () => {
31
+ const port = await freePort();
32
+ tempRoot = await mkdtemp(join(tmpdir(), "pi-webui-windows-drive-parent-"));
33
+ baseURL = `http://127.0.0.1:${port}`;
34
+ child = spawn(process.execPath, [serverScript, "--cwd", tempRoot, "--host", "127.0.0.1", "--port", String(port), "--pi", fakePi], {
35
+ stdio: ["ignore", "pipe", "pipe"],
36
+ env: {
37
+ ...process.env,
38
+ PI_WEBUI_RPC_SUPERVISOR: "0",
39
+ PI_CODING_AGENT_DIR: join(tempRoot, "agent"),
40
+ PI_WEBUI_SETTINGS_FILE: join(tempRoot, "settings.json"),
41
+ },
42
+ });
43
+ child.stdout.on("data", (chunk) => { output += String(chunk); });
44
+ child.stderr.on("data", (chunk) => { output += String(chunk); });
45
+ for (let attempt = 0; attempt < 80; attempt += 1) {
46
+ if (child.exitCode !== null) break;
47
+ try {
48
+ const response = await fetch(`${baseURL}/api/health`, { signal: AbortSignal.timeout(500) });
49
+ if (response.ok) return;
50
+ } catch {
51
+ // Wait for the local server and fake Pi fixture.
52
+ }
53
+ await delay(100);
54
+ }
55
+ throw new Error(`Pi Web UI did not start:\n${output}`);
56
+ });
57
+
58
+ test.afterAll(async () => {
59
+ child?.kill("SIGTERM");
60
+ if (child?.exitCode === null) await new Promise((resolve) => child.once("exit", resolve));
61
+ await rm(tempRoot, { recursive: true, force: true });
62
+ });
63
+
64
+ function directoryPayload(cwd, { parent = WINDOWS_DRIVES_PICKER_PATH, directories = [] } = {}) {
65
+ return {
66
+ cwd,
67
+ displayCwd: cwd,
68
+ parent,
69
+ roots: [],
70
+ directories,
71
+ truncated: false,
72
+ };
73
+ }
74
+
75
+ function virtualDrivesPayload() {
76
+ return {
77
+ cwd: "",
78
+ displayCwd: "This PC",
79
+ parent: null,
80
+ roots: [],
81
+ directories: ["C:\\", "D:\\", "E:\\"].map((cwd) => ({ name: cwd, cwd, displayCwd: cwd, hidden: false })),
82
+ truncated: false,
83
+ selectable: false,
84
+ };
85
+ }
86
+
87
+ test("Windows drive Parent flow remains navigation-only, accessible, and cwd-safe", async ({ page }) => {
88
+ const directoryRequests = [];
89
+ const tabCreateBodies = [];
90
+
91
+ await page.route("**/api/path-fast-picks*", async (route) => {
92
+ await route.fulfill({
93
+ status: 200,
94
+ contentType: "application/json",
95
+ body: JSON.stringify({ ok: true, data: { picks: [{ cwd: "D:\\", displayCwd: "D:\\" }] } }),
96
+ });
97
+ });
98
+ await page.route(/\/api\/tabs(?:\?.*)?$/, async (route) => {
99
+ if (route.request().method() !== "POST") return route.fallback();
100
+ tabCreateBodies.push(route.request().postDataJSON());
101
+ await route.fulfill({ status: 400, contentType: "application/json", body: JSON.stringify({ ok: false, error: "test stopped after cwd submission" }) });
102
+ });
103
+ await page.route("**/api/directories*", async (route) => {
104
+ if (route.request().method() !== "GET") return route.fallback();
105
+ const requestedPath = new URL(route.request().url()).searchParams.get("path") || "";
106
+ directoryRequests.push(requestedPath);
107
+ if (requestedPath === WINDOWS_DRIVES_PICKER_PATH) {
108
+ await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, data: virtualDrivesPayload() }) });
109
+ return;
110
+ }
111
+ if (requestedPath === "E:\\") {
112
+ await route.fulfill({ status: 400, contentType: "application/json", body: JSON.stringify({ ok: false, error: "Drive E is unavailable" }) });
113
+ return;
114
+ }
115
+ const data = requestedPath === "D:/project"
116
+ ? directoryPayload("D:\\project", { parent: "D:\\" })
117
+ : directoryPayload(requestedPath === "D:\\" ? "D:\\" : "C:\\");
118
+ await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, data }) });
119
+ });
120
+
121
+ await page.setViewportSize({ width: 1280, height: 850 });
122
+ await page.goto(baseURL);
123
+ await expect(page.locator("#promptInput")).toBeVisible();
124
+
125
+ await page.keyboard.press("Control+k");
126
+ await page.locator("#commandPaletteInput").fill("Choose directory for new tab");
127
+ await page.keyboard.press("Enter");
128
+
129
+ const dialog = page.locator("#pathPickerDialog");
130
+ const current = page.locator("#pathPickerCurrent");
131
+ const search = page.locator("#pathPickerSearchInput");
132
+ const directPath = page.locator("#pathPickerPathInput");
133
+ const choose = page.locator("#pathPickerChooseButton");
134
+ await expect(dialog).toBeVisible();
135
+ await expect(current).toHaveText("C:\\");
136
+
137
+ await page.locator("#pathPickerFastPicks .path-picker-fast-pick-button", { hasText: "D:" }).click();
138
+ await expect(current).toHaveText("D:\\");
139
+ await expect(search).toBeFocused();
140
+
141
+ await page.getByRole("button", { name: "↑ Parent" }).click();
142
+ await expect(current).toHaveText("This PC");
143
+ await expect(search).toBeFocused();
144
+ await expect(choose).toBeDisabled();
145
+ await expect(page.locator("#pathPickerCreateNameInput")).toBeDisabled();
146
+ await expect(page.locator("#pathPickerCreateButton")).toBeDisabled();
147
+ await expect(page.locator("#pathPickerAddFastPickButton")).toBeDisabled();
148
+ await expect(search).toBeEnabled();
149
+ await expect(directPath).toBeEnabled();
150
+
151
+ const accessibility = await new AxeBuilder({ page }).include("#pathPickerDialog").disableRules(["aria-required-children"]).analyze();
152
+ const serious = accessibility.violations.filter((violation) => ["serious", "critical"].includes(violation.impact));
153
+ assert.deepEqual(serious, [], `This PC picker should have no serious/critical Axe violations: ${serious.map(({ id }) => id).join(", ")}`);
154
+
155
+ await search.fill("D");
156
+ await expect(page.locator("#pathPickerList .path-picker-directory")).toHaveCount(1);
157
+ await expect(page.locator("#pathPickerList .path-picker-directory")).toHaveText("D:\\");
158
+ await page.locator("#pathPickerClearSearchButton").click();
159
+
160
+ await page.locator("#pathPickerList .path-picker-directory", { hasText: "D:\\" }).click();
161
+ await expect(current).toHaveText("D:\\");
162
+ await expect(search).toBeFocused();
163
+ await page.getByRole("button", { name: "↑ Parent" }).click();
164
+ await expect(current).toHaveText("This PC");
165
+ await expect(search).toBeFocused();
166
+
167
+ await directPath.fill("D:/project");
168
+ await page.locator("#pathPickerList .path-picker-directory", { hasText: "E:\\" }).click();
169
+ const alert = page.locator("#pathPickerError");
170
+ await expect(alert).toHaveAttribute("role", "alert");
171
+ await expect(alert).toContainText("Drive E is unavailable");
172
+ await expect(current).toHaveText("This PC");
173
+ await expect(directPath).toHaveValue("D:/project");
174
+
175
+ await page.locator("#pathPickerPathButton").click();
176
+ await expect(current).toHaveText("D:\\project");
177
+ await expect(search).not.toBeFocused();
178
+ assert.ok(directoryRequests.includes("D:/project"), "direct path entry should preserve slash-form drive-qualified input");
179
+
180
+ await page.getByRole("button", { name: "↑ Parent" }).click();
181
+ await expect(current).toHaveText("D:\\");
182
+ await expect(search).toBeFocused();
183
+ await page.getByRole("button", { name: "↑ Parent" }).click();
184
+ await expect(current).toHaveText("This PC");
185
+ await expect(search).toBeFocused();
186
+
187
+ await page.evaluate(() => document.querySelector("#pathPickerChooseButton").click());
188
+ await expect(dialog).toBeVisible();
189
+ assert.deepEqual(tabCreateBodies, [], "the virtual empty cwd must not create a tab");
190
+
191
+ await page.locator("#pathPickerList .path-picker-directory", { hasText: "C:\\" }).click();
192
+ await expect(current).toHaveText("C:\\");
193
+ await expect(search).toBeFocused();
194
+ await choose.click();
195
+ await expect.poll(() => tabCreateBodies.length).toBe(1);
196
+ assert.deepEqual(tabCreateBodies, [{ cwd: "C:\\" }]);
197
+ assert.ok(tabCreateBodies.every(({ cwd }) => cwd && cwd !== WINDOWS_DRIVES_PICKER_PATH), "only a real drive root may reach tab creation");
198
+ });
@@ -55,7 +55,7 @@ assert.match(app, /statusKey === CODEX_FAST_MODE_STATUS_KEY[\s\S]*?applyCodexFas
55
55
  assert.match(technical, /## Normal and compact output[\s\S]*?select \*\*Compact\*\*[\s\S]*?`compact-v1`/, "technical reference should document Compact mode with the stable identifier");
56
56
  assert.match(development, /### Codex subscription Fast mode[\s\S]*?service_tier: "priority"[\s\S]*?1\.5× faster[\s\S]*?2× Standard credits[\s\S]*?2\.5×/, "development guide should document Fast-mode integration and cost semantics");
57
57
  // Intent preserved: browser-asset changes must advance the coherent cache tuple.
58
- assert.match(serviceWorker, /pi-webui-pwa-v132/, "PWA cache identity should be bumped for changed browser assets");
59
- assert.match(html, /data-app-src="\/app\.js\?v=166"/, "browser module URL should be cache-busted for Fast-mode wiring");
58
+ assert.match(serviceWorker, /pi-webui-pwa-v142/, "PWA cache identity should be bumped for changed browser assets");
59
+ assert.match(html, /data-app-src="\/app\.js\?v=175"/, "browser module URL should be cache-busted for Fast-mode wiring");
60
60
 
61
61
  console.log("codex-fast-mode-static.test.mjs passed");
@@ -25,7 +25,7 @@ assert.match(server, /operation\.type === "delete"[\s\S]*queue\.splice\(slots\[o
25
25
  assert.match(server, /url\.pathname === "\/api\/queue\/mutate" && req\.method === "POST"[\s\S]*request\.source === "webui-compaction"[\s\S]*mutateCompactionFollowUpQueue[\s\S]*status = data\?\.mutated === true \? 200 : conflict \? 409 : 400/, "queue mutation HTTP handling should keep compaction mutations source-specific and map conflicts to 409");
26
26
 
27
27
  assert.match(app, /function isRunActive\(\) \{\n\s+return !!currentState\?\.isStreaming \|\| !!currentState\?\.isCompacting/, "frontend should treat compaction as an active run for composer controls");
28
- assert.match(app, /const targetWasCompacting = !!currentState\?\.isCompacting;[\s\S]*const targetWasBusy = targetWasStreaming \|\| targetWasCompacting[\s\S]*if \(targetWasBusy\) body\.streamingBehavior = streamingBehavior \|\| busyBehavior/, "prompt send should use busy behavior while streaming or compacting");
28
+ assert.match(app, /const targetState = targetTabId === activeTabId \? currentState : tabStateCache\.get\(targetTabId\);[\s\S]*const targetWasCompacting = !!targetState\?\.isCompacting;[\s\S]*const targetWasBusy = targetWasStreaming \|\| targetWasCompacting[\s\S]*if \(targetWasBusy\) body\.streamingBehavior = streamingBehavior \|\| busyBehavior/, "prompt send should use the captured target tab's busy behavior while streaming or compacting");
29
29
  assert.match(app, /case "webui_compaction_queue_update":[\s\S]*renderQueue\(event\)[\s\S]*queued compaction prompt sent; Pi is resuming/, "frontend should surface compaction queue and resume events");
30
30
 
31
31
  console.log("compaction-static.test.mjs passed");
@@ -57,8 +57,8 @@ assert.match(app, /function initializeComposerActionOrdering\(\)[\s\S]*MutationO
57
57
  assert.match(app, /event\.key === COMPOSER_ACTION_ORDER_STORAGE_KEY\) restoreComposerActionOrder\(\)[\s\S]*event\.key === COMPOSER_ACTION_LAYOUT_STORAGE_KEY\) restoreComposerActionSlotLayout\(\)/, "other tabs should apply persisted composer order and sparse-layout changes");
58
58
  assert.match(app, /initializeComposerActionOrdering\(\);[\s\S]*restoreSidePanelSectionOrder\(\);/, "composer ordering should initialize during guarded app startup");
59
59
 
60
- assert.match(html, /styles\.css\?v=137/, "changed composer styles should advance the stylesheet revision");
61
- assert.match(html, /app\.js\?v=166/, "changed composer behavior should advance the app revision");
62
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "changed browser assets should advance the PWA cache identity");
60
+ assert.match(html, /styles\.css\?v=143/, "changed composer styles should advance the stylesheet revision");
61
+ assert.match(html, /app\.js\?v=175/, "changed composer behavior should advance the app revision");
62
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v142"/, "changed browser assets should advance the PWA cache identity");
63
63
 
64
64
  console.log("composer-action-grid-reorder-static.test.mjs passed");
@@ -348,10 +348,10 @@ assert.match(
348
348
 
349
349
  assert.match(
350
350
  serviceWorker,
351
- /const CACHE_NAME = "pi-webui-pwa-v132";/,
351
+ /const CACHE_NAME = "pi-webui-pwa-v142";/,
352
352
  "browser asset changes should advance the PWA cache identity",
353
353
  );
354
- assert.match(html, /styles\.css\?v=137/, "visibility styles should advance the stylesheet query revision");
355
- assert.match(html, /data-app-src="\/app\.js\?v=166"/, "visibility behavior should advance the app query revision");
354
+ assert.match(html, /styles\.css\?v=143/, "visibility styles should advance the stylesheet query revision");
355
+ assert.match(html, /data-app-src="\/app\.js\?v=175"/, "visibility behavior should advance the app query revision");
356
356
 
357
357
  console.log("control-visibility-static.test.mjs passed");
@@ -15,8 +15,8 @@ assert.equal((html.match(/class="control-row-label"[^>]*data-tooltip=/g) || []).
15
15
  assert.match(app, /function initializeControlSettingTooltips\(\)[\s\S]*#sidePanelSectionControls \.control-row-label\[data-tooltip\][\s\S]*bindStyledTooltipEvents\(label\)[\s\S]*showFooterTooltip\(label\)/, "Controls help should use the viewport-safe floating tooltip for hover and keyboard access");
16
16
  assert.match(html, /class="control-row remote-auth-control-row" hidden[\s\S]*id="remoteAuthToggle"/, "optional PIN protection should retain its guarded visibility");
17
17
  assert.match(app, /remoteAuthToggle\?\.closest\("\.remote-auth-control-row"\)[\s\S]*remoteAuthRow\.hidden = false/, "loading remote status should reveal the optional PIN protection setting");
18
- assert.match(html, /styles\.css\?v=137/, "Controls stylesheet changes should advance the cache query");
19
- assert.match(html, /app\.js\?v=166/, "Controls tooltip wiring should advance the app cache query");
20
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "Controls browser assets should advance the PWA cache identity");
18
+ assert.match(html, /styles\.css\?v=143/, "Controls stylesheet changes should advance the cache query");
19
+ assert.match(html, /app\.js\?v=175/, "Controls tooltip wiring should advance the app cache query");
20
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v142"/, "Controls browser assets should advance the PWA cache identity");
21
21
 
22
22
  console.log("controls-layout-static.test.mjs passed");
@@ -124,8 +124,8 @@ assert.match(styles, /\.event-log\[data-display-mode="compact"\] \.event\[data-e
124
124
  assert.match(styles, /\.event-tree-context-menu \{[\s\S]*max-width: calc\(100vw - 1rem\)/, "the dedicated menu should remain viewport bounded");
125
125
 
126
126
  // Cache tuple for this browser-asset change.
127
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132";/, "the PWA cache identity should advance");
128
- assert.match(html, /styles\.css\?v=137/, "compact-mode styles should advance the stylesheet revision");
129
- assert.match(html, /data-app-src="\/app\.js\?v=166"/, "the app query revision should advance");
127
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v142";/, "the PWA cache identity should advance");
128
+ assert.match(html, /styles\.css\?v=143/, "compact-mode styles should advance the stylesheet revision");
129
+ assert.match(html, /data-app-src="\/app\.js\?v=175"/, "the app query revision should advance");
130
130
 
131
131
  console.log("events-tree-context-menu-static.test.mjs passed");
@@ -159,7 +159,7 @@ assert.match(worker, /pi-webui-pwa-v\d+[\s\S]*?"\/fast-output-live\.mjs"/, "PWA
159
159
  assert.match(html, /<label for="fastOutputModeSelect">Compact mode \(Experimental\)<\/label>/, "the sidebar should mark compact mode as experimental");
160
160
  assert.match(html, /Lightweight browser rendering; Markdown final output; live thinking expanded; stored thinking grouped and collapsed/, "the sidebar should distinguish compact rendering from model inference");
161
161
  // Intent preserved: the guarded PWA entry point must advance whenever app wiring changes.
162
- assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=166"/, "the guarded PWA entry point should cache-bust browser wiring");
162
+ assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=175"/, "the guarded PWA entry point should cache-bust browser wiring");
163
163
  assert.match(JSON.parse(packageRaw).scripts.check, /node --check public\/fast-output-live\.mjs/, "package checks should parse the compact helper");
164
164
 
165
165
  const events = createFastModeOutputEvents();
@@ -166,7 +166,7 @@ assert.match(functionSource("closeTerminalTabs"), /clearFeatureDecisionStateForT
166
166
  assert.match(app, /case "webui_connected":[\s\S]*clearFeatureDecisionStateForTab\(connectedTabId, \{ render: true \}\)[\s\S]*scheduleForegroundReconcile\("event stream reconnect", 0\)/, "reconnect should clear local state before authoritative replay");
167
167
  assert.match(app, /statusKey === FEATURE_DECISION_OUTPUT_STATUS_KEY[\s\S]*handleFeatureDecisionOutputStatus[\s\S]*return;[\s\S]*statusKey === FEATURE_CATEGORY_STATUS_KEY[\s\S]*return;[\s\S]*statusEntries\.set/, "both feature statuses should be intercepted before generic footer storage while preserving category handling");
168
168
 
169
- assert.match(html, /\/styles\.css\?v=137/, "integrated stylesheet changes should advance the cache query");
170
- assert.match(html, /\/app\.js\?v=166/, "integrated app changes should advance the cache query");
169
+ assert.match(html, /\/styles\.css\?v=143/, "integrated stylesheet changes should advance the cache query");
170
+ assert.match(html, /\/app\.js\?v=175/, "integrated app changes should advance the cache query");
171
171
 
172
172
  console.log("feature decision-output popup static checks passed");