@firstpick/pi-package-webui 0.7.9 → 0.8.1

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 (57) hide show
  1. package/README.md +32 -9
  2. package/bin/pi-webui.mjs +750 -113
  3. package/lib/git-workflow-preferences.mjs +16 -0
  4. package/lib/git-worktrees.mjs +43 -4
  5. package/lib/npm-command.mjs +81 -0
  6. package/lib/queue-mutation.mjs +6 -0
  7. package/lib/workspace-files-live-watcher.mjs +138 -0
  8. package/package.json +11 -4
  9. package/public/app.js +3397 -380
  10. package/public/index.html +119 -20
  11. package/public/mobile-shell-state.mjs +166 -0
  12. package/public/service-worker.js +60 -13
  13. package/public/styles.css +1066 -362
  14. package/public/subagent-gate-visibility.mjs +16 -0
  15. package/public/subagent-launch-slot-state.mjs +16 -0
  16. package/public/transcript-renderer.mjs +433 -0
  17. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  18. package/tests/browser/interaction-continuity.spec.mjs +739 -0
  19. package/tests/browser/mobile-foundation.spec.mjs +352 -0
  20. package/tests/browser/optimistic-prompt.spec.mjs +130 -0
  21. package/tests/chat-scroll-intent-static.test.mjs +6 -1
  22. package/tests/codex-fast-mode-static.test.mjs +59 -0
  23. package/tests/compact-sections-static.test.mjs +20 -2
  24. package/tests/compaction-mutation-contract.test.mjs +18 -4
  25. package/tests/compaction-static.test.mjs +1 -0
  26. package/tests/completion-signal-contract.test.mjs +13 -2
  27. package/tests/composer-skill-tag-layout.test.mjs +70 -0
  28. package/tests/fast-mode-client-static.test.mjs +14 -11
  29. package/tests/fixtures/fake-pi.mjs +222 -2
  30. package/tests/git-panel-gitignore-static.test.mjs +104 -0
  31. package/tests/git-workflow-preferences.test.mjs +8 -0
  32. package/tests/guided-git-publication-backend-static.test.mjs +40 -0
  33. package/tests/http-endpoints-harness.test.mjs +490 -3
  34. package/tests/interaction-state-stability-static.test.mjs +254 -0
  35. package/tests/mobile-continuity-tablet-static.test.mjs +55 -0
  36. package/tests/mobile-foundation-static.test.mjs +69 -0
  37. package/tests/mobile-phone-experience-static.test.mjs +65 -0
  38. package/tests/mobile-shell-state.test.mjs +69 -0
  39. package/tests/mobile-static.test.mjs +300 -43
  40. package/tests/mobile-transcript-cache-characterization.test.mjs +34 -0
  41. package/tests/npm-command.test.mjs +64 -1
  42. package/tests/open-issue-wizard-static.test.mjs +2 -1
  43. package/tests/queue-edit-reorder-static.test.mjs +9 -1
  44. package/tests/queue-mutation-contract.test.mjs +22 -0
  45. package/tests/service-worker-lifecycle.test.mjs +120 -0
  46. package/tests/side-panel-resize-static.test.mjs +8 -1
  47. package/tests/sse-backpressure-harness.test.mjs +98 -0
  48. package/tests/streaming-ui-coupling.test.mjs +7 -1
  49. package/tests/subagent-gate-visibility.test.mjs +18 -2
  50. package/tests/subagent-launch-slot-state.test.mjs +32 -0
  51. package/tests/subagent-launch-slots-static.test.mjs +8 -2
  52. package/tests/subagents-helper.test.mjs +90 -0
  53. package/tests/terminal-tab-workspace-static.test.mjs +1 -1
  54. package/tests/update-commands.test.mjs +4 -0
  55. package/tests/workspace-files-live-updates-static.test.mjs +76 -0
  56. package/tests/workspace-files-live-watcher.test.mjs +95 -0
  57. package/webui-rpc-helper.mjs +175 -3
@@ -0,0 +1,352 @@
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
+
16
+ async function freePort() {
17
+ const server = createServer();
18
+ await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
19
+ const { port } = server.address();
20
+ await new Promise((resolve) => server.close(resolve));
21
+ return port;
22
+ }
23
+
24
+ let child;
25
+ let baseURL;
26
+ let tempRoot;
27
+ let output = "";
28
+
29
+ async function assertAxeClean(page, label, selector = "#mobileShellV2") {
30
+ const accessibility = await new AxeBuilder({ page }).include(selector).analyze();
31
+ const serious = accessibility.violations.filter((violation) => ["serious", "critical"].includes(violation.impact));
32
+ assert.deepEqual(serious, [], `${label} should not introduce serious/critical axe violations: ${serious.map((item) => item.id).join(", ")}`);
33
+ }
34
+
35
+ test.beforeAll(async () => {
36
+ const port = await freePort();
37
+ tempRoot = await mkdtemp(join(tmpdir(), "pi-webui-mobile-browser-"));
38
+ await writeFile(join(tempRoot, "tablet-example.txt"), "tablet file viewer fixture\n", "utf8");
39
+ baseURL = `http://127.0.0.1:${port}`;
40
+ child = spawn(process.execPath, [serverScript, "--cwd", tempRoot, "--host", "127.0.0.1", "--port", String(port), "--pi", fakePi], {
41
+ stdio: ["ignore", "pipe", "pipe"],
42
+ env: {
43
+ ...process.env,
44
+ PI_WEBUI_RPC_SUPERVISOR: "0",
45
+ PI_CODING_AGENT_DIR: join(tempRoot, "agent"),
46
+ PI_WEBUI_SETTINGS_FILE: join(tempRoot, "settings.json"),
47
+ },
48
+ });
49
+ child.stdout.on("data", (chunk) => { output += String(chunk); });
50
+ child.stderr.on("data", (chunk) => { output += String(chunk); });
51
+ for (let attempt = 0; attempt < 80; attempt += 1) {
52
+ if (child.exitCode !== null) break;
53
+ try {
54
+ const response = await fetch(`${baseURL}/api/health`, { signal: AbortSignal.timeout(500) });
55
+ if (response.ok) return;
56
+ } catch {
57
+ // Wait for the real server and fake Pi fixture to start.
58
+ }
59
+ await delay(100);
60
+ }
61
+ throw new Error(`Pi Web UI did not start:\n${output}`);
62
+ });
63
+
64
+ test.afterAll(async () => {
65
+ child?.kill("SIGTERM");
66
+ if (child) await new Promise((resolve) => child.once("exit", resolve));
67
+ await rm(tempRoot, { recursive: true, force: true });
68
+ });
69
+
70
+ test("v2 flag is isolated on desktop and rollback remains explicit", async ({ page }) => {
71
+ await page.setViewportSize({ width: 1440, height: 900 });
72
+ await page.goto(`${baseURL}/?mobileShell=v2`);
73
+ await expect(page.locator("#promptInput")).toBeVisible();
74
+ await expect(page.locator("html")).toHaveAttribute("data-mobile-shell", "v2");
75
+ await expect(page.locator(".layout")).toHaveCSS("grid-template-columns", /.+/);
76
+ await page.setViewportSize({ width: 390, height: 844 });
77
+ await page.goto(`${baseURL}/?mobileShell=legacy`);
78
+ await expect(page.locator("#promptInput")).toBeVisible();
79
+ await expect(page.locator("html")).not.toHaveAttribute("data-mobile-shell");
80
+ await page.evaluate(() => window.dispatchEvent(new PopStateEvent("popstate", {
81
+ state: {
82
+ piMobileShellV2: true,
83
+ mobileShellState: { featureMode: "v2", tabletFeatureMode: "v2", viewportMode: "phone", route: "sessions", surface: "none", routeHistory: ["chat"] },
84
+ },
85
+ })));
86
+ await expect(page.locator("html")).not.toHaveAttribute("data-mobile-shell");
87
+ await expect(page.locator("#mobileShellV2")).toBeHidden();
88
+ });
89
+
90
+ test("phone v2 destinations, canonical actions, history, and presentation remain functional", async ({ browser }) => {
91
+ const phoneContext = await browser.newContext({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true });
92
+ const page = await phoneContext.newPage();
93
+ await page.goto(`${baseURL}/?mobileShell=v2`);
94
+ await expect(page.locator("html")).toHaveAttribute("data-mobile-shell", "v2");
95
+ await expect(page.locator("#mobileShellV2")).toBeVisible();
96
+ for (const selector of ["#mobileSessionButton", "#mobileSearchButton", "#mobileMoreButton", "#attachButton", "#composerActionsButton", "#sendButton"]) {
97
+ const box = await page.locator(selector).boundingBox();
98
+ assert.ok(box, `${selector} should have a box`);
99
+ assert.ok(box.width >= 44 && box.height >= 44, `${selector} should meet the 44px target floor, got ${box.width}×${box.height}`);
100
+ }
101
+ const phoneNav = page.getByRole("navigation", { name: "Phone destinations" });
102
+ await expect(phoneNav.getByRole("button")).toHaveCount(4);
103
+ await expect(page.locator("#chat")).not.toHaveAttribute("aria-live");
104
+ await assertAxeClean(page, "phone Chat route");
105
+
106
+ await phoneNav.getByRole("button", { name: "Sessions", exact: true }).click();
107
+ await expect(page.locator("#mobileSessionsRoute")).toBeVisible();
108
+ await expect(page.locator("#mobileSessionsTitle")).toBeFocused();
109
+ await expect(page.locator(".layout")).toHaveAttribute("inert", "");
110
+ await expect(page.locator(".layout")).toHaveAttribute("aria-hidden", "true");
111
+ await expect(page.locator("#mobileShellDestination")).toHaveAttribute("role", "main");
112
+ await expect(page.locator("#mobileSessionsSearchInput")).toBeVisible();
113
+ await page.locator("#promptInput").evaluate((node) => { node.value = "draft survives switch"; node.dispatchEvent(new Event("input", { bubbles: true })); });
114
+ await page.locator("#mobileNewCurrentDirectoryButton").click();
115
+ await expect(page.locator(".mobile-session-select")).toHaveCount(2);
116
+ await page.locator(".mobile-session-select").first().click();
117
+ await expect(page.locator("#promptInput")).toHaveValue("draft survives switch");
118
+ await assertAxeClean(page, "phone Sessions route");
119
+
120
+ await phoneNav.getByRole("button", { name: "Activity", exact: true }).click();
121
+ await expect(page.locator("#mobileActivityRoute")).toBeVisible();
122
+ await expect(page.locator("#mobileActivityTitle")).toBeFocused();
123
+ await expect(page.locator("#mobileActivityStatus")).toBeVisible();
124
+ await assertAxeClean(page, "phone Activity route");
125
+ await phoneNav.getByRole("button", { name: "Project", exact: true }).click();
126
+ await expect(page.locator("#mobileProjectRoute")).toBeVisible();
127
+ await expect(page.locator("#mobileProjectTitle")).toBeFocused();
128
+ await page.getByRole("tab", { name: "Files" }).focus();
129
+ await page.keyboard.press("ArrowRight");
130
+ await expect(page.getByRole("tab", { name: "Git" })).toBeFocused();
131
+ await expect(page.getByRole("tab", { name: "Git" })).toHaveAttribute("aria-selected", "true");
132
+ await page.getByRole("tab", { name: "Files" }).click();
133
+ await expect(page.locator("#fileTreeRoot")).toBeVisible();
134
+ await page.getByRole("tab", { name: "Queue" }).click();
135
+ await expect(page.locator("#queueBox")).toBeVisible();
136
+ await assertAxeClean(page, "phone Project route");
137
+
138
+ await phoneNav.getByRole("button", { name: "Chat", exact: true }).click();
139
+ await page.locator("#composerActionsButton").focus();
140
+ await page.locator("#composerActionsButton").click();
141
+ await expect(page.locator("#mobileShellSurface")).toBeVisible();
142
+ await expect(page.locator("#mobileShellSurface")).toHaveAttribute("role", "dialog");
143
+ await expect(page.locator("#mobileShellSurface")).toHaveAttribute("aria-modal", "true");
144
+ await page.getByRole("button", { name: "Session actions" }).click();
145
+ await page.getByRole("button", { name: "Command palette", exact: true }).click();
146
+ await expect(page.locator("#commandPaletteDialog")).toBeVisible();
147
+ await page.keyboard.press("Escape");
148
+ await expect(page.locator("#commandPaletteDialog")).toBeHidden();
149
+ await expect(page.locator("#mobileShellSurface")).toBeVisible();
150
+ await expect(page.getByRole("heading", { name: "Session actions" })).toBeVisible();
151
+ await page.locator("#mobileSurfaceBackButton").click();
152
+ await page.getByRole("button", { name: "Voice" }).click();
153
+ await expect(page.getByRole("heading", { name: "Voice" })).toBeVisible();
154
+ await assertAxeClean(page, "phone action sheet");
155
+ await page.locator("#mobileSurfaceBackButton").click();
156
+ await page.locator("#mobileSurfaceCloseButton").click();
157
+ await expect(page.locator("#mobileShellSurface")).toBeHidden();
158
+ await expect(page.locator("#composerActionsButton")).toBeFocused();
159
+
160
+ await page.locator("#mobileMoreButton").click();
161
+ await page.getByRole("button", { name: "Settings" }).click();
162
+ await expect(page.locator("#modelSelect")).toBeVisible();
163
+ await page.locator("#thinkingSelect").focus();
164
+ await page.evaluate(() => window.dispatchEvent(new Event("online")));
165
+ await page.waitForTimeout(500);
166
+ await expect(page.locator("#thinkingSelect")).toBeFocused();
167
+ await page.locator("#mobileSurfaceBackButton").click();
168
+ await page.getByRole("button", { name: "Detailed" }).click();
169
+ await expect(page.locator("html")).toHaveAttribute("data-mobile-presentation", "detailed");
170
+ await assertAxeClean(page, "phone More/Settings surface");
171
+ await page.locator("#mobileSurfaceCloseButton").click();
172
+
173
+ await phoneNav.getByRole("button", { name: "Sessions", exact: true }).click();
174
+ await page.goBack();
175
+ await expect(phoneNav.getByRole("button", { name: "Chat", exact: true })).toHaveAttribute("aria-current", "page");
176
+ await page.setViewportSize({ width: 844, height: 390 });
177
+ await expect(page.locator("#mobileShellV2")).toBeVisible();
178
+
179
+ await assertAxeClean(page, "phone shell after history and rotation");
180
+ await phoneContext.close();
181
+ });
182
+
183
+ test("mobile continuity preserves drafts, restores metadata honestly, and retries only on command", async ({ browser }) => {
184
+ const context = await browser.newContext({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true });
185
+ const page = await context.newPage();
186
+ await page.goto(`${baseURL}/?mobileShell=v2`);
187
+ await page.locator("#promptInput").fill("offline continuity draft");
188
+ await page.locator("#attachmentInput").setInputFiles({ name: "context.txt", mimeType: "text/plain", buffer: Buffer.from("context") });
189
+ await expect(page.locator("#attachmentTray")).toContainText("context.txt");
190
+ await page.reload();
191
+ await expect(page.locator("#promptInput")).toHaveValue("offline continuity draft");
192
+ await expect(page.locator("#attachmentTray")).toContainText("Reselect required");
193
+
194
+ await page.locator("#attachButton").click();
195
+ await expect(page.getByRole("heading", { name: "Add Context" })).toBeVisible();
196
+ for (const name of ["Camera", "Photos", "Files"]) await expect(page.locator("#mobileSurfaceRoot").getByRole("button", { name, exact: true })).toBeVisible();
197
+ await expect(page.locator("#mobileSurfaceRoot").getByText("Paste text", { exact: true })).toBeVisible();
198
+ const pasteInput = page.locator(".mobile-paste-context-text");
199
+ const pasteDraft = Array.from({ length: 18 }, (_, index) => `pasted context line ${index}`).join("\n");
200
+ await pasteInput.fill(pasteDraft);
201
+ const pasteBefore = await pasteInput.evaluate((node) => {
202
+ node.focus();
203
+ node.setSelectionRange(14, 41, "backward");
204
+ node.scrollTop = 48;
205
+ return { value: node.value, selectionStart: node.selectionStart, selectionEnd: node.selectionEnd, selectionDirection: node.selectionDirection, scrollTop: node.scrollTop };
206
+ });
207
+ await page.evaluate(() => window.dispatchEvent(new Event("online")));
208
+ await expect(pasteInput).toBeFocused();
209
+ await expect.poll(() => pasteInput.evaluate((node) => ({
210
+ value: node.value,
211
+ selectionStart: node.selectionStart,
212
+ selectionEnd: node.selectionEnd,
213
+ selectionDirection: node.selectionDirection,
214
+ scrollTop: node.scrollTop,
215
+ }))).toEqual(pasteBefore);
216
+ await page.locator("#mobileSurfaceCloseButton").click();
217
+ await page.locator(".attachment-remove-button").click();
218
+
219
+ await context.setOffline(true);
220
+ await page.locator("#sendButton").click();
221
+ await expect(page.locator("#mobileFailedSendRecovery")).toBeVisible();
222
+ await expect(page.locator("#mobileFailedSendRecovery")).toContainText("never retry automatically");
223
+ await assertAxeClean(page, "failed-send recovery", "#mobileFailedSendRecovery");
224
+ await context.setOffline(false);
225
+ await page.locator("#mobileFailedSendRetryButton").click();
226
+ await expect(page.locator("#mobileFailedSendRecovery")).toBeHidden();
227
+
228
+ const tabsResponse = await page.request.get(`${baseURL}/api/tabs`);
229
+ const tabsPayload = await tabsResponse.json();
230
+ const tabId = tabsPayload.data.tabs[0].id;
231
+ await page.goto(`${baseURL}/?mobileShell=v2&mobileRoute=activity&tab=${encodeURIComponent(tabId)}`);
232
+ await expect(page.locator("#mobileActivityRoute")).toBeVisible();
233
+ await expect(page.locator("#mobileContinuityNotice")).toContainText("checking current server state");
234
+
235
+ await page.goto(`${baseURL}/?mobileShell=v2&mobileRoute=activity&tab=stale_tab_12345678`);
236
+ await expect(page.locator("#mobileContinuityNotice")).toContainText("no longer available");
237
+ await expect(page.locator("#mobileSessionsRoute")).toBeVisible();
238
+ await context.close();
239
+ });
240
+
241
+ test("a blocker notification switches to its background tab before exact-target validation", async ({ browser }) => {
242
+ const context = await browser.newContext({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true });
243
+ const page = await context.newPage();
244
+ await page.goto(`${baseURL}/?mobileShell=v2`);
245
+ const initialTabs = await (await page.request.get(`${baseURL}/api/tabs`)).json();
246
+ const targetTabId = initialTabs.data.tabs[0].id;
247
+ await page.getByRole("button", { name: "Sessions", exact: true }).click();
248
+ await page.locator("#mobileNewCurrentDirectoryButton").click();
249
+ await expect(page.locator(".mobile-session-select")).toHaveCount(2);
250
+ const currentTabs = await (await page.request.get(`${baseURL}/api/tabs`)).json();
251
+ const activeTabId = currentTabs.data.activeTabId || currentTabs.data.tabs.find((tab) => tab.id !== targetTabId)?.id;
252
+ assert.notEqual(activeTabId, targetTabId, "fixture requires a different active tab");
253
+ const requestId = `fixture_request_${Date.now()}`;
254
+ const response = await page.request.post(`${baseURL}/api/prompt?tab=${encodeURIComponent(targetTabId)}`, { data: { message: "fixture mobile blocker", requestId } });
255
+ assert.equal(response.ok(), true);
256
+ await expect.poll(async () => {
257
+ const payload = await (await page.request.get(`${baseURL}/api/tabs`)).json();
258
+ return payload.data.tabs.find((tab) => tab.id === targetTabId)?.pendingExtensionUiRequestCount || 0;
259
+ }).toBe(1);
260
+ await page.evaluate(({ tabId }) => {
261
+ navigator.serviceWorker.dispatchEvent(new MessageEvent("message", {
262
+ data: { type: "pi-webui:navigate:v1", target: { v: 1, route: "activity", tabId, blockerId: "fixture_blocker_12345678" } },
263
+ }));
264
+ }, { tabId: targetTabId });
265
+ await expect(page.locator("#dialogTitle")).toHaveText("Fixture blocker");
266
+ await expect(page.locator("#mobileActivityRoute")).toBeVisible();
267
+ await expect(page.locator("#mobileContinuityNotice")).toContainText("Opened after reconnecting");
268
+ const cancel = await page.request.post(`${baseURL}/api/extension-ui-response?tab=${encodeURIComponent(targetTabId)}`, {
269
+ data: { id: "fixture_blocker_12345678", cancelled: true },
270
+ });
271
+ assert.equal(cancel.ok(), true);
272
+ await context.close();
273
+ });
274
+
275
+ test("tablet mode is independent, uses a rail and right inspector, and survives rotation and keyboard navigation", async ({ browser }) => {
276
+ const context = await browser.newContext({ viewport: { width: 820, height: 1180 }, hasTouch: true });
277
+ const page = await context.newPage();
278
+ await page.goto(`${baseURL}/?mobileShell=v2`);
279
+ await expect(page.locator("#mobileShellV2")).toBeHidden();
280
+
281
+ await page.goto(`${baseURL}/?tabletShell=v2`);
282
+ await expect(page.locator("html")).toHaveAttribute("data-tablet-shell", "v2");
283
+ await expect(page.locator("#mobileShellV2")).toBeVisible();
284
+ const rail = page.getByRole("navigation", { name: "Tablet destinations" });
285
+ await expect(rail).toBeVisible();
286
+ const railBox = await rail.boundingBox();
287
+ assert.ok(railBox && railBox.x === 0 && railBox.width >= 100 && railBox.width <= 120, `tablet rail geometry should remain stable, got ${JSON.stringify(railBox)}`);
288
+
289
+ await page.locator("#promptInput").fill("tablet rotation draft");
290
+ await rail.getByRole("button", { name: "Sessions", exact: true }).focus();
291
+ await page.keyboard.press("ArrowDown");
292
+ await expect(rail.getByRole("button", { name: "Activity", exact: true })).toBeFocused();
293
+ await rail.getByRole("button", { name: "Project", exact: true }).click();
294
+ await page.getByRole("tab", { name: "Files" }).click();
295
+ await expect(page.locator("#fileTreeRoot")).toBeVisible();
296
+ await page.locator('[role="treeitem"][data-path="tablet-example.txt"]').click();
297
+ await expect(page.locator("#fileViewerPane")).toBeVisible();
298
+ const fileBox = await page.locator("#fileViewerPane").boundingBox();
299
+ assert.ok(fileBox && fileBox.x === 0 && fileBox.y === 0 && fileBox.width === 820, `tablet file viewer must default to full-screen replacement, got ${JSON.stringify(fileBox)}`);
300
+ await page.locator("#fileViewerCloseButton").click();
301
+
302
+ await page.locator("#mobileMoreButton").click();
303
+ const inspectorBox = await page.locator("#mobileShellSurface").boundingBox();
304
+ assert.ok(inspectorBox && inspectorBox.width <= 480 && Math.abs(inspectorBox.x + inspectorBox.width - 820) <= 1, `tablet inspector must be a bounded right sheet, got ${JSON.stringify(inspectorBox)}`);
305
+ await page.setViewportSize({ width: 1024, height: 768 });
306
+ await expect(page.locator("#mobileShellSurface")).toBeVisible();
307
+ await page.locator("#mobileSurfaceCloseButton").click();
308
+ await rail.getByRole("button", { name: "Chat", exact: true }).click();
309
+ await expect(page.locator("#promptInput")).toHaveValue("tablet rotation draft");
310
+
311
+ for (const size of [{ width: 768, height: 1024 }, { width: 1024, height: 768 }]) {
312
+ await page.setViewportSize(size);
313
+ await expect(page.locator("#mobileShellV2")).toBeVisible();
314
+ }
315
+ await assertAxeClean(page, "tablet shell");
316
+
317
+ await page.goto(`${baseURL}/?tabletShell=legacy`);
318
+ await expect(page.locator("#mobileShellV2")).toBeHidden();
319
+ await context.close();
320
+ });
321
+
322
+ test("desktop remains equivalent at required viewport fixtures", async ({ page }) => {
323
+ for (const size of [{ width: 1280, height: 800 }, { width: 1440, height: 900 }, { width: 1920, height: 1080 }]) {
324
+ await page.setViewportSize(size);
325
+ await page.goto(`${baseURL}/?mobileShell=v2&tabletShell=v2`);
326
+ await expect(page.locator("#mobileShellV2")).toBeHidden();
327
+ await expect(page.locator("#promptInput")).toBeVisible();
328
+ await expect(page.locator(".terminal-tabs-shell")).toBeVisible();
329
+ await expect(page.locator(".side-panel")).toBeVisible();
330
+ }
331
+ });
332
+
333
+ test("desktop left-sidebar actions are compact accessible icon buttons", async ({ page }) => {
334
+ await page.setViewportSize({ width: 1440, height: 900 });
335
+ await page.goto(baseURL);
336
+ await page.locator("body").evaluate((body) => body.classList.add("terminal-tabs-left"));
337
+
338
+ const actions = page.locator(".terminal-sidebar-actions > button");
339
+ await expect(actions).toHaveCount(4);
340
+ const snapshots = await actions.evaluateAll((buttons) => buttons.map((button) => ({
341
+ text: button.textContent.trim(),
342
+ ariaLabel: button.getAttribute("aria-label"),
343
+ width: button.getBoundingClientRect().width,
344
+ height: button.getBoundingClientRect().height,
345
+ })));
346
+ for (const action of snapshots) {
347
+ assert.equal(action.text, "", "left-sidebar action buttons should not render visible text");
348
+ assert.ok(action.ariaLabel, "each icon-only action must retain an accessible name");
349
+ assert.ok(action.width >= 44 && action.height >= 44, `icon action must retain a 44px target, got ${action.width}×${action.height}`);
350
+ }
351
+ assert.ok(Math.max(...snapshots.map((action) => action.width)) - Math.min(...snapshots.map((action) => action.width)) <= 1, "icon actions should remain equal width");
352
+ });
@@ -0,0 +1,130 @@
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 { expect, test } from "@playwright/test";
9
+
10
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
11
+ const serverScript = join(root, "bin", "pi-webui.mjs");
12
+ const fakePi = join(root, "tests", "fixtures", "fake-pi.mjs");
13
+
14
+ async function freePort() {
15
+ const server = createServer();
16
+ await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
17
+ const { port } = server.address();
18
+ await new Promise((resolve) => server.close(resolve));
19
+ return port;
20
+ }
21
+
22
+ let child;
23
+ let baseURL;
24
+ let tempRoot;
25
+ let output = "";
26
+
27
+ test.beforeAll(async () => {
28
+ const port = await freePort();
29
+ tempRoot = await mkdtemp(join(tmpdir(), "pi-webui-optimistic-prompt-"));
30
+ baseURL = `http://127.0.0.1:${port}`;
31
+ child = spawn(process.execPath, [serverScript, "--cwd", tempRoot, "--host", "127.0.0.1", "--port", String(port), "--pi", fakePi], {
32
+ stdio: ["ignore", "pipe", "pipe"],
33
+ env: {
34
+ ...process.env,
35
+ PI_WEBUI_RPC_SUPERVISOR: "0",
36
+ PI_CODING_AGENT_DIR: join(tempRoot, "agent"),
37
+ PI_WEBUI_SETTINGS_FILE: join(tempRoot, "settings.json"),
38
+ FAKE_PI_CONTINUITY_MODE: "1",
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 isolated Web UI 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
+ if (child?.exitCode === null) child.kill("SIGTERM");
58
+ if (child && child.exitCode === null) await new Promise((resolve) => child.once("exit", resolve));
59
+ await rm(tempRoot, { recursive: true, force: true });
60
+ });
61
+
62
+ test("submitted prompt remains visible during transcript reconciliation", async ({ page }) => {
63
+ const prompt = "optimistic prompt survives reconciliation";
64
+ await page.goto(baseURL);
65
+ await page.locator("#promptInput").fill(prompt);
66
+ await page.locator("#sendButton").click();
67
+
68
+ const visiblePrompt = page.locator("#chat .message.user", { hasText: prompt });
69
+ await expect(visiblePrompt).toHaveCount(1);
70
+ await expect(page.locator("#promptInput")).toHaveValue("");
71
+
72
+ // Changing transcript visibility forces the same keyed reconciliation used
73
+ // by message refreshes while the fake backend intentionally withholds a
74
+ // canonical user-message entry.
75
+ await page.keyboard.press("Control+t");
76
+
77
+ await expect(visiblePrompt).toHaveCount(1);
78
+ });
79
+
80
+ test("run indicator remains visible until delayed agent start is confirmed", async ({ page }) => {
81
+ const prompt = "fixture continuity delayed start";
82
+ await page.goto(baseURL);
83
+ await page.locator("#promptInput").fill(prompt);
84
+ await page.locator("#sendButton").click();
85
+
86
+ const runIndicator = page.locator("#chat .runIndicator");
87
+ await expect(runIndicator).toBeVisible();
88
+ await page.evaluate(() => {
89
+ window.__runIndicatorFrameGaps = 0;
90
+ window.__monitorRunIndicator = true;
91
+ const sample = () => {
92
+ if (!window.__monitorRunIndicator) return;
93
+ if (!document.querySelector("#chat .runIndicator")) window.__runIndicatorFrameGaps += 1;
94
+ requestAnimationFrame(sample);
95
+ };
96
+ requestAnimationFrame(sample);
97
+ });
98
+ await delay(3300);
99
+ await expect(runIndicator).toBeVisible();
100
+ await expect(runIndicator).toContainText("Agent is running:");
101
+ const frameGaps = await page.evaluate(() => {
102
+ window.__monitorRunIndicator = false;
103
+ return window.__runIndicatorFrameGaps;
104
+ });
105
+ expect(frameGaps).toBe(0);
106
+ await expect(page.locator("#chat .message.assistant").last()).toContainText("continuity stream complete");
107
+ });
108
+
109
+ test("confirmed streaming replaces routing status before delayed activity events", async ({ page }) => {
110
+ await page.goto(baseURL);
111
+ await page.locator("#promptInput").fill("fixture continuity confirmed before tool");
112
+ await page.locator("#sendButton").click();
113
+
114
+ const runIndicator = page.locator("#chat .runIndicator");
115
+ await expect(runIndicator).toContainText("Agent run confirmed; waiting for first output or action…");
116
+ await expect(runIndicator).not.toContainText(/Routing/i);
117
+ await expect(runIndicator).toContainText("Running tool: read…");
118
+ });
119
+
120
+ test("persisted user message replaces its optimistic bubble without duplication", async ({ page }) => {
121
+ const prompt = "fixture continuity delayed stream";
122
+ await page.goto(baseURL);
123
+ await page.locator("#promptInput").fill(prompt);
124
+ await page.locator("#sendButton").click();
125
+
126
+ const matchingPrompts = page.locator("#chat .message.user", { hasText: prompt });
127
+ await expect(matchingPrompts).toHaveCount(1);
128
+ await expect(page.locator("#chat .message.assistant").last()).toContainText("continuity stream complete");
129
+ await expect(matchingPrompts).toHaveCount(1);
130
+ });
@@ -48,10 +48,15 @@ assert.match(touchStart, /touches\?\.\[0\]\?\.clientY[\s\S]*chatLastTouchClientY
48
48
  assert.match(awayIntent, /event\?\.type === "touchmove"[\s\S]*clientY > chatLastTouchClientY[\s\S]*return scrollAway/, "downward finger movement should pause follow while upward movement can resume at Latest");
49
49
  assert.match(awayIntent, /"ArrowUp"[\s\S]*"Home"[\s\S]*"PageUp"/, "upward keyboard navigation should pause streaming follow");
50
50
  assert.match(noteIntent, /autoFollowChat = false;[\s\S]*updateJumpToLatestButton\(\)/, "upward intent should pause follow and reveal Latest before the scroll event fires");
51
- assert.match(syncAutoFollow, /^\s*const nearBottom[\s\S]*if \(isChatUserScrollAwayIntentActive\(\)\) \{\s*autoFollowChat = false;/, "the near-bottom threshold must not re-enable follow during active upward input");
51
+ assert.match(noteIntent, /!isChatScrollAwayIntent\(event\)[\s\S]*chatPausedScrollRestoreUntil = 0;/, "fresh downward user intent should be able to resume follow after a reconciliation guard");
52
+ assert.match(syncAutoFollow, /^\s*const nearBottom[\s\S]*if \(performance\.now\(\) <= chatPausedScrollRestoreUntil\) \{\s*autoFollowChat = false;[\s\S]*else if \(isChatUserScrollAwayIntentActive\(\)/, "transcript reconciliation and active upward input must both suppress transient near-bottom follow");
53
+ assert.match(syncAutoFollow, /else if \(!autoFollowChat\) \{\s*if \(nearBottom && \(isChatUserScrollIntentActive\(\) \|\| !recentProgrammaticScroll\)\) autoFollowChat = true;/, "a transient programmatic clamp at the bottom must not resume paused follow without fresh user intent");
54
+ assert.doesNotMatch(syncAutoFollow, /\|\| !autoFollowChat \|\|/, "paused follow should not be folded into generic near-bottom reconciliation");
52
55
  assert.match(updateLatest, /hidden = autoFollowChat/, "Latest visibility should reflect paused follow even while still inside the near-bottom threshold");
53
56
  assert.doesNotMatch(updateLatest, /isChatNearBottom/, "Latest must not remain hidden solely because the first upward movement is near the bottom");
54
57
  assert.match(applyFollow, /if \(!autoFollowChat\)[\s\S]*return;/, "already queued streaming frames must honor the immediate follow pause");
58
+ assert.match(app, /if \(!autoFollowChat\) chatPausedScrollRestoreUntil = performance\.now\(\) \+ CHAT_PROGRAMMATIC_SCROLL_GRACE_MS;/, "paused transcript reconciliation should guard against scroll events from temporary DOM height changes");
59
+ assert.match(app, /lastChatProgrammaticScrollAt = performance\.now\(\);\s*setChatScrollTopInstant\(Math\.min\(previousScrollTop, elements\.chat\.scrollHeight\)\);/, "transcript reconciliation should mark its instant reader-position restoration as programmatic");
55
60
  assert.match(resumeFollow, /chatUserScrollAwayIntentUntil = 0;[\s\S]*autoFollowChat = true;/, "explicit resume should clear stale upward intent before following again");
56
61
  assert.match(forceFollow, /if \(force\) resumeChatAutoFollow\(\)/, "Latest and other forced-bottom actions should use the explicit resume path");
57
62
  assert.match(app, /addEventListener\("touchstart", noteChatTouchStart[\s\S]*addEventListener\("touchend", clearChatTouchIntent[\s\S]*addEventListener\("touchcancel", clearChatTouchIntent/, "touch direction tracking should be initialized and cleared for each gesture");
@@ -0,0 +1,59 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFile } from "node:fs/promises";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
7
+ const [server, app, html, styles, serviceWorker, readme, packageRaw, lockRaw] = await Promise.all([
8
+ readFile(join(root, "bin", "pi-webui.mjs"), "utf8"),
9
+ readFile(join(root, "public", "app.js"), "utf8"),
10
+ readFile(join(root, "public", "index.html"), "utf8"),
11
+ readFile(join(root, "public", "styles.css"), "utf8"),
12
+ readFile(join(root, "public", "service-worker.js"), "utf8"),
13
+ readFile(join(root, "README.md"), "utf8"),
14
+ readFile(join(root, "package.json"), "utf8"),
15
+ readFile(join(root, "package-lock.json"), "utf8"),
16
+ ]);
17
+ const pkg = JSON.parse(packageRaw);
18
+ const lock = JSON.parse(lockRaw);
19
+ const packageName = "@firstpick/pi-extension-codex-fast-mode";
20
+
21
+ assert.equal(pkg.optionalDependencies?.[packageName], "^0.1.0", "WebUI should declare the Fast-mode companion as optional");
22
+ assert.ok(pkg.pi?.extensions?.includes(`node_modules/${packageName}/index.ts`), "WebUI should load the optional Fast-mode extension when installed");
23
+ assert.equal(lock.packages?.[""]?.optionalDependencies?.[packageName], "^0.1.0", "lock root should mirror the unpublished optional requirement without inventing a resolved artifact");
24
+ assert.equal(lock.packages?.[`node_modules/${packageName}`]?.version, "0.1.0", "lockfile should resolve the published Fast-mode companion");
25
+ assert.equal(lock.packages?.[`node_modules/${packageName}`]?.optional, true, "resolved Fast-mode companion should remain optional");
26
+
27
+ assert.match(server, /\["codexFastMode", "@firstpick\/pi-extension-codex-fast-mode"\]/, "server should register the package in Optional Features");
28
+ assert.match(server, /CODEX_FAST_MODE_STATUS_KEY = "codex-fast-mode"[\s\S]*?CODEX_FAST_MODE_COMMAND_NAME = "fast-mode"/, "server should use the extension-owned status and command contracts");
29
+ assert.match(server, /function codexFastModeStatusState\(statusText\)[\s\S]*?text !== "on" && text !== "off"[\s\S]*?known: true, enabled: text === "on"/, "server should accept only exact published on/off states");
30
+ assert.match(server, /function codexFastModeSnapshot\(tab, patch = \{\}\)[\s\S]*?extensionStatusMap\(tab\)\.get\(CODEX_FAST_MODE_STATUS_KEY\)/, "server snapshots should come from remembered extension status");
31
+ assert.match(server, /async function codexFastModeFeatureData[\s\S]*?codexFastModeSnapshot\(tab\)[\s\S]*?tabHasActiveOutput\(tab\)[\s\S]*?CODEX_FAST_MODE_CREDIT_NOTICE/, "GET state should be tab-scoped, extension-owned, busy-aware, and disclose credit use");
32
+ assert.match(server, /async function waitForCodexFastModeStatus\(tab, desired\)[\s\S]*?snapshot\.statusKnown && snapshot\.enabled === desired[\s\S]*?makeHttpError\(409,[\s\S]*?did not confirm/, "server should require bounded authoritative status confirmation");
33
+ assert.match(server, /async function setCodexFastMode[\s\S]*?typeof body\?\.enabled !== "boolean"[\s\S]*?feature\.busy[\s\S]*?type: "prompt", message: `\/\$\{feature\.commandName\} \$\{desired \? "on" : "off"\}`[\s\S]*?waitForCodexFastModeStatus\(tab, desired\)[\s\S]*?requested: desired/, "PUT should require explicit intent, reject busy tabs, invoke the extension, and return only confirmed state");
34
+ assert.doesNotMatch(server, /codexFastModeSnapshot\(tab, \{ enabled: desired/, "server must not infer effective Fast state from RPC success");
35
+ assert.match(server, /url\.pathname === "\/api\/codex-fast-mode" && req\.method === "GET"[\s\S]*?url\.pathname === "\/api\/codex-fast-mode" && req\.method === "PUT"/, "server should expose GET and PUT routes");
36
+
37
+ assert.match(html, /<label for="fastOutputModeSelect">Compact mode \(Experimental\)<\/label>[\s\S]*?<option value="compact-v1">Compact<\/option>/, "legacy output processing should be presented as Compact mode while retaining compact-v1");
38
+ assert.doesNotMatch(html, /<label for="fastOutputModeSelect">Fast mode/, "legacy output processing should no longer be presented as Fast mode");
39
+ assert.match(html, /data-side-panel-section="codex-usage"[\s\S]*?id="codexUsageBox"[\s\S]*?class="control-field codex-fast-mode-control"[\s\S]*?class="codex-fast-mode-row"[\s\S]*?id="codexFastModeLabel"[\s\S]*?id="codexFastModeSelect"[\s\S]*?<option value="normal">Normal<\/option>[\s\S]*?<option value="fast">Fast<\/option>[\s\S]*?id="setCodexFastModeButton"[\s\S]*?id="codexFastModeStatus"/, "Codex Usage should render before the compact session Fast-mode row");
40
+ assert.match(styles, /\.codex-fast-mode-control \{[\s\S]*?margin-top: 0\.58rem[\s\S]*?padding: 0\.48rem 0\.55rem[\s\S]*?\.codex-fast-mode-row \{[\s\S]*?grid-template-columns: minmax\(0, 1fr\) minmax\(6\.5rem, 8rem\) auto/, "Codex Fast mode should use a compact horizontal control surface");
41
+ assert.match(app, /function codexFastModeStatusText\(\)[\s\S]*?return `\$\{codexFastModeState\.enabled \? "Fast" : "Normal"\} · This tab`;/, "ordinary Fast-mode status should stay concise");
42
+
43
+ assert.match(app, /id: "codexFastMode"[\s\S]*?packageName: "@firstpick\/pi-extension-codex-fast-mode"[\s\S]*?capabilityLabel: "\/fast-mode"/, "browser Optional Features should catalog Fast mode");
44
+ assert.match(app, /OPTIONAL_FEATURE_DISABLE_PREREQUISITES = new Map\([\s\S]*?\["codexFastMode", \(\) => disableCodexFastModeIntegration\(\)\]/, "browser should register disable-off-first behavior");
45
+ assert.match(app, /if \(disabled\) \{[\s\S]*?OPTIONAL_FEATURE_DISABLE_PREREQUISITES\.get\(feature\.id\)[\s\S]*?await turnOff\(\)[\s\S]*?setOptionalFeatureDisabled\(feature\.id, disabled\)/, "Optional Features Disable should abort before hiding integration if turn-off fails");
46
+ assert.match(app, /function applyCodexFastModeStatus\(statusText\)[\s\S]*?status !== "on" && status !== "off"[\s\S]*?enabled: status === "on"[\s\S]*?statusKnown: true/, "browser should consume only exact extension status values");
47
+ assert.match(app, /async function refreshCodexFastMode\(tabContext = activeTabContext\(\)\)[\s\S]*?api\("\/api\/codex-fast-mode", \{ tabId: tabContext\.tabId \}\)[\s\S]*?!featureEnabled && data\.available[\s\S]*?enabled: false[\s\S]*?isCurrentTabContext\(tabContext\)/, "browser status refresh should stay tab-scoped and disarm restored branches while the feature is hidden");
48
+ assert.match(app, /async function applyCodexFastMode\(\)[\s\S]*?body: \{ enabled \}, tabId: tabContext\.tabId[\s\S]*?1\.5x faster[\s\S]*?may spend 2x credits[\s\S]*?2\.5x/, "browser should apply explicit state and disclose conditional speed/credit multipliers");
49
+ assert.match(app, /async function disableCodexFastModeIntegration\(\)[\s\S]*?tabs\.filter[\s\S]*?Promise\.all\(tabIds\.map[\s\S]*?data\.busy[\s\S]*?enabled: false[\s\S]*?codexFastModeConfirmedOff\(response\.data\)/, "browser-global Disable should preflight every live tab and require each mutation to confirm off");
50
+ assert.match(app, /refreshNaturalConversationMode\(tabContext\),[\s\S]*?refreshCodexFastMode\(tabContext\),/, "tab refreshes should reload branch-scoped Fast-mode state");
51
+ assert.match(app, /statusKey === CODEX_FAST_MODE_STATUS_KEY[\s\S]*?applyCodexFastModeStatus\(request\.statusText\)/, "extension status events should refresh the active-tab selector");
52
+
53
+ assert.match(readme, /### Compact live output mode[\s\S]*?select \*\*Compact\*\*[\s\S]*?`compact-v1`/, "README should document Compact mode with the stable wire identifier");
54
+ assert.match(readme, /### Codex subscription Fast mode[\s\S]*?service_tier: "priority"[\s\S]*?1\.5× faster[\s\S]*?2× Standard credits[\s\S]*?2\.5×/, "README should separately document subscription Fast mode and its cost semantics");
55
+ // Intent preserved: browser-asset changes must advance the coherent cache tuple.
56
+ assert.match(serviceWorker, /pi-webui-pwa-v61/, "PWA cache identity should be bumped for changed browser assets");
57
+ assert.match(html, /data-app-src="\/app\.js\?v=103"/, "browser module URL should be cache-busted for Fast-mode wiring");
58
+
59
+ console.log("codex-fast-mode-static.test.mjs passed");
@@ -31,9 +31,23 @@ assert.match(
31
31
  );
32
32
  assert.match(
33
33
  css,
34
- /\/\* Compact high-density surfaces:[\s\S]*\.subagent-launch-slots-summary \{[\s\S]*min-height:\s*2\.7rem;[\s\S]*\.subagents-box \{[\s\S]*padding:\s*0\.48rem;[\s\S]*\.subagent-tab-header \{[\s\S]*min-height:\s*36px;/,
35
- "Subagents side-panel chrome should use the scoped compact density treatment",
34
+ /\/\* Compact high-density surfaces:[\s\S]*\.subagent-launch-slots-summary \{[\s\S]*min-height:\s*2\.35rem;[\s\S]*\.subagents-box \{[\s\S]*padding:\s*0\.48rem;[\s\S]*\.subagent-tab-header \{[\s\S]*min-height:\s*36px;/,
35
+ "Subagents side-panel chrome should use the minimal scoped density treatment",
36
36
  );
37
+
38
+ const controls = ruleBlock(".side-panel-controls");
39
+ assert.equal(propertyValue(controls, "gap"), "0.55rem", "Controls sections should keep compact spacing");
40
+ const controlGroup = ruleBlock(".control-group");
41
+ assert.equal(propertyValue(controlGroup, "gap"), "0.5rem", "Controls groups should keep compact internal spacing");
42
+ assert.equal(propertyValue(controlGroup, "padding"), "0.58rem", "Controls groups should use compact padding");
43
+ assert.equal(propertyValue(controlGroup, "box-shadow"), "none", "Controls groups should use flat minimal surfaces");
44
+ const controlElements = ruleBlock('.side-panel-controls select,\n.side-panel-controls button,\n.side-panel-controls input:not([type="checkbox"]):not([type="file"])');
45
+ assert.equal(propertyValue(controlElements, "min-height"), "2.25rem", "Desktop Controls inputs should use the compact height floor");
46
+ assert.equal(propertyValue(controlElements, "border-radius"), "0.55rem", "Controls inputs should use restrained corner geometry");
47
+ const controlsToggle = ruleBlock(".toggle-control");
48
+ assert.equal(propertyValue(controlsToggle, "min-height"), "2.25rem", "Desktop Controls toggles should match compact form rows");
49
+ assert.equal(propertyValue(controlsToggle, "padding"), "0.34rem 0.48rem", "Controls toggles should avoid nested-card padding");
50
+ assert.match(css, /\.side-panel-controls \.toggle-control > span \{[\s\S]*display:\s*flex;[\s\S]*justify-content:\s*space-between;/, "Controls toggle labels and statuses should share one compact row");
37
51
  assert.match(
38
52
  css,
39
53
  /\/\* Keep the Files tree visual language while giving Git its denser data-list rhythm\. \*\/[\s\S]*\.git-side-panel-folder-summary,[\s\S]*\.git-side-panel-file \{[\s\S]*min-height:\s*1\.55rem;[\s\S]*padding:\s*0\.08rem 0\.26rem;[\s\S]*border:\s*1px solid transparent;[\s\S]*border-radius:\s*0\.5rem;[\s\S]*\.git-side-panel-file:focus-visible \{[\s\S]*box-shadow:\s*inset 2px 0 0 var\(--ctp-blue\)/,
@@ -101,6 +115,10 @@ for (const selector of [
101
115
  ".git-side-panel-file",
102
116
  "button.git-workflow-step",
103
117
  ".git-workflow-message-input",
118
+ ".side-panel-controls select",
119
+ ".side-panel-controls button",
120
+ ".side-panel-controls input:not([type=\"checkbox\"]):not([type=\"file\"])",
121
+ ".side-panel-controls .toggle-control",
104
122
  ]) {
105
123
  assert.ok(coarseBlock.includes(selector), `${selector} should retain a coarse-pointer target floor`);
106
124
  }
@@ -150,17 +150,31 @@ assert.strictEqual(movedCommand.images[0], secondImage, "move retains the moved
150
150
  assert.deepEqual(movedCommand.metadata, { origin: "fixture", sequence: 2 }, "move retains moved command metadata");
151
151
  assert.equal(events.length, 2, "a successful compaction move emits exactly one additional queue update");
152
152
 
153
- tab.compactionQueueDraining = true;
154
- const draining = context.mutate(tab, {
153
+ const remove = context.mutate(tab, {
155
154
  source: "webui-compaction",
156
155
  kind: "followUp",
157
156
  revision: 2,
158
157
  expected: { steering: ["fixed steering"], followUp: ["second follow-up", "edited follow-up"] },
159
- operation: { type: "edit", index: 0, expectedText: "second follow-up", text: "must not apply" },
158
+ operation: { type: "delete", index: 1, expectedText: "edited follow-up" },
159
+ });
160
+ assert.equal(remove.mutated, true, "a current delete is accepted");
161
+ assert.deepEqual([...remove.queue.followUp], ["second follow-up"], "delete removes only the selected follow-up while preserving steering");
162
+ assert.deepEqual([...remove.queue.steering], ["fixed steering"]);
163
+ assert.equal(tab.compactionQueue.length, 2, "delete removes the complete queued command record");
164
+ assert.strictEqual(tab.compactionQueue[1].command, movedCommand, "delete preserves the remaining command identity");
165
+ assert.equal(events.length, 3, "a successful compaction delete emits exactly one additional queue update");
166
+
167
+ tab.compactionQueueDraining = true;
168
+ const draining = context.mutate(tab, {
169
+ source: "webui-compaction",
170
+ kind: "followUp",
171
+ revision: 3,
172
+ expected: { steering: ["fixed steering"], followUp: ["second follow-up"] },
173
+ operation: { type: "delete", index: 0, expectedText: "second follow-up" },
160
174
  });
161
175
  assert.equal(draining.mutated, false, "a draining compaction queue rejects mutation");
162
176
  assert.equal(draining.reason, "queue-draining");
163
- assert.equal(events.length, 2, "a rejected draining mutation emits no queue update");
177
+ assert.equal(events.length, 3, "a rejected draining mutation emits no queue update");
164
178
  assert.strictEqual(tab.compactionQueue[1].command, movedCommand, "a rejected draining mutation leaves the moved command untouched");
165
179
 
166
180
  console.log("compaction-mutation-contract.test.mjs passed");