@firstpick/pi-package-webui 0.10.6 → 0.10.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/DEVELOPMENT.md +95 -15
- package/README.md +1 -1
- package/TECHNICAL.md +6 -4
- package/bin/pi-webui-launcher.mjs +6 -3
- package/bin/pi-webui-native-update-guardian.mjs +37 -0
- package/bin/pi-webui-native-update-runner.mjs +148 -0
- package/bin/pi-webui-rpc-supervisor.mjs +85 -10
- package/bin/pi-webui-update-context.mjs +83 -0
- package/bin/pi-webui.mjs +537 -339
- package/lib/component-update-state.mjs +4 -4
- package/lib/rpc-supervisor-client.mjs +4 -0
- package/lib/rpc-supervisor-protocol.mjs +17 -4
- package/lib/update/coordination.mjs +207 -0
- package/lib/update/discovery.mjs +58 -0
- package/lib/update/migration.mjs +115 -0
- package/lib/update/native-jobs.mjs +215 -0
- package/lib/update/native-targets.mjs +81 -0
- package/lib/update/path-pi.mjs +76 -0
- package/lib/update/supervisor.mjs +50 -29
- package/lib/update/verification.mjs +18 -0
- package/lib/update-commands.mjs +17 -27
- package/package.json +3 -3
- package/public/app.js +170 -201
- package/public/index.html +5 -3
- package/public/styles.css +29 -1
- package/tests/browser/control-deck-component-updates.spec.mjs +90 -141
- package/tests/browser/update-reconnect.spec.mjs +37 -1
- package/tests/component-update-api-static.test.mjs +13 -11
- package/tests/control-deck-component-updates-static.test.mjs +25 -25
- package/tests/cwd-footer-reliability-static.test.mjs +4 -1
- package/tests/http-endpoints-harness.test.mjs +32 -9
- package/tests/mobile-static.test.mjs +9 -6
- package/tests/native-update-discovery.test.mjs +69 -0
- package/tests/native-update-lifecycle.test.mjs +90 -0
- package/tests/native-update-shell-survival.test.mjs +68 -0
- package/tests/native-update-verification.test.mjs +17 -0
- package/tests/rpc-supervisor-host.test.mjs +63 -1
- package/tests/rpc-supervisor-protocol.test.mjs +8 -0
- package/tests/run-all.mjs +6 -2
- package/tests/update-api-harness.test.mjs +57 -50
- package/tests/update-commands.test.mjs +29 -15
- package/tests/update-executor-process-tree-harness.test.mjs +84 -1
- package/tests/update-journal-harness.test.mjs +9 -1
- package/tests/update-lock-multiprocess-harness.test.mjs +60 -1
- package/tests/update-owners.test.mjs +32 -0
- package/tests/update-plan.test.mjs +110 -0
- package/tests/update-resolver.test.mjs +36 -0
- package/tests/update-supervisor-harness.test.mjs +74 -1
- package/tests/update-tab-restore-harness.test.mjs +9 -2
- package/bin/pi-webui-update-supervisor.mjs +0 -86
|
@@ -9,170 +9,119 @@ import { fileURLToPath } from "node:url";
|
|
|
9
9
|
import { expect, test } from "@playwright/test";
|
|
10
10
|
|
|
11
11
|
const root = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
12
|
-
const serverScript = join(root, "bin
|
|
13
|
-
const fakePi = join(root, "tests
|
|
14
|
-
|
|
12
|
+
const serverScript = join(root, "bin/pi-webui.mjs");
|
|
13
|
+
const fakePi = join(root, "tests/fixtures/fake-pi.mjs");
|
|
15
14
|
async function freePort() {
|
|
16
|
-
const
|
|
17
|
-
await new Promise((resolve) =>
|
|
18
|
-
const
|
|
19
|
-
await new Promise((resolve) =>
|
|
15
|
+
const listener = createServer();
|
|
16
|
+
await new Promise((resolve) => listener.listen(0, "127.0.0.1", resolve));
|
|
17
|
+
const port = listener.address().port;
|
|
18
|
+
await new Promise((resolve) => listener.close(resolve));
|
|
20
19
|
return port;
|
|
21
20
|
}
|
|
22
|
-
|
|
23
|
-
let child;
|
|
24
|
-
let baseURL;
|
|
25
|
-
let tempRoot;
|
|
26
|
-
let output = "";
|
|
27
|
-
|
|
21
|
+
let child, baseURL, tempRoot;
|
|
28
22
|
test.beforeAll(async () => {
|
|
29
|
-
const port = await freePort();
|
|
30
23
|
tempRoot = await mkdtemp(join(tmpdir(), "pi-webui-component-updates-"));
|
|
31
|
-
baseURL = `http://127.0.0.1:${
|
|
32
|
-
child = spawn(process.execPath, [serverScript, "--cwd", tempRoot, "--host", "127.0.0.1", "--port",
|
|
33
|
-
stdio:
|
|
34
|
-
env: {
|
|
35
|
-
...process.env,
|
|
36
|
-
PI_WEBUI_RPC_SUPERVISOR: "0",
|
|
37
|
-
PI_CODING_AGENT_DIR: join(tempRoot, "agent"),
|
|
38
|
-
PI_WEBUI_SETTINGS_FILE: join(tempRoot, "settings.json"),
|
|
39
|
-
},
|
|
24
|
+
baseURL = `http://127.0.0.1:${await freePort()}`;
|
|
25
|
+
child = spawn(process.execPath, [serverScript, "--cwd", tempRoot, "--host", "127.0.0.1", "--port", new URL(baseURL).port, "--pi", fakePi], {
|
|
26
|
+
stdio: "ignore",
|
|
27
|
+
env: { ...process.env, PI_WEBUI_RPC_SUPERVISOR: "0", PI_WEBUI_UPDATE_TEST_HOME: join(tempRoot, "coordination"), PI_CODING_AGENT_DIR: join(tempRoot, "agent"), PI_WEBUI_SETTINGS_FILE: join(tempRoot, "settings.json") },
|
|
40
28
|
});
|
|
41
|
-
|
|
42
|
-
child.stderr.on("data", (chunk) => { output += String(chunk); });
|
|
43
|
-
for (let attempt = 0; attempt < 80; attempt += 1) {
|
|
29
|
+
for (let i = 0; i < 80; i++) {
|
|
44
30
|
if (child.exitCode !== null) break;
|
|
45
|
-
try {
|
|
46
|
-
const response = await fetch(`${baseURL}/api/health`, { signal: AbortSignal.timeout(500) });
|
|
47
|
-
if (response.ok) return;
|
|
48
|
-
} catch {
|
|
49
|
-
// Wait for the package server and fake Pi fixture to start.
|
|
50
|
-
}
|
|
31
|
+
try { if ((await fetch(`${baseURL}/api/health`, { signal: AbortSignal.timeout(500) })).ok) return; } catch {}
|
|
51
32
|
await delay(100);
|
|
52
33
|
}
|
|
53
|
-
throw new Error(
|
|
34
|
+
throw new Error("fixture server did not become healthy");
|
|
54
35
|
});
|
|
55
|
-
|
|
56
36
|
test.afterAll(async () => {
|
|
57
|
-
child
|
|
58
|
-
|
|
37
|
+
if (child && child.exitCode === null) {
|
|
38
|
+
const exited = new Promise((resolve) => child.once("exit", resolve));
|
|
39
|
+
child.kill("SIGTERM");
|
|
40
|
+
await Promise.race([exited, delay(8_000)]);
|
|
41
|
+
if (child.exitCode === null) child.kill("SIGKILL");
|
|
42
|
+
}
|
|
59
43
|
await rm(tempRoot, { recursive: true, force: true });
|
|
60
44
|
});
|
|
61
45
|
|
|
62
|
-
test("
|
|
46
|
+
test("Pi and Web UI actions confirm independent native targets and show durable receipts", async ({ page }) => {
|
|
63
47
|
const requests = [];
|
|
64
|
-
|
|
65
|
-
const status = {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
webui: { checked: true, currentVersion: "0.8.1", latestVersion: "0.8.2", updateAvailable: true },
|
|
71
|
-
componentUpdates: {
|
|
72
|
-
pi: { target: "pi", state: "idle", message: "", error: "", canStart: true, unavailableReason: "", restartRequired: false },
|
|
73
|
-
webui: {
|
|
74
|
-
target: "webui",
|
|
75
|
-
state: "idle",
|
|
76
|
-
message: "",
|
|
77
|
-
error: "",
|
|
78
|
-
canStart: false,
|
|
79
|
-
unavailableReason: "Automatic Web UI update is unavailable from a source or development checkout.",
|
|
80
|
-
restartRequired: true,
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
await page.route("**/api/pi-release-notes", async (route) => {
|
|
86
|
-
await route.fulfill({
|
|
87
|
-
status: 200,
|
|
88
|
-
contentType: "application/json",
|
|
89
|
-
body: JSON.stringify({ ok: true, data: { version: "0.84.0", body: "Fixture v0.84.0 release notes", url: "https://example.test/pi/v0.84.0" } }),
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
const plan = { transactionId: "browser-pi-plan", digest: "a".repeat(64), targets: [{ id: "pi", currentVersion: "0.83.0", targetVersion: "0.84.0" }], refusals: [] };
|
|
93
|
-
await page.route("**/api/update/plan", async (route) => {
|
|
48
|
+
const jobs = { pi: null, webui: null };
|
|
49
|
+
const status = () => ({ updateAvailable: true, updateInProgress: Object.values(jobs).some((job) => job?.phase === "running"), canRunUpdate: !Object.values(jobs).some((job) => job?.phase === "running"), nativeJobs: jobs, nativeJobDiscoveryError: "", pi: { checked: true, currentVersion: "0.87.1", activeRuntimeVersion: "0.80.10", pathInstallationVersion: "0.87.1", latestVersion: "0.88.0", updateAvailable: true }, webui: { checked: true, currentVersion: "0.8.1", latestVersion: "0.8.2", updateAvailable: true } });
|
|
50
|
+
await page.route("**/api/update-status*", (route) => route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, data: status() }) }));
|
|
51
|
+
await page.route("**/api/pi-release-notes", (route) => route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, data: { version: "0.88.0", body: "Fixture release notes" } }) }));
|
|
52
|
+
const plan = (target) => ({ requested: target, transactionId: `fixture-${target}`, digest: "a".repeat(64), active: { pi: "0.80.10", piRoot: "/active/pi", webui: "0.8.1", webuiRoot: "/active/webui" }, pathPi: { eligible: true, version: "0.87.1", packageRoot: "/safe/path-pi", executable: "/usr/bin/node", cli: "/safe/path-pi/cli.js", guidance: "" }, context: { shell: "/bin/bash", cwd: "/safe/state", agentDir: "/safe/agent", npmPrefix: "/safe/prefix" }, targets: target === "pi" ? [{ id: "pi", packageName: "Pi", beforeVersion: "0.87.1", installedRoot: "/safe/path-pi", effectRoot: "/safe/prefix", command: { command: "/usr/bin/node", args: ["/safe/path-pi/cli.js", "update"] } }] : [{ id: "webui:npm-global", packageName: "Web UI", beforeVersion: "0.8.1", installedRoot: "/safe/npm/webui", effectRoot: "/safe/prefix", command: { command: "/usr/bin/node", args: ["/safe/npm-cli.js", "-g", "update", "@firstpick/pi-package-webui"] } }, { id: "webui:pi-user", packageName: "Web UI", beforeVersion: "0.8.1", installedRoot: "/safe/agent/npm/webui", effectRoot: "/safe/agent/npm", command: { command: "/usr/bin/node", args: ["/safe/path-pi/cli.js", "update", "--extension", "npm:@firstpick/pi-package-webui", "--no-approve"] } }], refusals: ["Project installation needs manual update."], warning: "Native lifecycle scripts run with existing configuration; not sandboxed." });
|
|
53
|
+
await page.route("**/api/update/plan", (route) => {
|
|
94
54
|
const body = route.request().postDataJSON();
|
|
95
|
-
requests.push(
|
|
96
|
-
|
|
55
|
+
requests.push(body);
|
|
56
|
+
return route.fulfill({ status: 201, contentType: "application/json", body: JSON.stringify({ ok: true, data: { plan: plan(body.targets[0]) } }) });
|
|
97
57
|
});
|
|
98
|
-
await page.route("**/api/update/apply",
|
|
58
|
+
await page.route("**/api/update/apply", (route) => {
|
|
99
59
|
const body = route.request().postDataJSON();
|
|
100
|
-
requests.push(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
60
|
+
requests.push(body);
|
|
61
|
+
const target = body.transactionId.endsWith("pi") ? "pi" : "webui";
|
|
62
|
+
jobs[target] = { transactionId: body.transactionId, plan: plan(target), phase: "running", receipts: [], verifiedTargets: [] };
|
|
63
|
+
return route.fulfill({ status: 202, contentType: "application/json", body: JSON.stringify({ ok: true, data: { transactionId: body.transactionId, phase: "running" } }) });
|
|
104
64
|
});
|
|
105
|
-
await page.route("**/api/update
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
status.componentUpdates.pi = {
|
|
109
|
-
...status.componentUpdates.pi,
|
|
110
|
-
state: "succeeded",
|
|
111
|
-
canStart: true,
|
|
112
|
-
message: "Pi update completed.",
|
|
113
|
-
};
|
|
114
|
-
status.updateInProgress = false;
|
|
115
|
-
}
|
|
116
|
-
await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, data: status }) });
|
|
65
|
+
await page.route("**/api/update/transactions/*", (route) => {
|
|
66
|
+
const job = Object.values(jobs).find((item) => item?.transactionId === route.request().url().split("/").pop());
|
|
67
|
+
return route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, data: job }) });
|
|
117
68
|
});
|
|
118
|
-
|
|
119
69
|
await page.goto(baseURL);
|
|
120
|
-
|
|
121
|
-
const webuiTag = page.locator("#webuiVersionButton");
|
|
122
|
-
await expect(piTag).toHaveAttribute("data-update-state", "available", { timeout: 8_000 });
|
|
123
|
-
await expect(piTag).toHaveAccessibleName(/Pi .*update available/);
|
|
124
|
-
await expect(webuiTag).toHaveAttribute("data-update-state", "available");
|
|
125
|
-
await expect(webuiTag).toHaveAccessibleName(/Web UI .*update available/);
|
|
126
|
-
await page.locator("#updateNotificationDismissButton").click();
|
|
127
|
-
await expect(page.locator("#updateNotification")).toBeHidden();
|
|
128
|
-
|
|
129
|
-
await webuiTag.click();
|
|
130
|
-
const webuiDialog = page.locator("#webuiPackageDialog");
|
|
131
|
-
await expect(webuiDialog).toBeVisible();
|
|
132
|
-
await expect(page.locator("#webuiPackageCurrentVersion")).toHaveText("v0.8.1");
|
|
133
|
-
await expect(page.locator("#webuiPackageLatestVersion")).toHaveText("v0.8.2");
|
|
134
|
-
await expect(page.locator("#webuiPackageNpmButton")).toHaveText("View on npm");
|
|
135
|
-
await expect(page.locator("#webuiComponentUpdateStatus")).toContainText("source or development checkout");
|
|
136
|
-
await expect(page.locator("#webuiComponentUpdateButton")).toBeDisabled();
|
|
137
|
-
await page.locator("#webuiPackageCloseButton").click();
|
|
138
|
-
|
|
139
|
-
await piTag.click();
|
|
140
|
-
const piDialog = page.locator("#piReleaseNotesDialog");
|
|
141
|
-
await expect(piDialog).toBeVisible();
|
|
142
|
-
await expect(page.locator("#piReleaseNotesTitle")).toHaveText("Pi v0.84.0 release notes");
|
|
143
|
-
await expect(page.locator("#piReleaseNotesBody")).toContainText("Fixture v0.84.0 release notes");
|
|
144
|
-
await expect(page.locator("#piReleaseNotesGithubLink")).toHaveAttribute("href", "https://example.test/pi/v0.84.0");
|
|
145
|
-
await expect(page.locator("#piComponentUpdateStatus")).toContainText("Pi v0.83.0 → v0.84.0 is available");
|
|
70
|
+
await page.locator("#piVersionButton").click();
|
|
146
71
|
await page.locator("#piComponentUpdateButton").click();
|
|
147
|
-
await expect(page.locator("#
|
|
148
|
-
await expect(page.locator("#confirmationSummary")).toContainText("
|
|
72
|
+
await expect(page.locator("#confirmationSummary")).toContainText("/safe/path-pi/cli.js");
|
|
73
|
+
await expect(page.locator("#confirmationSummary")).toContainText("0.80.10");
|
|
74
|
+
await expect(page.locator("#confirmationSummary")).toContainText("Confirmed PATH Pi: 0.87.1 at /safe/path-pi");
|
|
75
|
+
await expect(page.locator("#confirmationSummary")).toContainText("/safe/agent");
|
|
76
|
+
await expect(page.locator("#confirmationSummary")).toContainText("Native lifecycle scripts");
|
|
149
77
|
await page.locator("#confirmationConfirmButton").click();
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
await expect(piTag).toHaveAttribute("data-update-state", "succeeded", { timeout: 8_000 });
|
|
157
|
-
await expect(page.locator("#piComponentUpdateStatus")).toContainText("New or reloaded Pi sessions use the update");
|
|
158
|
-
await expect(page.locator("#piComponentUpdateStatus")).toContainText("already-running tabs keep their current runtime");
|
|
159
|
-
assert.ok(statusPollsAfterStart >= 1, "the browser should poll while the accepted job is running");
|
|
160
|
-
const pollsAtSuccess = statusPollsAfterStart;
|
|
161
|
-
await page.waitForTimeout(1_300);
|
|
162
|
-
assert.equal(statusPollsAfterStart, pollsAtSuccess, "short polling should stop after terminal success");
|
|
78
|
+
await expect(page.locator("#piComponentUpdateStatus")).toContainText("fixture-pi");
|
|
79
|
+
await expect(page.locator("#piComponentUpdateStatus")).toHaveAttribute("data-update-running");
|
|
80
|
+
jobs.pi = { ...jobs.pi, phase: "unchanged", receipts: [{ id: "pi", status: "unchanged", stdout: "Already current", stderr: "" }] };
|
|
81
|
+
await expect(page.locator("#piComponentUpdateStatus")).toContainText("No automatic restart", { timeout: 8_000 });
|
|
82
|
+
await expect(page.locator("#piComponentUpdateOutput")).toContainText("Already current");
|
|
163
83
|
await page.locator("#piReleaseNotesCloseButton").click();
|
|
164
|
-
await
|
|
84
|
+
await page.locator("#webuiVersionButton").click();
|
|
85
|
+
await page.locator("#webuiComponentUpdateButton").click();
|
|
86
|
+
await expect(page.locator("#confirmationSummary")).toContainText("/safe/npm/webui");
|
|
87
|
+
await expect(page.locator("#confirmationSummary")).toContainText("/safe/agent/npm/webui");
|
|
88
|
+
await expect(page.locator("#confirmationSummary")).toContainText("Confirmed PATH Pi: 0.87.1 at /safe/path-pi");
|
|
89
|
+
await expect(page.locator("#confirmationSummary")).toContainText("Project installation needs manual update");
|
|
90
|
+
await page.locator("#confirmationConfirmButton").click();
|
|
91
|
+
jobs.webui = { ...jobs.webui, phase: "partial", outcome: "partial", receipts: [{ id: "webui:npm-global", status: "changed", stdout: "updated" }, { id: "webui:pi-user", status: "failed", stderr: "fixture failure" }], verifiedTargets: [{ id: "webui:npm-global", status: "healthy" }] };
|
|
92
|
+
await expect(page.locator("#webuiComponentUpdateStatus")).toContainText("partial result", { timeout: 8_000 });
|
|
93
|
+
await expect(page.locator("#webuiComponentUpdateOutput")).toContainText("fixture failure");
|
|
94
|
+
assert.deepEqual(requests, [{ targets: ["pi"] }, { transactionId: "fixture-pi", planDigest: "a".repeat(64) }, { targets: ["webui"] }, { transactionId: "fixture-webui", planDigest: "a".repeat(64) }]);
|
|
95
|
+
});
|
|
165
96
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
await
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
97
|
+
test("ambiguous apply observes confirmed ID before authoritative discovery clears retry block", async ({ page }) => {
|
|
98
|
+
let applyCount = 0;
|
|
99
|
+
let releaseReceipt;
|
|
100
|
+
const receiptGate = new Promise((resolve) => { releaseReceipt = resolve; });
|
|
101
|
+
const plan = { requested: "pi", transactionId: "uncertain-pi-job", digest: "b".repeat(64),
|
|
102
|
+
active: { pi: "0.80.10", piRoot: "/active/pi" }, pathPi: { eligible: true, version: "0.87.1", packageRoot: "/path/pi", executable: "/node", cli: "/path/pi/cli.js" },
|
|
103
|
+
context: { cwd: "/state", agentDir: "/agent", shell: "/bin/bash", npmPrefix: "/prefix" },
|
|
104
|
+
targets: [{ id: "pi", installedRoot: "/path/pi", effectRoot: "/prefix", beforeVersion: "0.87.1", command: { command: "/node", args: ["/path/pi/cli.js", "update"] } }], refusals: [], warning: "Lifecycle scripts run." };
|
|
105
|
+
await page.route("**/api/update-status*", (route) => route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, data: {
|
|
106
|
+
canRunUpdate: true, updateInProgress: false, nativeJobs: { pi: null, webui: null }, nativeJobDiscoveryError: "",
|
|
107
|
+
pi: { currentVersion: "0.87.1", activeRuntimeVersion: "0.80.10", latestVersion: "0.88.0", checked: true, updateAvailable: true }, webui: {},
|
|
108
|
+
} }) }));
|
|
109
|
+
await page.route("**/api/pi-release-notes", (route) => route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, data: { version: "0.88.0", body: "Release notes" } }) }));
|
|
110
|
+
await page.route("**/api/update/plan", (route) => route.fulfill({ status: 201, contentType: "application/json", body: JSON.stringify({ ok: true, data: { plan } }) }));
|
|
111
|
+
await page.route("**/api/update/apply", (route) => { applyCount += 1; return route.fulfill({ status: 503, contentType: "application/json", body: JSON.stringify({ ok: false, error: "Reply lost after launch attempt" }) }); });
|
|
112
|
+
await page.route("**/api/update/transactions/*", async (route) => {
|
|
113
|
+
await receiptGate;
|
|
114
|
+
await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, data: { transactionId: plan.transactionId, plan, phase: "planned", receipts: [], verifiedTargets: [] } }) });
|
|
115
|
+
});
|
|
116
|
+
try {
|
|
117
|
+
await page.goto(baseURL);
|
|
118
|
+
await page.locator("#piVersionButton").click();
|
|
119
|
+
await page.locator("#piComponentUpdateButton").click();
|
|
120
|
+
await page.locator("#confirmationConfirmButton").click();
|
|
121
|
+
await expect(page.locator("#piComponentUpdateButton")).toBeDisabled();
|
|
122
|
+
await expect(page.locator("#piComponentUpdateStatus")).toContainText("uncertain-pi-job");
|
|
123
|
+
assert.equal(applyCount, 1, "no second apply before job inspection");
|
|
124
|
+
} finally { releaseReceipt(); }
|
|
125
|
+
await expect(page.locator("#piComponentUpdateButton")).toBeEnabled({ timeout: 8_000 });
|
|
126
|
+
assert.equal(applyCount, 1, "authoritative planned/no-running discovery does not apply automatically");
|
|
178
127
|
});
|
|
@@ -22,7 +22,7 @@ async function freePort() {
|
|
|
22
22
|
function startServer(port, temp) {
|
|
23
23
|
const child = spawn(process.execPath, [serverEntry, "--cwd", temp, "--host", "127.0.0.1", "--port", String(port), "--pi", fakePi], {
|
|
24
24
|
stdio: ["ignore", "pipe", "pipe"],
|
|
25
|
-
env: { ...process.env, PI_WEBUI_RPC_SUPERVISOR: "0", PI_CODING_AGENT_DIR: path.join(temp, "agent"), PI_WEBUI_SETTINGS_FILE: path.join(temp, "settings.json") },
|
|
25
|
+
env: { ...process.env, PI_WEBUI_RPC_SUPERVISOR: "0", PI_WEBUI_UPDATE_TEST_HOME: path.join(temp, "coordination"), PI_CODING_AGENT_DIR: path.join(temp, "agent"), PI_WEBUI_SETTINGS_FILE: path.join(temp, "settings.json") },
|
|
26
26
|
});
|
|
27
27
|
child.output = "";
|
|
28
28
|
child.stdout.on("data", (chunk) => { child.output += chunk; });
|
|
@@ -90,3 +90,39 @@ test("reconnect ignores the old boot and accepts only a changed boot identity",
|
|
|
90
90
|
await rm(temp, { recursive: true, force: true });
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
|
+
|
|
94
|
+
test("reload discovers the same partial job and unknown recovery blocks another update", async ({ page }) => {
|
|
95
|
+
const port = await freePort();
|
|
96
|
+
const temp = await mkdtemp(path.join(tmpdir(), "pi-webui-update-recovery-"));
|
|
97
|
+
const baseURL = `http://127.0.0.1:${port}`;
|
|
98
|
+
const server = startServer(port, temp);
|
|
99
|
+
let requests = 0;
|
|
100
|
+
const job = { transactionId: "durable-webui-job", phase: "partial", outcome: "partial", receipts: [
|
|
101
|
+
{ id: "webui:npm-global", status: "changed", stdout: "completed" },
|
|
102
|
+
{ id: "webui:pi-user", status: "failed", stderr: "install failed" },
|
|
103
|
+
], verifiedTargets: [{ id: "webui:npm-global", status: "healthy" }] };
|
|
104
|
+
try {
|
|
105
|
+
await waitForHealth(baseURL, server);
|
|
106
|
+
await page.route("**/api/update-status*", (route) => route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, data: {
|
|
107
|
+
canRunUpdate: job.phase !== "unknown", updateInProgress: job.phase === "unknown", nativeJobs: { pi: null, webui: job },
|
|
108
|
+
nativeJobDiscoveryError: "", pi: { checked: true, currentVersion: "0.87.1" }, webui: { checked: true, currentVersion: "0.8.1", latestVersion: "0.8.2", updateAvailable: true },
|
|
109
|
+
} }) }));
|
|
110
|
+
await page.route("**/api/update/plan", (route) => { requests += 1; return route.abort(); });
|
|
111
|
+
await page.goto(baseURL);
|
|
112
|
+
await page.locator("#webuiVersionButton").click();
|
|
113
|
+
await expect(page.locator("#webuiComponentUpdateStatus")).toContainText("durable-webui-job");
|
|
114
|
+
await expect(page.locator("#webuiComponentUpdateOutput")).toContainText("install failed");
|
|
115
|
+
await page.reload();
|
|
116
|
+
await page.locator("#webuiVersionButton").click();
|
|
117
|
+
await expect(page.locator("#webuiComponentUpdateStatus")).toContainText("partial result");
|
|
118
|
+
job.phase = "unknown";
|
|
119
|
+
await page.reload();
|
|
120
|
+
await page.locator("#webuiVersionButton").click();
|
|
121
|
+
await expect(page.locator("#webuiComponentUpdateStatus")).toContainText("Do not retry or restart");
|
|
122
|
+
await expect(page.locator("#webuiComponentUpdateButton")).toBeDisabled();
|
|
123
|
+
assert.equal(requests, 0, "unknown jobs cannot create a second plan");
|
|
124
|
+
} finally {
|
|
125
|
+
await stop(server);
|
|
126
|
+
await rm(temp, { recursive: true, force: true });
|
|
127
|
+
}
|
|
128
|
+
});
|
|
@@ -4,26 +4,28 @@ import { dirname, join } from "node:path";
|
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
|
|
6
6
|
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
|
-
const [server, state, launcher,
|
|
7
|
+
const [server, state, launcher, runner, trust] = await Promise.all([
|
|
8
8
|
readFile(join(root, "bin", "pi-webui.mjs"), "utf8"),
|
|
9
9
|
readFile(join(root, "lib", "component-update-state.mjs"), "utf8"),
|
|
10
10
|
readFile(join(root, "bin", "pi-webui-launcher.mjs"), "utf8"),
|
|
11
|
-
readFile(join(root, "bin", "pi-webui-update-
|
|
11
|
+
readFile(join(root, "bin", "pi-webui-native-update-runner.mjs"), "utf8"),
|
|
12
12
|
readFile(join(root, "lib", "trust-boundaries.mjs"), "utf8"),
|
|
13
13
|
]);
|
|
14
|
-
assert.match(state, /validateUpdatePlanRequest[\s\S]*targets must contain one
|
|
14
|
+
assert.match(state, /validateUpdatePlanRequest[\s\S]*targets must contain exactly one value/);
|
|
15
15
|
assert.match(state, /validateUpdateApplyRequest[\s\S]*Apply accepts only transactionId and planDigest/);
|
|
16
16
|
assert.match(server, /url\.pathname === "\/api\/update\/plan"[\s\S]*requireLocalhostRoute[\s\S]*validateUpdatePlanRequest[\s\S]*sendJson\(res, 201/);
|
|
17
|
-
assert.match(server, /url\.pathname === "\/api\/update\/apply"[\s\S]*requireLocalhostRoute[\s\S]*validateUpdateApplyRequest[\s\S]*
|
|
18
|
-
assert.match(server, /
|
|
19
|
-
assert.match(server, /
|
|
20
|
-
assert.match(server, /
|
|
21
|
-
|
|
17
|
+
assert.match(server, /url\.pathname === "\/api\/update\/apply"[\s\S]*requireLocalhostRoute[\s\S]*validateUpdateApplyRequest[\s\S]*applyNativeServerPlan/);
|
|
18
|
+
assert.match(server, /createNativeServerPlan\(validation\.targets\)/);
|
|
19
|
+
assert.match(server, /validateNativePlan\(job\.plan, digest\)/);
|
|
20
|
+
assert.match(server, /url\.pathname === "\/api\/restart"[\s\S]*requireLocalhostRoute[\s\S]*assertNativeMutationAdmission\(\)/,
|
|
21
|
+
"ordinary server restarts must not race a native update fence");
|
|
22
|
+
assert.match(server, /releaseEffectLocks\(job\.lock, \{ completionVerified: true \}\)/);
|
|
23
|
+
assert.match(server, /probeStartupRestore\(path\.join\(target\.installedRoot/);
|
|
22
24
|
assert.match(server, /Legacy update mutation is disabled/);
|
|
23
|
-
assert.
|
|
25
|
+
assert.doesNotMatch(server, /strategy: "pi-owned-optional"|"--ignore-scripts"|"managed-side-by-side"/);
|
|
24
26
|
assert.match(trust, /"\/api\/update\/plan"[\s\S]*"\/api\/update\/apply"[\s\S]*"\/api\/update\/rollback"/);
|
|
25
27
|
assert.match(server, /updateTransactionRoute && req\.method === "GET"[\s\S]*requireLocalhost\(req, "Viewing update transactions is only allowed from localhost"\)/);
|
|
26
28
|
assert.doesNotMatch(server, /function resolveUpdateTasks|function projectPackageRootUpdateTasks|function npmGlobalPackageRootUpdateTask|function bunGlobalPackageRootUpdateTask/);
|
|
27
|
-
assert.match(launcher, /
|
|
28
|
-
assert.
|
|
29
|
+
assert.match(launcher, /migrateLegacyBootstrap\(agentDir, bootstrapRoot\)/);
|
|
30
|
+
for (const file of ["started.json", "receipt.json", "complete.json"]) assert.ok(runner.includes(file), `${file} evidence must be durable`);
|
|
29
31
|
console.log("component update API static tests passed");
|
|
@@ -4,30 +4,30 @@ import { dirname, join } from "node:path";
|
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
|
|
6
6
|
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
|
-
const [html, css, app,
|
|
8
|
-
readFile(join(root, "public
|
|
9
|
-
readFile(join(root, "public
|
|
10
|
-
readFile(join(root, "public
|
|
11
|
-
readFile(join(root, "
|
|
12
|
-
readFile(join(root, "README.md"), "utf8"),
|
|
7
|
+
const [html, css, app, development] = await Promise.all([
|
|
8
|
+
readFile(join(root, "public/index.html"), "utf8"),
|
|
9
|
+
readFile(join(root, "public/styles.css"), "utf8"),
|
|
10
|
+
readFile(join(root, "public/app.js"), "utf8"),
|
|
11
|
+
readFile(join(root, "DEVELOPMENT.md"), "utf8"),
|
|
13
12
|
]);
|
|
14
|
-
|
|
15
|
-
assert.match(
|
|
16
|
-
|
|
17
|
-
assert.match(
|
|
18
|
-
|
|
19
|
-
assert.match(
|
|
20
|
-
assert.
|
|
21
|
-
assert.
|
|
22
|
-
assert.match(app, /
|
|
23
|
-
assert.match(
|
|
24
|
-
assert.match(app, /
|
|
25
|
-
assert.match(app, /
|
|
26
|
-
assert.match(app, /
|
|
27
|
-
assert.match(app, /
|
|
28
|
-
assert.match(app, /
|
|
29
|
-
assert.match(app, /
|
|
30
|
-
assert.match(
|
|
31
|
-
assert.match(
|
|
32
|
-
assert.match(
|
|
13
|
+
for (const target of ["pi", "webui"]) {
|
|
14
|
+
assert.match(app, new RegExp(`startComponentUpdate\\("${target}"\\)`));
|
|
15
|
+
assert.match(html, new RegExp(`id="${target}ComponentUpdateStatus"[^>]*aria-live="polite"`));
|
|
16
|
+
assert.match(html, new RegExp(`id="${target}ComponentUpdateOutput"[^>]*aria-label=`));
|
|
17
|
+
}
|
|
18
|
+
assert.match(html, /<option value="update-webui">Update Web UI<\/option>/);
|
|
19
|
+
assert.doesNotMatch(html, /update-all|Update all|Pi \+ Web UI update/);
|
|
20
|
+
assert.doesNotMatch(app, /runPiUpdateAndRestart|managed Web UI activation|side-by-side managed runtime/);
|
|
21
|
+
assert.match(app, /body: \{ targets: \[target\] \}/);
|
|
22
|
+
assert.match(app, /body: \{ transactionId: plan.transactionId, planDigest: plan.digest \}/);
|
|
23
|
+
assert.match(app, /componentUpdateConfirmationText\(plan\)[\s\S]*installedRoot[\s\S]*effectRoot[\s\S]*command\.command[\s\S]*command\.args[\s\S]*context\.cwd[\s\S]*context\.agentDir[\s\S]*context\.npmPrefix[\s\S]*plan\.refusals[\s\S]*plan\.warning[\s\S]*plan\.digest/);
|
|
24
|
+
assert.match(app, /nativeJobs[\s\S]*nativeJobDiscoveryError/);
|
|
25
|
+
assert.match(app, /plan\.pathPi\?\.eligible[\s\S]*plan\.pathPi\.version[\s\S]*plan\.pathPi\.packageRoot[\s\S]*plan\.pathPi\.executable[\s\S]*plan\.pathPi\.cli/);
|
|
26
|
+
assert.match(app, /uncertainApplyJobs\[target\] = plan\.transactionId[\s\S]*phase: "launching"/);
|
|
27
|
+
assert.match(app, /if \(latestUpdateStatus\?\.nativeJobs && !latestUpdateStatus\.nativeJobDiscoveryError\) nativeJobPollError = ""/);
|
|
28
|
+
assert.match(app, /api\/update\/transactions\/\$\{encodeURIComponent\(job\.transactionId\)\}/);
|
|
29
|
+
assert.match(app, /case "unknown"[\s\S]*Do not retry or restart/);
|
|
30
|
+
assert.match(app, /case "partial"[\s\S]*Verified healthy active changes may have restarted/);
|
|
31
|
+
assert.match(css, /\.component-update-status\[data-update-running\]::before[\s\S]*component-update-spin/);
|
|
32
|
+
assert.match(development, /Native Pi and Web UI updates[\s\S]*GET \/api\/update\/transactions\/.*[\s\S]*Native lifecycle scripts are not sandboxed/);
|
|
33
33
|
console.log("control deck component update static tests passed");
|
|
@@ -85,9 +85,12 @@ assert.match(
|
|
|
85
85
|
|
|
86
86
|
assert.match(
|
|
87
87
|
supervisor,
|
|
88
|
-
/queueTabCommand\(tabId, operation\)[\s\S]*?tab\.mutationTail = admission\.catch[\s\S]*?return admission\.then\(\(\) => response\)[\s\S]*?case "command": return this\.queueTabCommand[\s\S]*?case "write": return this\.queueTabMutation/,
|
|
88
|
+
/queueTabCommand\(tabId, operation, readOnly = false\)[\s\S]*?tab\.mutationTail = admission\.catch[\s\S]*?return admission\.then\(\(\) => response\)[\s\S]*?case "command": return this\.queueTabCommand[\s\S]*?case "write": return this\.queueTabMutation/,
|
|
89
89
|
"commands should release their FIFO admission barrier before the full Pi response while writes remain serialized",
|
|
90
90
|
);
|
|
91
|
+
const dispatchBeforeQueue = supervisor.slice(supervisor.indexOf(" async perform(request) {"), supervisor.indexOf(" switch (request.type)", supervisor.indexOf(" async perform(request) {")));
|
|
92
|
+
assert.doesNotMatch(dispatchBeforeQueue, /\bawait\b/, "asynchronous admission must not reorder requests before they enter the tab FIFO");
|
|
93
|
+
assert.match(supervisor, /host\.requests\.values\(\)[\s\S]*request\.mutating && !request\.settled/, "an unpublished or queued mutation must prevent an idle update acknowledgement");
|
|
91
94
|
assert.doesNotMatch(
|
|
92
95
|
supervisor,
|
|
93
96
|
/async afterTabMutation\(/,
|
|
@@ -130,6 +130,7 @@ function runGitFixture(args, cwd, message) {
|
|
|
130
130
|
|
|
131
131
|
const cwd = await mkdtemp(path.join(tmpdir(), "pi-webui-http-harness-"));
|
|
132
132
|
const harnessSideEffectsRoot = await mkdtemp(path.join(tmpdir(), "pi-webui-http-harness-side-effects-"));
|
|
133
|
+
const coordinationHome = await mkdtemp(path.join(tmpdir(), "pi-webui-http-coordination-"));
|
|
133
134
|
const settingsFile = path.join(harnessSideEffectsRoot, "webui-settings.json");
|
|
134
135
|
const workflowPolicyAgentDir = path.join(harnessSideEffectsRoot, "agent");
|
|
135
136
|
const agentRunStateHome = path.join(harnessSideEffectsRoot, "state");
|
|
@@ -283,6 +284,8 @@ const child = spawn(process.execPath, [serverScript, "--cwd", cwd, "--host", "0.
|
|
|
283
284
|
GIT_COMMITTER_EMAIL: "pi-webui-test@example.invalid",
|
|
284
285
|
PATH: `${fakeOpenBinDir}${path.delimiter}${process.env.PATH || ""}`,
|
|
285
286
|
PI_CODING_AGENT_DIR: workflowPolicyAgentDir,
|
|
287
|
+
NODE_ENV: "test",
|
|
288
|
+
PI_WEBUI_UPDATE_TEST_HOME: coordinationHome,
|
|
286
289
|
XDG_STATE_HOME: agentRunStateHome,
|
|
287
290
|
PI_WEBUI_SETTINGS_FILE: settingsFile,
|
|
288
291
|
PI_SESSION_SUMMARY_CONFIG_FILE: sessionSummaryConfigFile,
|
|
@@ -1018,18 +1021,26 @@ try {
|
|
|
1018
1021
|
});
|
|
1019
1022
|
assert.equal(crossOriginWorkflowPolicy.status, 403, "workflow policy saves must reject browser cross-origin requests");
|
|
1020
1023
|
|
|
1024
|
+
const updateStatus = await request("127.0.0.1", "/api/update-status?refresh=1");
|
|
1025
|
+
assert.equal(updateStatus.status, 200);
|
|
1026
|
+
const expectedReleaseVersion = updateStatus.body?.data?.pi?.updateAvailable
|
|
1027
|
+
? latestPiVersion : updateStatus.body?.data?.pi?.currentVersion || updateStatus.body?.data?.pi?.activeRuntimeVersion;
|
|
1028
|
+
assert.match(expectedReleaseVersion, /^\d+\.\d+\.\d+$/, "release identity must come from the confirmed PATH or active Pi installation");
|
|
1021
1029
|
const releaseNotes = await request("127.0.0.1", "/api/pi-release-notes");
|
|
1022
1030
|
assert.equal(releaseNotes.status, 200, `Pi release notes should load through the server: ${releaseNotes.body?.error || ""}`);
|
|
1023
|
-
assert.equal(releaseNotes.body?.data?.version,
|
|
1024
|
-
assert.equal(releaseNotes.body?.data?.tagName, `v${
|
|
1025
|
-
assert.equal(releaseNotes.body?.data?.title, `Pi v${
|
|
1031
|
+
assert.equal(releaseNotes.body?.data?.version, expectedReleaseVersion, "Pi release notes must follow the PATH-versus-active identity in update status");
|
|
1032
|
+
assert.equal(releaseNotes.body?.data?.tagName, `v${expectedReleaseVersion}`);
|
|
1033
|
+
assert.equal(releaseNotes.body?.data?.title, `Pi v${expectedReleaseVersion} test release`);
|
|
1026
1034
|
assert.match(releaseNotes.body?.data?.body || "", /Release notes from the test GitHub endpoint/);
|
|
1027
|
-
assert.equal(releaseNotes.body?.data?.url, `https://github.com/earendil-works/pi/releases/tag/v${
|
|
1035
|
+
assert.equal(releaseNotes.body?.data?.url, `https://github.com/earendil-works/pi/releases/tag/v${expectedReleaseVersion}`);
|
|
1028
1036
|
assert.equal(releaseNotes.headers.get("cache-control"), "private, no-store", "browser caches should not retain notes across Pi upgrades");
|
|
1029
1037
|
const cachedReleaseNotes = await request("127.0.0.1", "/api/pi-release-notes");
|
|
1030
|
-
assert.equal(cachedReleaseNotes.body?.data?.tagName, `v${
|
|
1031
|
-
assert.equal(voiceProviderRequests.filter((item) => item.url === `/pi-releases/v${
|
|
1032
|
-
|
|
1038
|
+
assert.equal(cachedReleaseNotes.body?.data?.tagName, `v${expectedReleaseVersion}`);
|
|
1039
|
+
assert.equal(voiceProviderRequests.filter((item) => item.url === `/pi-releases/v${expectedReleaseVersion}`).length, 1, "the selected Pi release should be fetched only once");
|
|
1040
|
+
if (!updateStatus.body?.data?.pi?.updateAvailable) {
|
|
1041
|
+
assert.equal(voiceProviderRequests.filter((item) => item.url === `/pi-releases/v${latestPiVersion}`).length, 0,
|
|
1042
|
+
"an unproven PATH Pi must not be presented as updatable");
|
|
1043
|
+
}
|
|
1033
1044
|
|
|
1034
1045
|
// Static assets: brotli/gzip compression plus ETag revalidation (P0-2).
|
|
1035
1046
|
const brotliResponse = await fetch(`http://127.0.0.1:${port}/app.js`, {
|
|
@@ -4005,6 +4016,17 @@ try {
|
|
|
4005
4016
|
assert.equal(initialAuth.status, 200);
|
|
4006
4017
|
assert.equal(initialAuth.body?.data?.auth?.enabled, false, "remote PIN auth should be off by default");
|
|
4007
4018
|
|
|
4019
|
+
const combinedUpdatePlan = await request("127.0.0.1", "/api/update/plan", {
|
|
4020
|
+
method: "POST", body: { targets: ["pi", "webui"] },
|
|
4021
|
+
});
|
|
4022
|
+
assert.equal(combinedUpdatePlan.status, 400, "a combined action must not reach native shell planning");
|
|
4023
|
+
const missingNativeJob = await request("127.0.0.1", "/api/update/apply", {
|
|
4024
|
+
method: "POST", body: { transactionId: "missing-fixture-job", planDigest: "a".repeat(64) },
|
|
4025
|
+
});
|
|
4026
|
+
assert.equal(missingNativeJob.status, 404, "native apply must require a server-owned confirmed job");
|
|
4027
|
+
const nativeRollback = await request("127.0.0.1", "/api/update/rollback", { method: "POST", body: {} });
|
|
4028
|
+
assert.equal(nativeRollback.status, 410, "native updates cannot claim managed-pointer rollback");
|
|
4029
|
+
|
|
4008
4030
|
const lan = lanAddress();
|
|
4009
4031
|
if (lan) {
|
|
4010
4032
|
const remoteHealthBeforeAuth = await request(lan, "/api/health");
|
|
@@ -4016,11 +4038,11 @@ try {
|
|
|
4016
4038
|
const remoteUpdatePlan = await request(lan, "/api/update/plan", { method: "POST", body: { targets: ["pi"] } });
|
|
4017
4039
|
assert.equal(remoteUpdatePlan.status, 403, "update plans must be localhost-only before target resolution");
|
|
4018
4040
|
const remoteUpdateApply = await request(lan, "/api/update/apply", { method: "POST", body: { transactionId: "remote", planDigest: "a".repeat(64) } });
|
|
4019
|
-
assert.equal(remoteUpdateApply.status, 403, "update apply must be localhost-only before
|
|
4041
|
+
assert.equal(remoteUpdateApply.status, 403, "update apply must be localhost-only before native job lookup");
|
|
4020
4042
|
const remoteUpdateTransaction = await request(lan, "/api/update/transactions/remote");
|
|
4021
4043
|
assert.equal(remoteUpdateTransaction.status, 403, "update transaction receipts must be localhost-only");
|
|
4022
4044
|
const remoteUpdateRollback = await request(lan, "/api/update/rollback", { method: "POST", body: { transactionId: "remote", planDigest: "a".repeat(64) } });
|
|
4023
|
-
assert.equal(remoteUpdateRollback.status, 403, "
|
|
4045
|
+
assert.equal(remoteUpdateRollback.status, 403, "retired rollback must remain localhost-only before a 410 response");
|
|
4024
4046
|
|
|
4025
4047
|
const remoteWorkflowPolicySave = await request(lan, "/api/workflow-policy", {
|
|
4026
4048
|
method: "POST",
|
|
@@ -4257,6 +4279,7 @@ try {
|
|
|
4257
4279
|
}
|
|
4258
4280
|
await rmWithRetry(cwd);
|
|
4259
4281
|
await rmWithRetry(harnessSideEffectsRoot);
|
|
4282
|
+
await rmWithRetry(coordinationHome);
|
|
4260
4283
|
}
|
|
4261
4284
|
|
|
4262
4285
|
console.log("http-endpoints-harness.test.mjs passed");
|
|
@@ -1073,7 +1073,8 @@ assert.match(server, /cwdExplicit: false/, "server should track whether startup
|
|
|
1073
1073
|
assert.match(server, /return options\.cwdExplicit \? \[await createTab\(\)\] : \[\]/, "server should wait for UI cwd selection when no --cwd is supplied");
|
|
1074
1074
|
assert.match(server, /async function resolvedPiCliScript\(\)[\s\S]*require\.resolve\.paths\(PI_CODING_AGENT_PACKAGE\)[\s\S]*nodeModulesRoot[\s\S]*dist[\s\S]*cli\.js/, "server should resolve the bundled Pi CLI through Node resolution roots so hoisted global installs can spawn RPC tabs");
|
|
1075
1075
|
assert.match(server, /canonicalPiRuntimeIdentity[\s\S]*bundledCli: await resolvedPiCliScript\(\)/, "standalone server should use the canonical resolver with the bundled Pi CLI before PATH pi");
|
|
1076
|
-
assert.match(server, /resolveCanonicalPiRuntime\([\s\S]*explicitCommand: options\.piBinExplicit \? options\.piBin : ""[\s\S]*bundledCli/, "
|
|
1076
|
+
assert.match(server, /resolveCanonicalPiRuntime\([\s\S]*explicitCommand: options\.piBinExplicit \? options\.piBin : ""[\s\S]*bundledCli/, "tabs should retain their explicit or bundled Pi selection independently of updates");
|
|
1077
|
+
assert.match(server, /resolveUpdatePathPi\(\{ runVersion: runCommand \}\)/, "native Pi updates should verify the separate PATH Pi identity");
|
|
1077
1078
|
assert.match(app, /serverActionSelect\.addEventListener\("change", updateServerActionButton\)/, "Server action dropdown should control the guarded run button");
|
|
1078
1079
|
assert.match(app, /runServerActionButton\.addEventListener\("click"[\s\S]*runSelectedServerAction/, "Server action run button should execute the selected action");
|
|
1079
1080
|
assert.match(app, /api\("\/api\/restart", \{ method: "POST", scoped: false \}\)/, "Restart Server action should call the unscoped restart endpoint");
|
|
@@ -1083,14 +1084,16 @@ assert.match(app, /api\("\/api\/shutdown", \{ method: "POST", scoped: false \}\)
|
|
|
1083
1084
|
assert.match(server, /url\.pathname === "\/api\/restart" && req\.method === "POST"/, "server should expose restart endpoint");
|
|
1084
1085
|
assert.match(server, /PI_WEBUI_RESTORE_FILE: restore\.file/, "server restart should pass tab metadata through a private read-once restore file");
|
|
1085
1086
|
assert.match(server, /if \(webuiDevServer\) env\.PI_WEBUI_DEV = "1";/, "server restart should explicitly preserve dev mode");
|
|
1086
|
-
assert.match(server, /url\.pathname === "\/api\/update\/plan"[\s\S]*
|
|
1087
|
-
assert.match(server, /url\.pathname === "\/api\/update\/apply"[\s\S]*validateUpdateApplyRequest[\s\S]*
|
|
1087
|
+
assert.match(server, /url\.pathname === "\/api\/update\/plan"[\s\S]*validateUpdatePlanRequest[\s\S]*createNativeServerPlan/, "server should expose single-action native update planning");
|
|
1088
|
+
assert.match(server, /url\.pathname === "\/api\/update\/apply"[\s\S]*validateUpdateApplyRequest[\s\S]*applyNativeServerPlan/, "server should apply only a confirmed native transaction id and digest");
|
|
1089
|
+
assert.match(server, /updateTransactionRoute && req\.method === "GET"[\s\S]*finalizeNativeJob\(updateTransactionRoute\[1\]\)/, "native job status should reconnect to the same transaction");
|
|
1088
1090
|
assert.match(server, /Legacy update mutation is disabled/, "divergent legacy update mutation routes should fail closed");
|
|
1089
1091
|
assert.doesNotMatch(server, /function resolveUpdateTasks|function projectPackageRootUpdateTasks|function npmGlobalPackageRootUpdateTask|function bunGlobalPackageRootUpdateTask/, "broad heuristic package-root mutation should be removed");
|
|
1090
|
-
assert.match(app, /
|
|
1092
|
+
assert.match(app, /componentUpdateConfirmationText\(plan\)[\s\S]*item\.installedRoot[\s\S]*item\.effectRoot[\s\S]*plan\.warning[\s\S]*Plan digest: \$\{plan\.digest\}/, "frontend should confirm affected installations and bound plan digest");
|
|
1091
1093
|
assert.match(app, /api\("\/api\/update\/apply", \{ method: "POST", body: \{ transactionId: plan\.transactionId, planDigest: plan\.digest \}/, "frontend should apply only the confirmed transaction and digest");
|
|
1092
|
-
assert.match(html, /<option value="update-
|
|
1093
|
-
assert.
|
|
1094
|
+
assert.match(html, /<option value="update-webui">Update Web UI<\/option>/, "side panel should offer Web UI separately from Pi");
|
|
1095
|
+
assert.doesNotMatch(html, /update-all|Update all/, "combined update action should be removed");
|
|
1096
|
+
assert.match(readme, /Update Pi[\s\S]*Update Web UI[\s\S]*lifecycle scripts/, "README should explain independent updates and the lifecycle warning");
|
|
1094
1097
|
assert.match(server, /async function closeNetworkAccess\(\)/, "server should expose a local-only rebind helper for closing network access");
|
|
1095
1098
|
assert.match(server, /url\.pathname === "\/api\/network\/close" && req\.method === "POST"/, "server should route network close requests");
|
|
1096
1099
|
assert.match(server, /server\.closeAllConnections\?\.\(\)/, "network rebind should force-close long-lived clients so close-to-localhost can complete");
|