@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.
Files changed (50) hide show
  1. package/DEVELOPMENT.md +95 -15
  2. package/README.md +1 -1
  3. package/TECHNICAL.md +6 -4
  4. package/bin/pi-webui-launcher.mjs +6 -3
  5. package/bin/pi-webui-native-update-guardian.mjs +37 -0
  6. package/bin/pi-webui-native-update-runner.mjs +148 -0
  7. package/bin/pi-webui-rpc-supervisor.mjs +85 -10
  8. package/bin/pi-webui-update-context.mjs +83 -0
  9. package/bin/pi-webui.mjs +537 -339
  10. package/lib/component-update-state.mjs +4 -4
  11. package/lib/rpc-supervisor-client.mjs +4 -0
  12. package/lib/rpc-supervisor-protocol.mjs +17 -4
  13. package/lib/update/coordination.mjs +207 -0
  14. package/lib/update/discovery.mjs +58 -0
  15. package/lib/update/migration.mjs +115 -0
  16. package/lib/update/native-jobs.mjs +215 -0
  17. package/lib/update/native-targets.mjs +81 -0
  18. package/lib/update/path-pi.mjs +76 -0
  19. package/lib/update/supervisor.mjs +50 -29
  20. package/lib/update/verification.mjs +18 -0
  21. package/lib/update-commands.mjs +17 -27
  22. package/package.json +3 -3
  23. package/public/app.js +170 -201
  24. package/public/index.html +5 -3
  25. package/public/styles.css +29 -1
  26. package/tests/browser/control-deck-component-updates.spec.mjs +90 -141
  27. package/tests/browser/update-reconnect.spec.mjs +37 -1
  28. package/tests/component-update-api-static.test.mjs +13 -11
  29. package/tests/control-deck-component-updates-static.test.mjs +25 -25
  30. package/tests/cwd-footer-reliability-static.test.mjs +4 -1
  31. package/tests/http-endpoints-harness.test.mjs +32 -9
  32. package/tests/mobile-static.test.mjs +9 -6
  33. package/tests/native-update-discovery.test.mjs +69 -0
  34. package/tests/native-update-lifecycle.test.mjs +90 -0
  35. package/tests/native-update-shell-survival.test.mjs +68 -0
  36. package/tests/native-update-verification.test.mjs +17 -0
  37. package/tests/rpc-supervisor-host.test.mjs +63 -1
  38. package/tests/rpc-supervisor-protocol.test.mjs +8 -0
  39. package/tests/run-all.mjs +6 -2
  40. package/tests/update-api-harness.test.mjs +57 -50
  41. package/tests/update-commands.test.mjs +29 -15
  42. package/tests/update-executor-process-tree-harness.test.mjs +84 -1
  43. package/tests/update-journal-harness.test.mjs +9 -1
  44. package/tests/update-lock-multiprocess-harness.test.mjs +60 -1
  45. package/tests/update-owners.test.mjs +32 -0
  46. package/tests/update-plan.test.mjs +110 -0
  47. package/tests/update-resolver.test.mjs +36 -0
  48. package/tests/update-supervisor-harness.test.mjs +74 -1
  49. package/tests/update-tab-restore-harness.test.mjs +9 -2
  50. 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", "pi-webui.mjs");
13
- const fakePi = join(root, "tests", "fixtures", "fake-pi.mjs");
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 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));
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:${port}`;
32
- child = spawn(process.execPath, [serverScript, "--cwd", tempRoot, "--host", "127.0.0.1", "--port", String(port), "--pi", fakePi], {
33
- stdio: ["ignore", "pipe", "pipe"],
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
- child.stdout.on("data", (chunk) => { output += String(chunk); });
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(`Pi Web UI did not start:\n${output}`);
34
+ throw new Error("fixture server did not become healthy");
54
35
  });
55
-
56
36
  test.afterAll(async () => {
57
- child?.kill("SIGTERM");
58
- if (child) await new Promise((resolve) => child.once("exit", resolve));
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("component tags and dialogs expose safe background update lifecycle", async ({ page }) => {
46
+ test("Pi and Web UI actions confirm independent native targets and show durable receipts", async ({ page }) => {
63
47
  const requests = [];
64
- let statusPollsAfterStart = 0;
65
- const status = {
66
- updateAvailable: true,
67
- updateInProgress: false,
68
- canRunUpdate: true,
69
- pi: { checked: true, currentVersion: "0.83.0", latestVersion: "0.84.0", updateAvailable: true },
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({ endpoint: "plan", method: route.request().method(), body });
96
- await route.fulfill({ status: 201, contentType: "application/json", body: JSON.stringify({ ok: true, data: { plan } }) });
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", async (route) => {
58
+ await page.route("**/api/update/apply", (route) => {
99
59
  const body = route.request().postDataJSON();
100
- requests.push({ endpoint: "apply", method: route.request().method(), body });
101
- status.updateInProgress = true;
102
- status.componentUpdates.pi = { ...status.componentUpdates.pi, state: "running", canStart: false, message: "Updating Pi…", error: "" };
103
- await route.fulfill({ status: 202, contentType: "application/json", body: JSON.stringify({ ok: true, data: { state: "applying", outcome: "success", receipts: [{ targetId: "pi", status: "success" }] } }) });
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-status*", async (route) => {
106
- if (status.componentUpdates.pi.state === "running") {
107
- statusPollsAfterStart += 1;
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
- const piTag = page.locator("#piVersionButton");
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("#confirmationDialog")).toBeVisible();
148
- await expect(page.locator("#confirmationSummary")).toContainText("Bundled Pi updates are staged with the current Web UI in a side-by-side managed runtime");
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
- assert.deepEqual(requests, [
152
- { endpoint: "plan", method: "POST", body: { targets: ["pi"] } },
153
- { endpoint: "apply", method: "POST", body: { transactionId: plan.transactionId, planDigest: plan.digest } },
154
- ], "the dialog must create one target-only plan and apply only its transaction id plus digest");
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 expect(piDialog).toBeHidden();
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
- status.componentUpdates.webui = {
167
- ...status.componentUpdates.webui,
168
- state: "failed",
169
- canStart: true,
170
- message: "Web UI update failed.",
171
- error: "bounded fixture failure",
172
- };
173
- await webuiTag.click();
174
- await expect(page.locator("#webuiComponentUpdateStatus")).toContainText("bounded fixture failure");
175
- await expect(page.locator("#webuiComponentUpdateStatus")).toContainText("retry the update");
176
- await expect(page.locator("#webuiComponentUpdateButton")).toBeEnabled();
177
- await expect(page.locator("#webuiComponentUpdateButton")).toHaveText("Retry Web UI update");
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, activation, trust] = await Promise.all([
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-supervisor.mjs"), "utf8"),
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 or both exact values/);
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]*applyServerOwnedUpdate/);
18
- assert.match(server, /assertActionableUpdatePlan\(plan\)[\s\S]*createUpdateJournal\(agentDir, plan\)/);
19
- assert.match(server, /assertUpdatePlanDigest\(journal\.plan, planDigest\)[\s\S]*assertActionableUpdatePlan\(journal\.plan\)[\s\S]*acquireInstallLock\(agentDir\)/);
20
- assert.match(server, /assertPlanIdentity\(target, active\)/);
21
- assert.match(server, /probeCandidateRuntime\(serverEntry, \{ expectedVersion: target\.metadata\.webuiVersion, expectedPiVersion: target\.metadata\.piVersion \}\)/);
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.match(server, /optionalFeaturePackageStatuses\(options\.cwd\)[\s\S]*strategy: "pi-owned-optional"[\s\S]*optionalFeature: true/);
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, /readRuntimePointer\(agentDir, "current"\)[\s\S]*pointer\?\.serverEntry \|\| bootstrapServer/);
28
- assert.match(activation, /switchRuntimePointer[\s\S]*waitForHealth[\s\S]*rollbackRuntimePointer/);
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, server, readme] = 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, "bin", "pi-webui.mjs"), "utf8"),
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
- assert.match(html, /id="piComponentUpdateStatus"[^>]*aria-live="polite"/);
15
- assert.match(html, /id="webuiComponentUpdateStatus"[^>]*aria-live="polite"/);
16
- for (const state of ["available", "running", "succeeded", "failed"]) assert.match(css, new RegExp(`data-update-state="${state}"`));
17
- assert.match(app, /api\("\/api\/update\/plan", \{ method: "POST", body: \{ targets: \[target\] \}/);
18
- assert.match(app, /Exact plan digest: \$\{plan\.digest\}/);
19
- assert.match(app, /api\("\/api\/update\/apply", \{ method: "POST", body: \{ transactionId: plan\.transactionId, planDigest: plan\.digest \}/);
20
- assert.match(app, /function piUpdateConfirmationText\(\{ all = false, plan = null \} = \{\}\)[\s\S]*Exact immutable plan digest/);
21
- assert.match(app, /const planTargets = Array\.isArray\(plan\?\.targets\)[\s\S]*planTargets\.length === 0[\s\S]*No update targets were accepted/);
22
- assert.match(app, /applyData\?\.state !== "activating"[\s\S]*completed without a Web UI restart[\s\S]*did not complete; no Web UI restart was requested/);
23
- assert.match(html, /id="serverRestartPanel"[\s\S]*server-restart-spinner[\s\S]*id="serverRestartKicker"[\s\S]*id="serverRestartTitle"/);
24
- assert.match(app, /function setServerRestartOverlay\(active[\s\S]*phase = "restarting"[\s\S]*phase === "updating"[\s\S]*Applying exact update/);
25
- assert.match(app, /async function startComponentUpdate\(target\)[\s\S]*setServerRestartOverlay\(true, `Starting exact \$\{label\} update…`, \{ phase: "updating" \}\)[\s\S]*setServerRestartOverlay\(false\)/);
26
- assert.match(app, /async function runPiUpdateAndRestart[\s\S]*setServerRestartOverlay\(true, progressMessage, \{ phase: "updating" \}\)/);
27
- assert.match(app, /will not re-resolve latest or scan package roots/);
28
- assert.match(app, /function separatePathPiPlanNotice\(plan\)[\s\S]*PATH Pi[\s\S]*separate installation[\s\S]*will remain untouched/);
29
- assert.match(app, /async function waitForServerRestart\(previousBootIdentity = serverBootIdentity\)[\s\S]*Date\.now\(\) \+ 90_000[\s\S]*health\.bootIdentity === previousBootIdentity/);
30
- assert.match(server, /bootIdentity,[\s\S]*startupPhase:/);
31
- assert.match(server, /url\.pathname === "\/api\/update\/rollback"[\s\S]*assertUpdatePlanDigest/);
32
- assert.match(readme, /exact-target plan|plan digest/i);
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, latestPiVersion, "an available update should select the latest Pi release");
1024
- assert.equal(releaseNotes.body?.data?.tagName, `v${latestPiVersion}`);
1025
- assert.equal(releaseNotes.body?.data?.title, `Pi v${latestPiVersion} test release`);
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${latestPiVersion}`);
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${latestPiVersion}`);
1031
- assert.equal(voiceProviderRequests.filter((item) => item.url === `/pi-releases/v${latestPiVersion}`).length, 1, "the server should fetch the available Pi release only once");
1032
- assert.equal(voiceProviderRequests.filter((item) => item.url === `/pi-releases/v${health.body.piVersion}`).length, 0, "the installed Pi release should not be fetched while a newer release is available");
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 journal lookup");
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, "update rollback must be localhost-only before pointer mutation");
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/, "updates should resolve the same canonical explicit or bundled Pi identity used by tabs");
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]*createServerOwnedUpdatePlan/, "server should expose exact server-owned update planning");
1087
- assert.match(server, /url\.pathname === "\/api\/update\/apply"[\s\S]*validateUpdateApplyRequest[\s\S]*applyServerOwnedUpdate/, "server should apply only a transaction id and plan digest");
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, /Exact immutable plan digest:[\s\S]*persisted exact-target plan[\s\S]*will not re-resolve latest or scan package roots/, "frontend confirmation should bind users to the exact plan digest and fail-closed scope");
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-all">/, "side panel should retain a combined update action while routing through exact plans");
1093
- assert.match(readme, /exact-target plan|plan digest/i, "README should document exact update plans");
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");