@firstpick/pi-package-webui 0.9.1 → 0.9.3

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 (107) hide show
  1. package/README.md +31 -9
  2. package/bin/pi-webui-launcher.mjs +23 -12
  3. package/bin/pi-webui.mjs +729 -93
  4. package/index.ts +266 -1
  5. package/lib/agent-run-adapters.mjs +500 -0
  6. package/lib/agent-run-protocol.mjs +262 -0
  7. package/lib/agent-run-registry.mjs +339 -0
  8. package/lib/git-workflow-preferences.mjs +18 -28
  9. package/lib/intercom-conversations.mjs +491 -0
  10. package/lib/intercom-transcript-filter.mjs +99 -0
  11. package/lib/resource-selection.mjs +140 -0
  12. package/lib/trust-boundaries.mjs +2 -0
  13. package/lib/ui-layout-settings.mjs +172 -28
  14. package/lib/update/package-layout.mjs +50 -0
  15. package/lib/update/plan.mjs +11 -0
  16. package/package.json +2 -2
  17. package/public/app.js +2276 -419
  18. package/public/index.html +142 -72
  19. package/public/service-worker.js +2 -1
  20. package/public/stream-output-controller.mjs +15 -0
  21. package/public/styles.css +764 -92
  22. package/public/syntax-highlight.mjs +622 -0
  23. package/tests/agent-run-adapters.test.mjs +217 -0
  24. package/tests/agent-run-launcher.test.mjs +41 -0
  25. package/tests/agent-run-protocol.test.mjs +82 -0
  26. package/tests/agent-run-registry.test.mjs +102 -0
  27. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  28. package/tests/browser/control-deck-side-panels.spec.mjs +354 -0
  29. package/tests/browser/controls-layout.spec.mjs +122 -0
  30. package/tests/browser/file-tree-git-ignored.spec.mjs +113 -0
  31. package/tests/browser/interaction-continuity.spec.mjs +161 -0
  32. package/tests/browser/intercom-conversation-viewer.spec.mjs +355 -0
  33. package/tests/browser/mobile-foundation.spec.mjs +26 -0
  34. package/tests/browser/model-search-focus.spec.mjs +96 -0
  35. package/tests/browser/optimistic-prompt.spec.mjs +22 -0
  36. package/tests/browser/persistent-ui-layout.spec.mjs +285 -66
  37. package/tests/browser/resource-profiles.spec.mjs +200 -0
  38. package/tests/browser/subagent-observability.spec.mjs +116 -0
  39. package/tests/codex-fast-mode-static.test.mjs +7 -6
  40. package/tests/common-options-submenus-interaction-static.test.mjs +2 -0
  41. package/tests/common-options-submenus-markup-static.test.mjs +1 -0
  42. package/tests/component-update-api-static.test.mjs +2 -1
  43. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  44. package/tests/composer-skill-tag-layout.test.mjs +32 -2
  45. package/tests/control-deck-component-updates-static.test.mjs +6 -0
  46. package/tests/control-deck-side-panels-static.test.mjs +68 -0
  47. package/tests/controls-layout-static.test.mjs +22 -0
  48. package/tests/fast-mode-client-static.test.mjs +2 -2
  49. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  50. package/tests/feature-system-prompt-optional-feature-static.test.mjs +5 -5
  51. package/tests/file-tree-git-ignored-static.test.mjs +152 -0
  52. package/tests/file-tree-search-layout-static.test.mjs +2 -1
  53. package/tests/file-viewer-image-static.test.mjs +69 -0
  54. package/tests/fixtures/fake-pi.mjs +147 -12
  55. package/tests/foreground-transcript-catch-up-static.test.mjs +1 -1
  56. package/tests/git-panel-file-preview-static.test.mjs +5 -5
  57. package/tests/git-panel-live-updates-static.test.mjs +3 -3
  58. package/tests/git-workflow-preferences.test.mjs +55 -6
  59. package/tests/http-endpoints-harness.test.mjs +295 -14
  60. package/tests/intercom-conversation-viewer-static.test.mjs +105 -0
  61. package/tests/intercom-conversations-http.test.mjs +252 -0
  62. package/tests/intercom-conversations.test.mjs +374 -0
  63. package/tests/intercom-main-transcript-suppression-static.test.mjs +52 -0
  64. package/tests/intercom-tag-layout-static.test.mjs +46 -0
  65. package/tests/intercom-transcript-filter.test.mjs +98 -0
  66. package/tests/main-output-loading-static.test.mjs +59 -0
  67. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  68. package/tests/mobile-compact-layout.test.mjs +2 -3
  69. package/tests/mobile-continuity-tablet-static.test.mjs +6 -6
  70. package/tests/mobile-foundation-static.test.mjs +3 -3
  71. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  72. package/tests/mobile-static.test.mjs +76 -42
  73. package/tests/native-parity.test.mjs +8 -7
  74. package/tests/open-issue-wizard-static.test.mjs +2 -2
  75. package/tests/optional-feature-migration-frontend.test.mjs +5 -5
  76. package/tests/optional-feature-resource-setup-static.test.mjs +29 -0
  77. package/tests/persistent-ui-layout-static.test.mjs +13 -13
  78. package/tests/questionnaire-dialog.test.mjs +3 -3
  79. package/tests/remote-auth-settings-harness.test.mjs +1 -1
  80. package/tests/resource-defaults-helper.test.mjs +60 -6
  81. package/tests/resource-selection.test.mjs +114 -0
  82. package/tests/resource-tui-extension.test.mjs +23 -0
  83. package/tests/session-sampling-ui-static.test.mjs +3 -3
  84. package/tests/side-panel-context-menu-static.test.mjs +1 -1
  85. package/tests/side-panel-resize-static.test.mjs +26 -16
  86. package/tests/side-panel-section-height-removal-static.test.mjs +4 -4
  87. package/tests/side-panel-section-reorder-static.test.mjs +16 -70
  88. package/tests/stream-output-controller.test.mjs +8 -0
  89. package/tests/stream-output-isolation-static.test.mjs +2 -2
  90. package/tests/streaming-ui-coupling.test.mjs +5 -0
  91. package/tests/subagent-gate-visibility.test.mjs +2 -1
  92. package/tests/subagent-launch-slots.test.mjs +1 -1
  93. package/tests/subagent-observability-static.test.mjs +32 -0
  94. package/tests/subagent-reliability-integration.test.mjs +183 -0
  95. package/tests/subagent-workflow-section-static.test.mjs +67 -0
  96. package/tests/subagents-helper.test.mjs +548 -5
  97. package/tests/syntax-highlight.test.mjs +235 -0
  98. package/tests/syntax-highlighting-static.test.mjs +84 -0
  99. package/tests/terminal-tabs-resize-static.test.mjs +35 -0
  100. package/tests/theme-customizer-static.test.mjs +5 -5
  101. package/tests/thinking-format-parser.test.mjs +64 -0
  102. package/tests/ui-layout-settings.test.mjs +104 -32
  103. package/tests/update-api-harness.test.mjs +24 -10
  104. package/tests/update-package-layout.test.mjs +38 -0
  105. package/tests/update-plan.test.mjs +11 -1
  106. package/tests/webui-settings-locking.test.mjs +33 -3
  107. package/webui-rpc-helper.mjs +700 -89
@@ -0,0 +1,354 @@
1
+ import assert from "node:assert/strict";
2
+ import { spawn } 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 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
+ let child;
16
+ let baseURL;
17
+ let tempRoot;
18
+
19
+ async function freePort() {
20
+ const server = createServer();
21
+ await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
22
+ const { port } = server.address();
23
+ await new Promise((resolve) => server.close(resolve));
24
+ return port;
25
+ }
26
+
27
+ async function startServer() {
28
+ const port = await freePort();
29
+ baseURL = `http://127.0.0.1:${port}`;
30
+ child = spawn(process.execPath, [serverScript, "--cwd", tempRoot, "--host", "127.0.0.1", "--port", String(port), "--pi", fakePi], {
31
+ stdio: ["ignore", "pipe", "pipe"],
32
+ env: { ...process.env, PI_WEBUI_RPC_SUPERVISOR: "0", PI_CODING_AGENT_DIR: join(tempRoot, "agent"), PI_WEBUI_SETTINGS_FILE: join(tempRoot, "settings.json") },
33
+ });
34
+ let output = "";
35
+ child.stdout.on("data", (chunk) => { output += String(chunk); });
36
+ child.stderr.on("data", (chunk) => { output += String(chunk); });
37
+ for (let attempt = 0; attempt < 100; attempt += 1) {
38
+ try {
39
+ if ((await fetch(`${baseURL}/api/health`, { signal: AbortSignal.timeout(500) })).ok) return;
40
+ } catch {}
41
+ await delay(100);
42
+ }
43
+ throw new Error(`server did not start: ${output}`);
44
+ }
45
+
46
+ async function stopServer() {
47
+ if (!child || child.exitCode !== null) return;
48
+ const exited = new Promise((resolve) => child.once("exit", resolve));
49
+ child.kill("SIGTERM");
50
+ await Promise.race([exited, delay(5_000).then(() => child.kill("SIGKILL"))]);
51
+ }
52
+
53
+ async function openControls(page) {
54
+ const toggle = page.locator('[data-side-panel-section-toggle="controls"]');
55
+ if (await toggle.getAttribute("aria-expanded") !== "true") await toggle.click();
56
+ await expect(page.locator("#controlDeckPlacementSelect")).toBeVisible();
57
+ }
58
+
59
+ async function selectPlacement(page, placement) {
60
+ await openControls(page);
61
+ await page.locator("#controlDeckPlacementSelect").selectOption(placement);
62
+ await expect(page.locator("#controlDeckPlacementSelect")).toHaveValue(placement);
63
+ }
64
+
65
+ async function assertSidePanelResizePillInGap(page, side) {
66
+ const handle = page.locator(side === "left" ? "#sidePanelLeftResizeHandle" : "#sidePanelResizeHandle");
67
+ const shell = page.locator(side === "left" ? "#sidePanelLeft" : "#sidePanel");
68
+ const [handleBox, shellBox, workspaceBox, paintedWidth] = await Promise.all([
69
+ handle.boundingBox(),
70
+ shell.boundingBox(),
71
+ page.locator(".workspace-column").boundingBox(),
72
+ handle.evaluate((node) => Number.parseFloat(getComputedStyle(node, "::after").width)),
73
+ ]);
74
+ assert.ok(handleBox && shellBox && workspaceBox && paintedWidth > 0, `${side} Control Deck resize pill should expose measurable geometry`);
75
+ const paintedLeft = handleBox.x + (handleBox.width - paintedWidth) / 2;
76
+ const paintedRight = paintedLeft + paintedWidth;
77
+ if (side === "right") {
78
+ assert.ok(paintedLeft >= workspaceBox.x + workspaceBox.width - 0.5 && paintedRight <= shellBox.x + 0.5, `right Control Deck resize pill should be fully inside the inter-column gap: ${JSON.stringify({ paintedLeft, paintedRight, workspaceBox, shellBox })}`);
79
+ } else {
80
+ assert.ok(paintedLeft >= shellBox.x + shellBox.width - 0.5 && paintedRight <= workspaceBox.x + 0.5, `left Control Deck resize pill should be fully inside the inter-column gap: ${JSON.stringify({ paintedLeft, paintedRight, workspaceBox, shellBox })}`);
81
+ }
82
+ }
83
+
84
+ async function assertAxeClean(page, label, selector) {
85
+ const accessibility = await new AxeBuilder({ page }).include(selector).disableRules(["aria-required-children"]).analyze();
86
+ const serious = accessibility.violations.filter((violation) => ["serious", "critical"].includes(violation.impact));
87
+ assert.deepEqual(serious, [], `${label} should have no serious/critical Axe violations: ${serious.map(({ id }) => id).join(", ")}`);
88
+ }
89
+
90
+ async function openAcceptanceFile(page) {
91
+ const files = page.locator('[data-side-panel-section-toggle="files"]');
92
+ if (await files.getAttribute("aria-expanded") !== "true") await files.click();
93
+ const fixture = page.locator('[role="treeitem"][data-path="acceptance.txt"]');
94
+ await expect(fixture).toBeVisible();
95
+ await fixture.click();
96
+ await expect(page.locator("#fileViewerPane")).toBeVisible();
97
+ }
98
+
99
+ async function dismissUpdateNotification(page, { waitMs = 2_500 } = {}) {
100
+ const notification = page.locator("#updateNotification");
101
+ const appeared = await notification.waitFor({ state: "visible", timeout: waitMs }).then(() => true).catch(() => false);
102
+ if (!appeared) return;
103
+ await page.locator("#updateNotificationDismissButton").click();
104
+ await expect(notification).toBeHidden();
105
+ }
106
+
107
+ test.beforeAll(async () => {
108
+ tempRoot = await mkdtemp(join(tmpdir(), "pi-webui-control-deck-"));
109
+ await writeFile(join(tempRoot, "acceptance.txt"), "Control Deck capacity fixture\n", "utf8");
110
+ await startServer();
111
+ });
112
+
113
+ test.afterAll(async () => {
114
+ await stopServer();
115
+ await rm(tempRoot, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
116
+ });
117
+
118
+ test("Mobile v2 repeatedly returns canonical project content to its Control Deck owner", async ({ browser }) => {
119
+ const context = await browser.newContext({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true });
120
+ const page = await context.newPage();
121
+ await page.goto(`${baseURL}/?mobileShell=v2`);
122
+ await expect(page.locator("html")).toHaveAttribute("data-mobile-shell", "v2");
123
+ const project = page.getByRole("navigation", { name: "Phone destinations" }).getByRole("button", { name: "Project", exact: true });
124
+ const chat = page.getByRole("navigation", { name: "Phone destinations" }).getByRole("button", { name: "Chat", exact: true });
125
+ for (let cycle = 0; cycle < 3; cycle += 1) {
126
+ await project.click();
127
+ await page.getByRole("tab", { name: "Files" }).click();
128
+ await expect.poll(() => page.locator("#sidePanelSectionFiles").evaluate((node) => node.parentElement?.id)).toBe("mobileProjectContent");
129
+ await expect(page.locator("#sidePanelBodyRight #sidePanelSectionFiles")).toHaveCount(0);
130
+ await chat.click();
131
+ await expect.poll(() => page.locator("#sidePanelSectionFiles").evaluate((node) => node.closest("[data-control-deck-body]")?.id || "")).toBe("sidePanelBodyRight");
132
+ await expect(page.locator("#mobileProjectContent #sidePanelSectionFiles")).toHaveCount(0);
133
+ }
134
+ await context.close();
135
+ });
136
+
137
+ test("Right, Left, Both, Sidebar rail, independent state, overlay, singleton ARIA, and reload", async ({ page }) => {
138
+ test.setTimeout(60_000);
139
+ await page.setViewportSize({ width: 2200, height: 1000 });
140
+ await page.goto(baseURL);
141
+ await page.waitForTimeout(600);
142
+ await dismissUpdateNotification(page);
143
+
144
+ const rightResizeHandle = page.locator("#sidePanelResizeHandle");
145
+ const leftResizeHandle = page.locator("#sidePanelLeftResizeHandle");
146
+ await expect(page.locator("#sidePanel")).toBeVisible();
147
+ await expect(page.locator("#sidePanelLeft")).toBeHidden();
148
+ await expect(rightResizeHandle).toBeVisible();
149
+ await expect(leftResizeHandle).toBeHidden();
150
+ await assertSidePanelResizePillInGap(page, "right");
151
+ const rightOnlyBefore = Number(await rightResizeHandle.getAttribute("aria-valuenow"));
152
+ await rightResizeHandle.focus();
153
+ await rightResizeHandle.press("Shift+ArrowLeft");
154
+ const rightOnlyWidth = Number(await rightResizeHandle.getAttribute("aria-valuenow"));
155
+ expect(rightOnlyWidth).toBeGreaterThan(rightOnlyBefore);
156
+
157
+ await selectPlacement(page, "left");
158
+ await expect(page.locator("#sidePanelLeft")).toBeVisible();
159
+ await expect(leftResizeHandle).toBeVisible();
160
+ await expect(rightResizeHandle).toBeHidden();
161
+ await assertSidePanelResizePillInGap(page, "left");
162
+ await expect(page.locator("#openIssueButton")).toBeVisible();
163
+ await expect(page.locator("#piVersionButton")).toHaveCount(1);
164
+ const leftOnlyBefore = Number(await leftResizeHandle.getAttribute("aria-valuenow"));
165
+ const leftHandleBox = await leftResizeHandle.boundingBox();
166
+ assert.ok(leftHandleBox, "left Control Deck resize handle should have pointer geometry");
167
+ await page.mouse.move(leftHandleBox.x + leftHandleBox.width / 2, leftHandleBox.y + leftHandleBox.height / 2);
168
+ await page.mouse.down();
169
+ await page.mouse.move(leftHandleBox.x + leftHandleBox.width / 2 + 80, leftHandleBox.y + leftHandleBox.height / 2, { steps: 8 });
170
+ await page.mouse.up();
171
+ const leftOnlyWidth = Number(await leftResizeHandle.getAttribute("aria-valuenow"));
172
+ expect(leftOnlyWidth).toBeGreaterThan(leftOnlyBefore);
173
+
174
+ await selectPlacement(page, "both");
175
+ await expect(page.locator("#sidePanelLeft")).toBeVisible();
176
+ await expect(page.locator("#sidePanel")).toBeVisible();
177
+ await expect(leftResizeHandle).toBeVisible();
178
+ await expect(rightResizeHandle).toBeVisible();
179
+ await expect.poll(() => page.evaluate(() => JSON.parse(localStorage.getItem("pi-webui-control-deck-layout-v2") || "null")?.panelWidths)).toMatchObject({ left: leftOnlyWidth, right: rightOnlyWidth });
180
+ await assertAxeClean(page, "visible left Control Deck", "#sidePanelLeft");
181
+ await assertAxeClean(page, "visible right Control Deck", "#sidePanel");
182
+ const controls = page.locator('[data-side-panel-section-toggle="controls"]');
183
+ const files = page.locator('[data-side-panel-section-toggle="files"]');
184
+ await expect(controls).toHaveAttribute("aria-keyshortcuts", "Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight");
185
+ const initialOrder = await page.locator("#sidePanelBodyRight > [data-side-panel-section]").evaluateAll((nodes) => nodes.map((node) => node.dataset.sidePanelSection));
186
+ await controls.focus();
187
+ await controls.press("Alt+ArrowRight");
188
+ await expect.poll(() => page.locator("#sidePanelBodyRight > [data-side-panel-section]").evaluateAll((nodes) => nodes.map((node) => node.dataset.sidePanelSection))).toEqual(initialOrder);
189
+ await controls.press("Alt+ArrowLeft");
190
+ await expect(page.locator('#sidePanelBodyLeft > [data-side-panel-section="controls"]')).toHaveCount(1);
191
+ await expect(controls).toBeFocused();
192
+ await expect(page.locator("#controlDeckMovementAnnouncer")).toContainText(/Controls moved to the left Control Deck, position 1 of 1/);
193
+ await files.focus();
194
+ await files.press("Alt+ArrowLeft");
195
+ await expect(page.locator('#sidePanelBodyLeft > [data-side-panel-section="files"]')).toHaveCount(1);
196
+ await expect(files).toBeFocused();
197
+ await expect(page.locator("#controlDeckMovementAnnouncer")).toContainText(/Files moved to the left Control Deck, position 2 of 2/);
198
+ await expect.poll(() => page.evaluate(() => JSON.parse(localStorage.getItem("pi-webui-control-deck-layout-v2") || "null")?.sectionLayout?.leftSectionIds || [])).toEqual(expect.arrayContaining(["controls", "files"]));
199
+ const git = page.locator('[data-side-panel-section-toggle="git"]');
200
+ await dismissUpdateNotification(page);
201
+ await git.scrollIntoViewIfNeeded();
202
+ await expect(git).toBeVisible();
203
+ await git.hover();
204
+ const gitBox = await git.boundingBox();
205
+ assert.ok(gitBox, "pointer cross-panel drag requires a visible source toggle");
206
+ await page.mouse.down();
207
+ await page.mouse.move(gitBox.x + gitBox.width / 2 + 32, gitBox.y + gitBox.height / 2 + 8, { steps: 8 });
208
+ await expect(page.locator("body")).toHaveClass(/control-deck-section-dragging/);
209
+ const leftDropBox = await page.locator('[data-control-deck-drop-target="left"]').boundingBox();
210
+ assert.ok(leftDropBox, "pointer drag should reveal the populated destination drop target");
211
+ await page.mouse.move(leftDropBox.x + leftDropBox.width / 2, leftDropBox.y + leftDropBox.height / 2, { steps: 12 });
212
+ await page.mouse.up();
213
+ await expect(page.locator('#sidePanelBodyLeft > [data-side-panel-section="git"]')).toHaveCount(1);
214
+ await git.press("Alt+ArrowRight");
215
+ await expect(page.locator('#sidePanelBodyRight > [data-side-panel-section="git"]')).toHaveCount(1);
216
+
217
+ await page.waitForTimeout(300);
218
+ if (await files.getAttribute("aria-expanded") !== "true") await files.click();
219
+ if (await controls.getAttribute("aria-expanded") !== "true") await controls.click();
220
+ await expect(files).toHaveAttribute("aria-expanded", "false");
221
+ await controls.press("Alt+ArrowRight");
222
+ await expect(controls).toHaveAttribute("aria-expanded", "true");
223
+ if (await files.getAttribute("aria-expanded") !== "true") await files.click();
224
+ await expect(files).toHaveAttribute("aria-expanded", "true");
225
+ await files.press("Alt+ArrowRight");
226
+ await expect(files).toHaveAttribute("aria-expanded", "true");
227
+ await expect(controls).toHaveAttribute("aria-expanded", "false");
228
+
229
+ await files.press("Alt+ArrowLeft");
230
+ const latentLeftBefore = await page.evaluate(() => JSON.parse(localStorage.getItem("pi-webui-control-deck-layout-v2") || "null")?.sectionLayout?.leftSectionIds || []);
231
+ await selectPlacement(page, "right");
232
+ await controls.focus();
233
+ await controls.press("Alt+ArrowDown");
234
+ const rightOrder = await page.locator("#sidePanelBodyRight > [data-side-panel-section]").evaluateAll((nodes) => nodes.map((node) => node.dataset.sidePanelSection));
235
+ await expect.poll(() => page.evaluate(() => JSON.parse(localStorage.getItem("pi-webui-control-deck-layout-v2") || "null")?.sectionLayout?.leftSectionIds || [])).toEqual(latentLeftBefore);
236
+ await page.reload();
237
+ await expect.poll(() => page.locator("#sidePanelBodyRight > [data-side-panel-section]").evaluateAll((nodes) => nodes.map((node) => node.dataset.sidePanelSection))).toEqual(rightOrder);
238
+ await selectPlacement(page, "both");
239
+ await expect(page.locator('#sidePanelBodyLeft > [data-side-panel-section="files"]')).toHaveCount(1);
240
+
241
+ await page.locator("#toggleSidePanelLeftButton").click();
242
+ await expect(page.locator("body")).toHaveClass(/side-panel-left-collapsed/);
243
+ await expect(page.locator("#sidePanel")).toBeVisible();
244
+ await page.locator("#sidePanelLeftExpandButton").click();
245
+ await expect(page.locator("body")).not.toHaveClass(/side-panel-left-collapsed/);
246
+ await leftResizeHandle.focus();
247
+ const leftBefore = Number(await leftResizeHandle.getAttribute("aria-valuenow"));
248
+ await leftResizeHandle.press("Shift+ArrowRight");
249
+ await expect.poll(async () => Number(await leftResizeHandle.getAttribute("aria-valuenow"))).toBeGreaterThan(leftBefore);
250
+ const bothLeftWidth = Number(await leftResizeHandle.getAttribute("aria-valuenow"));
251
+ await rightResizeHandle.focus();
252
+ const rightBefore = Number(await rightResizeHandle.getAttribute("aria-valuenow"));
253
+ await rightResizeHandle.press("Shift+ArrowLeft");
254
+ await expect.poll(async () => Number(await rightResizeHandle.getAttribute("aria-valuenow"))).toBeGreaterThan(rightBefore);
255
+ const bothRightWidth = Number(await rightResizeHandle.getAttribute("aria-valuenow"));
256
+ await expect.poll(() => page.evaluate(() => JSON.parse(localStorage.getItem("pi-webui-control-deck-layout-v2") || "null")?.panelWidths)).toMatchObject({ left: bothLeftWidth, right: bothRightWidth });
257
+
258
+ await openControls(page);
259
+ await page.locator("#terminalTabsLayoutSelect").selectOption("left");
260
+ await expect(page.locator("body")).toHaveClass(/terminal-tabs-left/);
261
+ const placementSelect = page.locator("#controlDeckPlacementSelect");
262
+ const bothPlacementOption = placementSelect.locator('option[value="both"]');
263
+ await expect(placementSelect).toBeEnabled();
264
+ await expect(bothPlacementOption).toBeDisabled();
265
+ await expect(placementSelect).toHaveValue("right");
266
+ await expect(page.locator("#sidePanel")).toBeVisible();
267
+ await expect(page.locator("#sidePanelLeft")).toBeHidden();
268
+ await expect.poll(() => page.evaluate(() => JSON.parse(localStorage.getItem("pi-webui-control-deck-layout-v2") || "null")?.placement)).toBe("right");
269
+
270
+ await placementSelect.selectOption("right");
271
+ await expect(page.locator("body")).toHaveClass(/terminal-tabs-sidebar-start/);
272
+ await expect(page.locator("#sidePanel")).toBeVisible();
273
+ await expect(page.locator("#sidePanelLeft")).toBeHidden();
274
+ const rightPlacementChatBox = await page.locator(".chat").boundingBox();
275
+ const leftRailBox = await page.locator(".terminal-tabs-shell").boundingBox();
276
+ assert.ok(rightPlacementChatBox && leftRailBox && leftRailBox.x < rightPlacementChatBox.x, "Right Control Deck placement should switch the terminal/tabs rail to the left of chat");
277
+
278
+ await page.locator("#controlDeckPlacementSelect").selectOption("left");
279
+ await expect(page.locator("body")).not.toHaveClass(/terminal-tabs-sidebar-start/);
280
+ await expect(page.locator("#sidePanelLeft")).toBeVisible();
281
+ await expect(page.locator("#sidePanel")).toBeHidden();
282
+ const chatBox = await page.locator(".chat").boundingBox();
283
+ const railBox = await page.locator(".terminal-tabs-shell").boundingBox();
284
+ assert.ok(chatBox && railBox && railBox.x > chatBox.x, "Left Control Deck placement should switch the terminal/tabs rail to the right of chat");
285
+ await expect(page.locator("#controlDeckPlacementStatus")).toContainText("Control Deck left, terminal/tabs right");
286
+ const newTabButton = page.locator("#newTabButton");
287
+ await newTabButton.hover();
288
+ await expect(page.locator("#newTabMenuPanel")).toBeVisible();
289
+ const pointerMenuBox = await page.locator("#newTabMenuPanel").boundingBox();
290
+ assert.ok(pointerMenuBox && pointerMenuBox.x < railBox.x && pointerMenuBox.x >= 0 && pointerMenuBox.x + pointerMenuBox.width <= 2200, `pointer-opened right-rail menu should open inward without viewport clipping: ${JSON.stringify({ pointerMenuBox, railBox })}`);
291
+ await page.mouse.move(chatBox.x + 20, chatBox.y + 20);
292
+ await expect(page.locator("#newTabMenuPanel")).toBeHidden();
293
+ await newTabButton.focus();
294
+ await expect(page.locator("#newTabMenuPanel")).toBeVisible();
295
+ const keyboardMenuBox = await page.locator("#newTabMenuPanel").boundingBox();
296
+ assert.ok(keyboardMenuBox && keyboardMenuBox.x < railBox.x && keyboardMenuBox.x >= 0 && keyboardMenuBox.x + keyboardMenuBox.width <= 2200, `keyboard-opened right-rail menu should open inward without viewport clipping: ${JSON.stringify({ keyboardMenuBox, railBox })}`);
297
+ await page.keyboard.press("Escape");
298
+ const workspaceButton = page.locator("#workspaceDashboardToggleButton");
299
+ await workspaceButton.hover();
300
+ await expect.poll(() => workspaceButton.evaluate((button) => getComputedStyle(button, "::after").opacity)).toBe("1");
301
+ await workspaceButton.focus();
302
+ await expect.poll(() => workspaceButton.evaluate((button) => getComputedStyle(button, "::after").opacity)).toBe("1");
303
+ await page.locator("#terminalTabsLayoutSelect").selectOption("top");
304
+ await expect(placementSelect).toHaveValue("left");
305
+ await expect(bothPlacementOption).toBeEnabled();
306
+ await placementSelect.selectOption("both");
307
+
308
+ await page.setViewportSize({ width: 1500, height: 900 });
309
+ await expect(page.locator("body")).not.toHaveClass(/control-deck-overlay/);
310
+ const firstTabId = await page.locator("[data-tab-id]").first().getAttribute("data-tab-id");
311
+ assert.ok(firstTabId, "the fixture should expose a splittable terminal tab");
312
+ await page.locator(`[data-tab-id="${firstTabId}"] .terminal-tab-split-button`).click();
313
+ await expect(page.locator("body")).toHaveClass(/terminal-split-open/);
314
+ await openAcceptanceFile(page);
315
+ await expect(page.locator("body")).toHaveClass(/control-deck-overlay/);
316
+ await expect(page.locator("body")).toHaveClass(/side-panel-collapsed/);
317
+ await expect(page.locator("#fileViewerPane")).toBeVisible();
318
+ await expect(page.locator("#terminalSplitShell")).toBeVisible();
319
+ await dismissUpdateNotification(page);
320
+ await page.locator("#fileViewerCloseButton").click();
321
+ await expect(page.locator("body")).not.toHaveClass(/control-deck-overlay/);
322
+ await expect(page.locator("body")).toHaveClass(/terminal-split-open/);
323
+ await expect(page.locator("#terminalSplitShell")).toBeVisible();
324
+ await expect(page.locator("body")).toHaveClass(/control-deck-both/);
325
+ await expect(page.locator('#sidePanelBodyLeft > [data-side-panel-section="files"]')).toHaveCount(1);
326
+
327
+ await page.setViewportSize({ width: 900, height: 900 });
328
+ await expect(page.locator("body")).toHaveClass(/control-deck-overlay/);
329
+ await expect(page.locator("#sidePanelLeft")).toBeHidden();
330
+ await page.locator("#sidePanelExpandButton").click();
331
+ await expect(page.locator("#sidePanel")).toHaveAttribute("role", "dialog");
332
+ await expect(page.locator("#sidePanelBackdrop")).toBeVisible();
333
+ await expect(page.locator("body")).toHaveCSS("overflow", "hidden");
334
+ await expect(page.locator(".workspace-column")).toHaveCSS("visibility", "hidden");
335
+ await assertAxeClean(page, "open Control Deck overlay", "#sidePanel");
336
+ await page.keyboard.press("Escape");
337
+ await expect(page.locator("#sidePanelBackdrop")).toBeHidden();
338
+
339
+ const duplicateIds = await page.locator("[id]").evaluateAll((nodes) => {
340
+ const ids = nodes.map((node) => node.id);
341
+ return ids.filter((id, index) => ids.indexOf(id) !== index);
342
+ });
343
+ expect(duplicateIds).toEqual([]);
344
+ const brokenAria = await page.locator("[aria-controls]").evaluateAll((nodes) => nodes.flatMap((node) => (node.getAttribute("aria-controls") || "").split(/\s+/)).filter((id) => id && !document.getElementById(id)));
345
+ expect(brokenAria).toEqual([]);
346
+
347
+ await page.setViewportSize({ width: 2200, height: 1000 });
348
+ await expect(page.locator("body")).toHaveClass(/control-deck-both/);
349
+ await page.reload();
350
+ await expect(page.locator("body")).toHaveClass(/control-deck-both/);
351
+ await expect(page.locator('#sidePanelBodyLeft > [data-side-panel-section="files"]')).toHaveCount(1);
352
+ await expect.poll(async () => Number(await leftResizeHandle.getAttribute("aria-valuenow"))).toBe(bothLeftWidth);
353
+ await expect.poll(async () => Number(await rightResizeHandle.getAttribute("aria-valuenow"))).toBe(bothRightWidth);
354
+ });
@@ -0,0 +1,122 @@
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 { expect, test } from "@playwright/test";
10
+
11
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
12
+ const serverScript = join(root, "bin", "pi-webui.mjs");
13
+ const fakePi = join(root, "tests", "fixtures", "fake-pi.mjs");
14
+
15
+ async function freePort() {
16
+ const server = createServer();
17
+ await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
18
+ const { port } = server.address();
19
+ await new Promise((resolve) => server.close(resolve));
20
+ return port;
21
+ }
22
+
23
+ let child;
24
+ let baseURL;
25
+ let tempRoot;
26
+ let output = "";
27
+
28
+ test.beforeAll(async () => {
29
+ const port = await freePort();
30
+ tempRoot = await mkdtemp(join(tmpdir(), "pi-webui-controls-layout-"));
31
+ baseURL = `http://127.0.0.1:${port}`;
32
+ child = spawn(process.execPath, [serverScript, "--cwd", tempRoot, "--host", "127.0.0.1", "--port", String(port), "--pi", fakePi], {
33
+ stdio: ["ignore", "pipe", "pipe"],
34
+ env: {
35
+ ...process.env,
36
+ PI_WEBUI_RPC_SUPERVISOR: "0",
37
+ PI_CODING_AGENT_DIR: join(tempRoot, "agent"),
38
+ PI_WEBUI_SETTINGS_FILE: join(tempRoot, "settings.json"),
39
+ },
40
+ });
41
+ child.stdout.on("data", (chunk) => { output += String(chunk); });
42
+ child.stderr.on("data", (chunk) => { output += String(chunk); });
43
+ for (let attempt = 0; attempt < 80; attempt += 1) {
44
+ if (child.exitCode !== null) break;
45
+ try {
46
+ const response = await fetch(`${baseURL}/api/health`, { signal: AbortSignal.timeout(500) });
47
+ if (response.ok) return;
48
+ } catch {
49
+ // Wait for the local server and fake Pi fixture.
50
+ }
51
+ await delay(100);
52
+ }
53
+ throw new Error(`Pi Web UI did not start:\n${output}`);
54
+ });
55
+
56
+ test.afterAll(async () => {
57
+ child?.kill("SIGTERM");
58
+ if (child) await new Promise((resolve) => child.once("exit", resolve));
59
+ await rm(tempRoot, { recursive: true, force: true });
60
+ });
61
+
62
+ async function openControls(page) {
63
+ await page.goto(baseURL);
64
+ await page.locator("#updateNotification").evaluate((notification) => { notification.hidden = true; notification.classList.remove("show"); });
65
+ const sidePanel = page.locator("#sidePanel");
66
+ if (!(await sidePanel.isVisible())) await page.locator("#sidePanelExpandButton").click();
67
+ const toggle = page.locator('[data-side-panel-section-toggle="controls"]');
68
+ if (await toggle.getAttribute("aria-expanded") !== "true") await toggle.click();
69
+ await expect(page.locator("#sidePanelSectionControls")).toBeVisible();
70
+ }
71
+
72
+ test("Controls use aligned name and parameter columns with viewport-safe tooltips", async ({ page }) => {
73
+ await page.setViewportSize({ width: 1440, height: 900 });
74
+ await openControls(page);
75
+
76
+ const rows = page.locator("#sidePanelSectionControls .control-row");
77
+ await expect(rows).toHaveCount(13);
78
+ const visibleRows = rows.filter({ visible: true });
79
+ await expect(visibleRows).toHaveCount(10);
80
+ for (let index = 0; index < await visibleRows.count(); index += 1) {
81
+ const columns = await visibleRows.nth(index).evaluate((row) => getComputedStyle(row).gridTemplateColumns.split(" ").filter(Boolean));
82
+ assert.equal(columns.length, 2, `visible setting row ${index + 1} should have two grid columns`);
83
+ }
84
+
85
+ const thinkingLabel = page.locator('.control-row-label:has-text("Thinking effort")');
86
+ await thinkingLabel.hover();
87
+ const tooltip = page.locator("#footerFloatingTooltip");
88
+ await expect(tooltip).toBeVisible();
89
+ await expect(tooltip).toContainText("hidden reasoning");
90
+ const box = await tooltip.boundingBox();
91
+ assert.ok(box, "tooltip should have a visible bounding box");
92
+ assert.ok(box.x >= 0 && box.y >= 0, "tooltip should stay inside the top and left viewport edges");
93
+ assert.ok(box.x + box.width <= 1440 && box.y + box.height <= 900, "tooltip should stay inside the bottom and right viewport edges");
94
+
95
+ await page.keyboard.press("Tab");
96
+ await thinkingLabel.focus();
97
+ await page.keyboard.press("Enter");
98
+ await expect(tooltip).toBeVisible();
99
+ await expect(tooltip).toContainText("hidden reasoning");
100
+ });
101
+
102
+ test("Controls stay two-column and touch-sized on a narrow viewport", async ({ page }) => {
103
+ await page.setViewportSize({ width: 390, height: 844 });
104
+ await openControls(page);
105
+
106
+ const thinkingRow = page.locator('.control-row:has(#thinkingSelect)');
107
+ const columns = await thinkingRow.evaluate((row) => getComputedStyle(row).gridTemplateColumns.split(" ").filter(Boolean));
108
+ assert.equal(columns.length, 2);
109
+ await expect(page.locator("#thinkingSelect")).toBeVisible();
110
+ await expect(page.locator("#setThinkingButton")).toBeVisible();
111
+ assert.ok(await page.locator("#setThinkingButton").evaluate((button) => button.getBoundingClientRect().height >= 36));
112
+
113
+ const modelLabel = page.locator('.control-row-label:has(#modelControlLabel)');
114
+ await modelLabel.focus();
115
+ await page.keyboard.press("Enter");
116
+ await expect(page.locator("#modelSearchInput")).toBeVisible();
117
+ const searchBox = await page.locator("#modelSearchInput").boundingBox();
118
+ const rowBox = await page.locator('.control-row:has(#modelSelect)').boundingBox();
119
+ assert.ok(searchBox && rowBox);
120
+ assert.ok(Math.abs(searchBox.x - rowBox.x) <= 1, "expanded search should span the full setting row");
121
+ assert.ok(Math.abs(searchBox.width - rowBox.width) <= 1, "expanded search should retain the full row width");
122
+ });
@@ -0,0 +1,113 @@
1
+ import assert from "node:assert/strict";
2
+ import { spawn, spawnSync } from "node:child_process";
3
+ import { createServer } from "node:net";
4
+ import { mkdir, 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
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
12
+ const serverScript = join(root, "bin", "pi-webui.mjs");
13
+ const fakePi = join(root, "tests", "fixtures", "fake-pi.mjs");
14
+
15
+ async function freePort() {
16
+ const server = createServer();
17
+ await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
18
+ const { port } = server.address();
19
+ await new Promise((resolve) => server.close(resolve));
20
+ return port;
21
+ }
22
+
23
+ let child;
24
+ let baseURL;
25
+ let tempRoot;
26
+ let output = "";
27
+
28
+ test.beforeAll(async () => {
29
+ const port = await freePort();
30
+ tempRoot = await mkdtemp(join(tmpdir(), "pi-webui-git-ignored-files-"));
31
+ await mkdir(join(tempRoot, "ignored-output"), { recursive: true });
32
+ await Promise.all([
33
+ writeFile(join(tempRoot, ".gitignore"), "ignored-note.txt\nignored-output/\n", "utf8"),
34
+ writeFile(join(tempRoot, "ordinary.txt"), "ordinary\n", "utf8"),
35
+ writeFile(join(tempRoot, "ignored-note.txt"), "ignored but visible\n", "utf8"),
36
+ writeFile(join(tempRoot, "ignored-output", "nested.log"), "nested ignored file\n", "utf8"),
37
+ ]);
38
+ const init = spawnSync("git", ["init", "--quiet"], { cwd: tempRoot, encoding: "utf8" });
39
+ assert.equal(init.status, 0, `Git fixture initialization failed: ${init.stderr || init.stdout}`);
40
+
41
+ baseURL = `http://127.0.0.1:${port}`;
42
+ child = spawn(process.execPath, [serverScript, "--cwd", tempRoot, "--host", "127.0.0.1", "--port", String(port), "--pi", fakePi], {
43
+ stdio: ["ignore", "pipe", "pipe"],
44
+ env: {
45
+ ...process.env,
46
+ PI_WEBUI_RPC_SUPERVISOR: "0",
47
+ PI_CODING_AGENT_DIR: join(tempRoot, "agent"),
48
+ PI_WEBUI_SETTINGS_FILE: join(tempRoot, "settings.json"),
49
+ },
50
+ });
51
+ child.stdout.on("data", (chunk) => { output += String(chunk); });
52
+ child.stderr.on("data", (chunk) => { output += String(chunk); });
53
+ for (let attempt = 0; attempt < 80; attempt += 1) {
54
+ if (child.exitCode !== null) break;
55
+ try {
56
+ const response = await fetch(`${baseURL}/api/health`, { signal: AbortSignal.timeout(500) });
57
+ if (response.ok) return;
58
+ } catch {
59
+ // Poll only until the package server and fake Pi fixture are ready.
60
+ }
61
+ await delay(100);
62
+ }
63
+ throw new Error(`Pi Web UI did not start:\n${output}`);
64
+ });
65
+
66
+ test.afterAll(async () => {
67
+ if (child?.exitCode === null) {
68
+ await fetch(`${baseURL}/api/shutdown`, { method: "POST", signal: AbortSignal.timeout(1_000) }).catch(() => undefined);
69
+ await new Promise((resolve) => child.once("exit", resolve));
70
+ }
71
+ await rm(tempRoot, { recursive: true, force: true });
72
+ });
73
+
74
+ test("keeps Git-ignored browse and search rows visible, muted, and interactive", async ({ page }) => {
75
+ await page.setViewportSize({ width: 1440, height: 900 });
76
+ await page.goto(baseURL);
77
+ await page.locator("#sidePanelSectionToggleFiles").click();
78
+
79
+ const ignoredFile = page.locator('.file-tree-node.git-ignored > .file-tree-item[data-path="ignored-note.txt"]');
80
+ const ignoredDirectory = page.locator('.file-tree-node.git-ignored > .file-tree-item[data-path="ignored-output"]');
81
+ const ordinaryFile = page.locator('.file-tree-node:not(.git-ignored) > .file-tree-item[data-path="ordinary.txt"]');
82
+ await expect(ignoredFile).toBeVisible();
83
+ await expect(ignoredDirectory).toBeVisible();
84
+ await expect(ordinaryFile).toBeVisible();
85
+ await expect(ignoredFile).toHaveAttribute("title", /Ignored by Git/);
86
+ await expect(ignoredFile).not.toBeDisabled();
87
+ await expect(ignoredFile).not.toHaveAttribute("aria-disabled", "true");
88
+
89
+ const colors = await page.evaluate(() => {
90
+ const ignored = document.querySelector('.file-tree-item[data-path="ignored-note.txt"]');
91
+ const ordinary = document.querySelector('.file-tree-item[data-path="ordinary.txt"]');
92
+ return {
93
+ ignored: getComputedStyle(ignored).color,
94
+ ordinary: getComputedStyle(ordinary).color,
95
+ opacity: getComputedStyle(ignored).opacity,
96
+ };
97
+ });
98
+ assert.notEqual(colors.ignored, colors.ordinary, "ignored rows should use a visibly different muted color");
99
+ assert.equal(colors.opacity, "1", "ignored rows should stay clearly legible instead of fading the whole row");
100
+
101
+ await page.locator("#fileTreeSearchInput").fill("ignored");
102
+ await expect(page.locator('.file-tree-search-node.git-ignored > .file-tree-search-item[data-path="ignored-note.txt"]')).toBeVisible();
103
+ await expect(page.locator('.file-tree-search-node.git-ignored > .file-tree-search-item[data-path="ignored-output"]')).toBeVisible();
104
+ await page.locator("#fileTreeSearchClearButton").click();
105
+
106
+ await ignoredDirectory.click();
107
+ const nestedFile = page.locator('.file-tree-node.git-ignored > .file-tree-item[data-path="ignored-output/nested.log"]');
108
+ await expect(nestedFile).toBeVisible();
109
+ await nestedFile.click();
110
+ await expect(page.locator("#fileViewerPane")).toBeVisible();
111
+ await expect(page.locator("#fileViewerTitle")).toHaveText("nested.log");
112
+ await expect(page.locator("#fileViewerEditor")).toHaveValue("nested ignored file\n");
113
+ });