@firstpick/pi-package-webui 0.8.2 → 0.8.4
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 +76 -19
- package/bin/pi-webui.mjs +864 -140
- package/lib/WEBUI_TUI_NATIVE_PARITY.json +26 -0
- package/lib/git-workflow-preferences.mjs +246 -19
- package/lib/optional-feature-catalog.mjs +29 -0
- package/lib/optional-feature-migration.mjs +410 -0
- package/lib/session-summary-core.mjs +320 -0
- package/lib/session-summary-preferences.mjs +267 -0
- package/lib/thinking-stream-recovery.mjs +156 -0
- package/lib/ui-layout-settings.mjs +254 -0
- package/package.json +5 -40
- package/public/app.js +2898 -92
- package/public/index.html +77 -14
- package/public/service-worker.js +1 -1
- package/public/styles.css +669 -2
- package/session-summary.ts +403 -0
- package/tests/aur-review-widget-static.test.mjs +3 -2
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/composer-action-grid-reorder.spec.mjs +303 -0
- package/tests/browser/feature-decision-output-popup.spec.mjs +156 -0
- package/tests/browser/interaction-continuity.spec.mjs +29 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +744 -0
- package/tests/browser/session-summary.spec.mjs +271 -0
- package/tests/codex-fast-mode-static.test.mjs +10 -9
- package/tests/composer-action-grid-reorder-static.test.mjs +63 -0
- package/tests/fast-mode-client-static.test.mjs +2 -2
- package/tests/feature-decision-output-popup-static.test.mjs +172 -0
- package/tests/fixtures/fake-pi.mjs +51 -1
- package/tests/git-workflow-preferences.test.mjs +4 -2
- package/tests/http-endpoints-harness.test.mjs +507 -4
- package/tests/interaction-state-stability-static.test.mjs +3 -0
- 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 +118 -103
- package/tests/native-parity-harness.test.mjs +9 -1
- package/tests/native-parity.test.mjs +23 -1
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/optional-feature-migration-frontend.test.mjs +72 -0
- package/tests/optional-feature-migration.test.mjs +142 -0
- package/tests/persistent-ui-layout-static.test.mjs +267 -0
- package/tests/questionnaire-dialog.test.mjs +511 -0
- package/tests/queue-edit-reorder-static.test.mjs +1 -0
- package/tests/remote-auth-settings-harness.test.mjs +1 -1
- package/tests/session-summary-core.test.mjs +491 -0
- package/tests/session-summary-preferences.test.mjs +103 -0
- package/tests/side-panel-resize-static.test.mjs +1 -0
- package/tests/side-panel-section-reorder-static.test.mjs +3 -3
- package/tests/subagent-launch-slots.test.mjs +1 -1
- package/tests/thinking-stream-recovery.test.mjs +88 -0
- package/tests/ui-layout-settings.test.mjs +92 -0
- package/tests/webui-settings-locking.test.mjs +159 -0
|
@@ -0,0 +1,303 @@
|
|
|
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
|
+
const storageKey = "pi-webui-composer-action-order-v1";
|
|
14
|
+
const layoutStorageKey = "pi-webui-composer-action-layout-v2";
|
|
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
|
+
test.beforeAll(async () => {
|
|
30
|
+
const port = await freePort();
|
|
31
|
+
tempRoot = await mkdtemp(join(tmpdir(), "pi-webui-composer-action-order-"));
|
|
32
|
+
baseURL = `http://127.0.0.1:${port}`;
|
|
33
|
+
child = spawn(process.execPath, [serverScript, "--cwd", tempRoot, "--host", "127.0.0.1", "--port", String(port), "--pi", fakePi], {
|
|
34
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
35
|
+
env: {
|
|
36
|
+
...process.env,
|
|
37
|
+
PI_WEBUI_RPC_SUPERVISOR: "0",
|
|
38
|
+
PI_CODING_AGENT_DIR: join(tempRoot, "agent"),
|
|
39
|
+
PI_WEBUI_SETTINGS_FILE: join(tempRoot, "settings.json"),
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
child.stdout.on("data", (chunk) => { output += String(chunk); });
|
|
43
|
+
child.stderr.on("data", (chunk) => { output += String(chunk); });
|
|
44
|
+
for (let attempt = 0; attempt < 80; attempt += 1) {
|
|
45
|
+
if (child.exitCode !== null) break;
|
|
46
|
+
try {
|
|
47
|
+
const response = await fetch(`${baseURL}/api/health`, { signal: AbortSignal.timeout(500) });
|
|
48
|
+
if (response.ok) return;
|
|
49
|
+
} catch {
|
|
50
|
+
// Wait for the real server and fake Pi fixture to start.
|
|
51
|
+
}
|
|
52
|
+
await delay(100);
|
|
53
|
+
}
|
|
54
|
+
throw new Error(`Pi Web UI did not start:\n${output}`);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test.afterAll(async () => {
|
|
58
|
+
child?.kill("SIGTERM");
|
|
59
|
+
if (child) await new Promise((resolve) => child.once("exit", resolve));
|
|
60
|
+
await rm(tempRoot, { recursive: true, force: true });
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test.beforeEach(async () => {
|
|
64
|
+
const currentResponse = await fetch(`${baseURL}/api/interface-preferences`);
|
|
65
|
+
const current = await currentResponse.json();
|
|
66
|
+
expect(currentResponse.ok).toBe(true);
|
|
67
|
+
const resetResponse = await fetch(`${baseURL}/api/interface-preferences`, {
|
|
68
|
+
method: "PUT",
|
|
69
|
+
headers: { "content-type": "application/json" },
|
|
70
|
+
body: JSON.stringify({
|
|
71
|
+
layout: { version: 1, composerActions: null },
|
|
72
|
+
expectedLayoutRevision: current.data.layoutRevision,
|
|
73
|
+
}),
|
|
74
|
+
});
|
|
75
|
+
expect(resetResponse.ok).toBe(true);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
async function storedOrder(page) {
|
|
79
|
+
return page.evaluate((key) => JSON.parse(localStorage.getItem(key) || "[]"), storageKey);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function storedLayout(page) {
|
|
83
|
+
return page.evaluate((key) => JSON.parse(localStorage.getItem(key) || "null"), layoutStorageKey);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
test("composer actions persist pointer and keyboard grid reordering", async ({ page }) => {
|
|
87
|
+
await page.setViewportSize({ width: 1440, height: 900 });
|
|
88
|
+
await page.goto(baseURL);
|
|
89
|
+
await expect(page.locator("body")).toHaveClass(/composer-action-grid-enabled/);
|
|
90
|
+
|
|
91
|
+
const send = page.locator('[data-composer-action-id="send"]');
|
|
92
|
+
const newSession = page.locator('[data-composer-action-id="new"]');
|
|
93
|
+
await expect(send).toBeVisible();
|
|
94
|
+
await expect(newSession).toBeVisible();
|
|
95
|
+
|
|
96
|
+
const sendBox = await send.boundingBox();
|
|
97
|
+
const newBox = await newSession.boundingBox();
|
|
98
|
+
expect(sendBox).toBeTruthy();
|
|
99
|
+
expect(newBox).toBeTruthy();
|
|
100
|
+
const newLabelCenterOffset = await newSession.evaluate((button) => {
|
|
101
|
+
const range = document.createRange();
|
|
102
|
+
range.selectNodeContents(button);
|
|
103
|
+
const labelRect = range.getBoundingClientRect();
|
|
104
|
+
const buttonRect = button.getBoundingClientRect();
|
|
105
|
+
return (labelRect.left + labelRect.width / 2) - (buttonRect.left + buttonRect.width / 2);
|
|
106
|
+
});
|
|
107
|
+
expect(Math.abs(newLabelCenterOffset)).toBeLessThan(1);
|
|
108
|
+
const minimumCellWidth = await page.evaluate(() => 3.2 * Number.parseFloat(getComputedStyle(document.documentElement).fontSize));
|
|
109
|
+
const gridGuide = page.locator("#composerActionGridGuide");
|
|
110
|
+
await expect(gridGuide).toBeHidden();
|
|
111
|
+
await page.mouse.move(sendBox.x + sendBox.width / 2, sendBox.y + sendBox.height / 2);
|
|
112
|
+
await page.mouse.down();
|
|
113
|
+
await page.mouse.move(sendBox.x + sendBox.width / 2 - 12, sendBox.y + sendBox.height / 2, { steps: 2 });
|
|
114
|
+
await expect(gridGuide).toBeVisible();
|
|
115
|
+
|
|
116
|
+
const [rowBox, guideBox, firstCellBox, lastCellBox] = await Promise.all([
|
|
117
|
+
page.locator(".composer-row").boundingBox(),
|
|
118
|
+
gridGuide.boundingBox(),
|
|
119
|
+
gridGuide.locator(".composer-action-grid-cell").first().boundingBox(),
|
|
120
|
+
gridGuide.locator(".composer-action-grid-cell").last().boundingBox(),
|
|
121
|
+
]);
|
|
122
|
+
expect(rowBox).toBeTruthy();
|
|
123
|
+
expect(guideBox).toBeTruthy();
|
|
124
|
+
expect(firstCellBox).toBeTruthy();
|
|
125
|
+
expect(lastCellBox).toBeTruthy();
|
|
126
|
+
expect(Math.abs(guideBox.x - rowBox.x)).toBeLessThan(1);
|
|
127
|
+
expect(Math.abs(guideBox.width - rowBox.width)).toBeLessThan(1);
|
|
128
|
+
expect(Math.abs(firstCellBox.width - lastCellBox.width)).toBeLessThan(1);
|
|
129
|
+
expect(firstCellBox.width).toBeGreaterThanOrEqual(minimumCellWidth - 1);
|
|
130
|
+
expect(Math.abs(firstCellBox.width - newBox.width)).toBeLessThan(1);
|
|
131
|
+
expect(Math.abs(firstCellBox.height - newBox.height)).toBeLessThan(1);
|
|
132
|
+
expect(await gridGuide.locator(".composer-action-grid-cell").count()).toBeGreaterThan(await page.locator("[data-composer-action-id]:visible").count());
|
|
133
|
+
|
|
134
|
+
await page.mouse.move(newBox.x + 3, newBox.y + newBox.height / 2, { steps: 8 });
|
|
135
|
+
await page.mouse.up();
|
|
136
|
+
await expect(gridGuide).toBeHidden();
|
|
137
|
+
|
|
138
|
+
await expect.poll(async () => (await storedOrder(page)).slice(0, 2)).toEqual(["send", "new"]);
|
|
139
|
+
await expect.poll(async () => {
|
|
140
|
+
const [sendRect, newRect] = await Promise.all([send.boundingBox(), newSession.boundingBox()]);
|
|
141
|
+
return sendRect.x < newRect.x;
|
|
142
|
+
}).toBe(true);
|
|
143
|
+
|
|
144
|
+
await page.reload();
|
|
145
|
+
await expect.poll(async () => (await storedOrder(page)).slice(0, 2)).toEqual(["send", "new"]);
|
|
146
|
+
await expect.poll(async () => {
|
|
147
|
+
const [sendRect, newRect] = await Promise.all([send.boundingBox(), newSession.boundingBox()]);
|
|
148
|
+
return sendRect.x < newRect.x;
|
|
149
|
+
}).toBe(true);
|
|
150
|
+
|
|
151
|
+
await newSession.focus();
|
|
152
|
+
await newSession.press("Alt+ArrowLeft");
|
|
153
|
+
await expect.poll(async () => (await storedOrder(page)).slice(0, 2)).toEqual(["new", "send"]);
|
|
154
|
+
await expect(newSession).toBeFocused();
|
|
155
|
+
await expect(page.locator("#composerActionOrderStatus")).toContainText("New moved to position 1");
|
|
156
|
+
|
|
157
|
+
const movedNewBox = await newSession.boundingBox();
|
|
158
|
+
expect(movedNewBox).toBeTruthy();
|
|
159
|
+
await page.mouse.move(movedNewBox.x + movedNewBox.width / 2, movedNewBox.y + movedNewBox.height / 2);
|
|
160
|
+
await page.mouse.down();
|
|
161
|
+
await page.mouse.move(movedNewBox.x + movedNewBox.width / 2 + 12, movedNewBox.y + movedNewBox.height / 2, { steps: 2 });
|
|
162
|
+
await expect(gridGuide).toBeVisible();
|
|
163
|
+
const emptyEndCellBox = await gridGuide.locator(".composer-action-grid-cell").last().boundingBox();
|
|
164
|
+
expect(emptyEndCellBox).toBeTruthy();
|
|
165
|
+
await page.mouse.move(emptyEndCellBox.x + emptyEndCellBox.width / 2, emptyEndCellBox.y + emptyEndCellBox.height / 2, { steps: 8 });
|
|
166
|
+
await expect(gridGuide.locator(".composer-action-grid-cell-target")).toHaveCount(1);
|
|
167
|
+
await page.mouse.up();
|
|
168
|
+
await expect(gridGuide).toBeHidden();
|
|
169
|
+
await expect.poll(async () => {
|
|
170
|
+
const [nextNewRect, nextSendRect] = await Promise.all([newSession.boundingBox(), send.boundingBox()]);
|
|
171
|
+
return nextNewRect.x > nextSendRect.x;
|
|
172
|
+
}).toBe(true);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test("empty composer grid cells retain their space and accept later drops", async ({ page }) => {
|
|
176
|
+
await page.setViewportSize({ width: 1440, height: 900 });
|
|
177
|
+
await page.goto(baseURL);
|
|
178
|
+
|
|
179
|
+
const options = page.locator('[data-composer-action-id="options"]');
|
|
180
|
+
const appRunner = page.locator('[data-composer-action-id="app-runner"]');
|
|
181
|
+
const newSession = page.locator('[data-composer-action-id="new"]');
|
|
182
|
+
const gridGuide = page.locator("#composerActionGridGuide");
|
|
183
|
+
await expect(options).toBeVisible();
|
|
184
|
+
await expect(appRunner).toBeVisible();
|
|
185
|
+
await expect(newSession).toBeVisible();
|
|
186
|
+
|
|
187
|
+
const optionsBox = await options.boundingBox();
|
|
188
|
+
expect(optionsBox).toBeTruthy();
|
|
189
|
+
const optionsCenter = { x: optionsBox.x + optionsBox.width / 2, y: optionsBox.y + optionsBox.height / 2 };
|
|
190
|
+
await page.mouse.move(optionsCenter.x, optionsCenter.y);
|
|
191
|
+
await page.mouse.down();
|
|
192
|
+
await page.mouse.move(optionsCenter.x + 12, optionsCenter.y, { steps: 2 });
|
|
193
|
+
await expect(gridGuide).toBeVisible();
|
|
194
|
+
|
|
195
|
+
const endCellIndex = await gridGuide.locator(".composer-action-grid-cell").count() - 1;
|
|
196
|
+
const endCellBox = await gridGuide.locator(".composer-action-grid-cell").last().boundingBox();
|
|
197
|
+
expect(endCellBox).toBeTruthy();
|
|
198
|
+
const endCellCenter = { x: endCellBox.x + endCellBox.width / 2, y: endCellBox.y + endCellBox.height / 2 };
|
|
199
|
+
await page.mouse.move(endCellCenter.x, endCellCenter.y, { steps: 8 });
|
|
200
|
+
await page.mouse.up();
|
|
201
|
+
await expect.poll(async () => page.evaluate((key) => JSON.parse(localStorage.getItem(key) || "null")?.positions?.options, layoutStorageKey)).toBe(endCellIndex);
|
|
202
|
+
|
|
203
|
+
await expect.poll(async () => {
|
|
204
|
+
const box = await options.boundingBox();
|
|
205
|
+
return Math.abs((box.x + box.width / 2) - endCellCenter.x);
|
|
206
|
+
}).toBeLessThan(1);
|
|
207
|
+
await page.reload();
|
|
208
|
+
await expect(appRunner).toBeVisible();
|
|
209
|
+
const expectedOptionColumn = String((endCellIndex % (endCellIndex + 1)) + 1);
|
|
210
|
+
await expect.poll(async () => options.evaluate((node) => node.style.getPropertyValue("--composer-action-grid-column"))).toBe(expectedOptionColumn);
|
|
211
|
+
await expect.poll(async () => {
|
|
212
|
+
const box = await options.boundingBox();
|
|
213
|
+
return Math.abs((box.x + box.width / 2) - endCellCenter.x);
|
|
214
|
+
}).toBeLessThan(1);
|
|
215
|
+
|
|
216
|
+
const movedNewBox = await newSession.boundingBox();
|
|
217
|
+
expect(movedNewBox).toBeTruthy();
|
|
218
|
+
await page.mouse.move(movedNewBox.x + movedNewBox.width / 2, movedNewBox.y + movedNewBox.height / 2);
|
|
219
|
+
await page.mouse.down();
|
|
220
|
+
await page.mouse.move(movedNewBox.x + movedNewBox.width / 2 + 12, movedNewBox.y + movedNewBox.height / 2, { steps: 2 });
|
|
221
|
+
await expect(gridGuide).toBeVisible();
|
|
222
|
+
const middleEmptyCellIndex = await gridGuide.locator(".composer-action-grid-cell").evaluateAll((cells) => {
|
|
223
|
+
const actions = Array.from(document.querySelectorAll("[data-composer-action-id]"))
|
|
224
|
+
.filter((action) => !action.hidden && action.getClientRects().length > 0);
|
|
225
|
+
return cells.findIndex((cell, index) => {
|
|
226
|
+
if (index === 0 || index === cells.length - 1) return false;
|
|
227
|
+
const rect = cell.getBoundingClientRect();
|
|
228
|
+
const centerX = rect.left + rect.width / 2;
|
|
229
|
+
const centerY = rect.top + rect.height / 2;
|
|
230
|
+
return !actions.some((action) => {
|
|
231
|
+
const actionRect = action.getBoundingClientRect();
|
|
232
|
+
return centerX >= actionRect.left && centerX <= actionRect.right && centerY >= actionRect.top && centerY <= actionRect.bottom;
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
expect(middleEmptyCellIndex).toBeGreaterThan(0);
|
|
237
|
+
const middleEmptyCellBox = await gridGuide.locator(".composer-action-grid-cell").nth(middleEmptyCellIndex).boundingBox();
|
|
238
|
+
expect(middleEmptyCellBox).toBeTruthy();
|
|
239
|
+
const middleEmptyCellCenter = { x: middleEmptyCellBox.x + middleEmptyCellBox.width / 2, y: middleEmptyCellBox.y + middleEmptyCellBox.height / 2 };
|
|
240
|
+
await page.mouse.move(middleEmptyCellCenter.x, middleEmptyCellCenter.y, { steps: 8 });
|
|
241
|
+
await expect(gridGuide.locator(".composer-action-grid-cell-target")).toHaveCount(1);
|
|
242
|
+
await page.mouse.up();
|
|
243
|
+
await expect.poll(async () => {
|
|
244
|
+
const box = await newSession.boundingBox();
|
|
245
|
+
return Math.abs((box.x + box.width / 2) - middleEmptyCellCenter.x);
|
|
246
|
+
}).toBeLessThan(1);
|
|
247
|
+
await expect.poll(async () => page.evaluate((key) => JSON.parse(localStorage.getItem(key) || "null")?.positions?.new, layoutStorageKey)).toBe(middleEmptyCellIndex);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
test("sparse composer buttons keep responsive positions when the Control Deck width changes", async ({ page }) => {
|
|
251
|
+
await page.setViewportSize({ width: 1440, height: 900 });
|
|
252
|
+
await page.goto(baseURL);
|
|
253
|
+
|
|
254
|
+
const row = page.locator(".composer-row");
|
|
255
|
+
const options = page.locator('[data-composer-action-id="options"]');
|
|
256
|
+
const gridGuide = page.locator("#composerActionGridGuide");
|
|
257
|
+
const resizeHandle = page.locator("#sidePanelResizeHandle");
|
|
258
|
+
const wideRowBox = await row.boundingBox();
|
|
259
|
+
const optionsBox = await options.boundingBox();
|
|
260
|
+
expect(wideRowBox).toBeTruthy();
|
|
261
|
+
expect(optionsBox).toBeTruthy();
|
|
262
|
+
|
|
263
|
+
await page.mouse.move(optionsBox.x + optionsBox.width / 2, optionsBox.y + optionsBox.height / 2);
|
|
264
|
+
await page.mouse.down();
|
|
265
|
+
await page.mouse.move(optionsBox.x + optionsBox.width / 2 + 12, optionsBox.y + optionsBox.height / 2, { steps: 2 });
|
|
266
|
+
await expect(gridGuide).toBeVisible();
|
|
267
|
+
const lastCellBox = await gridGuide.locator(".composer-action-grid-cell").last().boundingBox();
|
|
268
|
+
expect(lastCellBox).toBeTruthy();
|
|
269
|
+
await page.mouse.move(lastCellBox.x + lastCellBox.width / 2, lastCellBox.y + lastCellBox.height / 2, { steps: 8 });
|
|
270
|
+
await page.mouse.up();
|
|
271
|
+
|
|
272
|
+
const wideColumn = await options.evaluate((node) => node.style.getPropertyValue("--composer-action-grid-column"));
|
|
273
|
+
const savedWideLayout = await storedLayout(page);
|
|
274
|
+
expect(Number(wideColumn)).toBeGreaterThan(1);
|
|
275
|
+
expect(savedWideLayout?.columns).toBeGreaterThan(1);
|
|
276
|
+
|
|
277
|
+
await resizeHandle.focus();
|
|
278
|
+
await resizeHandle.press("Shift+ArrowLeft");
|
|
279
|
+
await resizeHandle.press("Shift+ArrowLeft");
|
|
280
|
+
await resizeHandle.press("Shift+ArrowLeft");
|
|
281
|
+
|
|
282
|
+
await expect.poll(async () => (await row.boundingBox()).width).toBeLessThan(wideRowBox.width - 50);
|
|
283
|
+
await expect.poll(async () => options.evaluate((node) => node.style.getPropertyValue("--composer-action-grid-column"))).not.toBe("");
|
|
284
|
+
await expect.poll(async () => page.evaluate(() => {
|
|
285
|
+
const composerRow = document.querySelector(".composer-row");
|
|
286
|
+
const action = document.querySelector('[data-composer-action-id="options"]');
|
|
287
|
+
const rowRect = composerRow.getBoundingClientRect();
|
|
288
|
+
const actionRect = action.getBoundingClientRect();
|
|
289
|
+
return Math.abs(rowRect.right - actionRect.right);
|
|
290
|
+
})).toBeLessThan(2);
|
|
291
|
+
expect(await storedLayout(page)).toEqual(savedWideLayout);
|
|
292
|
+
|
|
293
|
+
await page.reload();
|
|
294
|
+
await expect.poll(async () => options.evaluate((node) => node.style.getPropertyValue("--composer-action-grid-column"))).not.toBe("");
|
|
295
|
+
await expect.poll(async () => page.evaluate(() => {
|
|
296
|
+
const composerRow = document.querySelector(".composer-row");
|
|
297
|
+
const action = document.querySelector('[data-composer-action-id="options"]');
|
|
298
|
+
const rowRect = composerRow.getBoundingClientRect();
|
|
299
|
+
const actionRect = action.getBoundingClientRect();
|
|
300
|
+
return Math.abs(rowRect.right - actionRect.right);
|
|
301
|
+
})).toBeLessThan(2);
|
|
302
|
+
expect(await storedLayout(page)).toEqual(savedWideLayout);
|
|
303
|
+
});
|
|
@@ -0,0 +1,156 @@
|
|
|
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
|
+
|
|
15
|
+
async function freePort() {
|
|
16
|
+
const server = createServer();
|
|
17
|
+
await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
|
|
18
|
+
const { port } = server.address();
|
|
19
|
+
await new Promise((resolve) => server.close(resolve));
|
|
20
|
+
return port;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let child;
|
|
24
|
+
let baseURL;
|
|
25
|
+
let tempRoot;
|
|
26
|
+
let output = "";
|
|
27
|
+
|
|
28
|
+
async function api(page, pathname, { method = "GET", data } = {}) {
|
|
29
|
+
const response = await page.request.fetch(`${baseURL}${pathname}`, {
|
|
30
|
+
method,
|
|
31
|
+
data,
|
|
32
|
+
headers: data === undefined ? undefined : { "content-type": "application/json" },
|
|
33
|
+
});
|
|
34
|
+
const payload = await response.json().catch(() => ({}));
|
|
35
|
+
assert.equal(response.ok(), true, `${method} ${pathname} should succeed: ${payload.error || output}`);
|
|
36
|
+
return payload;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function activeTabId(page) {
|
|
40
|
+
const payload = await api(page, "/api/tabs");
|
|
41
|
+
return payload.data?.activeTabId || payload.data?.tabs?.[0]?.id || "";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function emitDecision(page, mode) {
|
|
45
|
+
const tabId = await activeTabId(page);
|
|
46
|
+
assert.ok(tabId, "the fixture requires an active WebUI tab");
|
|
47
|
+
await api(page, `/api/prompt?tab=${encodeURIComponent(tabId)}`, {
|
|
48
|
+
method: "POST",
|
|
49
|
+
data: { message: `fixture feature decision ${mode}`, requestId: `feature-decision-${mode}-${Date.now()}` },
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
test.beforeAll(async () => {
|
|
54
|
+
const port = await freePort();
|
|
55
|
+
tempRoot = await mkdtemp(join(tmpdir(), "pi-webui-feature-decision-popup-"));
|
|
56
|
+
baseURL = `http://127.0.0.1:${port}`;
|
|
57
|
+
child = spawn(process.execPath, [serverScript, "--cwd", tempRoot, "--host", "127.0.0.1", "--port", String(port), "--pi", fakePi], {
|
|
58
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
59
|
+
env: {
|
|
60
|
+
...process.env,
|
|
61
|
+
PI_WEBUI_RPC_SUPERVISOR: "0",
|
|
62
|
+
PI_CODING_AGENT_DIR: join(tempRoot, "agent"),
|
|
63
|
+
PI_WEBUI_SETTINGS_FILE: join(tempRoot, "settings.json"),
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
child.stdout.on("data", (chunk) => { output += String(chunk); });
|
|
67
|
+
child.stderr.on("data", (chunk) => { output += String(chunk); });
|
|
68
|
+
for (let attempt = 0; attempt < 80; attempt += 1) {
|
|
69
|
+
if (child.exitCode !== null) break;
|
|
70
|
+
try {
|
|
71
|
+
const response = await fetch(`${baseURL}/api/health`, { signal: AbortSignal.timeout(500) });
|
|
72
|
+
if (response.ok) return;
|
|
73
|
+
} catch {
|
|
74
|
+
// Wait for the isolated WebUI fixture.
|
|
75
|
+
}
|
|
76
|
+
await delay(100);
|
|
77
|
+
}
|
|
78
|
+
throw new Error(`Pi WebUI did not start:\n${output}`);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test.afterAll(async () => {
|
|
82
|
+
if (child?.exitCode === null) child.kill("SIGTERM");
|
|
83
|
+
if (child && child.exitCode === null) await new Promise((resolve) => child.once("exit", resolve));
|
|
84
|
+
await rm(tempRoot, { recursive: true, force: true }).catch(() => {});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const COMPLEX_DIALOG_TEXT = "Decision: Complex feature (feature_complex)\nReason: Crosses the classifier extension and the WebUI status consumer.";
|
|
88
|
+
const LEGACY_DIALOG_TEXT = "Decision: Complex feature (feature_complex)\nReason: The classifier reported feature_complex without a reason.";
|
|
89
|
+
|
|
90
|
+
test("feature tag opens the readable classifier decision and replays it after reconnect", async ({ page }) => {
|
|
91
|
+
await page.goto(baseURL);
|
|
92
|
+
await emitDecision(page, "complex");
|
|
93
|
+
|
|
94
|
+
const tag = page.locator("#featureCategoryTag");
|
|
95
|
+
const dialog = page.locator("#featureDecisionDialog");
|
|
96
|
+
const outputText = page.locator("#featureDecisionDialogOutput");
|
|
97
|
+
const close = page.locator("#featureDecisionDialogCloseButton");
|
|
98
|
+
|
|
99
|
+
await expect(tag).toBeVisible();
|
|
100
|
+
await expect(tag).toBeEnabled();
|
|
101
|
+
await expect(tag).toHaveText("complex-feature");
|
|
102
|
+
|
|
103
|
+
await tag.click();
|
|
104
|
+
await expect(dialog).toBeVisible();
|
|
105
|
+
await expect(outputText).toHaveText(COMPLEX_DIALOG_TEXT);
|
|
106
|
+
await expect(close).toBeFocused();
|
|
107
|
+
|
|
108
|
+
await close.click();
|
|
109
|
+
await expect(dialog).toBeHidden();
|
|
110
|
+
await expect(tag).toBeFocused();
|
|
111
|
+
|
|
112
|
+
await tag.press("Enter");
|
|
113
|
+
await expect(dialog).toBeVisible();
|
|
114
|
+
await page.keyboard.press("Escape");
|
|
115
|
+
await expect(dialog).toBeHidden();
|
|
116
|
+
await expect(tag).toBeFocused();
|
|
117
|
+
|
|
118
|
+
await page.reload();
|
|
119
|
+
await expect(tag).toBeVisible();
|
|
120
|
+
await expect(tag).toBeEnabled();
|
|
121
|
+
await tag.click();
|
|
122
|
+
await expect(outputText).toHaveText(COMPLEX_DIALOG_TEXT);
|
|
123
|
+
await page.keyboard.press("Escape");
|
|
124
|
+
|
|
125
|
+
await emitDecision(page, "clear");
|
|
126
|
+
await expect(dialog).toBeHidden();
|
|
127
|
+
await expect(tag).toBeHidden();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("legacy labels stay readable while mismatched and malformed payloads fail closed", async ({ page }) => {
|
|
131
|
+
await page.goto(baseURL);
|
|
132
|
+
|
|
133
|
+
const tag = page.locator("#featureCategoryTag");
|
|
134
|
+
const dialog = page.locator("#featureDecisionDialog");
|
|
135
|
+
const outputText = page.locator("#featureDecisionDialogOutput");
|
|
136
|
+
|
|
137
|
+
await emitDecision(page, "legacy");
|
|
138
|
+
await expect(tag).toBeEnabled();
|
|
139
|
+
await tag.click();
|
|
140
|
+
await expect(outputText).toHaveText(LEGACY_DIALOG_TEXT);
|
|
141
|
+
await page.keyboard.press("Escape");
|
|
142
|
+
await expect(dialog).toBeHidden();
|
|
143
|
+
|
|
144
|
+
await emitDecision(page, "mismatch");
|
|
145
|
+
await expect(tag).toBeVisible();
|
|
146
|
+
await expect(tag).toHaveText("complex-feature");
|
|
147
|
+
await expect(tag).toBeDisabled();
|
|
148
|
+
|
|
149
|
+
await emitDecision(page, "malformed");
|
|
150
|
+
await expect(tag).toBeVisible();
|
|
151
|
+
await expect(tag).toBeDisabled();
|
|
152
|
+
await expect(dialog).toBeHidden();
|
|
153
|
+
|
|
154
|
+
await emitDecision(page, "clear");
|
|
155
|
+
await expect(tag).toBeHidden();
|
|
156
|
+
});
|
|
@@ -431,6 +431,35 @@ test("streaming thinking selection survives a later thinking delta", async ({ pa
|
|
|
431
431
|
await expect.poll(() => page.evaluate(() => window.getSelection()?.toString() || "")).toBe("");
|
|
432
432
|
});
|
|
433
433
|
|
|
434
|
+
test("live thinking, assistant output, and tool calls keep chronological tail order", async ({ page }) => {
|
|
435
|
+
await page.setViewportSize({ width: 1280, height: 800 });
|
|
436
|
+
await page.goto(baseURL);
|
|
437
|
+
await triggerTranscriptContinuity(page, "order");
|
|
438
|
+
|
|
439
|
+
const chat = page.locator("#chat");
|
|
440
|
+
await expect(chat.locator(".message.thinking.streaming").last()).toContainText("ordering thinking");
|
|
441
|
+
await expect(chat.locator(".message.assistant.streaming").last()).toContainText("ordering assistant output");
|
|
442
|
+
await expect.poll(() => chat.evaluate((root) => {
|
|
443
|
+
const messages = [...root.querySelectorAll(":scope > .message")];
|
|
444
|
+
const thinkingIndex = messages.findIndex((message) => message.matches(".thinking.streaming") && message.textContent?.includes("ordering thinking"));
|
|
445
|
+
const outputIndex = messages.findIndex((message) => message.matches(".assistant.streaming") && message.textContent?.includes("ordering assistant output"));
|
|
446
|
+
return thinkingIndex >= 0 && outputIndex > thinkingIndex;
|
|
447
|
+
})).toBe(true);
|
|
448
|
+
|
|
449
|
+
const streamingToolCalls = chat.locator(".message.toolCall.streaming", { hasText: "order.txt" });
|
|
450
|
+
await expect(streamingToolCalls.last()).toContainText("order.txt");
|
|
451
|
+
await expect.poll(() => chat.evaluate((root) => {
|
|
452
|
+
const messages = [...root.querySelectorAll(":scope > .message")];
|
|
453
|
+
const thinkingIndex = messages.findIndex((message) => message.matches(".thinking.streaming") && message.textContent?.includes("ordering thinking"));
|
|
454
|
+
const toolIndex = messages.findIndex((message) => message.matches(".toolCall.streaming") && message.textContent?.includes("order.txt"));
|
|
455
|
+
return thinkingIndex >= 0 && toolIndex > thinkingIndex;
|
|
456
|
+
})).toBe(true);
|
|
457
|
+
await page.waitForTimeout(500);
|
|
458
|
+
await expect(streamingToolCalls).toHaveCount(1);
|
|
459
|
+
await expect(chat.locator(".message.thinking.streaming", { hasText: "ordering thinking" })).toHaveCount(1);
|
|
460
|
+
await waitForFixtureSettlement(page);
|
|
461
|
+
});
|
|
462
|
+
|
|
434
463
|
test("thinking visibility change explicitly invalidates a live thinking selection", async ({ page }) => {
|
|
435
464
|
await page.setViewportSize({ width: 1280, height: 800 });
|
|
436
465
|
await page.goto(baseURL);
|