@firstpick/pi-package-webui 0.8.5 → 0.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -584
- package/bin/pi-webui-launcher.mjs +22 -0
- package/bin/pi-webui-update-supervisor.mjs +86 -0
- package/bin/pi-webui.mjs +933 -554
- package/index.ts +16 -6
- package/lib/component-update-state.mjs +21 -0
- package/lib/git-workflow-preferences.mjs +20 -2
- package/lib/optional-feature-catalog.mjs +1 -0
- package/lib/sampling-parameter-capabilities.mjs +160 -0
- package/lib/session-summary-core.mjs +4 -3
- package/lib/session-summary-preferences.mjs +16 -1
- package/lib/subagent-launch-slots.mjs +14 -2
- package/lib/trust-boundaries.mjs +16 -0
- package/lib/update/executor.mjs +99 -0
- package/lib/update/journal.mjs +175 -0
- package/lib/update/owners.mjs +70 -0
- package/lib/update/plan.mjs +134 -0
- package/lib/update/resolver.mjs +168 -0
- package/lib/update/supervisor.mjs +238 -0
- package/lib/update/verify.mjs +52 -0
- package/lib/update-commands.mjs +25 -13
- package/lib/webui-workspaces.mjs +17 -1
- package/lib/workspace-session-summaries.mjs +400 -0
- package/package.json +4 -4
- package/public/app.js +2487 -349
- package/public/index.html +200 -51
- package/public/middle-button-drag-scroll.mjs +154 -0
- package/public/sampling-parameter-controls.mjs +361 -0
- package/public/service-worker.js +5 -1
- package/public/stream-output-controller.mjs +327 -0
- package/public/styles.css +666 -71
- package/public/theme-contract.mjs +244 -0
- package/session-summary.ts +164 -4
- package/tests/aur-review-widget-static.test.mjs +2 -1
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/control-deck-component-updates.spec.mjs +20 -22
- package/tests/browser/interaction-continuity.spec.mjs +2 -2
- package/tests/browser/middle-button-drag-scroll.spec.mjs +145 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +68 -23
- package/tests/browser/sampling-tooltip.spec.mjs +228 -0
- package/tests/browser/session-summary.spec.mjs +131 -3
- package/tests/browser/stream-output-isolation.spec.mjs +510 -0
- package/tests/browser/update-reconnect.spec.mjs +92 -0
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/common-options-submenus-interaction-static.test.mjs +172 -0
- package/tests/common-options-submenus-markup-static.test.mjs +152 -0
- package/tests/component-update-api-static.test.mjs +22 -61
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/control-deck-component-updates-static.test.mjs +13 -237
- package/tests/durable-rpc-supervisor-harness.test.mjs +3 -1
- package/tests/fast-mode-client-static.test.mjs +3 -2
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/feature-system-prompt-optional-feature-static.test.mjs +49 -0
- package/tests/fixtures/fake-pi.mjs +269 -2
- package/tests/fixtures/update/tree-timeout-descendant.mjs +6 -0
- package/tests/fixtures/update/tree-timeout-parent.mjs +11 -0
- package/tests/git-footer-context-menu-static.test.mjs +58 -0
- package/tests/git-workflow-preferences.test.mjs +7 -1
- package/tests/guided-git-aur-review.test.mjs +4 -3
- package/tests/http-endpoints-harness.test.mjs +274 -23
- package/tests/middle-button-drag-scroll-static.test.mjs +24 -0
- package/tests/middle-button-drag-scroll.test.mjs +170 -0
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +5 -6
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +85 -50
- package/tests/native-parity.test.mjs +1 -1
- package/tests/open-issue-wizard-static.test.mjs +2 -3
- package/tests/optional-feature-migration-frontend.test.mjs +9 -5
- package/tests/persistent-ui-layout-static.test.mjs +13 -2
- package/tests/questionnaire-dialog.test.mjs +3 -3
- package/tests/remote-auth-settings-harness.test.mjs +43 -0
- package/tests/rpc-supervisor-host.test.mjs +11 -2
- package/tests/safety-guard-auto-review-harness.test.mjs +117 -0
- package/tests/safety-guard-auto-review-static.test.mjs +34 -0
- package/tests/sampling-native-controls-user-flow.test.mjs +752 -0
- package/tests/sampling-parameter-capabilities.test.mjs +167 -0
- package/tests/sampling-parameter-controls.test.mjs +241 -0
- package/tests/session-sampling-helper.test.mjs +228 -0
- package/tests/session-sampling-http.test.mjs +168 -0
- package/tests/session-sampling-ui-static.test.mjs +370 -0
- package/tests/session-summary-core.test.mjs +205 -10
- package/tests/side-panel-section-height-removal-static.test.mjs +34 -0
- package/tests/side-panel-section-reorder-static.test.mjs +3 -3
- package/tests/staged-content-hash-contract.test.mjs +52 -11
- package/tests/stream-lifecycle-core.test.mjs +134 -0
- package/tests/stream-output-controller.test.mjs +252 -0
- package/tests/stream-output-isolation-static.test.mjs +89 -0
- package/tests/streaming-ui-coupling.test.mjs +50 -0
- package/tests/subagent-gate-visibility.test.mjs +1 -1
- package/tests/subagent-launch-slots-static.test.mjs +1 -1
- package/tests/subagent-launch-slots.test.mjs +18 -1
- package/tests/theme-contract.test.mjs +104 -0
- package/tests/theme-customizer-static.test.mjs +82 -0
- package/tests/theme-scheme-mode.test.mjs +15 -0
- package/tests/ui-layout-settings.test.mjs +18 -1
- package/tests/update-api-harness.test.mjs +111 -0
- package/tests/update-commands.test.mjs +15 -45
- package/tests/update-executor-process-tree-harness.test.mjs +22 -0
- package/tests/update-journal-harness.test.mjs +59 -0
- package/tests/update-lock-multiprocess-harness.test.mjs +46 -0
- package/tests/update-owners.test.mjs +27 -0
- package/tests/update-plan.test.mjs +58 -0
- package/tests/update-resolver.test.mjs +56 -0
- package/tests/update-supervisor-harness.test.mjs +57 -0
- package/tests/update-tab-restore-harness.test.mjs +24 -0
- package/tests/update-verify.test.mjs +31 -0
- package/tests/workspace-files-live-updates-static.test.mjs +13 -4
- package/tests/workspace-session-summaries.test.mjs +288 -0
- package/webui-rpc-helper.mjs +119 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { readRuntimePointer } from "../lib/update/supervisor.mjs";
|
|
7
|
+
|
|
8
|
+
const bootstrapRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
9
|
+
const bootstrapServer = path.join(bootstrapRoot, "bin", "pi-webui.mjs");
|
|
10
|
+
const agentDir = process.env.PI_CODING_AGENT_DIR || path.join(homedir(), ".pi", "agent");
|
|
11
|
+
const pointer = await readRuntimePointer(agentDir, "current");
|
|
12
|
+
const serverEntry = pointer?.serverEntry || bootstrapServer;
|
|
13
|
+
const child = spawn(process.execPath, [serverEntry, ...process.argv.slice(2)], {
|
|
14
|
+
cwd: process.cwd(), env: process.env, stdio: "inherit", windowsHide: true,
|
|
15
|
+
});
|
|
16
|
+
child.once("error", (error) => { console.error(`Pi Web UI launcher failed: ${error.message || error}`); process.exitCode = 1; });
|
|
17
|
+
child.once("exit", (code, signal) => {
|
|
18
|
+
if (signal) {
|
|
19
|
+
try { process.kill(process.pid, signal); } catch { process.exitCode = 1; }
|
|
20
|
+
} else process.exitCode = code ?? 1;
|
|
21
|
+
});
|
|
22
|
+
for (const signal of ["SIGINT", "SIGTERM"]) process.on(signal, () => { try { child.kill(signal); } catch {} });
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { rollbackRuntimePointer, switchRuntimePointer } from "../lib/update/supervisor.mjs";
|
|
6
|
+
import { releaseInstallLock, transitionUpdateJournal, updateStatePaths } from "../lib/update/journal.mjs";
|
|
7
|
+
|
|
8
|
+
function args(argv) {
|
|
9
|
+
const result = {};
|
|
10
|
+
for (let i = 0; i < argv.length; i += 2) {
|
|
11
|
+
const key = argv[i], value = argv[i + 1];
|
|
12
|
+
if (!key?.startsWith("--") || !value) throw new Error("Activation helper requires paired --key value arguments.");
|
|
13
|
+
result[key.slice(2)] = value;
|
|
14
|
+
}
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
function integer(value, name) {
|
|
18
|
+
const parsed = Number.parseInt(value, 10);
|
|
19
|
+
if (!Number.isInteger(parsed) || parsed <= 0) throw new Error(`${name} is invalid`);
|
|
20
|
+
return parsed;
|
|
21
|
+
}
|
|
22
|
+
async function health(url, expectedVersion, expectedPiVersion, oldBootIdentity) {
|
|
23
|
+
try {
|
|
24
|
+
const response = await fetch(`${url.replace(/\/$/, "")}/api/health`, { signal: AbortSignal.timeout(1_500) });
|
|
25
|
+
const body = await response.json();
|
|
26
|
+
return response.ok
|
|
27
|
+
&& body?.ok === true
|
|
28
|
+
&& (!expectedVersion || body.webuiVersion === expectedVersion)
|
|
29
|
+
&& (!expectedPiVersion || body.piVersion === expectedPiVersion)
|
|
30
|
+
&& body.bootIdentity
|
|
31
|
+
&& body.bootIdentity !== oldBootIdentity ? body : null;
|
|
32
|
+
} catch { return null; }
|
|
33
|
+
}
|
|
34
|
+
async function waitForHealth(url, expectedVersion, expectedPiVersion, oldBootIdentity, timeoutMs) {
|
|
35
|
+
const deadline = Date.now() + timeoutMs;
|
|
36
|
+
while (Date.now() < deadline) {
|
|
37
|
+
const body = await health(url, expectedVersion, expectedPiVersion, oldBootIdentity);
|
|
38
|
+
if (body) return body;
|
|
39
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
function launch(launcher, serverArgs, env) {
|
|
44
|
+
const child = spawn(process.execPath, [launcher, ...serverArgs], { cwd: process.cwd(), env, detached: true, stdio: "ignore", windowsHide: true });
|
|
45
|
+
child.unref();
|
|
46
|
+
return child.pid;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const options = args(process.argv.slice(2));
|
|
50
|
+
const agentDir = path.resolve(options["agent-dir"] || "");
|
|
51
|
+
const runtimeRoot = path.resolve(options["runtime-root"] || "");
|
|
52
|
+
const serverEntry = path.resolve(options["server-entry"] || "");
|
|
53
|
+
const version = String(options.version || "");
|
|
54
|
+
const piVersion = String(options["pi-version"] || "");
|
|
55
|
+
const outcome = String(options.outcome || "success");
|
|
56
|
+
const transactionId = String(options.transaction || "");
|
|
57
|
+
const url = String(options.url || "");
|
|
58
|
+
const oldBootIdentity = String(options["old-boot"] || "");
|
|
59
|
+
const timeoutMs = integer(options["timeout-ms"] || "90000", "timeout");
|
|
60
|
+
const serverArgs = JSON.parse(Buffer.from(options["server-args"] || "", "base64url").toString("utf8"));
|
|
61
|
+
if (!Array.isArray(serverArgs) || !agentDir || !runtimeRoot || !serverEntry || !version || !piVersion || !url || !transactionId || !new Set(["success", "partial"]).has(outcome)) throw new Error("Activation helper arguments are incomplete.");
|
|
62
|
+
const launcher = path.join(path.dirname(fileURLToPath(import.meta.url)), "pi-webui-launcher.mjs");
|
|
63
|
+
|
|
64
|
+
const lockToken = String(process.env.PI_WEBUI_UPDATE_LOCK_TOKEN || "");
|
|
65
|
+
delete process.env.PI_WEBUI_UPDATE_LOCK_TOKEN;
|
|
66
|
+
const transferredLock = lockToken ? { path: updateStatePaths(agentDir).installLock, token: lockToken } : null;
|
|
67
|
+
let exitCode = 1;
|
|
68
|
+
try {
|
|
69
|
+
await transitionUpdateJournal(agentDir, transactionId, "activating", { activation: { runtimeRoot, serverEntry, expectedVersion: version } });
|
|
70
|
+
await switchRuntimePointer(agentDir, { runtimeRoot, serverEntry, version });
|
|
71
|
+
launch(launcher, serverArgs, { ...process.env, PI_WEBUI_ACTIVATION_TRANSACTION: transactionId });
|
|
72
|
+
const activated = await waitForHealth(url, version, piVersion, oldBootIdentity, timeoutMs);
|
|
73
|
+
if (activated) {
|
|
74
|
+
await transitionUpdateJournal(agentDir, transactionId, outcome, { outcome, activated: { version, piVersion, bootIdentity: activated.bootIdentity, at: new Date().toISOString() } });
|
|
75
|
+
exitCode = 0;
|
|
76
|
+
} else {
|
|
77
|
+
await rollbackRuntimePointer(agentDir);
|
|
78
|
+
launch(launcher, serverArgs, { ...process.env, PI_WEBUI_ACTIVATION_TRANSACTION: transactionId, PI_WEBUI_ROLLBACK_TRANSACTION: transactionId });
|
|
79
|
+
const rolledBack = await waitForHealth(url, "", "", oldBootIdentity, Math.min(timeoutMs, 30_000));
|
|
80
|
+
await transitionUpdateJournal(agentDir, transactionId, "rolled-back", { outcome: "rolled-back", rollback: { reachable: Boolean(rolledBack), at: new Date().toISOString(), reason: "Candidate failed the changed-identity health gate." } });
|
|
81
|
+
exitCode = rolledBack ? 2 : 3;
|
|
82
|
+
}
|
|
83
|
+
} finally {
|
|
84
|
+
if (transferredLock) await releaseInstallLock(transferredLock).catch(() => false);
|
|
85
|
+
}
|
|
86
|
+
process.exit(exitCode);
|