@firstpick/pi-package-webui 0.9.6 → 0.9.7
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 +7 -3
- package/bin/pi-webui.mjs +367 -72
- package/lib/git-workflow-preferences.mjs +21 -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 +721 -35
- package/public/index.html +38 -2
- package/public/service-worker.js +1 -1
- package/public/styles.css +254 -3
- 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/guided-git-fallback.spec.mjs +153 -0
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/compact-sections-static.test.mjs +4 -0
- 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/git-workflow-preferences.test.mjs +30 -1
- package/tests/guided-git-fallback-runtime.test.mjs +418 -0
- package/tests/guided-git-fallback-ui-static.test.mjs +60 -0
- package/tests/guided-git-message-reliability-static.test.mjs +8 -7
- package/tests/intercom-conversation-viewer-static.test.mjs +3 -3
- package/tests/main-output-loading-static.test.mjs +3 -3
- 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 +7 -5
- 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 +3 -3
- 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 +23 -0
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/webui-rpc-helper.mjs +220 -3
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
3
|
+
import { createServer } from "node:net";
|
|
4
|
+
import { chmod, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { dirname, join } from "node:path";
|
|
7
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
import { 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
|
+
|
|
14
|
+
async function freePort() {
|
|
15
|
+
const server = createServer();
|
|
16
|
+
await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
|
|
17
|
+
const { port } = server.address();
|
|
18
|
+
await new Promise((resolve) => server.close(resolve));
|
|
19
|
+
return port;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let child;
|
|
23
|
+
let baseURL;
|
|
24
|
+
let tempRoot;
|
|
25
|
+
let output = "";
|
|
26
|
+
|
|
27
|
+
async function waitForServer() {
|
|
28
|
+
for (let attempt = 0; attempt < 100; attempt += 1) {
|
|
29
|
+
if (child.exitCode !== null) break;
|
|
30
|
+
try {
|
|
31
|
+
const response = await fetch(`${baseURL}/api/health`, { signal: AbortSignal.timeout(500) });
|
|
32
|
+
if (response.ok) return;
|
|
33
|
+
} catch {
|
|
34
|
+
// Wait for the isolated real server and fake RPC fixture.
|
|
35
|
+
}
|
|
36
|
+
await delay(100);
|
|
37
|
+
}
|
|
38
|
+
throw new Error(`Pi Web UI did not start:\n${output}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
test.beforeAll(async () => {
|
|
42
|
+
const port = await freePort();
|
|
43
|
+
tempRoot = await mkdtemp(join(tmpdir(), "pi-webui-guided-git-browser-"));
|
|
44
|
+
const fakePi = join(tempRoot, "fake-pi.mjs");
|
|
45
|
+
const logFile = join(tempRoot, "rpc.jsonl");
|
|
46
|
+
await writeFile(fakePi, `#!/usr/bin/env node
|
|
47
|
+
import { appendFileSync } from "node:fs";
|
|
48
|
+
import { createInterface } from "node:readline";
|
|
49
|
+
const logFile = process.env.GUIDED_GIT_BROWSER_LOG;
|
|
50
|
+
let model = { provider: "fake", id: "original" };
|
|
51
|
+
let thinkingLevel = "high";
|
|
52
|
+
function send(value) { process.stdout.write(JSON.stringify(value) + "\\n"); }
|
|
53
|
+
function log(value) { appendFileSync(logFile, JSON.stringify(value) + "\\n"); }
|
|
54
|
+
const models = [
|
|
55
|
+
{ provider: "fake", id: "original", name: "Original", reasoning: true },
|
|
56
|
+
{ provider: "fake", id: "primary", name: "Primary", reasoning: true },
|
|
57
|
+
{ provider: "fake", id: "fallback", name: "Fallback", reasoning: false },
|
|
58
|
+
];
|
|
59
|
+
createInterface({ input: process.stdin }).on("line", (line) => {
|
|
60
|
+
const command = JSON.parse(line);
|
|
61
|
+
if (!command?.id) return;
|
|
62
|
+
log({ type: command.type, modelId: command.modelId, activeModel: model.id, message: command.message });
|
|
63
|
+
const response = { type: "response", id: command.id, command: command.type, success: true };
|
|
64
|
+
if (command.type === "get_state") send({ ...response, data: { model, thinkingLevel, isStreaming: false, isCompacting: false, pendingMessageCount: 0, sessionId: "browser", sessionName: "browser" } });
|
|
65
|
+
else if (command.type === "get_available_models") send({ ...response, data: { models } });
|
|
66
|
+
else if (command.type === "get_commands") send({ ...response, data: { commands: [
|
|
67
|
+
{ name: "git-staged-msg", source: "extension", description: "Generate commit messages" },
|
|
68
|
+
{ name: "git-branch-name", source: "extension", description: "Generate branch names" },
|
|
69
|
+
{ name: "pr", source: "extension", description: "Generate PR text" },
|
|
70
|
+
] } });
|
|
71
|
+
else if (command.type === "get_messages") send({ ...response, data: { messages: [] } });
|
|
72
|
+
else if (command.type === "set_model" && command.modelId === "primary") send({ ...response, success: false, error: "SECRET primary failure at /private/provider.mjs:12" });
|
|
73
|
+
else if (command.type === "set_model") { model = { provider: command.provider, id: command.modelId }; send({ ...response, data: model }); }
|
|
74
|
+
else if (command.type === "set_thinking_level") { thinkingLevel = command.level; send({ ...response, data: { level: thinkingLevel } }); }
|
|
75
|
+
else if (command.type === "prompt" && model.id === "fallback") send({ ...response, success: false, error: "SECRET fallback failure at /private/provider.mjs:44" });
|
|
76
|
+
else send({ ...response, data: {} });
|
|
77
|
+
});
|
|
78
|
+
`, "utf8");
|
|
79
|
+
await chmod(fakePi, 0o755);
|
|
80
|
+
assert.equal(spawnSync("git", ["init", "--quiet"], { cwd: tempRoot }).status, 0);
|
|
81
|
+
await writeFile(join(tempRoot, "guided-git-browser.txt"), "browser fixture\n", "utf8");
|
|
82
|
+
const settingsFile = join(tempRoot, "settings.json");
|
|
83
|
+
await writeFile(settingsFile, `${JSON.stringify({
|
|
84
|
+
version: 8,
|
|
85
|
+
gitWorkflow: {
|
|
86
|
+
reviewProcessEnabled: false,
|
|
87
|
+
stagingPolicy: "all",
|
|
88
|
+
generation: {
|
|
89
|
+
provider: "fake",
|
|
90
|
+
modelId: "primary",
|
|
91
|
+
thinkingLevel: "low",
|
|
92
|
+
unavailablePolicy: "ask",
|
|
93
|
+
fallback: { provider: "fake", modelId: "fallback", thinkingLevel: "off" },
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
}, null, 2)}\n`, "utf8");
|
|
97
|
+
baseURL = `http://127.0.0.1:${port}`;
|
|
98
|
+
child = spawn(process.execPath, [serverScript, "--cwd", tempRoot, "--host", "127.0.0.1", "--port", String(port), "--pi", fakePi], {
|
|
99
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
100
|
+
env: {
|
|
101
|
+
...process.env,
|
|
102
|
+
PI_WEBUI_RPC_SUPERVISOR: "0",
|
|
103
|
+
PI_CODING_AGENT_DIR: join(tempRoot, "agent"),
|
|
104
|
+
PI_WEBUI_SETTINGS_FILE: settingsFile,
|
|
105
|
+
GUIDED_GIT_BROWSER_LOG: logFile,
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
child.stdout.on("data", (chunk) => { output += String(chunk); });
|
|
109
|
+
child.stderr.on("data", (chunk) => { output += String(chunk); });
|
|
110
|
+
await waitForServer();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test.afterAll(async () => {
|
|
114
|
+
if (child?.exitCode === null) child.kill("SIGTERM");
|
|
115
|
+
if (child && child.exitCode === null) await new Promise((resolve) => child.once("exit", resolve));
|
|
116
|
+
await rm(tempRoot, { recursive: true, force: true });
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test("pre-response fallback lifecycle survives correlation and remains browser-observation-only", async ({ page }) => {
|
|
120
|
+
await page.route("**/api/commands?*", async (route) => {
|
|
121
|
+
await route.fulfill({
|
|
122
|
+
status: 200,
|
|
123
|
+
contentType: "application/json",
|
|
124
|
+
body: JSON.stringify({ ok: true, data: { commands: [
|
|
125
|
+
{ name: "git-staged-msg", source: "extension", description: "Generate commit messages" },
|
|
126
|
+
{ name: "git-branch-name", source: "extension", description: "Generate branch names" },
|
|
127
|
+
{ name: "pr", source: "extension", description: "Generate PR text" },
|
|
128
|
+
] } }),
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
await page.goto(baseURL);
|
|
132
|
+
const guidedGit = page.locator("#gitWorkflowButton");
|
|
133
|
+
await expect(guidedGit).toBeVisible();
|
|
134
|
+
await expect(guidedGit).toBeEnabled();
|
|
135
|
+
await guidedGit.click();
|
|
136
|
+
|
|
137
|
+
const panel = page.locator("#gitWorkflowPanel");
|
|
138
|
+
await expect(panel).toBeVisible();
|
|
139
|
+
await panel.getByRole("button", { name: "Run git add ." }).click();
|
|
140
|
+
await expect(panel.getByRole("button", { name: "Generate commit message" })).toBeVisible();
|
|
141
|
+
await panel.getByRole("button", { name: "Generate commit message" }).click();
|
|
142
|
+
|
|
143
|
+
const outputText = page.locator("#gitWorkflowOutput");
|
|
144
|
+
await expect(outputText).toContainText("Generation continued with the fallback fake/fallback");
|
|
145
|
+
await expect(outputText).toContainText("The fallback Git-writing model fake/fallback at off effort also failed");
|
|
146
|
+
await expect(outputText).toContainText("Guided Git generation failed after the configured model attempts.");
|
|
147
|
+
await expect(outputText).not.toContainText("SECRET");
|
|
148
|
+
await expect(outputText).not.toContainText("/private/provider.mjs");
|
|
149
|
+
|
|
150
|
+
const log = (await import("node:fs/promises")).readFile(join(tempRoot, "rpc.jsonl"), "utf8");
|
|
151
|
+
const entries = (await log).trim().split("\n").filter(Boolean).map((line) => JSON.parse(line));
|
|
152
|
+
assert.equal(entries.filter((entry) => entry.type === "prompt" && entry.activeModel === "fallback").length, 1, "the browser must not dispatch another fallback prompt");
|
|
153
|
+
});
|
|
@@ -55,7 +55,7 @@ assert.match(app, /statusKey === CODEX_FAST_MODE_STATUS_KEY[\s\S]*?applyCodexFas
|
|
|
55
55
|
assert.match(technical, /## Normal and compact output[\s\S]*?select \*\*Compact\*\*[\s\S]*?`compact-v1`/, "technical reference should document Compact mode with the stable identifier");
|
|
56
56
|
assert.match(development, /### Codex subscription Fast mode[\s\S]*?service_tier: "priority"[\s\S]*?1\.5× faster[\s\S]*?2× Standard credits[\s\S]*?2\.5×/, "development guide should document Fast-mode integration and cost semantics");
|
|
57
57
|
// Intent preserved: browser-asset changes must advance the coherent cache tuple.
|
|
58
|
-
assert.match(serviceWorker, /pi-webui-pwa-
|
|
59
|
-
assert.match(html, /data-app-src="\/app\.js\?v=
|
|
58
|
+
assert.match(serviceWorker, /pi-webui-pwa-v132/, "PWA cache identity should be bumped for changed browser assets");
|
|
59
|
+
assert.match(html, /data-app-src="\/app\.js\?v=166"/, "browser module URL should be cache-busted for Fast-mode wiring");
|
|
60
60
|
|
|
61
61
|
console.log("codex-fast-mode-static.test.mjs passed");
|
|
@@ -70,6 +70,10 @@ const gitTree = ruleBlock(".git-side-panel-tree", compactStart);
|
|
|
70
70
|
assert.equal(propertyValue(gitTree, "gap"), "0", "Git tree rows should not add inter-row gaps");
|
|
71
71
|
assert.equal(propertyValue(gitTree, "padding"), "0.14rem 0.18rem", "Git tree container padding should remain compact");
|
|
72
72
|
const denseGitRowsStart = css.indexOf("/* Keep the Files tree visual language", compactStart);
|
|
73
|
+
const denseGitFileRowStart = css.indexOf("\n.git-side-panel-file {\n grid-template-columns", denseGitRowsStart);
|
|
74
|
+
assert.notEqual(denseGitFileRowStart, -1, "missing compact Git file-row grid rule");
|
|
75
|
+
const denseGitFileRow = ruleBlock(".git-side-panel-file", denseGitFileRowStart);
|
|
76
|
+
assert.equal(propertyValue(denseGitFileRow, "grid-template-columns"), "1rem minmax(4rem, 1fr) auto auto", "Git file rows should keep status, filename, stats, and overflow actions on one line");
|
|
73
77
|
const genericDetailsStart = css.indexOf("\ndetails {\n margin: 0.5rem 0;");
|
|
74
78
|
assert.notEqual(genericDetailsStart, -1, "missing generic details card rule");
|
|
75
79
|
const genericDetails = ruleBlock("details", genericDetailsStart);
|
|
@@ -57,8 +57,8 @@ assert.match(app, /function initializeComposerActionOrdering\(\)[\s\S]*MutationO
|
|
|
57
57
|
assert.match(app, /event\.key === COMPOSER_ACTION_ORDER_STORAGE_KEY\) restoreComposerActionOrder\(\)[\s\S]*event\.key === COMPOSER_ACTION_LAYOUT_STORAGE_KEY\) restoreComposerActionSlotLayout\(\)/, "other tabs should apply persisted composer order and sparse-layout changes");
|
|
58
58
|
assert.match(app, /initializeComposerActionOrdering\(\);[\s\S]*restoreSidePanelSectionOrder\(\);/, "composer ordering should initialize during guarded app startup");
|
|
59
59
|
|
|
60
|
-
assert.match(html, /styles\.css\?v=
|
|
61
|
-
assert.match(html, /app\.js\?v=
|
|
62
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
60
|
+
assert.match(html, /styles\.css\?v=137/, "changed composer styles should advance the stylesheet revision");
|
|
61
|
+
assert.match(html, /app\.js\?v=166/, "changed composer behavior should advance the app revision");
|
|
62
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "changed browser assets should advance the PWA cache identity");
|
|
63
63
|
|
|
64
64
|
console.log("composer-action-grid-reorder-static.test.mjs passed");
|
|
@@ -246,6 +246,69 @@ assert.match(
|
|
|
246
246
|
"checked menu items should expose a visible check mark as well as aria-checked",
|
|
247
247
|
);
|
|
248
248
|
|
|
249
|
+
// --- Catalog-driven setup dialog -----------------------------------------------
|
|
250
|
+
|
|
251
|
+
assert.equal(catalog.length, 24, "the approved visibility catalog should contain 24 entries");
|
|
252
|
+
assert.equal(groupLabels.length, 5, "the setup should retain the five approved groups");
|
|
253
|
+
assert.match(
|
|
254
|
+
html,
|
|
255
|
+
/<dialog id="controlVisibilitySetupDialog"[^>]*aria-labelledby="controlVisibilitySetupDialogTitle"[^>]*aria-describedby="controlVisibilitySetupDescription"[\s\S]*?<div id="controlVisibilitySetupBody"[^>]*><\/div>[\s\S]*?<button id="controlVisibilitySetupCloseButton"[^>]*type="button">Close<\/button>/,
|
|
256
|
+
"the setup should use a labelled native dialog with a generated body and explicit Close button",
|
|
257
|
+
);
|
|
258
|
+
assert.equal(
|
|
259
|
+
app.match(/controlVisibilityMenuAction\("open-setup", "Open setup"\)/g)?.length,
|
|
260
|
+
2,
|
|
261
|
+
"both the direct and grouped visibility menus should offer Open setup",
|
|
262
|
+
);
|
|
263
|
+
assert.match(
|
|
264
|
+
app,
|
|
265
|
+
/function renderControlVisibilitySetupDialog\(\)[\s\S]*CONTROL_VISIBILITY_GROUP_LABELS\.map[\s\S]*CONTROL_VISIBILITY_CATALOG\.filter[\s\S]*checkbox\.dataset\.visibilitySetupId = entry\.id[\s\S]*body\.replaceChildren\(\.\.\.groups\)/,
|
|
266
|
+
"the five setup groups and their checkboxes should be generated from the canonical catalog",
|
|
267
|
+
);
|
|
268
|
+
assert.match(
|
|
269
|
+
app,
|
|
270
|
+
/controlVisibilitySetupBody\?\.addEventListener\("change"[\s\S]*CONTROL_VISIBILITY_REGISTRY\.get\(checkbox\.dataset\.visibilitySetupId\)[\s\S]*setControlVisibilityHidden\(entry\.id, !checkbox\.checked\)/,
|
|
271
|
+
"native setup checkbox changes should persist immediately through the existing setter",
|
|
272
|
+
);
|
|
273
|
+
assert.match(
|
|
274
|
+
app,
|
|
275
|
+
/function applyControlVisibility\(hiddenIdsOverride\)[\s\S]*refreshControlVisibilitySetupDialog\(\)/,
|
|
276
|
+
"normal visibility application should synchronize an open setup dialog",
|
|
277
|
+
);
|
|
278
|
+
assert.match(
|
|
279
|
+
app,
|
|
280
|
+
/controlVisibilitySetupShowAllButton\?\.addEventListener\("click"[\s\S]*showAllControls\(\)[\s\S]*refreshControlVisibilitySetupDialog\(\)[\s\S]*controlVisibilitySetupResetButton\?\.addEventListener\("click"[\s\S]*resetControlVisibilityDefaults\(\)[\s\S]*refreshControlVisibilitySetupDialog\(\)/,
|
|
281
|
+
"setup quick actions should retain the existing [] and null setters and refresh checkbox state",
|
|
282
|
+
);
|
|
283
|
+
assert.match(
|
|
284
|
+
app,
|
|
285
|
+
/if \(action === "open-setup"\) \{[\s\S]*closeVisibilityContextMenu\(\{ returnFocus: false \}\)[\s\S]*openControlVisibilitySetupDialog\(trigger\)/,
|
|
286
|
+
"Open setup should transfer the context-menu trigger to the dialog without intermediate focus restoration",
|
|
287
|
+
);
|
|
288
|
+
{
|
|
289
|
+
const restoreSetupFocus = app.match(/function restoreControlVisibilitySetupFocus\(\) \{[\s\S]*?^\}/m)?.[0] || "";
|
|
290
|
+
assert.match(
|
|
291
|
+
restoreSetupFocus,
|
|
292
|
+
/trigger\.isConnected[\s\S]*!trigger\.closest\?\.\("\[hidden\], \.webui-user-hidden"\)[\s\S]*if \(triggerSurvives\) trigger\.focus[\s\S]*else elements\.promptInput\?\.focus/,
|
|
293
|
+
"Close and Escape should restore a surviving opener or use the prompt fallback",
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
assert.match(
|
|
297
|
+
app,
|
|
298
|
+
/controlVisibilitySetupDialog\?\.addEventListener\("close", restoreControlVisibilitySetupFocus\)/,
|
|
299
|
+
"native dialog dismissal should share the setup focus-restoration path",
|
|
300
|
+
);
|
|
301
|
+
assert.match(
|
|
302
|
+
styles,
|
|
303
|
+
/\.control-visibility-setup-body \{[\s\S]*overflow: auto;[\s\S]*overscroll-behavior: contain;[\s\S]*@media \(max-width: 34rem\)[\s\S]*\.control-visibility-setup-grid \{ grid-template-columns: minmax\(0, 1fr\); \}[\s\S]*min-height: 44px;/,
|
|
304
|
+
"the generated catalog should scroll independently and retain usable narrow-screen controls",
|
|
305
|
+
);
|
|
306
|
+
assert.doesNotMatch(
|
|
307
|
+
app.match(/function renderControlVisibilitySetupDialog\(\)[\s\S]*?function refreshControlVisibilitySetupDialog/)?.[0] || "",
|
|
308
|
+
/send/i,
|
|
309
|
+
"the setup renderer should not introduce a Send-specific entry outside the catalog",
|
|
310
|
+
);
|
|
311
|
+
|
|
249
312
|
// --- Keyboard-only recovery from Send ------------------------------------------
|
|
250
313
|
|
|
251
314
|
assert.match(
|
|
@@ -285,10 +348,10 @@ assert.match(
|
|
|
285
348
|
|
|
286
349
|
assert.match(
|
|
287
350
|
serviceWorker,
|
|
288
|
-
/const CACHE_NAME = "pi-webui-pwa-
|
|
351
|
+
/const CACHE_NAME = "pi-webui-pwa-v132";/,
|
|
289
352
|
"browser asset changes should advance the PWA cache identity",
|
|
290
353
|
);
|
|
291
|
-
assert.match(html, /styles\.css\?v=
|
|
292
|
-
assert.match(html, /data-app-src="\/app\.js\?v=
|
|
354
|
+
assert.match(html, /styles\.css\?v=137/, "visibility styles should advance the stylesheet query revision");
|
|
355
|
+
assert.match(html, /data-app-src="\/app\.js\?v=166"/, "visibility behavior should advance the app query revision");
|
|
293
356
|
|
|
294
357
|
console.log("control-visibility-static.test.mjs passed");
|
|
@@ -15,8 +15,8 @@ assert.equal((html.match(/class="control-row-label"[^>]*data-tooltip=/g) || []).
|
|
|
15
15
|
assert.match(app, /function initializeControlSettingTooltips\(\)[\s\S]*#sidePanelSectionControls \.control-row-label\[data-tooltip\][\s\S]*bindStyledTooltipEvents\(label\)[\s\S]*showFooterTooltip\(label\)/, "Controls help should use the viewport-safe floating tooltip for hover and keyboard access");
|
|
16
16
|
assert.match(html, /class="control-row remote-auth-control-row" hidden[\s\S]*id="remoteAuthToggle"/, "optional PIN protection should retain its guarded visibility");
|
|
17
17
|
assert.match(app, /remoteAuthToggle\?\.closest\("\.remote-auth-control-row"\)[\s\S]*remoteAuthRow\.hidden = false/, "loading remote status should reveal the optional PIN protection setting");
|
|
18
|
-
assert.match(html, /styles\.css\?v=
|
|
19
|
-
assert.match(html, /app\.js\?v=
|
|
20
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
18
|
+
assert.match(html, /styles\.css\?v=137/, "Controls stylesheet changes should advance the cache query");
|
|
19
|
+
assert.match(html, /app\.js\?v=166/, "Controls tooltip wiring should advance the app cache query");
|
|
20
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "Controls browser assets should advance the PWA cache identity");
|
|
21
21
|
|
|
22
22
|
console.log("controls-layout-static.test.mjs passed");
|