@firstpick/pi-package-webui 0.8.8 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +12 -0
  2. package/bin/pi-webui-rpc-supervisor.mjs +4 -1
  3. package/bin/pi-webui.mjs +15 -3
  4. package/lib/rpc-supervisor-protocol.mjs +6 -1
  5. package/package.json +1 -1
  6. package/public/app.js +659 -150
  7. package/public/index.html +28 -13
  8. package/public/service-worker.js +1 -1
  9. package/public/styles.css +789 -23
  10. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  11. package/tests/browser/interaction-continuity.spec.mjs +120 -0
  12. package/tests/browser/mobile-foundation.spec.mjs +363 -5
  13. package/tests/browser/optimistic-prompt.spec.mjs +24 -10
  14. package/tests/browser/persistent-ui-layout.spec.mjs +2 -0
  15. package/tests/browser/search-match-highlighting.spec.mjs +104 -0
  16. package/tests/browser/side-panel-section-reorder.spec.mjs +16 -1
  17. package/tests/codex-fast-mode-static.test.mjs +2 -2
  18. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  19. package/tests/fast-mode-client-static.test.mjs +1 -1
  20. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  21. package/tests/file-tree-search-layout-static.test.mjs +261 -0
  22. package/tests/file-viewer-search-static.test.mjs +7 -2
  23. package/tests/fixtures/fake-pi.mjs +4 -1
  24. package/tests/foreground-transcript-catch-up-static.test.mjs +91 -0
  25. package/tests/http-endpoints-harness.test.mjs +35 -2
  26. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  27. package/tests/mobile-compact-layout.test.mjs +60 -0
  28. package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
  29. package/tests/mobile-foundation-static.test.mjs +12 -12
  30. package/tests/mobile-phone-experience-static.test.mjs +2 -2
  31. package/tests/mobile-static.test.mjs +39 -20
  32. package/tests/open-issue-wizard-static.test.mjs +1 -1
  33. package/tests/persistent-ui-layout-static.test.mjs +3 -3
  34. package/tests/questionnaire-dialog.test.mjs +3 -3
  35. package/tests/rpc-supervisor-host.test.mjs +18 -1
  36. package/tests/rpc-supervisor-protocol.test.mjs +5 -0
  37. package/tests/search-match-highlighting-static.test.mjs +27 -0
  38. package/tests/session-sampling-ui-static.test.mjs +3 -3
  39. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  40. package/tests/side-panel-section-reorder-static.test.mjs +23 -10
  41. package/tests/stream-output-isolation-static.test.mjs +1 -1
  42. package/tests/streaming-ui-coupling.test.mjs +8 -0
  43. package/tests/terminal-tab-workspace-static.test.mjs +15 -1
  44. package/tests/theme-customizer-static.test.mjs +1 -1
@@ -65,7 +65,7 @@ function makeEnvironment({
65
65
  reload: new FakeElement(),
66
66
  copyStatus: new FakeElement(),
67
67
  };
68
- const styleLink = new FakeElement({ href: "http://127.0.0.1:31415/styles.css?v=104", sheet: stylesheetLoaded ? {} : null });
68
+ const styleLink = new FakeElement({ href: "http://127.0.0.1:31415/styles.css?v=107", sheet: stylesheetLoaded ? {} : null });
69
69
  const listeners = new Map();
70
70
  const timers = new Map();
71
71
  let timerId = 0;
@@ -84,7 +84,7 @@ function makeEnvironment({
84
84
  removeEventListener(name) { listeners.delete(name); },
85
85
  };
86
86
  const document = {
87
- currentScript: new FakeElement({ dataset: { appSrc: "/app.js?v=120" } }),
87
+ currentScript: new FakeElement({ dataset: { appSrc: "/app.js?v=121" } }),
88
88
  readyState: "complete",
89
89
  querySelector(selector) {
90
90
  return {
@@ -232,7 +232,7 @@ for (const moduleName of startupModuleNames) {
232
232
  assert.ok(serviceWorker.includes(`"/${moduleName}"`), `the PWA app shell should include every app.js startup module: ${moduleName}`);
233
233
  }
234
234
  assert.match(serviceWorker, /pi-webui-pwa-v\d+/, "the app-shell cache should retain a versioned identity");
235
- assert.ok(html.indexOf('id="webuiBootLoader"') < html.indexOf("/app.js?v=120"), "the inline loader should own app module startup");
235
+ assert.ok(html.indexOf('id="webuiBootLoader"') < html.indexOf("/app.js?v=121"), "the inline loader should own app module startup");
236
236
  assert.doesNotMatch(html, /<script type="module" src="\/app\.js/, "the app module should not bypass the guarded loader");
237
237
 
238
238
  console.log("boot-failure-diagnostics.test.mjs passed");
@@ -45,6 +45,11 @@ async function activeTabId(page) {
45
45
  return page.locator("#tabBar [role=\"tab\"][aria-selected=\"true\"]").evaluate((node) => node.closest("[data-tab-id]")?.dataset.tabId || "");
46
46
  }
47
47
 
48
+ async function tabClientCount(page, tabId) {
49
+ const payload = await api(page, "/api/tabs");
50
+ return Number(payload.data?.tabs?.find((tab) => tab.id === tabId)?.clientCount || 0);
51
+ }
52
+
48
53
  async function startContinuityRunner(page) {
49
54
  const tabId = await activeTabId(page) || (await tabIds(page))[0];
50
55
  const configured = await api(page, "/api/app-runner-config", {
@@ -205,6 +210,85 @@ test.afterAll(async () => {
205
210
  await rm(tempRoot, { recursive: true, force: true });
206
211
  });
207
212
 
213
+ test("only hidden pages disconnect live events and resume from one authoritative snapshot", async ({ page }) => {
214
+ await page.setViewportSize({ width: 1280, height: 800 });
215
+ await page.goto(baseURL);
216
+ const tabId = await activeTabId(page) || (await tabIds(page))[0];
217
+ assert.ok(tabId, "the background catch-up fixture requires an active tab");
218
+ await expect.poll(() => tabClientCount(page, tabId)).toBe(1);
219
+
220
+ await page.evaluate(() => {
221
+ window.__backgroundStreamProof = { closeCalls: 0, constructions: 0 };
222
+ const NativeEventSource = window.EventSource;
223
+ const nativeClose = NativeEventSource.prototype.close;
224
+ NativeEventSource.prototype.close = function (...args) {
225
+ window.__backgroundStreamProof.closeCalls += 1;
226
+ return nativeClose.apply(this, args);
227
+ };
228
+ window.EventSource = new Proxy(NativeEventSource, {
229
+ construct(target, args, receiver) {
230
+ window.__backgroundStreamProof.constructions += 1;
231
+ return Reflect.construct(target, args, receiver);
232
+ },
233
+ });
234
+ window.dispatchEvent(new Event("blur"));
235
+ });
236
+ await expect.poll(() => tabClientCount(page, tabId)).toBe(1);
237
+ await expect.poll(() => page.evaluate(() => window.__backgroundStreamProof.closeCalls)).toBe(0);
238
+
239
+ await page.evaluate(() => {
240
+ window.__backgroundVisibilityState = "hidden";
241
+ Object.defineProperty(document, "visibilityState", {
242
+ configurable: true,
243
+ get: () => window.__backgroundVisibilityState,
244
+ });
245
+ document.dispatchEvent(new Event("visibilitychange"));
246
+ });
247
+ await expect.poll(() => tabClientCount(page, tabId)).toBe(0);
248
+ await expect.poll(() => page.evaluate(() => window.__backgroundStreamProof.closeCalls)).toBe(1);
249
+
250
+ const completedBefore = await page.locator("#chat .message.assistant", { hasText: "continuity stream complete" }).count();
251
+ await api(page, `/api/prompt?tab=${encodeURIComponent(tabId)}`, {
252
+ method: "POST",
253
+ data: { message: "fixture continuity delayed stream", requestId: `background-catch-up-${Date.now()}` },
254
+ });
255
+ await waitForFixtureSettlement(page, tabId);
256
+ await expect(page.locator("#chat .message.assistant", { hasText: "continuity stream complete" })).toHaveCount(completedBefore);
257
+
258
+ const resumedAt = Date.now();
259
+ await page.evaluate(() => {
260
+ window.__backgroundVisibilityState = "visible";
261
+ document.dispatchEvent(new Event("visibilitychange"));
262
+ });
263
+ await expect.poll(() => tabClientCount(page, tabId)).toBe(1);
264
+ await expect(page.locator("#chat .message.assistant", { hasText: "continuity stream complete" })).toHaveCount(completedBefore + 1);
265
+ const proof = await page.evaluate(() => window.__backgroundStreamProof);
266
+ assert.equal(proof.constructions, 1, "foreground catch-up should create exactly one replacement EventSource");
267
+ assert.ok(Date.now() - resumedAt < 4_000, "the bounded snapshot resume should complete without replaying the hidden stream duration");
268
+ });
269
+
270
+ test("autosizing the main input does not move settled agent output", async ({ page }) => {
271
+ await page.setViewportSize({ width: 1280, height: 800 });
272
+ await page.goto(baseURL);
273
+ const outputCard = page.locator("#chat > .message.assistant").last();
274
+ await expect(outputCard).toBeVisible();
275
+
276
+ const promptInput = page.locator("#promptInput");
277
+ const initial = await outputCard.evaluate((node) => ({
278
+ top: node.getBoundingClientRect().top,
279
+ inputHeight: document.querySelector("#promptInput")?.getBoundingClientRect().height || 0,
280
+ }));
281
+ await promptInput.fill("composer stability ".repeat(120));
282
+ await expect.poll(() => promptInput.evaluate((node) => node.getBoundingClientRect().height)).toBeGreaterThan(initial.inputHeight + 40);
283
+ const expandedTop = await outputCard.evaluate((node) => node.getBoundingClientRect().top);
284
+ assert.ok(Math.abs(expandedTop - initial.top) <= 1, `agent output moved ${expandedTop - initial.top}px while the composer expanded`);
285
+
286
+ await promptInput.fill("short draft");
287
+ await expect.poll(() => promptInput.evaluate((node) => node.getBoundingClientRect().height)).toBeLessThan(initial.inputHeight + 2);
288
+ const collapsedTop = await outputCard.evaluate((node) => node.getBoundingClientRect().top);
289
+ assert.ok(Math.abs(collapsedTop - initial.top) <= 1, `agent output moved ${collapsedTop - initial.top}px while the composer collapsed`);
290
+ });
291
+
208
292
  test("same-context app-runner refresh preserves directional selection, control scroll, and reader scroll mode", async ({ page }) => {
209
293
  await page.setViewportSize({ width: 1280, height: 800 });
210
294
  await page.goto(baseURL);
@@ -924,3 +1008,39 @@ test("compact live output keeps the selected Text node through repeated flushes"
924
1008
  await api(page, "/api/webui-output-mode", { method: "PUT", data: { outputModeDefault: "normal" } });
925
1009
  }
926
1010
  });
1011
+
1012
+ test("submitting a new turn resumes bottom-follow and keeps the streamed tail anchored", async ({ page }) => {
1013
+ await page.setViewportSize({ width: 900, height: 420 });
1014
+ await page.goto(baseURL);
1015
+ await expect.poll(() => page.locator("#chat .message").count()).toBeGreaterThanOrEqual(3);
1016
+ await page.addStyleTag({ content: "#chat > .message { min-height: 10rem; }" });
1017
+
1018
+ const chat = page.locator("#chat");
1019
+ const pausedRemaining = await chat.evaluate((node) => {
1020
+ node.style.scrollBehavior = "auto";
1021
+ node.scrollTop = node.scrollHeight;
1022
+ node.dispatchEvent(new WheelEvent("wheel", { deltaY: -180, bubbles: true }));
1023
+ node.scrollTop = Math.max(0, node.scrollHeight - node.clientHeight - 180);
1024
+ node.dispatchEvent(new Event("scroll", { bubbles: true }));
1025
+ node.style.removeProperty("scroll-behavior");
1026
+ return node.scrollHeight - node.clientHeight - node.scrollTop;
1027
+ });
1028
+ assert.ok(pausedRemaining > 96, `the fixture must pause above the bottom threshold, got ${pausedRemaining}px`);
1029
+ await expect(page.locator("#jumpToLatestButton")).toBeVisible();
1030
+
1031
+ await page.locator("#promptInput").fill("fixture continuity delayed stream");
1032
+ await page.locator("#sendButton").click();
1033
+ await expect(page.locator("#chat .message.user", { hasText: "fixture continuity delayed stream" }).last()).toBeVisible();
1034
+ await expect.poll(() => chat.evaluate((node) => ({
1035
+ following: document.querySelector("#jumpToLatestButton")?.hidden === true,
1036
+ remaining: Math.round(node.scrollHeight - node.clientHeight - node.scrollTop),
1037
+ }))).toEqual({ following: true, remaining: 0 });
1038
+
1039
+ const streamingOutput = page.locator(".message.assistant.streaming .streaming-markdown").last();
1040
+ for (const text of ["continuity", "continuity stream", "continuity stream complete"]) {
1041
+ await expect(streamingOutput).toContainText(text);
1042
+ await expect.poll(() => chat.evaluate((node) => Math.round(node.scrollHeight - node.clientHeight - node.scrollTop))).toBe(0);
1043
+ }
1044
+ await waitForFixtureSettlement(page);
1045
+ await expect.poll(() => chat.evaluate((node) => Math.round(node.scrollHeight - node.clientHeight - node.scrollTop))).toBe(0);
1046
+ });
@@ -26,8 +26,10 @@ let baseURL;
26
26
  let tempRoot;
27
27
  let output = "";
28
28
 
29
- async function assertAxeClean(page, label, selector = "#mobileShellV2") {
30
- const accessibility = await new AxeBuilder({ page }).include(selector).analyze();
29
+ async function assertAxeClean(page, label, selector = "#mobileShellV2", disabledRules = []) {
30
+ let builder = new AxeBuilder({ page }).include(selector);
31
+ if (disabledRules.length) builder = builder.disableRules(disabledRules);
32
+ const accessibility = await builder.analyze();
31
33
  const serious = accessibility.violations.filter((violation) => ["serious", "critical"].includes(violation.impact));
32
34
  assert.deepEqual(serious, [], `${label} should not introduce serious/critical axe violations: ${serious.map((item) => item.id).join(", ")}`);
33
35
  }
@@ -87,16 +89,372 @@ test("v2 flag is isolated on desktop and rollback remains explicit", async ({ pa
87
89
  await expect(page.locator("#mobileShellV2")).toBeHidden();
88
90
  });
89
91
 
92
+ test("legacy phone keeps terminal navigation and secondary composer actions collapsed", async ({ browser }) => {
93
+ const context = await browser.newContext({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true });
94
+ const page = await context.newPage();
95
+ await page.goto(`${baseURL}/?mobileShell=legacy`);
96
+ await page.addStyleTag({ content: "#optionalFeatureMigrationSurface, #updateNotification { display: none !important; }" });
97
+
98
+ await expect(page.locator("html")).not.toHaveAttribute("data-mobile-shell");
99
+ await expect(page.locator("body")).toHaveClass(/mobile-composer-disclosure/);
100
+ await expect(page.locator("#terminalTabsDrawerContent")).toBeHidden();
101
+ await expect(page.locator("#terminalTabsBackdrop")).toBeHidden();
102
+ await expect(page.locator("#terminalTabsToggleButton")).toHaveAttribute("aria-expanded", "false");
103
+ await expect(page.locator("#promptInput")).toBeVisible();
104
+ await expect(page.locator("#attachButton")).toBeVisible();
105
+ await expect(page.locator("#composerActionsButton")).toBeVisible();
106
+ await expect(page.locator("#sendButton")).toBeVisible();
107
+ await expect(page.locator("#composerActionsPanel")).toBeHidden();
108
+ const legacyDensity = await page.evaluate(() => ({
109
+ controlSize: getComputedStyle(document.documentElement).getPropertyValue("--mobile-control-size").trim(),
110
+ bodyFontSize: Number.parseFloat(getComputedStyle(document.body).fontSize),
111
+ attachSize: document.querySelector("#attachButton").getBoundingClientRect().width,
112
+ }));
113
+ assert.equal(legacyDensity.controlSize, "40px");
114
+ assert.ok(legacyDensity.bodyFontSize <= 14, `legacy mobile body text should use the balanced compact scale, got ${legacyDensity.bodyFontSize}px`);
115
+ assert.equal(legacyDensity.attachSize, 40, `legacy attachment control should use the selected 40px target, got ${legacyDensity.attachSize}px`);
116
+
117
+ await page.evaluate(() => {
118
+ const widget = document.createElement("details");
119
+ widget.id = "mobileTodoProgressFixture";
120
+ widget.className = "widget todo-widget";
121
+ widget.innerHTML = `
122
+ <summary class="todo-widget-summary">
123
+ <div class="todo-widget-goal">Goal: Keep mobile progress compact</div>
124
+ <div class="todo-widget-header">
125
+ <span class="todo-widget-toggle">›</span>
126
+ <span class="todo-widget-title">Todo progress</span>
127
+ <span class="todo-widget-count">1/3</span>
128
+ <span class="todo-widget-meta">active</span>
129
+ </div>
130
+ <div class="todo-widget-progress"><span class="todo-widget-progress-fill" style="width: 33%"></span></div>
131
+ </summary>
132
+ <div class="todo-widget-body"><ol class="todo-widget-list"><li class="todo-widget-item partial"><span class="todo-widget-marker">–</span><span class="todo-widget-text">Add regression coverage</span></li></ol></div>
133
+ `;
134
+ document.querySelector(".widget-area").append(widget);
135
+ });
136
+ const mobileTodo = page.locator("#mobileTodoProgressFixture");
137
+ const collapsedTodoSummary = await mobileTodo.locator("summary").boundingBox();
138
+ assert.ok(collapsedTodoSummary && collapsedTodoSummary.height <= 24, `collapsed mobile todo progress should be one line, got ${JSON.stringify(collapsedTodoSummary)}`);
139
+ await expect(mobileTodo.locator(".todo-widget-goal")).toBeHidden();
140
+ await expect(mobileTodo.locator(".todo-widget-progress")).toBeHidden();
141
+ await expect(mobileTodo.locator(".todo-widget-body")).toBeHidden();
142
+ await mobileTodo.locator("summary").tap();
143
+ await expect(mobileTodo).toHaveAttribute("open", "");
144
+ await expect(mobileTodo.locator(".todo-widget-goal")).toBeVisible();
145
+ await expect(mobileTodo.locator(".todo-widget-progress")).toBeVisible();
146
+ await expect(mobileTodo.locator(".todo-widget-body")).toBeVisible();
147
+ await mobileTodo.evaluate((node) => node.remove());
148
+
149
+ await page.locator("#terminalTabsToggleButton").tap();
150
+ await expect(page.locator("#footerFloatingTooltip")).toHaveCount(0);
151
+ await expect(page.locator("#terminalTabsToggleButton")).toHaveAttribute("aria-expanded", "true");
152
+ await expect(page.locator("#terminalTabsDrawerContent")).toBeVisible();
153
+ await expect(page.locator("#terminalTabsBackdrop")).toBeVisible();
154
+ await expect(page.locator(".terminal-sidebar-actions")).toBeVisible();
155
+ await expect(page.locator("#closeAllTabsButton")).toBeVisible();
156
+ const drawer = await page.locator(".terminal-tabs-shell").boundingBox();
157
+ assert.ok(drawer && drawer.x === 0 && drawer.y === 0 && drawer.width === 390 && drawer.height === 844, `terminal navigation should fill 390×844, got ${JSON.stringify(drawer)}`);
158
+ await expect(page.locator("#sidePanelExpandButton")).toBeHidden();
159
+ await page.locator("#terminalTabsToggleButton").tap();
160
+ await expect(page.locator("#terminalTabsDrawerContent")).toBeHidden();
161
+ await expect(page.locator("#terminalTabsToggleButton")).toBeFocused();
162
+ await page.setViewportSize({ width: 320, height: 720 });
163
+ await page.locator("#terminalTabsToggleButton").focus();
164
+ await page.keyboard.press("Enter");
165
+ await expect(page.locator("#terminalTabsDrawerContent")).toBeVisible();
166
+ const narrowDrawer = await page.locator(".terminal-tabs-shell").boundingBox();
167
+ assert.ok(narrowDrawer && narrowDrawer.x === 0 && narrowDrawer.y === 0 && narrowDrawer.width === 320 && narrowDrawer.height === 720, `terminal navigation should fill 320×720, got ${JSON.stringify(narrowDrawer)}`);
168
+ await expect(page.locator("#sidePanelExpandButton")).toBeHidden();
169
+ await expect(page.locator(".terminal-tabs-shell")).toHaveAttribute("role", "dialog");
170
+ await expect(page.locator(".terminal-tabs-shell")).toHaveAttribute("aria-modal", "true");
171
+
172
+ await page.locator("#newTabButton").tap();
173
+ await expect(page.locator("#newTabMenuPanel")).toBeVisible();
174
+ let drawerLayers = await page.evaluate(() => ({
175
+ drawer: Number.parseInt(getComputedStyle(document.querySelector(".terminal-tabs-shell")).zIndex, 10),
176
+ backdrop: Number.parseInt(getComputedStyle(document.querySelector("#terminalTabsBackdrop")).zIndex, 10),
177
+ }));
178
+ assert.ok(drawerLayers.drawer > drawerLayers.backdrop, `open + Tab options must remain above the blurred backdrop, got ${JSON.stringify(drawerLayers)}`);
179
+
180
+ await page.evaluate(() => {
181
+ const fixture = document.createElement("div");
182
+ fixture.id = "mobileGroupToggleFixture";
183
+ fixture.className = "terminal-tab terminal-tab-group";
184
+ const button = document.createElement("button");
185
+ button.className = "terminal-tab-button terminal-tab-group-button";
186
+ button.setAttribute("aria-expanded", "false");
187
+ button.innerHTML = '<span class="terminal-tab-title-row"><span class="terminal-tab-title">Fixture group</span><span class="terminal-tab-group-dropdown-indicator">⌄</span></span><span class="terminal-tab-meta">project-cwd · idle</span>';
188
+ const menu = document.createElement("div");
189
+ menu.className = "terminal-tab-group-menu";
190
+ menu.textContent = "Fixture terminal";
191
+ button.addEventListener("click", () => {
192
+ const open = !fixture.classList.contains("menu-open");
193
+ fixture.classList.toggle("menu-open", open);
194
+ button.setAttribute("aria-expanded", String(open));
195
+ });
196
+ fixture.append(button, menu);
197
+
198
+ const visibilityFixture = document.createElement("div");
199
+ visibilityFixture.id = "mobileGroupedTabsVisibilityFixture";
200
+ visibilityFixture.className = "terminal-tabs";
201
+ for (const label of ["group-a", "group-b"]) {
202
+ const group = document.createElement("div");
203
+ group.className = "terminal-tab terminal-tab-group";
204
+ group.dataset.groupKey = label;
205
+ visibilityFixture.append(group);
206
+ }
207
+ const overallNewTab = document.createElement("div");
208
+ overallNewTab.id = "mobileOverallNewTabFixture";
209
+ overallNewTab.className = "terminal-new-tab-menu composer-publish-menu";
210
+ overallNewTab.textContent = "+ Tab";
211
+ visibilityFixture.append(overallNewTab);
212
+
213
+ document.querySelector("#terminalTabsDrawerContent").append(fixture, visibilityFixture);
214
+ });
215
+ await expect(page.locator("#mobileOverallNewTabFixture")).toBeVisible();
216
+ await page.locator("#mobileGroupedTabsVisibilityFixture > .terminal-tab-group").first().evaluate((node) => node.classList.add("menu-open"));
217
+ await expect(page.locator("#mobileOverallNewTabFixture")).toBeHidden();
218
+ await page.locator("#mobileGroupedTabsVisibilityFixture > .terminal-tab-group").first().evaluate((node) => node.classList.remove("menu-open"));
219
+ await expect(page.locator("#mobileOverallNewTabFixture")).toBeVisible();
220
+ await page.locator("#mobileGroupedTabsVisibilityFixture").evaluate((node) => node.remove());
221
+ const mobileGroupFixture = page.locator("#mobileGroupToggleFixture");
222
+ const mobileGroupFixtureButton = mobileGroupFixture.locator(".terminal-tab-group-button");
223
+ const mobileGroupFixtureMenu = mobileGroupFixture.locator(".terminal-tab-group-menu");
224
+ await expect(mobileGroupFixtureButton.locator(".terminal-tab-meta")).toBeVisible();
225
+ await expect(mobileGroupFixtureButton.locator(".terminal-tab-meta")).toContainText("project-cwd");
226
+ await mobileGroupFixtureButton.tap();
227
+ await expect(page.locator("#newTabMenuPanel")).toBeHidden();
228
+ await expect(mobileGroupFixtureButton).toHaveAttribute("aria-expanded", "true");
229
+ await expect(mobileGroupFixtureMenu).toBeVisible();
230
+ drawerLayers = await page.evaluate(() => ({
231
+ drawer: Number.parseInt(getComputedStyle(document.querySelector(".terminal-tabs-shell")).zIndex, 10),
232
+ backdrop: Number.parseInt(getComputedStyle(document.querySelector("#terminalTabsBackdrop")).zIndex, 10),
233
+ }));
234
+ assert.ok(drawerLayers.drawer > drawerLayers.backdrop, `open group options must remain above the blurred backdrop, got ${JSON.stringify(drawerLayers)}`);
235
+ await mobileGroupFixtureButton.tap();
236
+ await expect(mobileGroupFixtureButton).toHaveAttribute("aria-expanded", "false");
237
+ await expect(mobileGroupFixtureMenu).toBeHidden();
238
+ await mobileGroupFixture.evaluate((node) => node.remove());
239
+
240
+ await page.locator("#closeAllTabsButton").focus();
241
+ await page.keyboard.press("Tab");
242
+ await expect(page.locator("#terminalTabsToggleButton")).toBeFocused();
243
+ await page.keyboard.press("Shift+Tab");
244
+ await expect.poll(() => page.evaluate(() => document.activeElement?.closest?.(".terminal-tabs-shell") !== null)).toBe(true);
245
+ await assertAxeClean(page, "legacy terminal drawer", ".terminal-tabs-shell", ["aria-required-children"]);
246
+ await page.keyboard.press("Escape");
247
+ await expect(page.locator("#terminalTabsDrawerContent")).toBeHidden();
248
+ await expect(page.locator("#terminalTabsToggleButton")).toBeFocused();
249
+
250
+ await page.locator("#composerActionsButton").focus();
251
+ await page.locator("#composerActionsButton").click();
252
+ await expect(page.locator("#composerActionsButton")).toHaveText("−");
253
+ await expect(page.locator("#composerActionsButton")).toHaveAttribute("aria-label", "Minimize more composer actions");
254
+ await expect(page.locator("#composerActionsPanel")).toBeVisible();
255
+ await expect(page.locator("#sidePanelExpandButton")).toBeHidden();
256
+ const moreOverlayBox = await page.locator("#composerActionsPanel").boundingBox();
257
+ assert.ok(moreOverlayBox && moreOverlayBox.x === 0 && moreOverlayBox.y === 0 && moreOverlayBox.width === 320 && moreOverlayBox.height === 720, `mobile More actions should fill 320×720, got ${JSON.stringify(moreOverlayBox)}`);
258
+ const minimizeButtonBox = await page.locator("#composerActionsButton").boundingBox();
259
+ assert.ok(minimizeButtonBox && minimizeButtonBox.y < 60 && minimizeButtonBox.width === 40 && minimizeButtonBox.height === 40 && minimizeButtonBox.x + minimizeButtonBox.width <= 320, `mobile minimize should remain compact and reachable at the top-right of the full-screen overlay, got ${JSON.stringify(minimizeButtonBox)}`);
260
+ await expect(page.getByRole("heading", { name: "Session & workspace" })).toBeVisible();
261
+ await expect(page.getByRole("heading", { name: "Tools & commands" })).toBeVisible();
262
+ await expect(page.getByRole("heading", { name: "Context & modes" })).toBeVisible();
263
+ await expect(page.locator("#newSessionButton")).toBeVisible();
264
+ await expect(page.locator("#optionsMenuButton")).toBeVisible();
265
+ await expect.poll(() => page.locator("#workflowModeControls").evaluate((node) => node.parentElement?.id)).toBe("composerActionsPanel");
266
+ await expect.poll(() => page.locator("#btwButton").evaluate((node) => node.parentElement?.id)).toBe("composerActionsPanel");
267
+ await page.keyboard.press("Escape");
268
+ await expect(page.locator("#composerActionsPanel")).toBeHidden();
269
+ await expect(page.locator("#sidePanelExpandButton")).toBeVisible();
270
+ await expect(page.locator("#composerActionsButton")).toHaveText("More");
271
+ await expect(page.locator("#composerActionsButton")).toBeFocused();
272
+
273
+ await page.locator("#sidePanelExpandButton").click();
274
+ await expect(page.locator("#sidePanel")).toBeVisible();
275
+ await expect(page.getByText("Control Deck", { exact: true })).toBeVisible();
276
+ const editSectionsButton = page.locator("#sidePanelEditButton");
277
+ await expect(editSectionsButton).toHaveText(/Edit/);
278
+ await expect(editSectionsButton).toHaveAttribute("aria-pressed", "false");
279
+ const dragVisibleSections = (pointerId) => page.evaluate((id) => {
280
+ const sections = [...document.querySelectorAll("[data-side-panel-section]")].filter((section) => !section.hidden);
281
+ const source = sections[0]?.querySelector("[data-side-panel-section-toggle]");
282
+ const target = sections[1]?.querySelector("[data-side-panel-section-toggle]");
283
+ const before = sections.map((section) => section.dataset.sidePanelSection);
284
+ const sourceRect = source.getBoundingClientRect();
285
+ const targetRect = target.getBoundingClientRect();
286
+ source.dispatchEvent(new PointerEvent("pointerdown", { bubbles: true, pointerId: id, button: 0, clientX: sourceRect.left + 10, clientY: sourceRect.top + 10 }));
287
+ window.dispatchEvent(new PointerEvent("pointermove", { bubbles: true, pointerId: id, button: 0, clientX: targetRect.left + 10, clientY: targetRect.bottom - 4 }));
288
+ window.dispatchEvent(new PointerEvent("pointerup", { bubbles: true, pointerId: id, button: 0, clientX: targetRect.left + 10, clientY: targetRect.bottom - 4 }));
289
+ return {
290
+ before,
291
+ after: [...document.querySelectorAll("[data-side-panel-section]")].filter((section) => !section.hidden).map((section) => section.dataset.sidePanelSection),
292
+ title: source.title,
293
+ touchAction: getComputedStyle(source).touchAction,
294
+ storedOrder: JSON.parse(localStorage.getItem("pi-webui-side-panel-section-order-v1") || "[]"),
295
+ };
296
+ }, pointerId);
297
+
298
+ const lockedDragResult = await dragVisibleSections(71);
299
+ assert.deepEqual(lockedDragResult.after, lockedDragResult.before, "Control Deck sections must remain locked before Edit is activated");
300
+ assert.doesNotMatch(lockedDragResult.title, /drag|Alt\+/i, "locked section titles should not advertise reorder controls");
301
+ assert.equal(lockedDragResult.touchAction, "manipulation", "locked section headers should retain native tap/scroll behavior");
302
+
303
+ await editSectionsButton.tap();
304
+ await expect(editSectionsButton).toHaveText(/Done/);
305
+ await expect(editSectionsButton).toHaveAttribute("aria-pressed", "true");
306
+ await expect(page.locator("#sidePanel")).toHaveClass(/section-edit-mode/);
307
+ await expect(page.locator("#sidePanelEditHint")).toBeVisible();
308
+ const editableDragResult = await dragVisibleSections(72);
309
+ assert.notDeepEqual(editableDragResult.after, editableDragResult.before, "Edit mode should enable touch/pointer section reordering");
310
+ assert.match(editableDragResult.title, /drag to reorder · Alt\+↑\/↓ moves/, "Edit mode should advertise pointer and keyboard movement");
311
+ assert.equal(editableDragResult.touchAction, "none", "Edit mode should reserve section-header gestures for drag movement");
312
+ assert.deepEqual(editableDragResult.storedOrder.slice(0, editableDragResult.after.length), editableDragResult.after, "Edit-mode drag order should persist through the existing layout preference");
313
+
314
+ const keyboardOrderBefore = await page.locator("[data-side-panel-section]:not([hidden])").evaluateAll((sections) => sections.map((section) => section.dataset.sidePanelSection));
315
+ await page.locator("[data-side-panel-section]:not([hidden]) [data-side-panel-section-toggle]").first().focus();
316
+ await page.keyboard.press("Alt+ArrowDown");
317
+ const keyboardOrderAfter = await page.locator("[data-side-panel-section]:not([hidden])").evaluateAll((sections) => sections.map((section) => section.dataset.sidePanelSection));
318
+ assert.notDeepEqual(keyboardOrderAfter, keyboardOrderBefore, "Edit mode should enable accessible Alt+Arrow section movement");
319
+
320
+ await editSectionsButton.tap();
321
+ await expect(editSectionsButton).toHaveText(/Edit/);
322
+ await expect(editSectionsButton).toHaveAttribute("aria-pressed", "false");
323
+ await expect(page.locator("#sidePanel")).not.toHaveClass(/section-edit-mode/);
324
+ await expect(page.locator("#sidePanelEditHint")).toBeHidden();
325
+ const doneDragResult = await dragVisibleSections(73);
326
+ assert.deepEqual(doneDragResult.after, doneDragResult.before, "Done should lock Control Deck section order again");
327
+
328
+ await editSectionsButton.tap();
329
+ await page.locator("#toggleSidePanelButton").click();
330
+ await expect(editSectionsButton).toHaveAttribute("aria-pressed", "false");
331
+
332
+ await page.evaluate(() => {
333
+ const statusBar = document.querySelector("#statusBar");
334
+ statusBar.className = "statusbar statusbar-git-footer";
335
+ statusBar.replaceChildren();
336
+ const metric = (icon, label, value) => {
337
+ const node = document.createElement("span");
338
+ node.className = "footer-metric";
339
+ node.innerHTML = `<span class="footer-metric-icon">${icon}</span><span class="footer-metric-label">${label}</span><span class="footer-metric-value">${value}</span>`;
340
+ return node;
341
+ };
342
+ const meta = (className, label, value) => {
343
+ const node = document.createElement("span");
344
+ node.className = `footer-meta ${className}`;
345
+ node.innerHTML = `<span class="footer-meta-label">${label}</span><span class="footer-meta-value">${value}</span>`;
346
+ return node;
347
+ };
348
+ const main = document.createElement("div");
349
+ main.className = "footer-line footer-line-main";
350
+ main.append(
351
+ metric("🪙", "tokens", "↑1.1M · ↓76k"),
352
+ metric("π", "pi", "21k tok"),
353
+ metric("⚡", "speed", "76k tok @ 35.1/s"),
354
+ metric("🧠", "context", "59.8%/272k"),
355
+ metric("📊", "usage", "weekly 2% · session 8%"),
356
+ );
357
+ const details = document.createElement("button");
358
+ details.className = "footer-details-toggle";
359
+ details.textContent = "−";
360
+ details.setAttribute("aria-label", "Minimize Git footer details");
361
+ const metadata = document.createElement("div");
362
+ metadata.className = "footer-line footer-line-meta";
363
+ metadata.append(
364
+ meta("footer-worktree", "git+", "🕘 1h"),
365
+ meta("footer-workspace", "cwd", "~/npm-packages"),
366
+ meta("footer-context", "context", "59.8%/272k (auto)"),
367
+ meta("footer-branch", "git", "main"),
368
+ meta("footer-changes", "changes", "✏️ 13 · ✓ fetch"),
369
+ meta("footer-model", "model", "(openai-codex) gpt-5.6-sol"),
370
+ meta("footer-thinking", "effort", "high"),
371
+ details,
372
+ );
373
+ const refresh = document.createElement("button");
374
+ refresh.className = "git-footer-refresh-button";
375
+ refresh.textContent = "↻";
376
+ statusBar.append(main, metadata, refresh);
377
+ document.body.classList.add("footer-details-expanded");
378
+ });
379
+ const footerOverlay = page.locator("#statusBar");
380
+ const footerOverlayBox = await footerOverlay.boundingBox();
381
+ assert.ok(footerOverlayBox && footerOverlayBox.x === 0 && footerOverlayBox.y === 0 && footerOverlayBox.width === 320 && footerOverlayBox.height === 720, `mobile Git footer details should fill 320×720, got ${JSON.stringify(footerOverlayBox)}`);
382
+ await expect(footerOverlay.locator(".footer-details-toggle")).toHaveText("−");
383
+ await expect(footerOverlay.locator(".footer-details-toggle")).toHaveAttribute("aria-label", "Minimize Git footer details");
384
+ await expect(footerOverlay.locator(".git-footer-refresh-button")).toBeVisible();
385
+ const footerDetailsLayout = await footerOverlay.evaluate((node) => {
386
+ const main = node.querySelector(".footer-line-main");
387
+ const metadata = node.querySelector(".footer-line-meta");
388
+ const metrics = [...main.querySelectorAll(".footer-metric")].map((item) => item.getBoundingClientRect());
389
+ const workspace = metadata.querySelector(".footer-workspace").getBoundingClientRect();
390
+ const branch = metadata.querySelector(".footer-branch").getBoundingClientRect();
391
+ const metaCards = [...metadata.querySelectorAll(".footer-meta")].map((item) => item.getBoundingClientRect());
392
+ return {
393
+ alignContent: getComputedStyle(node).alignContent,
394
+ mainColumns: getComputedStyle(main).gridTemplateColumns,
395
+ metaColumns: getComputedStyle(metadata).gridTemplateColumns,
396
+ mainHeading: getComputedStyle(main, "::before").content,
397
+ metaHeading: getComputedStyle(metadata, "::before").content,
398
+ firstMetricWidth: metrics[0].width,
399
+ lastMetricWidth: metrics.at(-1).width,
400
+ maxMetricHeight: Math.max(...metrics.map((item) => item.height)),
401
+ workspaceWidth: workspace.width,
402
+ branchWidth: branch.width,
403
+ maxMetaHeight: Math.max(...metaCards.map((item) => item.height)),
404
+ };
405
+ });
406
+ assert.equal(footerDetailsLayout.alignContent, "start", "expanded footer rows should pack at the top instead of stretching across the viewport");
407
+ assert.match(footerDetailsLayout.mainColumns, /px .*px/, "session metrics should use two balanced columns");
408
+ assert.match(footerDetailsLayout.metaColumns, /px .*px/, "workspace and Git metadata should use two balanced columns");
409
+ assert.equal(footerDetailsLayout.mainHeading, '"Session"');
410
+ assert.equal(footerDetailsLayout.metaHeading, '"Workspace, Git & runtime"');
411
+ assert.ok(footerDetailsLayout.lastMetricWidth >= footerDetailsLayout.firstMetricWidth * 1.9, `an odd final metric should span both columns, got ${JSON.stringify(footerDetailsLayout)}`);
412
+ assert.ok(footerDetailsLayout.workspaceWidth >= footerDetailsLayout.branchWidth * 1.9, `long workspace metadata should span both columns, got ${JSON.stringify(footerDetailsLayout)}`);
413
+ assert.ok(footerDetailsLayout.maxMetricHeight <= 52 && footerDetailsLayout.maxMetaHeight <= 46, `footer cards should stay compact, got ${JSON.stringify(footerDetailsLayout)}`);
414
+ await expect(page.locator("#sidePanelExpandButton")).toBeHidden();
415
+ await page.evaluate(() => document.body.classList.remove("footer-details-expanded"));
416
+ await expect(footerOverlay.locator(".git-footer-refresh-button")).toBeHidden();
417
+
418
+ await context.close();
419
+
420
+ const desktopContext = await browser.newContext({ viewport: { width: 1280, height: 800 } });
421
+ const desktopPage = await desktopContext.newPage();
422
+ await desktopPage.goto(`${baseURL}/?mobileShell=legacy`);
423
+ await desktopPage.addStyleTag({ content: "#optionalFeatureMigrationSurface, #updateNotification { display: none !important; }" });
424
+ await expect(desktopPage.locator("#terminalTabsToggleButton")).toBeHidden();
425
+ await expect.poll(() => desktopPage.locator("#workflowModeControls").evaluate((node) => node.parentElement?.className)).toContain("composer-input-row");
426
+ await expect.poll(() => desktopPage.locator("#btwButton").evaluate((node) => node.parentElement?.className)).toContain("composer-row");
427
+ await desktopContext.close();
428
+ });
429
+
90
430
  test("phone v2 destinations, canonical actions, history, and presentation remain functional", async ({ browser }) => {
91
431
  const phoneContext = await browser.newContext({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true });
92
432
  const page = await phoneContext.newPage();
93
433
  await page.goto(`${baseURL}/?mobileShell=v2`);
94
434
  await expect(page.locator("html")).toHaveAttribute("data-mobile-shell", "v2");
95
435
  await expect(page.locator("#mobileShellV2")).toBeVisible();
436
+ const v2Density = await page.evaluate(() => {
437
+ const appbar = document.querySelector(".mobile-shell-appbar");
438
+ const nav = document.querySelector(".mobile-shell-nav");
439
+ return {
440
+ controlSize: getComputedStyle(document.documentElement).getPropertyValue("--mobile-control-size").trim(),
441
+ appbarHeight: appbar.getBoundingClientRect().height,
442
+ appbarMinHeight: Number.parseFloat(getComputedStyle(appbar).minHeight),
443
+ appbarGridRows: getComputedStyle(appbar).gridTemplateRows,
444
+ appbarPadding: `${getComputedStyle(appbar).paddingTop} ${getComputedStyle(appbar).paddingBottom}`,
445
+ sessionHeight: document.querySelector("#mobileSessionButton").getBoundingClientRect().height,
446
+ indicatorHeight: document.querySelector("#mobileShellIndicators").getBoundingClientRect().height,
447
+ searchHeight: document.querySelector("#mobileSearchButton").getBoundingClientRect().height,
448
+ navHeight: nav.getBoundingClientRect().height,
449
+ navMinHeight: Number.parseFloat(getComputedStyle(nav).minHeight),
450
+ };
451
+ });
452
+ assert.equal(v2Density.controlSize, "40px");
453
+ assert.ok(v2Density.appbarHeight <= v2Density.appbarMinHeight + 2 && v2Density.navHeight <= v2Density.navMinHeight + 0.5, `v2 chrome should stay at its compact safe-area-aware minimum, got ${JSON.stringify(v2Density)}`);
96
454
  for (const selector of ["#mobileSessionButton", "#mobileSearchButton", "#mobileMoreButton", "#attachButton", "#composerActionsButton", "#sendButton"]) {
97
455
  const box = await page.locator(selector).boundingBox();
98
456
  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}`);
457
+ assert.ok(box.width >= 40 && box.height >= 40, `${selector} should meet the selected 40px target floor, got ${box.width}×${box.height}`);
100
458
  }
101
459
  const phoneNav = page.getByRole("navigation", { name: "Phone destinations" });
102
460
  await expect(phoneNav.getByRole("button")).toHaveCount(4);
@@ -243,10 +601,10 @@ test("an extension response clears stale local running state after canonical idl
243
601
  await page.locator("#promptInput").fill("fixture mobile blocker");
244
602
  await page.locator("#sendButton").click();
245
603
  await expect(page.locator("#dialogTitle")).toHaveText("Fixture blocker");
246
- await expect(page.locator("#chat .runIndicator")).toContainText("Waiting for your confirm response…");
604
+ await expect(page.locator("#runIndicatorHost .runIndicator")).toContainText("Waiting for your confirm response…");
247
605
  await page.locator("#dialogActions").getByRole("button", { name: "Yes", exact: true }).click();
248
606
  await expect(page.locator("#dialog")).not.toBeVisible();
249
- await expect(page.locator("#chat .runIndicator")).toBeHidden({ timeout: 5_000 });
607
+ await expect(page.locator("#runIndicatorHost .runIndicator")).toBeHidden({ timeout: 5_000 });
250
608
  });
251
609
 
252
610
  test("a blocker notification switches to its background tab before exact-target validation", async ({ browser }) => {
@@ -77,32 +77,46 @@ test("submitted prompt remains visible during transcript reconciliation", async
77
77
  await expect(visiblePrompt).toHaveCount(1);
78
78
  });
79
79
 
80
- test("run indicator remains visible until delayed agent start is confirmed", async ({ page }) => {
80
+ test("run indicator remains visible and stable on mobile until delayed agent start is confirmed", async ({ page }) => {
81
81
  const prompt = "fixture continuity delayed start";
82
+ await page.setViewportSize({ width: 390, height: 844 });
82
83
  await page.goto(baseURL);
83
84
  await page.locator("#promptInput").fill(prompt);
84
85
  await page.locator("#sendButton").click();
85
86
 
86
- const runIndicator = page.locator("#chat .runIndicator");
87
+ const runIndicator = page.locator("#runIndicatorHost .runIndicator");
87
88
  await expect(runIndicator).toBeVisible();
89
+ await expect(page.locator("#chat .runIndicator")).toHaveCount(0);
90
+ expect(await runIndicator.evaluate((node) => node.parentElement?.id)).toBe("runIndicatorHost");
91
+ await delay(250);
88
92
  await page.evaluate(() => {
89
93
  window.__runIndicatorFrameGaps = 0;
94
+ window.__runIndicatorPositions = [];
90
95
  window.__monitorRunIndicator = true;
91
96
  const sample = () => {
92
97
  if (!window.__monitorRunIndicator) return;
93
- if (!document.querySelector("#chat .runIndicator")) window.__runIndicatorFrameGaps += 1;
98
+ const indicator = document.querySelector("#runIndicatorHost .runIndicator");
99
+ if (!indicator) window.__runIndicatorFrameGaps += 1;
100
+ else window.__runIndicatorPositions.push(indicator.getBoundingClientRect().top);
94
101
  requestAnimationFrame(sample);
95
102
  };
96
103
  requestAnimationFrame(sample);
97
104
  });
98
- await delay(3300);
99
- await expect(runIndicator).toBeVisible();
100
- await expect(runIndicator).toContainText("Agent is running:");
101
- const frameGaps = await page.evaluate(() => {
105
+ await delay(2000);
106
+ const indicatorSamples = await page.evaluate(() => {
102
107
  window.__monitorRunIndicator = false;
103
- return window.__runIndicatorFrameGaps;
108
+ const positions = window.__runIndicatorPositions || [];
109
+ return {
110
+ frameGaps: window.__runIndicatorFrameGaps,
111
+ drift: positions.length ? Math.max(...positions) - Math.min(...positions) : 0,
112
+ positions,
113
+ };
104
114
  });
105
- expect(frameGaps).toBe(0);
115
+ expect(indicatorSamples.frameGaps).toBe(0);
116
+ expect(indicatorSamples.drift, JSON.stringify(indicatorSamples.positions)).toBeLessThanOrEqual(1.5);
117
+ await delay(1300);
118
+ await expect(runIndicator).toBeVisible();
119
+ await expect(runIndicator).toContainText("Agent is running:");
106
120
  await expect(page.locator("#chat .message.assistant").last()).toContainText("continuity stream complete");
107
121
  });
108
122
 
@@ -111,7 +125,7 @@ test("confirmed streaming replaces routing status before delayed activity events
111
125
  await page.locator("#promptInput").fill("fixture continuity confirmed before tool");
112
126
  await page.locator("#sendButton").click();
113
127
 
114
- const runIndicator = page.locator("#chat .runIndicator");
128
+ const runIndicator = page.locator("#runIndicatorHost .runIndicator");
115
129
  await expect(runIndicator).toContainText("Agent run confirmed; waiting for first output or action…");
116
130
  await expect(runIndicator).not.toContainText(/Routing/i);
117
131
  await expect(runIndicator).toContainText("Running tool: read…");