@firstpick/pi-package-webui 0.9.6 → 0.9.8
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.
- package/README.md +13 -5
- package/bin/pi-webui.mjs +480 -96
- package/index.ts +2 -1
- package/lib/git-workflow-preferences.mjs +21 -1
- package/lib/optional-feature-catalog.mjs +1 -1
- package/lib/session-tree-event-targets.mjs +70 -0
- package/lib/subagent-launch-policy.mjs +375 -0
- package/lib/subagent-launch-slots.mjs +2 -1
- package/package.json +1 -1
- package/public/app.js +1348 -131
- package/public/guided-git-command-state.mjs +175 -1
- package/public/index.html +48 -9
- package/public/service-worker.js +1 -1
- package/public/styles.css +387 -34
- package/public/transcript-renderer.mjs +62 -0
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/control-visibility.spec.mjs +141 -2
- package/tests/browser/events-tree-context-menu.spec.mjs +240 -0
- package/tests/browser/footer-model-advanced-layout.spec.mjs +512 -0
- package/tests/browser/guided-git-extension-command.spec.mjs +180 -0
- package/tests/browser/guided-git-fallback.spec.mjs +218 -0
- package/tests/browser/interaction-continuity.spec.mjs +33 -0
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/compact-sections-static.test.mjs +4 -0
- package/tests/compaction-static.test.mjs +1 -1
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/control-visibility-static.test.mjs +66 -3
- package/tests/controls-layout-static.test.mjs +3 -3
- package/tests/events-tree-context-menu-static.test.mjs +131 -0
- package/tests/fast-mode-client-static.test.mjs +5 -2
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/file-viewer-image-static.test.mjs +3 -3
- package/tests/fixtures/fake-pi.mjs +34 -3
- package/tests/git-footer-context-menu-static.test.mjs +103 -1
- package/tests/git-workflow-preferences.test.mjs +30 -1
- package/tests/guided-git-activation-http.test.mjs +194 -0
- package/tests/guided-git-activation-static.test.mjs +80 -0
- package/tests/guided-git-activation.test.mjs +244 -0
- package/tests/guided-git-fallback-runtime.test.mjs +419 -0
- package/tests/guided-git-fallback-ui-static.test.mjs +60 -0
- package/tests/guided-git-message-reliability-static.test.mjs +9 -7
- package/tests/guided-git-optional-feature.test.mjs +31 -0
- package/tests/http-endpoints-harness.test.mjs +3 -0
- package/tests/interaction-state-stability-static.test.mjs +1 -1
- package/tests/intercom-conversation-viewer-static.test.mjs +3 -3
- package/tests/main-output-loading-static.test.mjs +11 -9
- package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +3 -3
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +92 -9
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/persistent-ui-layout-static.test.mjs +3 -3
- package/tests/prompt-input-vertical-scroll-static.test.mjs +6 -6
- package/tests/prompt-routing-input-clear-static.test.mjs +1 -1
- package/tests/questionnaire-dialog.test.mjs +3 -3
- package/tests/remote-auth-settings-harness.test.mjs +23 -0
- package/tests/resource-defaults-helper.test.mjs +12 -0
- package/tests/session-sampling-helper.test.mjs +1 -0
- package/tests/session-sampling-ui-static.test.mjs +3 -3
- package/tests/session-tree-event-targets.test.mjs +106 -0
- package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
- package/tests/subagent-launch-policy.test.mjs +532 -0
- package/tests/subagent-observability-static.test.mjs +2 -2
- package/tests/subagents-helper.test.mjs +211 -1
- package/tests/syntax-highlighting-static.test.mjs +3 -3
- package/tests/tab-close-continuity-static.test.mjs +25 -0
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/thinking-block-grouping.test.mjs +79 -0
- package/webui-rpc-helper.mjs +220 -3
|
@@ -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=
|
|
68
|
+
const styleLink = new FakeElement({ href: "http://127.0.0.1:31415/styles.css?v=142", 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=
|
|
87
|
+
currentScript: new FakeElement({ dataset: { appSrc: "/app.js?v=172" } }),
|
|
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=
|
|
235
|
+
assert.ok(html.indexOf('id="webuiBootLoader"') < html.indexOf("/app.js?v=172"), "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");
|
|
@@ -119,6 +119,17 @@ async function suppressUnrelatedOverlays(page) {
|
|
|
119
119
|
await page.addStyleTag({ content: "#optionalFeatureMigrationSurface, #updateNotification { display: none !important; }" });
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
async function openSetupFromDirect(page, selector) {
|
|
123
|
+
const menu = page.locator(MENU_SELECTOR);
|
|
124
|
+
await page.locator(selector).click({ button: "right" });
|
|
125
|
+
await expect(menu).toBeVisible();
|
|
126
|
+
await menu.getByRole("menuitem", { name: "Open setup" }).click();
|
|
127
|
+
await expect(menu).toBeHidden();
|
|
128
|
+
const dialog = page.locator("#controlVisibilitySetupDialog");
|
|
129
|
+
await expect(dialog).toBeVisible();
|
|
130
|
+
return dialog;
|
|
131
|
+
}
|
|
132
|
+
|
|
122
133
|
test.describe.configure({ mode: "serial" });
|
|
123
134
|
|
|
124
135
|
test.beforeAll(async () => {
|
|
@@ -136,6 +147,131 @@ test.afterAll(async () => {
|
|
|
136
147
|
await rm(tempRoot, { recursive: true, force: true });
|
|
137
148
|
});
|
|
138
149
|
|
|
150
|
+
test("setup dialog covers the catalog, immediate durability, quick actions, focus, gating, and narrow viewports", async ({ page }) => {
|
|
151
|
+
await page.goto(baseURL, { waitUntil: "domcontentloaded" });
|
|
152
|
+
await suppressUnrelatedOverlays(page);
|
|
153
|
+
const menu = page.locator(MENU_SELECTOR);
|
|
154
|
+
const optionsButton = page.locator("#optionsMenuButton");
|
|
155
|
+
const optionsAction = page.locator('[data-composer-action-id="options"]');
|
|
156
|
+
|
|
157
|
+
// The grouped area menu opens setup and its non-focusable host uses the
|
|
158
|
+
// prompt fallback when setup closes.
|
|
159
|
+
await openAreaMenu(page);
|
|
160
|
+
await menu.getByRole("menuitem", { name: "Open setup" }).click();
|
|
161
|
+
let dialog = page.locator("#controlVisibilitySetupDialog");
|
|
162
|
+
await expect(dialog).toBeVisible();
|
|
163
|
+
await dialog.getByRole("button", { name: "Close" }).click();
|
|
164
|
+
await expect(dialog).toBeHidden();
|
|
165
|
+
await expect(page.locator("#promptInput")).toBeFocused();
|
|
166
|
+
|
|
167
|
+
// Wrapped controls preserve the actual inner button for pointer and keyboard
|
|
168
|
+
// invocation instead of retaining their non-focusable catalog wrapper.
|
|
169
|
+
dialog = await openSetupFromDirect(page, "#optionsMenuButton");
|
|
170
|
+
await page.keyboard.press("Escape");
|
|
171
|
+
await expect(dialog).toBeHidden();
|
|
172
|
+
await expect(optionsButton).toBeFocused();
|
|
173
|
+
|
|
174
|
+
await optionsButton.focus();
|
|
175
|
+
await page.keyboard.press("Shift+F10");
|
|
176
|
+
await expect(menu).toBeVisible();
|
|
177
|
+
await menu.getByRole("menuitem", { name: "Open setup" }).focus();
|
|
178
|
+
await page.keyboard.press("Enter");
|
|
179
|
+
await expect(dialog).toBeVisible();
|
|
180
|
+
await dialog.getByRole("button", { name: "Close" }).click();
|
|
181
|
+
await expect(optionsButton).toBeFocused();
|
|
182
|
+
|
|
183
|
+
// If setup hides the wrapped catalog root, its inner button is no longer a
|
|
184
|
+
// surviving return target and focus falls back safely to the prompt.
|
|
185
|
+
dialog = await openSetupFromDirect(page, "#optionsMenuButton");
|
|
186
|
+
await dialog.getByLabel("Show Common options").uncheck();
|
|
187
|
+
await expect(optionsAction).toHaveClass(/webui-user-hidden/);
|
|
188
|
+
await dialog.getByRole("button", { name: "Close" }).click();
|
|
189
|
+
await expect(page.locator("#promptInput")).toBeFocused();
|
|
190
|
+
await openAreaMenu(page);
|
|
191
|
+
await menu.getByRole("menuitem", { name: "Reset defaults" }).click();
|
|
192
|
+
await expect(optionsAction).not.toHaveClass(/webui-user-hidden/);
|
|
193
|
+
await expect.poll(hiddenIdsOnDisk).toBe(null);
|
|
194
|
+
|
|
195
|
+
// A direct visibility menu opens the generated setup and transfers focus.
|
|
196
|
+
dialog = await openSetupFromDirect(page, "#newSessionButton");
|
|
197
|
+
await expect(dialog.getByRole("checkbox")).toHaveCount(24);
|
|
198
|
+
await expect(dialog.getByRole("group")).toHaveCount(5);
|
|
199
|
+
assert.deepEqual(
|
|
200
|
+
await dialog.getByRole("group").evaluateAll((groups) => groups.map((group) => group.querySelector("legend")?.textContent?.trim())),
|
|
201
|
+
["Workspace toolbar", "Control Deck", "Composer actions", "Input-frame controls", "Input-frame tags"],
|
|
202
|
+
"setup groups should follow the approved catalog order",
|
|
203
|
+
);
|
|
204
|
+
await expect(dialog.locator('[data-visibility-setup-id="composer.send"]')).toHaveCount(0);
|
|
205
|
+
await expect(dialog.getByText("Send", { exact: true })).toHaveCount(0);
|
|
206
|
+
await expect(dialog.getByLabel("Show Save workspace")).toBeFocused();
|
|
207
|
+
|
|
208
|
+
// Simulate runtime capability gating deterministically: preference application
|
|
209
|
+
// may toggle only its class and must leave the capability-owned hidden state intact.
|
|
210
|
+
const gitButton = page.locator('[data-composer-action-id="git"]');
|
|
211
|
+
await expect(dialog.getByLabel("Show Guided Git workflow")).toBeChecked();
|
|
212
|
+
await gitButton.evaluate((element) => { element.hidden = true; });
|
|
213
|
+
await expect(gitButton).toBeHidden();
|
|
214
|
+
|
|
215
|
+
// Escape follows the native dialog close path and restores a surviving opener.
|
|
216
|
+
await page.keyboard.press("Escape");
|
|
217
|
+
await expect(dialog).toBeHidden();
|
|
218
|
+
await expect(page.locator("#newSessionButton")).toBeFocused();
|
|
219
|
+
|
|
220
|
+
// Hiding the invoking control persists immediately and makes Close use the prompt fallback.
|
|
221
|
+
dialog = await openSetupFromDirect(page, "#attachButton");
|
|
222
|
+
const attachToggle = dialog.getByLabel("Show Attach files");
|
|
223
|
+
await attachToggle.uncheck();
|
|
224
|
+
await expect(page.locator("#attachButton")).toHaveClass(/webui-user-hidden/);
|
|
225
|
+
assert.deepEqual(await hiddenIdsInLocal(page), ["input.attach-files"], "setup changes should update the local cache immediately");
|
|
226
|
+
await expect.poll(hiddenIdsOnDisk).toEqual(["input.attach-files"]);
|
|
227
|
+
await dialog.getByRole("button", { name: "Close" }).click();
|
|
228
|
+
await expect(dialog).toBeHidden();
|
|
229
|
+
await expect(page.locator("#promptInput")).toBeFocused();
|
|
230
|
+
|
|
231
|
+
// Reload from durable settings, not the browser cache, and synchronize the setup checkbox.
|
|
232
|
+
await page.evaluate((key) => localStorage.removeItem(key), HIDDEN_IDS_KEY);
|
|
233
|
+
await page.reload({ waitUntil: "domcontentloaded" });
|
|
234
|
+
await suppressUnrelatedOverlays(page);
|
|
235
|
+
await expect(page.locator("#attachButton")).toHaveClass(/webui-user-hidden/);
|
|
236
|
+
dialog = await openSetupFromDirect(page, "#newSessionButton");
|
|
237
|
+
await expect(dialog.getByLabel("Show Attach files")).not.toBeChecked();
|
|
238
|
+
|
|
239
|
+
// Reapply the simulated capability state after reload, which replaced the DOM.
|
|
240
|
+
await gitButton.evaluate((element) => { element.hidden = true; });
|
|
241
|
+
await expect(gitButton).toBeHidden();
|
|
242
|
+
|
|
243
|
+
// Setup quick actions preserve the [] versus null contract and refresh all toggles.
|
|
244
|
+
await dialog.getByRole("button", { name: "Show all" }).click();
|
|
245
|
+
await expect.poll(() => dialog.getByRole("checkbox").evaluateAll((checkboxes) => checkboxes.every((checkbox) => checkbox.checked))).toBe(true);
|
|
246
|
+
assert.deepEqual(await hiddenIdsInLocal(page), [], "Show all should persist an explicit empty list");
|
|
247
|
+
await expect.poll(hiddenIdsOnDisk).toEqual([]);
|
|
248
|
+
assert.ok(await gitButton.evaluate((element) => element.hidden), "Show all must not clear capability-owned hidden state");
|
|
249
|
+
|
|
250
|
+
await dialog.getByRole("button", { name: "Reset defaults" }).click();
|
|
251
|
+
await expect.poll(() => dialog.getByRole("checkbox").evaluateAll((checkboxes) => checkboxes.every((checkbox) => checkbox.checked))).toBe(true);
|
|
252
|
+
assert.equal(await hiddenIdsInLocal(page), null, "Reset defaults should clear the preference to null");
|
|
253
|
+
await expect.poll(hiddenIdsOnDisk).toBe(null);
|
|
254
|
+
await dialog.getByRole("button", { name: "Close" }).click();
|
|
255
|
+
await expect(page.locator("#newSessionButton")).toBeFocused();
|
|
256
|
+
|
|
257
|
+
// A short viewport keeps the dialog bounded, its persistent actions usable,
|
|
258
|
+
// and the full generated catalog reachable through an independently scrolling body.
|
|
259
|
+
dialog = await openSetupFromDirect(page, "#newSessionButton");
|
|
260
|
+
await page.setViewportSize({ width: 360, height: 640 });
|
|
261
|
+
await expect(dialog.getByRole("button", { name: "Show all" })).toBeVisible();
|
|
262
|
+
await expect(dialog.getByRole("button", { name: "Reset defaults" })).toBeVisible();
|
|
263
|
+
await expect(dialog.getByRole("button", { name: "Close" })).toBeVisible();
|
|
264
|
+
const dialogBounds = await dialog.boundingBox();
|
|
265
|
+
assert.ok(dialogBounds.x >= 0 && dialogBounds.y >= 0, "the setup should not overflow the top or left viewport edges");
|
|
266
|
+
assert.ok(dialogBounds.x + dialogBounds.width <= 360 && dialogBounds.y + dialogBounds.height <= 640, "the setup should remain bounded by the narrow viewport");
|
|
267
|
+
assert.ok(await dialog.locator("#controlVisibilitySetupBody").evaluate((body) => body.scrollHeight > body.clientHeight), "the setup catalog should scroll within its bounded body");
|
|
268
|
+
await dialog.locator("#controlVisibilitySetupBody").evaluate((body) => { body.scrollTop = body.scrollHeight; });
|
|
269
|
+
await expect(dialog.getByLabel("Show Workflow-mode tag")).toBeVisible();
|
|
270
|
+
await dialog.getByRole("button", { name: "Close" }).click();
|
|
271
|
+
await expect(dialog).toBeHidden();
|
|
272
|
+
await expect(menu).toBeHidden();
|
|
273
|
+
});
|
|
274
|
+
|
|
139
275
|
test("grouped area menu, direct hide, recovery, persistence, gating, Send exclusion, keyboard", async ({ page }) => {
|
|
140
276
|
await page.goto(baseURL, { waitUntil: "domcontentloaded" });
|
|
141
277
|
await suppressUnrelatedOverlays(page);
|
|
@@ -152,10 +288,12 @@ test("grouped area menu, direct hide, recovery, persistence, gating, Send exclus
|
|
|
152
288
|
await page.reload({ waitUntil: "domcontentloaded" });
|
|
153
289
|
await suppressUnrelatedOverlays(page);
|
|
154
290
|
const optionsAction = page.locator('[data-composer-action-id="options"]');
|
|
291
|
+
const compactAction = page.locator('[data-composer-action-id="compact"]');
|
|
155
292
|
const newAction = page.locator('[data-composer-action-id="new"]');
|
|
156
293
|
await expect.poll(() => optionsAction.evaluate((element) => Number(element.style.getPropertyValue("--composer-action-grid-column")))).toBeGreaterThan(1);
|
|
157
294
|
await expect.poll(() => newAction.evaluate((element) => Number(element.style.getPropertyValue("--composer-action-grid-column")))).toBeGreaterThan(0);
|
|
158
295
|
const initialOptionsColumn = Number(await optionsAction.evaluate((element) => element.style.getPropertyValue("--composer-action-grid-column")));
|
|
296
|
+
const initialCompactColumn = Number(await compactAction.evaluate((element) => element.style.getPropertyValue("--composer-action-grid-column")));
|
|
159
297
|
const initialNewColumn = Number(await newAction.evaluate((element) => element.style.getPropertyValue("--composer-action-grid-column")));
|
|
160
298
|
|
|
161
299
|
// Send and editable controls are not region-menu proxies.
|
|
@@ -193,13 +331,14 @@ test("grouped area menu, direct hide, recovery, persistence, gating, Send exclus
|
|
|
193
331
|
await menu.locator('[data-visibility-menu-action="hide"]').click();
|
|
194
332
|
await expect(page.locator("#newSessionButton")).toHaveClass(/webui-user-hidden/);
|
|
195
333
|
await expect(page.locator("#promptInput")).toBeFocused();
|
|
196
|
-
await expect.poll(() =>
|
|
334
|
+
await expect.poll(() => compactAction.evaluate((element) => Number(element.style.getPropertyValue("--composer-action-grid-column")))).toBeLessThan(initialCompactColumn);
|
|
197
335
|
assert.ok(Number(await optionsAction.evaluate((element) => element.style.getPropertyValue("--composer-action-grid-column"))) > 0, "repacked actions should keep a positive dense slot");
|
|
198
336
|
assert.deepEqual(await hiddenIdsInLocal(page), ["composer.new"], "direct hide should persist locally first");
|
|
199
337
|
await expect.poll(async () => (await hiddenIdsOnDisk())?.slice?.().sort?.()).toEqual(["composer.new"]);
|
|
200
338
|
|
|
201
|
-
//
|
|
339
|
+
// Simulate runtime capability gating deterministically before preferences show all.
|
|
202
340
|
const gitButton = page.locator('[data-composer-action-id="git"]');
|
|
341
|
+
await gitButton.evaluate((element) => { element.hidden = true; });
|
|
203
342
|
await openAreaMenu(page);
|
|
204
343
|
assert.ok(await gitButton.evaluate((element) => element.hidden), "capability-hidden controls keep the hidden attribute");
|
|
205
344
|
await menu.getByRole("menuitem", { name: "Show all" }).click();
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { createServer } from "node:net";
|
|
4
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { dirname, join } from "node:path";
|
|
7
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
import { expect, test } from "@playwright/test";
|
|
10
|
+
|
|
11
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
12
|
+
const serverScript = join(root, "bin", "pi-webui.mjs");
|
|
13
|
+
const fakePi = join(root, "tests", "fixtures", "fake-pi.mjs");
|
|
14
|
+
const mappedEntryId = "fixture-finish-entry";
|
|
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 api(page, pathname) {
|
|
30
|
+
const response = await page.request.get(`${baseURL}${pathname}`);
|
|
31
|
+
const payload = await response.json().catch(() => ({}));
|
|
32
|
+
assert.equal(response.ok(), true, `${pathname} should succeed: ${payload.error || output}`);
|
|
33
|
+
return payload;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function emitToolLifecycle(page) {
|
|
37
|
+
await page.locator("#promptInput").fill("fixture transcript continuity tool");
|
|
38
|
+
await page.locator("#sendButton").click();
|
|
39
|
+
const finishRow = page.locator('#eventLog .event[data-event-tool-phase="finish"]').first();
|
|
40
|
+
await expect(finishRow).toContainText("tool read finished");
|
|
41
|
+
await expect(finishRow).toContainText("target: continuity.txt");
|
|
42
|
+
return finishRow;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function dispatchPointerMenu(row) {
|
|
46
|
+
await row.evaluate((element) => {
|
|
47
|
+
const rect = element.getBoundingClientRect();
|
|
48
|
+
element.dispatchEvent(new MouseEvent("contextmenu", {
|
|
49
|
+
bubbles: true,
|
|
50
|
+
cancelable: true,
|
|
51
|
+
button: 2,
|
|
52
|
+
clientX: rect.left + 8,
|
|
53
|
+
clientY: rect.bottom,
|
|
54
|
+
}));
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function openEvents(page) {
|
|
59
|
+
const section = page.locator("#sidePanelSectionEvents");
|
|
60
|
+
if (await section.isHidden()) await page.locator("#sidePanelSectionToggleEvents").click();
|
|
61
|
+
await expect(section).toBeVisible();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
test.describe.configure({ mode: "serial" });
|
|
65
|
+
|
|
66
|
+
test.beforeAll(async () => {
|
|
67
|
+
const port = await freePort();
|
|
68
|
+
tempRoot = await mkdtemp(join(tmpdir(), "pi-webui-events-tree-menu-"));
|
|
69
|
+
baseURL = `http://127.0.0.1:${port}`;
|
|
70
|
+
child = spawn(process.execPath, [serverScript, "--cwd", tempRoot, "--host", "127.0.0.1", "--port", String(port), "--pi", fakePi], {
|
|
71
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
72
|
+
env: {
|
|
73
|
+
...process.env,
|
|
74
|
+
PI_WEBUI_RPC_SUPERVISOR: "0",
|
|
75
|
+
PI_CODING_AGENT_DIR: join(tempRoot, "agent"),
|
|
76
|
+
PI_WEBUI_SETTINGS_FILE: join(tempRoot, "settings.json"),
|
|
77
|
+
FAKE_PI_CONTINUITY_MODE: "1",
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
child.stdout.on("data", (chunk) => { output += String(chunk); });
|
|
81
|
+
child.stderr.on("data", (chunk) => { output += String(chunk); });
|
|
82
|
+
for (let attempt = 0; attempt < 80; attempt += 1) {
|
|
83
|
+
if (child.exitCode !== null) break;
|
|
84
|
+
try {
|
|
85
|
+
const response = await fetch(`${baseURL}/api/health`, { signal: AbortSignal.timeout(500) });
|
|
86
|
+
if (response.ok) return;
|
|
87
|
+
} catch {
|
|
88
|
+
// Wait for the isolated WebUI fixture.
|
|
89
|
+
}
|
|
90
|
+
await delay(100);
|
|
91
|
+
}
|
|
92
|
+
throw new Error(`Pi WebUI did not start:\n${output}`);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test.afterAll(async () => {
|
|
96
|
+
if (child?.exitCode === null) child.kill("SIGTERM");
|
|
97
|
+
if (child && child.exitCode === null) await new Promise((resolve) => child.once("exit", resolve));
|
|
98
|
+
await rm(tempRoot, { recursive: true, force: true }).catch(() => {});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test("display modes persist while pointer and keyboard Tree actions remain safe", async ({ page }) => {
|
|
102
|
+
await page.goto(baseURL, { waitUntil: "domcontentloaded" });
|
|
103
|
+
await openEvents(page);
|
|
104
|
+
let finishRow = await emitToolLifecycle(page);
|
|
105
|
+
const menu = page.locator("#eventTreeContextMenu");
|
|
106
|
+
const eventDetails = finishRow.locator(".event-details");
|
|
107
|
+
const filter = page.locator("#eventFilterSelect");
|
|
108
|
+
const visibleRows = page.locator("#eventLog .event:not([hidden])");
|
|
109
|
+
await expect(page.locator("#eventLog")).toHaveAttribute("data-display-mode", "detailed");
|
|
110
|
+
await expect(filter).toHaveValue("all");
|
|
111
|
+
await expect(eventDetails).toBeVisible();
|
|
112
|
+
|
|
113
|
+
await page.locator("#eventLog").evaluate((log) => {
|
|
114
|
+
const row = document.createElement("button");
|
|
115
|
+
row.type = "button";
|
|
116
|
+
row.className = "event error";
|
|
117
|
+
row.dataset.eventLevel = "error";
|
|
118
|
+
row.dataset.eventTreeAvailable = "false";
|
|
119
|
+
row.textContent = "fixture filter failure";
|
|
120
|
+
log.prepend(row);
|
|
121
|
+
});
|
|
122
|
+
await filter.selectOption("errors");
|
|
123
|
+
await expect(visibleRows).toHaveCount(1);
|
|
124
|
+
await expect(visibleRows).toContainText("fixture filter failure");
|
|
125
|
+
await expect(page.locator("#eventFilterStatus")).toContainText("1 of");
|
|
126
|
+
await filter.selectOption("warnings");
|
|
127
|
+
await expect(visibleRows).toHaveCount(0);
|
|
128
|
+
await expect(page.locator("#eventFilterEmpty")).toBeVisible();
|
|
129
|
+
await filter.selectOption("tools");
|
|
130
|
+
await expect(visibleRows).toHaveCount(2);
|
|
131
|
+
await filter.selectOption("tree");
|
|
132
|
+
await expect(visibleRows).toHaveCount(2);
|
|
133
|
+
expect(await page.evaluate(() => localStorage.getItem("pi-webui-event-filter-v1"))).toBe("tree");
|
|
134
|
+
await filter.selectOption("all");
|
|
135
|
+
|
|
136
|
+
await dispatchPointerMenu(finishRow);
|
|
137
|
+
await expect(menu).toBeVisible();
|
|
138
|
+
await expect(page.locator("#eventDisplayDetailedAction")).toBeFocused();
|
|
139
|
+
await expect(page.locator("#eventDisplayDetailedAction")).toHaveAttribute("aria-checked", "true");
|
|
140
|
+
await page.locator("#eventDisplayCompactAction").click();
|
|
141
|
+
await expect(menu).toBeHidden();
|
|
142
|
+
await expect(eventDetails).toBeHidden();
|
|
143
|
+
await expect(finishRow.locator(".event-time")).toBeVisible();
|
|
144
|
+
await expect(finishRow.locator(".event-summary")).toContainText("tool read finished");
|
|
145
|
+
await expect(finishRow).toHaveCSS("border-left-style", "solid");
|
|
146
|
+
expect(await page.evaluate(() => localStorage.getItem("pi-webui-event-display-mode-v1"))).toBe("compact");
|
|
147
|
+
await filter.selectOption("tree");
|
|
148
|
+
|
|
149
|
+
await page.reload({ waitUntil: "domcontentloaded" });
|
|
150
|
+
await openEvents(page);
|
|
151
|
+
await expect(page.locator("#eventLog")).toHaveAttribute("data-display-mode", "compact");
|
|
152
|
+
await expect(page.locator("#eventFilterSelect")).toHaveValue("tree");
|
|
153
|
+
finishRow = await emitToolLifecycle(page);
|
|
154
|
+
await expect(finishRow.locator(".event-details")).toBeHidden();
|
|
155
|
+
await expect(page.locator("#eventLog .event:not([hidden])")).toHaveCount(2);
|
|
156
|
+
await page.locator("#eventFilterSelect").selectOption("all");
|
|
157
|
+
await dispatchPointerMenu(finishRow);
|
|
158
|
+
await expect(page.locator("#eventDisplayCompactAction")).toBeFocused();
|
|
159
|
+
await expect(page.locator("#eventDisplayCompactAction")).toHaveAttribute("aria-checked", "true");
|
|
160
|
+
await page.locator("#eventDisplayDetailedAction").click();
|
|
161
|
+
await expect(finishRow.locator(".event-details")).toBeVisible();
|
|
162
|
+
|
|
163
|
+
const toolCallId = await finishRow.getAttribute("data-chat-tool-call-id");
|
|
164
|
+
assert.ok(toolCallId, "the rendered finish row should carry its stable tool-call ID");
|
|
165
|
+
|
|
166
|
+
const tabsPayload = await api(page, "/api/tabs");
|
|
167
|
+
const tabId = tabsPayload.data?.activeTabId || tabsPayload.data?.tabs?.[0]?.id;
|
|
168
|
+
assert.ok(tabId, "the fixture should expose an active tab");
|
|
169
|
+
|
|
170
|
+
const sessionTreeUrls = [];
|
|
171
|
+
const navigationRequests = [];
|
|
172
|
+
const refreshUrls = [];
|
|
173
|
+
let releaseNavigation;
|
|
174
|
+
let navigationCanFinish = new Promise((resolve) => { releaseNavigation = resolve; });
|
|
175
|
+
let navigationReleased = false;
|
|
176
|
+
|
|
177
|
+
page.on("request", (request) => {
|
|
178
|
+
const url = new URL(request.url());
|
|
179
|
+
if (navigationReleased && url.pathname === "/api/state") refreshUrls.push(url);
|
|
180
|
+
});
|
|
181
|
+
await page.route("**/api/session-tree?*", async (route) => {
|
|
182
|
+
const url = new URL(route.request().url());
|
|
183
|
+
sessionTreeUrls.push(url);
|
|
184
|
+
await route.fulfill({
|
|
185
|
+
contentType: "application/json",
|
|
186
|
+
body: JSON.stringify({
|
|
187
|
+
ok: true,
|
|
188
|
+
data: {
|
|
189
|
+
nodes: [{ id: mappedEntryId }],
|
|
190
|
+
eventTargets: [{ toolCallId, toolName: "read", startEntryId: "fixture-start-entry", finishEntryId: mappedEntryId }],
|
|
191
|
+
},
|
|
192
|
+
}),
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
await page.route("**/api/tree-navigate?*", async (route) => {
|
|
196
|
+
const request = route.request();
|
|
197
|
+
navigationRequests.push({ url: new URL(request.url()), body: request.postDataJSON() });
|
|
198
|
+
await navigationCanFinish;
|
|
199
|
+
await route.fulfill({
|
|
200
|
+
contentType: "application/json",
|
|
201
|
+
body: JSON.stringify({ ok: true, data: { message: "Fixture tree navigation complete." } }),
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
await dispatchPointerMenu(finishRow);
|
|
206
|
+
await expect(menu).toBeVisible();
|
|
207
|
+
await expect(page.locator("#eventDisplayDetailedAction")).toBeFocused();
|
|
208
|
+
await page.locator("#eventTreeContextMenuAction").click();
|
|
209
|
+
await expect(page.locator("#confirmationDialog")).toBeVisible();
|
|
210
|
+
await page.locator("#confirmationCancelButton").click();
|
|
211
|
+
await expect(page.locator("#confirmationDialog")).toBeHidden();
|
|
212
|
+
expect(navigationRequests).toHaveLength(0);
|
|
213
|
+
|
|
214
|
+
await finishRow.focus();
|
|
215
|
+
await page.keyboard.press("Shift+F10");
|
|
216
|
+
await expect(menu).toBeVisible();
|
|
217
|
+
await expect(page.locator("#eventDisplayDetailedAction")).toBeFocused();
|
|
218
|
+
await page.keyboard.press("End");
|
|
219
|
+
await expect(page.locator("#eventTreeContextMenuAction")).toBeFocused();
|
|
220
|
+
await page.keyboard.press("Enter");
|
|
221
|
+
await expect(page.locator("#confirmationDialog")).toBeVisible();
|
|
222
|
+
await page.locator("#confirmationConfirmButton").dispatchEvent("click");
|
|
223
|
+
await expect.poll(() => navigationRequests.length).toBe(1);
|
|
224
|
+
|
|
225
|
+
expect(navigationRequests[0].body).toEqual({ entryId: mappedEntryId, summarize: false });
|
|
226
|
+
expect(navigationRequests[0].url.searchParams.get("tab")).toBe(tabId);
|
|
227
|
+
expect(sessionTreeUrls.length).toBeGreaterThanOrEqual(2);
|
|
228
|
+
expect(sessionTreeUrls.every((url) => url.searchParams.get("tab") === tabId)).toBe(true);
|
|
229
|
+
|
|
230
|
+
await menu.evaluate((element) => {
|
|
231
|
+
element.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true }));
|
|
232
|
+
});
|
|
233
|
+
await expect(menu).toBeHidden();
|
|
234
|
+
navigationReleased = true;
|
|
235
|
+
releaseNavigation();
|
|
236
|
+
|
|
237
|
+
await expect(page.locator("#chat")).toContainText("Fixture tree navigation complete.");
|
|
238
|
+
await expect.poll(() => refreshUrls.length).toBeGreaterThan(0);
|
|
239
|
+
expect(refreshUrls.every((url) => url.searchParams.get("tab") === tabId)).toBe(true);
|
|
240
|
+
});
|