@firstpick/pi-package-webui 0.9.4 → 0.9.6

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 (70) hide show
  1. package/README.md +7 -2
  2. package/bin/pi-webui.mjs +90 -5
  3. package/lib/optional-feature-catalog.mjs +1 -1
  4. package/lib/session-actions.mjs +20 -2
  5. package/lib/ui-layout-settings.mjs +37 -6
  6. package/package.json +1 -1
  7. package/public/app.js +2311 -257
  8. package/public/index.html +82 -55
  9. package/public/service-worker.js +4 -1
  10. package/public/stream-derived-output.mjs +799 -0
  11. package/public/stream-markdown-tail.mjs +204 -0
  12. package/public/stream-output-controller.mjs +222 -51
  13. package/public/stream-render-scheduler.mjs +85 -0
  14. package/public/styles.css +276 -20
  15. package/public/transcript-renderer.mjs +73 -24
  16. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  17. package/tests/browser/composer-action-grid-reorder.spec.mjs +114 -31
  18. package/tests/browser/control-deck-side-panels.spec.mjs +42 -0
  19. package/tests/browser/control-visibility.spec.mjs +396 -0
  20. package/tests/browser/mobile-foundation.spec.mjs +28 -0
  21. package/tests/browser/persistent-ui-layout.spec.mjs +9 -9
  22. package/tests/browser/stream-output-isolation.spec.mjs +308 -3
  23. package/tests/browser/user-noticeable-fixes.spec.mjs +204 -0
  24. package/tests/codex-fast-mode-static.test.mjs +2 -2
  25. package/tests/composer-action-grid-reorder-static.test.mjs +8 -7
  26. package/tests/control-deck-side-panels-static.test.mjs +3 -1
  27. package/tests/control-visibility-static.test.mjs +294 -0
  28. package/tests/controls-layout-static.test.mjs +3 -3
  29. package/tests/cwd-footer-reliability-static.test.mjs +1 -1
  30. package/tests/fast-mode-client-static.test.mjs +1 -1
  31. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  32. package/tests/file-viewer-image-static.test.mjs +3 -3
  33. package/tests/fixtures/fake-pi.mjs +57 -10
  34. package/tests/fixtures/streaming-workloads.mjs +167 -0
  35. package/tests/footer-provider-usage-visual-static.test.mjs +15 -0
  36. package/tests/foreground-transcript-catch-up-static.test.mjs +7 -1
  37. package/tests/git-workflow-preferences.test.mjs +2 -2
  38. package/tests/http-endpoints-harness.test.mjs +4 -4
  39. package/tests/interaction-state-stability-static.test.mjs +3 -1
  40. package/tests/intercom-conversation-viewer-static.test.mjs +4 -4
  41. package/tests/intercom-conversations-http.test.mjs +16 -0
  42. package/tests/main-output-loading-static.test.mjs +3 -3
  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 +77 -66
  48. package/tests/open-issue-wizard-static.test.mjs +2 -2
  49. package/tests/persistent-ui-layout-static.test.mjs +7 -7
  50. package/tests/prompt-input-vertical-scroll-static.test.mjs +26 -0
  51. package/tests/questionnaire-dialog.test.mjs +3 -3
  52. package/tests/runtime-error-visibility.test.mjs +3 -3
  53. package/tests/session-auth-harness.test.mjs +26 -1
  54. package/tests/session-sampling-ui-static.test.mjs +3 -3
  55. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  56. package/tests/stream-derived-output.test.mjs +121 -0
  57. package/tests/stream-markdown-tail.test.mjs +218 -0
  58. package/tests/stream-output-controller.test.mjs +119 -4
  59. package/tests/stream-output-isolation-static.test.mjs +34 -6
  60. package/tests/stream-output-workloads.test.mjs +276 -0
  61. package/tests/stream-render-scheduler.test.mjs +115 -0
  62. package/tests/streaming-ui-coupling.test.mjs +1 -1
  63. package/tests/subagent-observability-static.test.mjs +2 -2
  64. package/tests/syntax-highlighting-static.test.mjs +3 -3
  65. package/tests/theme-customizer-static.test.mjs +1 -1
  66. package/tests/thinking-format-parser.test.mjs +15 -0
  67. package/tests/todo-filter-static.test.mjs +148 -0
  68. package/tests/transcript-markdown-tail.test.mjs +137 -0
  69. package/tests/ui-layout-settings.test.mjs +54 -7
  70. package/tests/webui-settings-locking.test.mjs +3 -3
@@ -0,0 +1,396 @@
1
+ import assert from "node:assert/strict";
2
+ import { spawn } from "node:child_process";
3
+ import { createServer } from "node:net";
4
+ import { mkdir, mkdtemp, readFile, 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
+ const HIDDEN_IDS_KEY = "pi-webui-control-visibility-hidden-ids-v1";
15
+ const MENU_SELECTOR = "#visibilityContextMenu";
16
+
17
+ let child;
18
+ let baseURL;
19
+ let port;
20
+ let tempRoot;
21
+ let settingsFile;
22
+ let output = "";
23
+
24
+ async function freePort() {
25
+ const server = createServer();
26
+ await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
27
+ const { port } = server.address();
28
+ await new Promise((resolve) => server.close(resolve));
29
+ return port;
30
+ }
31
+
32
+ async function startServer() {
33
+ child = spawn(process.execPath, [serverScript, "--cwd", tempRoot, "--host", "127.0.0.1", "--port", String(port), "--pi", fakePi], {
34
+ stdio: ["ignore", "pipe", "pipe"],
35
+ env: {
36
+ ...process.env,
37
+ PI_WEBUI_RPC_SUPERVISOR: "0",
38
+ PI_CODING_AGENT_DIR: join(tempRoot, "agent"),
39
+ PI_WEBUI_SETTINGS_FILE: settingsFile,
40
+ },
41
+ });
42
+ child.stdout.on("data", (chunk) => { output += String(chunk); });
43
+ child.stderr.on("data", (chunk) => { output += String(chunk); });
44
+ for (let attempt = 0; attempt < 100; attempt += 1) {
45
+ if (child.exitCode !== null) break;
46
+ try {
47
+ const response = await fetch(`${baseURL}/api/health`, { signal: AbortSignal.timeout(500) });
48
+ if (response.ok) return;
49
+ } catch {
50
+ // Wait for the fixture server to start.
51
+ }
52
+ await delay(100);
53
+ }
54
+ throw new Error(`Pi Web UI did not start:\n${output}`);
55
+ }
56
+
57
+ async function stopServer() {
58
+ const stoppingChild = child;
59
+ if (!stoppingChild || stoppingChild.exitCode !== null) return;
60
+ const exited = new Promise((resolve) => stoppingChild.once("exit", resolve));
61
+ stoppingChild.kill("SIGTERM");
62
+ await Promise.race([
63
+ exited,
64
+ delay(5_000).then(() => {
65
+ if (stoppingChild.exitCode === null) stoppingChild.kill("SIGKILL");
66
+ return exited;
67
+ }),
68
+ ]);
69
+ }
70
+
71
+ async function hiddenIdsOnDisk() {
72
+ for (let attempt = 0; attempt < 40; attempt += 1) {
73
+ try {
74
+ const settings = JSON.parse(await readFile(settingsFile, "utf8"));
75
+ const hiddenIds = settings?.uiLayout?.controlVisibility?.hiddenIds;
76
+ if (hiddenIds !== undefined) return Array.isArray(hiddenIds) ? hiddenIds : hiddenIds;
77
+ } catch {
78
+ // The settings file may be replaced atomically during the write.
79
+ }
80
+ await delay(100);
81
+ }
82
+ return undefined;
83
+ }
84
+
85
+ async function hiddenIdsInLocal(page) {
86
+ return page.evaluate((key) => JSON.parse(localStorage.getItem(key) || "null"), HIDDEN_IDS_KEY);
87
+ }
88
+
89
+ async function openAreaMenu(page) {
90
+ // Dispatch on marked header padding so responsive Control Deck overlays do
91
+ // not make the empty-area recovery path flaky in the browser harness.
92
+ await page.locator('.side-panel-header[data-visibility-region="control-deck"]').evaluate((element) => {
93
+ const rect = element.getBoundingClientRect();
94
+ element.dispatchEvent(new MouseEvent("contextmenu", {
95
+ bubbles: true,
96
+ cancelable: true,
97
+ button: 2,
98
+ clientX: rect.left + 4,
99
+ clientY: rect.top + 4,
100
+ }));
101
+ });
102
+ return page.locator(MENU_SELECTOR);
103
+ }
104
+
105
+ async function dispatchAreaMenuAt(page, clientX, clientY) {
106
+ await page.locator(".composer-row").evaluate((element, point) => {
107
+ element.dispatchEvent(new MouseEvent("contextmenu", {
108
+ bubbles: true,
109
+ cancelable: true,
110
+ button: 2,
111
+ clientX: point.clientX,
112
+ clientY: point.clientY,
113
+ }));
114
+ }, { clientX, clientY });
115
+ return page.locator(MENU_SELECTOR);
116
+ }
117
+
118
+ async function suppressUnrelatedOverlays(page) {
119
+ await page.addStyleTag({ content: "#optionalFeatureMigrationSurface, #updateNotification { display: none !important; }" });
120
+ }
121
+
122
+ test.describe.configure({ mode: "serial" });
123
+
124
+ test.beforeAll(async () => {
125
+ tempRoot = await mkdtemp(join(tmpdir(), "pi-webui-control-visibility-"));
126
+ settingsFile = join(tempRoot, "settings.json");
127
+ await writeFile(settingsFile, "{}", "utf8");
128
+ await mkdir(join(tempRoot, "agent"), { recursive: true });
129
+ port = await freePort();
130
+ baseURL = `http://127.0.0.1:${port}`;
131
+ await startServer();
132
+ });
133
+
134
+ test.afterAll(async () => {
135
+ await stopServer();
136
+ await rm(tempRoot, { recursive: true, force: true });
137
+ });
138
+
139
+ test("grouped area menu, direct hide, recovery, persistence, gating, Send exclusion, keyboard", async ({ page }) => {
140
+ await page.goto(baseURL, { waitUntil: "domcontentloaded" });
141
+ await suppressUnrelatedOverlays(page);
142
+ await expect(page.locator("#sendButton")).toBeVisible();
143
+
144
+ // Seed a saved grid so visibility changes must project a dense visible layout.
145
+ await page.evaluate(() => {
146
+ localStorage.setItem("pi-webui-composer-action-layout-v2", JSON.stringify({
147
+ version: 2,
148
+ columns: 4,
149
+ positions: { new: 0, compact: 1, options: 3, send: 6 },
150
+ }));
151
+ });
152
+ await page.reload({ waitUntil: "domcontentloaded" });
153
+ await suppressUnrelatedOverlays(page);
154
+ const optionsAction = page.locator('[data-composer-action-id="options"]');
155
+ const newAction = page.locator('[data-composer-action-id="new"]');
156
+ await expect.poll(() => optionsAction.evaluate((element) => Number(element.style.getPropertyValue("--composer-action-grid-column")))).toBeGreaterThan(1);
157
+ await expect.poll(() => newAction.evaluate((element) => Number(element.style.getPropertyValue("--composer-action-grid-column")))).toBeGreaterThan(0);
158
+ const initialOptionsColumn = Number(await optionsAction.evaluate((element) => element.style.getPropertyValue("--composer-action-grid-column")));
159
+ const initialNewColumn = Number(await newAction.evaluate((element) => element.style.getPropertyValue("--composer-action-grid-column")));
160
+
161
+ // Send and editable controls are not region-menu proxies.
162
+ const menu = page.locator(MENU_SELECTOR);
163
+ await page.locator("#sendButton").click({ button: "right" });
164
+ await expect(menu).toBeHidden();
165
+ await page.locator("#promptInput").click({ button: "right" });
166
+ await expect(menu).toBeHidden();
167
+
168
+ // Open submenu contents keep their specialized context behavior even though
169
+ // their registered composer wrapper is an ancestor.
170
+ await page.locator("#optionsMenuButton").click();
171
+ await expect(page.locator("#optionsMenu")).toBeVisible();
172
+ await page.locator("#optionsSettingsButton").click({ button: "right" });
173
+ await expect(menu).toBeHidden();
174
+ await page.keyboard.press("Escape");
175
+
176
+ // Empty marked area opens the complete grouped catalog.
177
+ await openAreaMenu(page);
178
+ await expect(menu).toBeVisible();
179
+ const checkboxes = menu.locator('[role="menuitemcheckbox"]');
180
+ await expect(checkboxes).toHaveCount(24);
181
+ await expect.poll(async () => checkboxes.evaluateAll((items) => items.map((item) => item.getAttribute("aria-checked")))).toEqual(Array(24).fill("true"));
182
+ await expect(menu.getByRole("menuitem", { name: "Show all" })).toHaveCount(1);
183
+ await expect(menu.getByRole("menuitem", { name: "Reset defaults" })).toHaveCount(1);
184
+ await expect(menu.locator('[data-visibility-menu-toggle="composer.send"]')).toHaveCount(0);
185
+ await page.keyboard.press("Escape");
186
+ await expect(menu).toBeHidden();
187
+ // Non-focusable region hosts restore focus to the prompt fallback on Escape.
188
+ await expect(page.locator("#promptInput")).toBeFocused();
189
+
190
+ // Direct hide applies immediately and reflows the sparse composer grid.
191
+ await page.locator("#newSessionButton").click({ button: "right" });
192
+ await expect(menu).toContainText("Hide New");
193
+ await menu.locator('[data-visibility-menu-action="hide"]').click();
194
+ await expect(page.locator("#newSessionButton")).toHaveClass(/webui-user-hidden/);
195
+ await expect(page.locator("#promptInput")).toBeFocused();
196
+ await expect.poll(() => optionsAction.evaluate((element) => Number(element.style.getPropertyValue("--composer-action-grid-column")))).toBeLessThan(initialOptionsColumn);
197
+ assert.ok(Number(await optionsAction.evaluate((element) => element.style.getPropertyValue("--composer-action-grid-column"))) > 0, "repacked actions should keep a positive dense slot");
198
+ assert.deepEqual(await hiddenIdsInLocal(page), ["composer.new"], "direct hide should persist locally first");
199
+ await expect.poll(async () => (await hiddenIdsOnDisk())?.slice?.().sort?.()).toEqual(["composer.new"]);
200
+
201
+ // Runtime capability gating remains authoritative when preferences show all.
202
+ const gitButton = page.locator('[data-composer-action-id="git"]');
203
+ await openAreaMenu(page);
204
+ assert.ok(await gitButton.evaluate((element) => element.hidden), "capability-hidden controls keep the hidden attribute");
205
+ await menu.getByRole("menuitem", { name: "Show all" }).click();
206
+ await expect(page.locator("#newSessionButton")).not.toHaveClass(/webui-user-hidden/);
207
+ // Un-hiding must schedule a restore that returns actions to their saved slots.
208
+ await expect.poll(() => newAction.evaluate((element) => Number(element.style.getPropertyValue("--composer-action-grid-column")))).toBe(initialNewColumn);
209
+ await expect.poll(() => optionsAction.evaluate((element) => Number(element.style.getPropertyValue("--composer-action-grid-column")))).toBe(initialOptionsColumn);
210
+ assert.deepEqual(await hiddenIdsInLocal(page), [], "Show all should persist an explicit empty list");
211
+ assert.ok(await gitButton.evaluate((element) => element.hidden), "Show all must not clear runtime hidden gating");
212
+
213
+ // Reset defaults is distinct from Show all: null vs [].
214
+ await openAreaMenu(page);
215
+ await menu.getByRole("menuitem", { name: "Reset defaults" }).click();
216
+ assert.equal(await hiddenIdsInLocal(page), null, "Reset defaults should clear hiddenIds to null");
217
+ await expect.poll(hiddenIdsOnDisk).toBe(null);
218
+
219
+ // Shift+F10 supports complete menu navigation and restores surviving focus.
220
+ await page.locator("#attachButton").focus();
221
+ await page.keyboard.press("Shift+F10");
222
+ await expect(menu).toBeVisible();
223
+ await page.keyboard.press("End");
224
+ await expect(menu.getByRole("menuitem", { name: "Reset defaults" })).toBeFocused();
225
+ await page.keyboard.press("Home");
226
+ await expect(menu.getByRole("menuitem", { name: "Hide Attach files" })).toBeFocused();
227
+ await page.keyboard.press("ArrowDown");
228
+ await page.keyboard.press("ArrowUp");
229
+ await page.keyboard.press("Escape");
230
+ await expect(menu).toBeHidden();
231
+ await expect(page.locator("#attachButton")).toBeFocused();
232
+
233
+ // The Context Menu key plus Enter performs direct hide. A hidden trigger
234
+ // returns focus to the safe prompt fallback.
235
+ await page.keyboard.press("ContextMenu");
236
+ await expect(menu).toBeVisible();
237
+ await page.keyboard.press("Enter");
238
+ await expect(page.locator("#attachButton")).toHaveClass(/webui-user-hidden/);
239
+ await expect(page.locator("#promptInput")).toBeFocused();
240
+ await expect.poll(hiddenIdsOnDisk).toEqual(["input.attach-files"]);
241
+
242
+ // Prove reload recovery comes from durable settings rather than only cache.
243
+ await page.evaluate((key) => localStorage.removeItem(key), HIDDEN_IDS_KEY);
244
+ await page.reload({ waitUntil: "domcontentloaded" });
245
+ await suppressUnrelatedOverlays(page);
246
+ await expect(page.locator("#attachButton")).toHaveClass(/webui-user-hidden/);
247
+ await expect(page.locator("#sendButton")).toBeVisible();
248
+
249
+ // Area recovery remains available and tag categories toggle independently.
250
+ await openAreaMenu(page);
251
+ const attachToggle = menu.locator('[data-visibility-menu-toggle="input.attach-files"]');
252
+ await expect(attachToggle).toHaveAttribute("aria-checked", "false");
253
+ await attachToggle.click();
254
+ await expect(attachToggle).toHaveAttribute("aria-checked", "true");
255
+ await expect(page.locator("#attachButton")).not.toHaveClass(/webui-user-hidden/);
256
+ const tagsToggle = menu.locator('[data-visibility-menu-toggle="tag.skills"]');
257
+ await tagsToggle.click();
258
+ await expect(page.locator("#sessionSkillTags")).toHaveClass(/webui-user-hidden/);
259
+ assert.deepEqual(await hiddenIdsInLocal(page), ["tag.skills"], "each tag category toggles independently");
260
+ await page.locator("#promptInput").click();
261
+ await expect(menu).toBeHidden();
262
+
263
+ // Coordinates beyond the viewport are clamped into the visible page.
264
+ const viewport = page.viewportSize();
265
+ await dispatchAreaMenuAt(page, viewport.width + 500, viewport.height + 500);
266
+ await expect(menu).toBeVisible();
267
+ const bounds = await menu.boundingBox();
268
+ assert.ok(bounds.x >= 0 && bounds.y >= 0, "menu should not overflow the top or left viewport edges");
269
+ assert.ok(bounds.x + bounds.width <= viewport.width && bounds.y + bounds.height <= viewport.height, "menu should remain inside the viewport");
270
+ await page.keyboard.press("Escape");
271
+ });
272
+
273
+ test("keyboard-only recovery from Send after every catalog item is hidden", async ({ page }) => {
274
+ await page.goto(baseURL, { waitUntil: "domcontentloaded" });
275
+ await suppressUnrelatedOverlays(page);
276
+ const menu = page.locator(MENU_SELECTOR);
277
+ await expect(page.locator("#sendButton")).toHaveAttribute("aria-keyshortcuts", /Shift\+F10/);
278
+
279
+ // Hide every catalog item through the grouped area menu (setup may use the
280
+ // pointer; only the recovery below must be keyboard-only).
281
+ await openAreaMenu(page);
282
+ await expect(menu).toBeVisible();
283
+ const checkboxes = menu.locator('[role="menuitemcheckbox"]');
284
+ await expect(checkboxes).toHaveCount(24);
285
+ for (let index = 0; index < 24; index += 1) {
286
+ const item = checkboxes.nth(index);
287
+ // Hiding controls can shift the layout and legitimately auto-dismiss the
288
+ // menu on the resulting scroll, so drive the same click handler directly.
289
+ if ((await item.getAttribute("aria-checked")) === "true") await item.dispatchEvent("click");
290
+ }
291
+ await expect.poll(async () => checkboxes.evaluateAll((items) => items.map((item) => item.getAttribute("aria-checked")))).toEqual(Array(24).fill("false"));
292
+ await expect.poll(async () => (await hiddenIdsInLocal(page))?.length).toBe(24);
293
+ if (!(await menu.isHidden())) await page.keyboard.press("Escape");
294
+ await expect(page.locator("#attachButton")).toHaveClass(/webui-user-hidden/);
295
+ await expect(page.locator("#newSessionButton")).toHaveClass(/webui-user-hidden/);
296
+ await expect(page.locator("#sendButton")).toBeVisible();
297
+
298
+ // Keyboard-only recovery: the Context Menu key on Send opens the grouped
299
+ // menu even though no optional control remains visible.
300
+ await page.locator("#sendButton").focus();
301
+ await page.keyboard.press("ContextMenu");
302
+ await expect(menu).toBeVisible();
303
+ await expect(menu.locator('[role="menuitemcheckbox"]')).toHaveCount(24);
304
+ await page.keyboard.press("Escape");
305
+ await expect(menu).toBeHidden();
306
+ await expect(page.locator("#sendButton")).toBeFocused();
307
+
308
+ // Shift+F10 opens the same menu; activate Show all without touching the pointer.
309
+ await page.keyboard.press("Shift+F10");
310
+ await expect(menu).toBeVisible();
311
+ await page.keyboard.press("End");
312
+ await expect(menu.getByRole("menuitem", { name: "Reset defaults" })).toBeFocused();
313
+ await page.keyboard.press("ArrowUp");
314
+ await expect(menu.getByRole("menuitem", { name: "Show all" })).toBeFocused();
315
+ await page.keyboard.press("Enter");
316
+ await expect(menu).toBeHidden();
317
+ await expect(page.locator("#sendButton")).toBeFocused();
318
+
319
+ // Every catalog item is restored and the explicit show-all state persists.
320
+ assert.deepEqual(await hiddenIdsInLocal(page), [], "Show all should persist an explicit empty list");
321
+ await expect(page.locator("#attachButton")).not.toHaveClass(/webui-user-hidden/);
322
+ await expect(page.locator("#newSessionButton")).not.toHaveClass(/webui-user-hidden/);
323
+ await expect(page.locator("#sessionSkillTags")).not.toHaveClass(/webui-user-hidden/);
324
+ await openAreaMenu(page);
325
+ await expect.poll(async () => checkboxes.evaluateAll((items) => items.map((item) => item.getAttribute("aria-checked")))).toEqual(Array(24).fill("true"));
326
+ await page.keyboard.press("Escape");
327
+ });
328
+
329
+ test("pending visibility mutation survives same-origin cache adoption and rewrites the cache after acknowledgment", async ({ browser }) => {
330
+ const context = await browser.newContext();
331
+ const page1 = await context.newPage();
332
+ const page2 = await context.newPage();
333
+ try {
334
+ await page1.goto(baseURL, { waitUntil: "domcontentloaded" });
335
+ await suppressUnrelatedOverlays(page1);
336
+ await page2.goto(baseURL, { waitUntil: "domcontentloaded" });
337
+ await suppressUnrelatedOverlays(page2);
338
+
339
+ // Hold page1's first layout PUT so its visibility mutation stays dirty.
340
+ let heldRoute = null;
341
+ await page1.route("**/api/interface-preferences", async (route) => {
342
+ if (route.request().method() === "PUT" && !heldRoute) {
343
+ heldRoute = route;
344
+ return;
345
+ }
346
+ await route.continue();
347
+ });
348
+
349
+ // Page 1 hides Attach files; the save is intercepted before acknowledgment.
350
+ await page1.locator("#attachButton").click({ button: "right" });
351
+ await page1.locator(MENU_SELECTOR).locator('[data-visibility-menu-action="hide"]').click();
352
+ await expect(page1.locator("#attachButton")).toHaveClass(/webui-user-hidden/);
353
+ await expect.poll(() => heldRoute !== null, { message: "page 1's visibility PUT should be held" }).toBe(true);
354
+
355
+ // Page 2 adopts page 1's cache, then hides a tag category and saves
356
+ // successfully; its cache write fires a same-origin storage event in page 1.
357
+ await openAreaMenu(page2);
358
+ await page2.locator(MENU_SELECTOR).locator('[data-visibility-menu-toggle="tag.skills"]').click();
359
+ await page2.keyboard.press("Escape");
360
+ await expect.poll(async () => hiddenIdsInLocal(page2)).toEqual(["input.attach-files", "tag.skills"]);
361
+ await expect.poll(hiddenIdsOnDisk).toEqual(["input.attach-files", "tag.skills"]);
362
+
363
+ // Page 1 keeps showing its own pending mutation instead of adopting the
364
+ // incoming cache: Attach stays hidden and skill tags stay visible. The
365
+ // grouped menu must use that same dirty set, not the overwritten cache.
366
+ await delay(500);
367
+ await expect(page1.locator("#attachButton")).toHaveClass(/webui-user-hidden/);
368
+ await expect(page1.locator("#sessionSkillTags")).not.toHaveClass(/webui-user-hidden/);
369
+ const page1Menu = await openAreaMenu(page1);
370
+ await expect(page1Menu.locator('[data-visibility-menu-toggle="input.attach-files"]')).toHaveAttribute("aria-checked", "false");
371
+ await expect(page1Menu.locator('[data-visibility-menu-toggle="tag.skills"]')).toHaveAttribute("aria-checked", "true");
372
+ await page1Menu.locator('[data-visibility-menu-toggle="tag.skills"]').click();
373
+ await expect(page1.locator("#sessionSkillTags")).toHaveClass(/webui-user-hidden/);
374
+ await page1.keyboard.press("Escape");
375
+ await expect.poll(async () => hiddenIdsInLocal(page1)).toEqual(["input.attach-files", "tag.skills"]);
376
+
377
+ // Release the held write. The stale revision retries once; after the
378
+ // acknowledged PUT page 1 rewrites its value into the same-origin cache.
379
+ await heldRoute.continue();
380
+ await expect.poll(hiddenIdsOnDisk).toEqual(["input.attach-files", "tag.skills"]);
381
+ await expect.poll(async () => hiddenIdsInLocal(page1)).toEqual(["input.attach-files", "tag.skills"]);
382
+ await expect(page1.locator("#attachButton")).toHaveClass(/webui-user-hidden/);
383
+ await expect(page1.locator("#sessionSkillTags")).toHaveClass(/webui-user-hidden/);
384
+
385
+ // Page 2 adopts the acknowledged value through the storage event and the
386
+ // pending journal no longer holds a visibility mutation in either tab.
387
+ await expect.poll(async () => page2.locator("#sessionSkillTags").evaluate((element) => element.classList.contains("webui-user-hidden"))).toBe(true);
388
+ await expect(page2.locator("#attachButton")).toHaveClass(/webui-user-hidden/);
389
+ await expect.poll(async () => page1.evaluate(() => Object.entries(localStorage)
390
+ .filter(([key]) => key.startsWith("pi-webui-ui-layout-pending"))
391
+ .filter(([, raw]) => { try { return JSON.parse(raw)?.field === "controlVisibility"; } catch { return false; } })
392
+ .map(([key]) => key))).toEqual([]);
393
+ } finally {
394
+ await context.close();
395
+ }
396
+ });
@@ -90,6 +90,34 @@ test("v2 flag is isolated on desktop and rollback remains explicit", async ({ pa
90
90
  await expect(page.locator("#mobileShellV2")).toBeHidden();
91
91
  });
92
92
 
93
+ test("the main prompt scrolls vertically after bounded auto-growth", async ({ page }) => {
94
+ await page.setViewportSize({ width: 1280, height: 800 });
95
+ await page.goto(baseURL);
96
+ const prompt = page.locator("#promptInput");
97
+ const longPrompt = Array.from({ length: 20 }, (_, index) => `line ${index + 1}: keep this prompt line reachable`).join("\n");
98
+
99
+ await prompt.fill(longPrompt);
100
+ const longMetrics = await prompt.evaluate((node) => {
101
+ const style = getComputedStyle(node);
102
+ node.scrollTop = node.scrollHeight;
103
+ return {
104
+ clientHeight: node.clientHeight,
105
+ maxHeight: Number.parseFloat(style.maxHeight),
106
+ overflowY: style.overflowY,
107
+ scrollHeight: node.scrollHeight,
108
+ scrollTop: node.scrollTop,
109
+ };
110
+ });
111
+ assert.equal(longMetrics.overflowY, "auto");
112
+ assert.ok(longMetrics.scrollHeight > longMetrics.clientHeight + 1, `long prompt should overflow vertically: ${JSON.stringify(longMetrics)}`);
113
+ assert.ok(longMetrics.scrollTop > 0, `long prompt should accept vertical scrolling: ${JSON.stringify(longMetrics)}`);
114
+ assert.ok(longMetrics.clientHeight <= longMetrics.maxHeight + 1, `prompt should retain its height cap: ${JSON.stringify(longMetrics)}`);
115
+
116
+ await prompt.fill("short prompt");
117
+ const shortMetrics = await prompt.evaluate((node) => ({ clientHeight: node.clientHeight, scrollHeight: node.scrollHeight }));
118
+ assert.ok(shortMetrics.clientHeight < longMetrics.clientHeight, `short prompt should shrink after long input: ${JSON.stringify(shortMetrics)}`);
119
+ });
120
+
93
121
  test("legacy phone keeps terminal navigation and secondary composer actions collapsed", async ({ browser }) => {
94
122
  const context = await browser.newContext({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true });
95
123
  const page = await context.newPage();
@@ -114,7 +114,7 @@ async function seedStaleServerLayout() {
114
114
  sidePanelWidth: 352,
115
115
  expectedLayoutRevision: current.data.layoutRevision,
116
116
  layout: {
117
- version: 2,
117
+ version: 3,
118
118
  sidePanel: {
119
119
  placement: "right",
120
120
  sectionLayout: { order: ["git", "files", "controls"], leftSectionIds: [] },
@@ -528,7 +528,7 @@ test("returning browsers adopt authoritative Control Deck state without echo wri
528
528
  body: {
529
529
  expectedLayoutRevision: current.data.layoutRevision,
530
530
  layout: {
531
- version: 2,
531
+ version: 3,
532
532
  sidePanel: {
533
533
  placement: "right",
534
534
  sectionLayout: { order: serverSideOrder, leftSectionIds: [] },
@@ -585,7 +585,7 @@ test("failed layout writes remain pending across reload and later synchronize",
585
585
  method: "PUT",
586
586
  body: {
587
587
  expectedLayoutRevision: current.data.layoutRevision,
588
- layout: { version: 2, composerActions: { order: ["send", "new"], grid: null } },
588
+ layout: { version: 3, composerActions: { order: ["send", "new"], grid: null } },
589
589
  },
590
590
  });
591
591
 
@@ -628,7 +628,7 @@ test("conflict retry updates only the changed Control Deck subfield", async ({ b
628
628
  body: {
629
629
  expectedLayoutRevision: current.data.layoutRevision,
630
630
  layout: {
631
- version: 2,
631
+ version: 3,
632
632
  sidePanel: {
633
633
  placement: "right",
634
634
  sectionLayout: { order: initialOrder, leftSectionIds: [] },
@@ -672,7 +672,7 @@ test("one tab cannot erase another tab's failed pending journal", async ({ brows
672
672
  body: {
673
673
  expectedLayoutRevision: current.data.layoutRevision,
674
674
  layout: {
675
- version: 2,
675
+ version: 3,
676
676
  sidePanel: {
677
677
  placement: "right",
678
678
  sectionLayout: { order: ["files", "controls", "git"], leftSectionIds: [] },
@@ -732,7 +732,7 @@ test("in-flight sibling acknowledgement clears only the acknowledged subfield",
732
732
  body: {
733
733
  expectedLayoutRevision: current.data.layoutRevision,
734
734
  layout: {
735
- version: 2,
735
+ version: 3,
736
736
  sidePanel: {
737
737
  placement: "right",
738
738
  sectionLayout: { order: initialOrder, leftSectionIds: [] },
@@ -816,7 +816,7 @@ test("same-origin sibling placement adoption cannot overwrite a dirty section la
816
816
  body: {
817
817
  expectedLayoutRevision: current.data.layoutRevision,
818
818
  layout: {
819
- version: 2,
819
+ version: 3,
820
820
  sidePanel: {
821
821
  placement: "right",
822
822
  sectionLayout: { order: initialOrder, leftSectionIds: [] },
@@ -874,7 +874,7 @@ test("seeded v3 Control Deck journal recovers legacy fields without widening par
874
874
  body: {
875
875
  expectedLayoutRevision: current.data.layoutRevision,
876
876
  layout: {
877
- version: 2,
877
+ version: 3,
878
878
  sidePanel: {
879
879
  placement: "right",
880
880
  sectionLayout: { order: ["controls", "files", "git"], leftSectionIds: [] },
@@ -926,7 +926,7 @@ test("a delayed GET cannot regress the revision acknowledged by a newer PUT", as
926
926
  body: {
927
927
  expectedLayoutRevision: current.data.layoutRevision,
928
928
  layout: {
929
- version: 2,
929
+ version: 3,
930
930
  sidePanel: {
931
931
  placement: "right",
932
932
  sectionLayout: { order: ["files", "controls", "git"], leftSectionIds: [] },