@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { spawn, spawnSync } from "node:child_process";
|
|
3
3
|
import { createServer } from "node:http";
|
|
4
|
-
import { chmod, link, mkdir, mkdtemp, readFile, rename, rm, stat, symlink, writeFile } from "node:fs/promises";
|
|
4
|
+
import { chmod, link, mkdir, mkdtemp, readFile, readdir, rename, rm, stat, symlink, writeFile } from "node:fs/promises";
|
|
5
5
|
import { networkInterfaces, tmpdir } from "node:os";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { setTimeout as delay } from "node:timers/promises";
|
|
@@ -9,6 +9,7 @@ import { dirname, join } from "node:path";
|
|
|
9
9
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
10
10
|
import { terminateProcessTree } from "../lib/process-tree.mjs";
|
|
11
11
|
import { readSupervisorState, supervisorPaths, supervisorPidIsAlive } from "../lib/rpc-supervisor-state.mjs";
|
|
12
|
+
import { REQUIRED_THEME_TOKENS, serializeTheme } from "../public/theme-contract.mjs";
|
|
12
13
|
|
|
13
14
|
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
14
15
|
const serverScript = join(root, "bin", "pi-webui.mjs");
|
|
@@ -16,6 +17,14 @@ const fakePi = join(root, "tests", "fixtures", "fake-pi.mjs");
|
|
|
16
17
|
const port = 30000 + Math.floor(Math.random() * 20000);
|
|
17
18
|
const optionalFeatureFocus = process.env.PI_WEBUI_OPTIONAL_FEATURES_FOCUS === "1";
|
|
18
19
|
|
|
20
|
+
function themeFixture(name, color = "#123456") {
|
|
21
|
+
return {
|
|
22
|
+
name,
|
|
23
|
+
colors: Object.fromEntries(REQUIRED_THEME_TOKENS.map((token) => [token, color])),
|
|
24
|
+
export: { pageBg: color, cardBg: color, infoBg: color },
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
19
28
|
function lanAddress() {
|
|
20
29
|
for (const entries of Object.values(networkInterfaces())) {
|
|
21
30
|
for (const entry of entries || []) {
|
|
@@ -79,14 +88,14 @@ async function waitForSseEvent(tabId, predicate, trigger) {
|
|
|
79
88
|
|
|
80
89
|
async function rmWithRetry(target) {
|
|
81
90
|
let lastError;
|
|
82
|
-
for (let attempt = 0; attempt <
|
|
91
|
+
for (let attempt = 0; attempt < 20; attempt++) {
|
|
83
92
|
try {
|
|
84
93
|
await rm(target, { recursive: true, force: true });
|
|
85
94
|
return;
|
|
86
95
|
} catch (error) {
|
|
87
96
|
lastError = error;
|
|
88
97
|
if (error?.code !== "EBUSY" && error?.code !== "EPERM" && error?.code !== "ENOTEMPTY") throw error;
|
|
89
|
-
await delay(150 * (attempt + 1));
|
|
98
|
+
await delay(Math.min(500, 150 * (attempt + 1)));
|
|
90
99
|
}
|
|
91
100
|
}
|
|
92
101
|
throw lastError;
|
|
@@ -121,6 +130,8 @@ const cwd = await mkdtemp(path.join(tmpdir(), "pi-webui-http-harness-"));
|
|
|
121
130
|
const harnessSideEffectsRoot = await mkdtemp(path.join(tmpdir(), "pi-webui-http-harness-side-effects-"));
|
|
122
131
|
const settingsFile = path.join(harnessSideEffectsRoot, "webui-settings.json");
|
|
123
132
|
const workflowPolicyAgentDir = path.join(harnessSideEffectsRoot, "agent");
|
|
133
|
+
const managedThemePackageRoot = path.join(workflowPolicyAgentDir, "npm", "node_modules", "@firstpick", "pi-themes-bundle");
|
|
134
|
+
const managedThemeDir = path.join(managedThemePackageRoot, "themes");
|
|
124
135
|
const workflowPolicyFile = path.join(workflowPolicyAgentDir, "workflow-policy.json");
|
|
125
136
|
const sessionSummaryConfigFile = path.join(workflowPolicyAgentDir, "session-summary.json");
|
|
126
137
|
const canonicalWorkflowPolicySuggestions = {
|
|
@@ -140,6 +151,10 @@ await mkdir(artifactDir, { recursive: true });
|
|
|
140
151
|
await writeFile(artifactDownload, Buffer.from("fixture docx download bytes"));
|
|
141
152
|
await writeFile(artifactPage, Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]));
|
|
142
153
|
await writeFile(artifactManifest, JSON.stringify({ artifact: { schema: "pi.artifact/v1", kind: "document", id: "fixture-document-artifact", revisionId: "fixture-revision", title: "fixture.docx", mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", pageCount: 1, manifestPath: artifactManifest, downloadPath: artifactDownload, expiresAt: artifactExpiresAt }, sourcePath: "/private/source.docx", sourceSha256: "a".repeat(64), renderer: { engine: "fixture" }, pages: [{ pageNum: 1, width: 10, height: 20, outputPath: artifactPage }], warnings: [] }));
|
|
154
|
+
await mkdir(managedThemeDir, { recursive: true });
|
|
155
|
+
await writeFile(path.join(managedThemePackageRoot, "package.json"), JSON.stringify({ name: "@firstpick/pi-themes-bundle", version: "0.0.0-test", pi: { themes: ["./themes"] } }));
|
|
156
|
+
await writeFile(path.join(managedThemeDir, "managed-fixture.json"), serializeTheme(themeFixture("managed-fixture")));
|
|
157
|
+
await writeFile(path.join(workflowPolicyAgentDir, "trust.json"), `${JSON.stringify({ [cwd]: true }, null, 2)}\n`);
|
|
143
158
|
await chmod(fakePi, 0o755);
|
|
144
159
|
await mkdir(fakeOpenBinDir, { recursive: true });
|
|
145
160
|
await writeFile(openCommandScript, `#!/usr/bin/env node\nimport { appendFile } from "node:fs/promises";\nawait appendFile(process.env.PI_WEBUI_OPEN_LOG, "custom-open\\t" + process.argv.slice(2).join("\\t") + "\\n", "utf8");\n`, "utf8");
|
|
@@ -155,7 +170,9 @@ const args = process.argv.slice(2);
|
|
|
155
170
|
const log = async (entry) => appendFile(process.env.FAKE_PI_CLI_LOG, JSON.stringify({ at: Date.now(), ...entry }) + "\\n", "utf8");
|
|
156
171
|
process.on("SIGTERM", () => process.exit(143));
|
|
157
172
|
process.on("SIGINT", () => process.exit(130));
|
|
158
|
-
if (args[0] === "
|
|
173
|
+
if (args[0] === "--version") {
|
|
174
|
+
console.log("0.84.0");
|
|
175
|
+
} else if (args[0] === "install") {
|
|
159
176
|
const source = String(args[1] || "");
|
|
160
177
|
await log({ event: "start", args });
|
|
161
178
|
if (source === "npm:@firstpick/pi-extension-stats") {
|
|
@@ -186,6 +203,7 @@ if (args[0] === "install") {
|
|
|
186
203
|
`, "utf8");
|
|
187
204
|
await chmod(fakePiCli, 0o755);
|
|
188
205
|
|
|
206
|
+
const latestPiVersion = "999.0.0";
|
|
189
207
|
const voiceProviderRequests = [];
|
|
190
208
|
const voiceProvider = createServer(async (req, res) => {
|
|
191
209
|
const chunks = [];
|
|
@@ -202,6 +220,11 @@ const voiceProvider = createServer(async (req, res) => {
|
|
|
202
220
|
res.end(Buffer.from("fake mp3 bytes"));
|
|
203
221
|
return;
|
|
204
222
|
}
|
|
223
|
+
if (req.url === "/pi-latest") {
|
|
224
|
+
res.writeHead(200, { "content-type": "application/json" });
|
|
225
|
+
res.end(JSON.stringify({ version: latestPiVersion, packageName: "@earendil-works/pi-coding-agent" }));
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
205
228
|
if (req.url?.startsWith("/pi-releases/")) {
|
|
206
229
|
const tagName = decodeURIComponent(req.url.slice("/pi-releases/".length));
|
|
207
230
|
res.writeHead(200, { "content-type": "application/json" });
|
|
@@ -244,6 +267,7 @@ const child = spawn(process.execPath, [serverScript, "--cwd", cwd, "--host", "0.
|
|
|
244
267
|
PI_WEBUI_RECOVERY_TOKEN: recoveryEndpointToken,
|
|
245
268
|
PI_VOICE_STT_URL: `http://127.0.0.1:${voiceProviderPort}/stt`,
|
|
246
269
|
PI_VOICE_TTS_URL: `http://127.0.0.1:${voiceProviderPort}/tts`,
|
|
270
|
+
PI_WEBUI_PI_LATEST_VERSION_URL: `http://127.0.0.1:${voiceProviderPort}/pi-latest`,
|
|
247
271
|
PI_WEBUI_PI_RELEASES_API_BASE_URL: `http://127.0.0.1:${voiceProviderPort}/pi-releases`,
|
|
248
272
|
},
|
|
249
273
|
});
|
|
@@ -301,7 +325,7 @@ async function runOptionalFeatureFocus() {
|
|
|
301
325
|
|
|
302
326
|
const initial = await request("127.0.0.1", "/api/optional-features");
|
|
303
327
|
assert.equal(initial.status, 200);
|
|
304
|
-
assert.equal(initial.body?.data?.features?.length,
|
|
328
|
+
assert.equal(initial.body?.data?.features?.length, 20);
|
|
305
329
|
const aurBefore = initial.body?.data?.features?.find(({ featureId }) => featureId === "aurReview");
|
|
306
330
|
assert.deepEqual({ installed: aurBefore?.installed, configured: aurBefore?.configured, ready: aurBefore?.ready }, { installed: true, configured: false, ready: false });
|
|
307
331
|
assert.equal(aurBefore?.expectedSpec, "^0.1.1");
|
|
@@ -441,12 +465,220 @@ try {
|
|
|
441
465
|
assert.equal(health.body.piRunning, true, "fake pi RPC process should be attached and running");
|
|
442
466
|
assert.match(health.body.piVersion, /^\d+\.\d+\.\d+/, "health metadata should expose the installed Pi version");
|
|
443
467
|
|
|
468
|
+
const managedThemesResponse = await request("127.0.0.1", "/api/themes");
|
|
469
|
+
assert.equal(managedThemesResponse.status, 200, managedThemesResponse.body?.error);
|
|
470
|
+
assert.equal(managedThemesResponse.body?.data?.source, "@firstpick/pi-themes-bundle");
|
|
471
|
+
assert.deepEqual(managedThemesResponse.body?.data?.themes?.map(({ name }) => name), ["managed-fixture"], "themes installed only under PI_CODING_AGENT_DIR/npm/node_modules should be exposed to the browser");
|
|
472
|
+
assert.equal(managedThemesResponse.body?.data?.themes?.[0]?.colors?.accent, "#123456");
|
|
473
|
+
assert.equal(managedThemesResponse.body?.data?.themes?.[0]?.scope, "bundled");
|
|
474
|
+
|
|
475
|
+
const themeTabs = await request("127.0.0.1", "/api/tabs");
|
|
476
|
+
const themeTabId = themeTabs.body?.data?.tabs?.[0]?.id;
|
|
477
|
+
assert.ok(themeTabId, "custom theme endpoint checks require the startup tab");
|
|
478
|
+
const customThemePath = `/api/themes/custom?tab=${encodeURIComponent(themeTabId)}`;
|
|
479
|
+
const globalTheme = themeFixture("global-fixture", "#224466");
|
|
480
|
+
const createdGlobalTheme = await request("127.0.0.1", customThemePath, {
|
|
481
|
+
method: "POST",
|
|
482
|
+
body: { scope: "global", fileName: "global-fixture.json", theme: globalTheme, overwrite: false, expectedMtimeMs: null },
|
|
483
|
+
});
|
|
484
|
+
assert.equal(createdGlobalTheme.status, 201, createdGlobalTheme.body?.error);
|
|
485
|
+
assert.deepEqual({ created: createdGlobalTheme.body?.data?.created, overwritten: createdGlobalTheme.body?.data?.overwritten }, { created: true, overwritten: false });
|
|
486
|
+
assert.equal(Object.hasOwn(createdGlobalTheme.body?.data || {}, "path"), false, "theme save responses must not disclose host paths");
|
|
487
|
+
const globalThemeFile = path.join(workflowPolicyAgentDir, "themes", "global-fixture.json");
|
|
488
|
+
assert.equal(await readFile(globalThemeFile, "utf8"), serializeTheme(globalTheme), "global themes must use canonical Pi JSON bytes");
|
|
489
|
+
if (process.platform !== "win32") assert.equal((await stat(globalThemeFile)).mode & 0o777, 0o600, "saved themes must have private permissions");
|
|
490
|
+
|
|
491
|
+
const projectTheme = themeFixture("project-fixture", "#335577");
|
|
492
|
+
const createdProjectTheme = await request("127.0.0.1", customThemePath, {
|
|
493
|
+
method: "POST",
|
|
494
|
+
headers: { "Sec-Fetch-Site": "same-site" },
|
|
495
|
+
body: { scope: "project", fileName: "project-fixture.json", theme: projectTheme, overwrite: false, expectedMtimeMs: null },
|
|
496
|
+
});
|
|
497
|
+
assert.equal(createdProjectTheme.status, 201, createdProjectTheme.body?.error);
|
|
498
|
+
assert.equal(await readFile(path.join(cwd, ".pi", "themes", "project-fixture.json"), "utf8"), serializeTheme(projectTheme));
|
|
499
|
+
|
|
500
|
+
const customCatalog = await request("127.0.0.1", `/api/themes?tab=${encodeURIComponent(themeTabId)}`);
|
|
501
|
+
assert.equal(customCatalog.status, 200);
|
|
502
|
+
assert.deepEqual(customCatalog.body?.data?.themes?.map(({ name }) => name), ["managed-fixture", "global-fixture", "project-fixture"]);
|
|
503
|
+
assert.deepEqual(customCatalog.body?.data?.themes?.map(({ scope }) => scope), ["bundled", "global", "project"]);
|
|
504
|
+
assert.equal(customCatalog.body?.data?.scopes?.project?.trusted, true);
|
|
505
|
+
|
|
506
|
+
const bundledCollision = await request("127.0.0.1", customThemePath, {
|
|
507
|
+
method: "POST",
|
|
508
|
+
body: { scope: "global", fileName: "managed-fixture.json", theme: themeFixture("managed-fixture"), overwrite: false, expectedMtimeMs: null },
|
|
509
|
+
});
|
|
510
|
+
assert.equal(bundledCollision.status, 409);
|
|
511
|
+
assert.equal(bundledCollision.body?.code, "THEME_NAME_COLLISION");
|
|
512
|
+
const oppositeScopeCollision = await request("127.0.0.1", customThemePath, {
|
|
513
|
+
method: "POST",
|
|
514
|
+
body: { scope: "global", fileName: "project-fixture.json", theme: projectTheme, overwrite: false, expectedMtimeMs: null },
|
|
515
|
+
});
|
|
516
|
+
assert.equal(oppositeScopeCollision.status, 409);
|
|
517
|
+
assert.equal(oppositeScopeCollision.body?.code, "THEME_NAME_COLLISION");
|
|
518
|
+
|
|
519
|
+
const existingGlobalTheme = await request("127.0.0.1", customThemePath, {
|
|
520
|
+
method: "POST",
|
|
521
|
+
body: { scope: "global", fileName: "global-fixture.json", theme: globalTheme, overwrite: false, expectedMtimeMs: null },
|
|
522
|
+
});
|
|
523
|
+
assert.equal(existingGlobalTheme.status, 409);
|
|
524
|
+
assert.equal(existingGlobalTheme.body?.code, "THEME_EXISTS");
|
|
525
|
+
assert.deepEqual(
|
|
526
|
+
{ scope: existingGlobalTheme.body?.details?.scope, fileName: existingGlobalTheme.body?.details?.fileName },
|
|
527
|
+
{ scope: "global", fileName: "global-fixture.json" },
|
|
528
|
+
);
|
|
529
|
+
assert.equal(typeof existingGlobalTheme.body?.details?.mtimeMs, "number");
|
|
530
|
+
await delay(25);
|
|
531
|
+
await writeFile(globalThemeFile, serializeTheme(themeFixture("global-fixture", "#446688")), { mode: 0o600 });
|
|
532
|
+
const staleOverwrite = await request("127.0.0.1", customThemePath, {
|
|
533
|
+
method: "POST",
|
|
534
|
+
body: { scope: "global", fileName: "global-fixture.json", theme: globalTheme, overwrite: true, expectedMtimeMs: existingGlobalTheme.body.details.mtimeMs },
|
|
535
|
+
});
|
|
536
|
+
assert.equal(staleOverwrite.status, 409);
|
|
537
|
+
assert.equal(staleOverwrite.body?.code, "THEME_CHANGED");
|
|
538
|
+
assert.equal(await readFile(globalThemeFile, "utf8"), serializeTheme(themeFixture("global-fixture", "#446688")), "a stale overwrite must preserve current bytes");
|
|
539
|
+
const refreshedConflict = await request("127.0.0.1", customThemePath, {
|
|
540
|
+
method: "POST",
|
|
541
|
+
body: { scope: "global", fileName: "global-fixture.json", theme: globalTheme, overwrite: false, expectedMtimeMs: null },
|
|
542
|
+
});
|
|
543
|
+
const overwrittenGlobalTheme = await request("127.0.0.1", customThemePath, {
|
|
544
|
+
method: "POST",
|
|
545
|
+
body: { scope: "global", fileName: "global-fixture.json", theme: globalTheme, overwrite: true, expectedMtimeMs: refreshedConflict.body?.details?.mtimeMs },
|
|
546
|
+
});
|
|
547
|
+
assert.equal(overwrittenGlobalTheme.status, 200, overwrittenGlobalTheme.body?.error);
|
|
548
|
+
assert.deepEqual({ created: overwrittenGlobalTheme.body?.data?.created, overwritten: overwrittenGlobalTheme.body?.data?.overwritten }, { created: false, overwritten: true });
|
|
549
|
+
assert.equal(await readFile(globalThemeFile, "utf8"), serializeTheme(globalTheme));
|
|
550
|
+
assert.equal((await readdir(path.dirname(globalThemeFile))).some((name) => name.endsWith(".tmp")), false, "atomic theme saves must clean temporary artifacts");
|
|
551
|
+
|
|
552
|
+
const rejectedThemeBodies = [
|
|
553
|
+
{ body: { scope: "global", fileName: "bad-name.json", theme: themeFixture("different-name"), overwrite: false, expectedMtimeMs: null }, code: "THEME_NAME_MISMATCH" },
|
|
554
|
+
{ body: { scope: "global", fileName: "path-field.json", theme: themeFixture("path-field"), overwrite: false, expectedMtimeMs: null, path: "/tmp/escape" }, code: "THEME_REQUEST_INVALID" },
|
|
555
|
+
{ body: { scope: "elsewhere", fileName: "scope.json", theme: themeFixture("scope"), overwrite: false, expectedMtimeMs: null }, code: "THEME_SCOPE_INVALID" },
|
|
556
|
+
{ body: { scope: "global", fileName: "invalid.json", theme: { name: "invalid", colors: {} }, overwrite: false, expectedMtimeMs: null }, code: "THEME_INVALID" },
|
|
557
|
+
];
|
|
558
|
+
for (const { body, code } of rejectedThemeBodies) {
|
|
559
|
+
const rejected = await request("127.0.0.1", customThemePath, { method: "POST", body });
|
|
560
|
+
assert.equal(rejected.status, 400, rejected.body?.error);
|
|
561
|
+
assert.equal(rejected.body?.code, code);
|
|
562
|
+
}
|
|
563
|
+
const nonJsonTheme = await fetch(`http://127.0.0.1:${port}${customThemePath}`, { method: "POST", headers: { "content-type": "text/plain" }, body: "{}" });
|
|
564
|
+
assert.equal(nonJsonTheme.status, 415);
|
|
565
|
+
const crossSiteTheme = await request("127.0.0.1", customThemePath, {
|
|
566
|
+
method: "POST",
|
|
567
|
+
headers: { "Sec-Fetch-Site": "cross-site" },
|
|
568
|
+
body: { scope: "global", fileName: "cross-site.json", theme: themeFixture("cross-site"), overwrite: false, expectedMtimeMs: null },
|
|
569
|
+
});
|
|
570
|
+
assert.equal(crossSiteTheme.status, 403);
|
|
571
|
+
assert.equal(crossSiteTheme.body?.code, "THEME_CROSS_SITE_BLOCKED");
|
|
572
|
+
const malformedThemeJson = await fetch(`http://127.0.0.1:${port}${customThemePath}`, { method: "POST", headers: { "content-type": "application/json" }, body: "{" });
|
|
573
|
+
assert.equal(malformedThemeJson.status, 400);
|
|
574
|
+
assert.equal((await malformedThemeJson.json()).code, "THEME_JSON_INVALID");
|
|
575
|
+
const oversizedTheme = await fetch(`http://127.0.0.1:${port}${customThemePath}`, {
|
|
576
|
+
method: "POST",
|
|
577
|
+
headers: { "content-type": "application/json" },
|
|
578
|
+
body: JSON.stringify({ padding: "x".repeat(257 * 1024) }),
|
|
579
|
+
});
|
|
580
|
+
assert.equal(oversizedTheme.status, 413);
|
|
581
|
+
|
|
582
|
+
const untrustedThemeCwd = await mkdtemp(path.join(harnessSideEffectsRoot, "untrusted-theme-"));
|
|
583
|
+
const untrustedTab = await request("127.0.0.1", "/api/tabs", { method: "POST", body: { cwd: untrustedThemeCwd, title: "untrusted theme fixture" } });
|
|
584
|
+
assert.equal(untrustedTab.status, 201, untrustedTab.body?.error);
|
|
585
|
+
const untrustedTabId = untrustedTab.body?.data?.tab?.id;
|
|
586
|
+
const untrustedSave = await request("127.0.0.1", `/api/themes/custom?tab=${encodeURIComponent(untrustedTabId)}`, {
|
|
587
|
+
method: "POST",
|
|
588
|
+
body: { scope: "project", fileName: "untrusted.json", theme: themeFixture("untrusted"), overwrite: false, expectedMtimeMs: null },
|
|
589
|
+
});
|
|
590
|
+
assert.equal(untrustedSave.status, 403);
|
|
591
|
+
assert.equal(untrustedSave.body?.code, "THEME_PROJECT_UNTRUSTED");
|
|
592
|
+
assert.equal(await pathExists(path.join(untrustedThemeCwd, ".pi", "themes")), false, "untrusted project saves must not create .pi/themes");
|
|
593
|
+
await request("127.0.0.1", "/api/tabs/close", { method: "POST", body: { ids: [untrustedTabId] } });
|
|
594
|
+
|
|
595
|
+
const outsideTheme = path.join(harnessSideEffectsRoot, "outside-theme.json");
|
|
596
|
+
await writeFile(outsideTheme, "outside bytes", "utf8");
|
|
597
|
+
const symlinkThemeTarget = path.join(workflowPolicyAgentDir, "themes", "symlink-fixture.json");
|
|
598
|
+
try {
|
|
599
|
+
await symlink(outsideTheme, symlinkThemeTarget);
|
|
600
|
+
const symlinkSave = await request("127.0.0.1", customThemePath, {
|
|
601
|
+
method: "POST",
|
|
602
|
+
body: { scope: "global", fileName: "symlink-fixture.json", theme: themeFixture("symlink-fixture"), overwrite: false, expectedMtimeMs: null },
|
|
603
|
+
});
|
|
604
|
+
assert.equal(symlinkSave.status, 409);
|
|
605
|
+
assert.equal(symlinkSave.body?.code, "THEME_UNSAFE_TARGET");
|
|
606
|
+
assert.equal(await readFile(outsideTheme, "utf8"), "outside bytes", "theme saves must never follow a target symlink");
|
|
607
|
+
} catch (error) {
|
|
608
|
+
if (!["EPERM", "EACCES", "EINVAL", "ENOTSUP"].includes(error?.code)) throw error;
|
|
609
|
+
console.log(`http-endpoints-harness: symlink unavailable (${error.code}); skipping theme target symlink check`);
|
|
610
|
+
} finally {
|
|
611
|
+
await rm(symlinkThemeTarget, { force: true });
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
const symlinkProjectCwd = await mkdtemp(path.join(harnessSideEffectsRoot, "symlink-theme-project-"));
|
|
615
|
+
const outsideProjectPi = await mkdtemp(path.join(harnessSideEffectsRoot, "outside-project-pi-"));
|
|
616
|
+
const symlinkProjectPi = path.join(symlinkProjectCwd, ".pi");
|
|
617
|
+
let symlinkProjectTabId;
|
|
618
|
+
try {
|
|
619
|
+
await symlink(outsideProjectPi, symlinkProjectPi, process.platform === "win32" ? "junction" : "dir");
|
|
620
|
+
await writeFile(path.join(workflowPolicyAgentDir, "trust.json"), `${JSON.stringify({ [cwd]: true, [symlinkProjectCwd]: true }, null, 2)}\n`);
|
|
621
|
+
const symlinkProjectTab = await request("127.0.0.1", "/api/tabs", { method: "POST", body: { cwd: symlinkProjectCwd, title: "symlink theme project" } });
|
|
622
|
+
assert.equal(symlinkProjectTab.status, 201, symlinkProjectTab.body?.error);
|
|
623
|
+
symlinkProjectTabId = symlinkProjectTab.body?.data?.tab?.id;
|
|
624
|
+
const symlinkProjectSave = await request("127.0.0.1", `/api/themes/custom?tab=${encodeURIComponent(symlinkProjectTabId)}`, {
|
|
625
|
+
method: "POST",
|
|
626
|
+
body: { scope: "project", fileName: "escaped.json", theme: themeFixture("escaped"), overwrite: false, expectedMtimeMs: null },
|
|
627
|
+
});
|
|
628
|
+
assert.equal(symlinkProjectSave.status, 409);
|
|
629
|
+
assert.equal(symlinkProjectSave.body?.code, "THEME_UNSAFE_TARGET");
|
|
630
|
+
assert.equal(await pathExists(path.join(outsideProjectPi, "themes")), false, "a symlinked .pi directory must not receive theme writes");
|
|
631
|
+
} catch (error) {
|
|
632
|
+
if (!["EPERM", "EACCES", "EINVAL", "ENOTSUP"].includes(error?.code)) throw error;
|
|
633
|
+
console.log(`http-endpoints-harness: directory symlink unavailable (${error.code}); skipping theme root symlink check`);
|
|
634
|
+
} finally {
|
|
635
|
+
if (symlinkProjectTabId) await request("127.0.0.1", "/api/tabs/close", { method: "POST", body: { ids: [symlinkProjectTabId] } });
|
|
636
|
+
await rm(symlinkProjectPi, { force: true });
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
const themeLanHost = lanAddress();
|
|
640
|
+
if (themeLanHost) {
|
|
641
|
+
const remoteThemeSave = await request(themeLanHost, customThemePath, {
|
|
642
|
+
method: "POST",
|
|
643
|
+
body: { scope: "global", fileName: "remote.json", theme: themeFixture("remote"), overwrite: false, expectedMtimeMs: null },
|
|
644
|
+
});
|
|
645
|
+
assert.equal(remoteThemeSave.status, 403, "custom theme saves must be localhost-only");
|
|
646
|
+
}
|
|
647
|
+
// Keep this focused persistence fixture out of the later git-workflow fixture.
|
|
648
|
+
await rm(path.join(cwd, ".pi"), { recursive: true, force: true });
|
|
649
|
+
|
|
444
650
|
if (optionalFeatureFocus) {
|
|
445
651
|
await runOptionalFeatureFocus();
|
|
446
652
|
} else {
|
|
447
653
|
const summaryTabs = await request("127.0.0.1", "/api/tabs");
|
|
448
654
|
const summaryTabId = summaryTabs.body?.data?.tabs?.[0]?.id;
|
|
449
655
|
assert.ok(summaryTabId, "session-summary endpoint checks require the startup tab");
|
|
656
|
+
|
|
657
|
+
const samplingPath = `/api/tabs/${encodeURIComponent(summaryTabId)}/sampling-parameters`;
|
|
658
|
+
const initialSampling = await request("127.0.0.1", samplingPath);
|
|
659
|
+
assert.equal(initialSampling.status, 200, initialSampling.body?.error);
|
|
660
|
+
assert.equal(initialSampling.headers.get("cache-control"), "private, no-store");
|
|
661
|
+
assert.equal(initialSampling.body?.data?.support?.supported, true);
|
|
662
|
+
assert.equal(initialSampling.body?.data?.support?.api, "openai-completions");
|
|
663
|
+
assert.deepEqual(initialSampling.body?.data?.support?.model, { provider: "fake", id: "fake-model", name: "Fake Model" });
|
|
664
|
+
assert.equal(initialSampling.body?.data?.support?.parameters?.temperature?.supported, true);
|
|
665
|
+
assert.equal(initialSampling.body?.data?.support?.parameters?.top_k?.supported, false);
|
|
666
|
+
assert.equal(initialSampling.body?.data?.support?.parameters?.min_p?.source, "unsupported");
|
|
667
|
+
assert.ok(Array.isArray(initialSampling.body?.data?.support?.compatibleApis), "legacy support diagnostics must remain available");
|
|
668
|
+
|
|
669
|
+
const savedSampling = await request("127.0.0.1", samplingPath, {
|
|
670
|
+
method: "PUT",
|
|
671
|
+
body: { temperature: 0.3, top_k: 32, vendor_mode: "strict" },
|
|
672
|
+
});
|
|
673
|
+
assert.equal(savedSampling.status, 200, savedSampling.body?.error);
|
|
674
|
+
assert.deepEqual(savedSampling.body?.data?.session, { temperature: 0.3, top_k: 32, vendor_mode: "strict" });
|
|
675
|
+
assert.deepEqual(savedSampling.body?.data?.effective, { temperature: 0.3 }, "unsupported stored sampling values must remain inert");
|
|
676
|
+
assert.equal(savedSampling.body?.data?.support?.parameters?.top_k?.supported, false);
|
|
677
|
+
const resetSampling = await request("127.0.0.1", samplingPath, { method: "PUT", body: {} });
|
|
678
|
+
assert.equal(resetSampling.status, 200, resetSampling.body?.error);
|
|
679
|
+
assert.deepEqual(resetSampling.body?.data?.session, {});
|
|
680
|
+
assert.deepEqual(resetSampling.body?.data?.effective, { temperature: 0.7 });
|
|
681
|
+
|
|
450
682
|
const summaryPath = `/api/session-summary/preferences?tab=${encodeURIComponent(summaryTabId)}`;
|
|
451
683
|
const initialSummaryPreferences = await request("127.0.0.1", summaryPath);
|
|
452
684
|
assert.equal(initialSummaryPreferences.status, 200, initialSummaryPreferences.body?.error);
|
|
@@ -512,7 +744,7 @@ try {
|
|
|
512
744
|
assert.equal(persistedSummaryPreferences.configured, true);
|
|
513
745
|
assert.equal(persistedSummaryPreferences.model.modelId, "fake-model");
|
|
514
746
|
assert.equal(Object.hasOwn(persistedSummaryPreferences, "credentials"), false, "summary preferences must not persist credentials");
|
|
515
|
-
assert.equal((await stat(sessionSummaryConfigFile)).mode & 0o777, 0o600, "summary preferences must be private");
|
|
747
|
+
if (process.platform !== "win32") assert.equal((await stat(sessionSummaryConfigFile)).mode & 0o777, 0o600, "summary preferences must be private");
|
|
516
748
|
persistedSummaryPreferences.credentials = "fixture-secret-must-not-cross-http";
|
|
517
749
|
persistedSummaryPreferences.model.providerToken = "fixture-provider-token";
|
|
518
750
|
await writeFile(sessionSummaryConfigFile, `${JSON.stringify(persistedSummaryPreferences, null, 2)}\n`, { mode: 0o600 });
|
|
@@ -680,7 +912,7 @@ try {
|
|
|
680
912
|
assert.deepEqual(persistedWorkflowPolicy, savedWorkflowPolicy.body?.data?.policy, "workflow policy file should contain exactly the canonical saved policy");
|
|
681
913
|
assert.equal(Object.hasOwn(savedWorkflowPolicy.body?.data?.policy || {}, "suggestions"), false, "saved v1 response policy must not persist advisory suggestions");
|
|
682
914
|
assert.equal(Object.hasOwn(persistedWorkflowPolicy, "suggestions"), false, "saved v1 file must not persist advisory suggestions");
|
|
683
|
-
assert.equal((await stat(workflowPolicyFile)).mode & 0o777, 0o600, "workflow policy file must be private");
|
|
915
|
+
if (process.platform !== "win32") assert.equal((await stat(workflowPolicyFile)).mode & 0o777, 0o600, "workflow policy file must be private");
|
|
684
916
|
|
|
685
917
|
const readWorkflowPolicy = await request("127.0.0.1", "/api/workflow-policy");
|
|
686
918
|
assert.equal(readWorkflowPolicy.status, 200, `saved workflow policy should reload: ${readWorkflowPolicy.body?.error || ""}`);
|
|
@@ -730,15 +962,16 @@ try {
|
|
|
730
962
|
|
|
731
963
|
const releaseNotes = await request("127.0.0.1", "/api/pi-release-notes");
|
|
732
964
|
assert.equal(releaseNotes.status, 200, `Pi release notes should load through the server: ${releaseNotes.body?.error || ""}`);
|
|
733
|
-
assert.equal(releaseNotes.body?.data?.version,
|
|
734
|
-
assert.equal(releaseNotes.body?.data?.tagName, `v${
|
|
735
|
-
assert.equal(releaseNotes.body?.data?.title, `Pi v${
|
|
965
|
+
assert.equal(releaseNotes.body?.data?.version, latestPiVersion, "an available update should select the latest Pi release");
|
|
966
|
+
assert.equal(releaseNotes.body?.data?.tagName, `v${latestPiVersion}`);
|
|
967
|
+
assert.equal(releaseNotes.body?.data?.title, `Pi v${latestPiVersion} test release`);
|
|
736
968
|
assert.match(releaseNotes.body?.data?.body || "", /Release notes from the test GitHub endpoint/);
|
|
737
|
-
assert.equal(releaseNotes.body?.data?.url, `https://github.com/earendil-works/pi/releases/tag/v${
|
|
969
|
+
assert.equal(releaseNotes.body?.data?.url, `https://github.com/earendil-works/pi/releases/tag/v${latestPiVersion}`);
|
|
738
970
|
assert.equal(releaseNotes.headers.get("cache-control"), "private, no-store", "browser caches should not retain notes across Pi upgrades");
|
|
739
971
|
const cachedReleaseNotes = await request("127.0.0.1", "/api/pi-release-notes");
|
|
740
|
-
assert.equal(cachedReleaseNotes.body?.data?.tagName, `v${
|
|
741
|
-
assert.equal(voiceProviderRequests.filter((item) => item.url === `/pi-releases/v${
|
|
972
|
+
assert.equal(cachedReleaseNotes.body?.data?.tagName, `v${latestPiVersion}`);
|
|
973
|
+
assert.equal(voiceProviderRequests.filter((item) => item.url === `/pi-releases/v${latestPiVersion}`).length, 1, "the server should fetch the available Pi release only once");
|
|
974
|
+
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");
|
|
742
975
|
|
|
743
976
|
// Static assets: brotli/gzip compression plus ETag revalidation (P0-2).
|
|
744
977
|
const brotliResponse = await fetch(`http://127.0.0.1:${port}/app.js`, {
|
|
@@ -778,12 +1011,16 @@ try {
|
|
|
778
1011
|
const appSource = await readFile(join(root, "public", "app.js"), "utf8");
|
|
779
1012
|
const startupModuleNames = [...new Set([...appSource.matchAll(/(?:\bfrom\s+|\bimport\s*(?:\(\s*)?)["']\.\/([^"'?]+)(?:\?[^"']*)?["']/g)].map((match) => match[1]))];
|
|
780
1013
|
assert.ok(startupModuleNames.length >= 1, "the startup-module harness should discover app.js imports");
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
1014
|
+
const startupHosts = [...new Set(["127.0.0.1", lanAddress()].filter(Boolean))];
|
|
1015
|
+
for (const host of startupHosts) {
|
|
1016
|
+
for (const moduleName of startupModuleNames) {
|
|
1017
|
+
const response = await fetch(`http://${host}:${port}/${moduleName}`, { signal: AbortSignal.timeout(5_000) });
|
|
1018
|
+
assert.equal(response.status, 200, `${moduleName} is imported by app.js and must be served by the WebUI on ${host}`);
|
|
1019
|
+
assert.match(response.headers.get("content-type") || "", /text\/javascript/, `${moduleName} should use a JavaScript MIME type on ${host}`);
|
|
1020
|
+
assert.equal(await response.text(), await readFile(join(root, "public", moduleName), "utf8"), `served startup module ${moduleName} must match its source file on ${host}`);
|
|
1021
|
+
}
|
|
786
1022
|
}
|
|
1023
|
+
assert.ok(startupModuleNames.includes("stream-output-controller.mjs"), "the remote startup regression must exercise the stream output controller import");
|
|
787
1024
|
|
|
788
1025
|
const mermaidModuleResponse = await fetch(`http://127.0.0.1:${port}/vendor/mermaid/mermaid.esm.min.mjs`, {
|
|
789
1026
|
signal: AbortSignal.timeout(5_000),
|
|
@@ -1020,7 +1257,7 @@ try {
|
|
|
1020
1257
|
|
|
1021
1258
|
const optionalFeatures = await request("127.0.0.1", "/api/optional-features");
|
|
1022
1259
|
assert.equal(optionalFeatures.status, 200, "optional feature status should load");
|
|
1023
|
-
assert.equal(optionalFeatures.body?.data?.features?.length,
|
|
1260
|
+
assert.equal(optionalFeatures.body?.data?.features?.length, 20, "the explicit server catalog should expose every allowlisted feature");
|
|
1024
1261
|
const aurReviewFeature = optionalFeatures.body?.data?.features?.find((feature) => feature.featureId === "aurReview");
|
|
1025
1262
|
assert.equal(aurReviewFeature?.expectedSpec, "^0.1.1", "status should expose the catalog-owned compatibility spec");
|
|
1026
1263
|
assert.equal(aurReviewFeature?.installed, true, "workspace discovery should find the local pi-extension-aur-review sibling without an npm dependency");
|
|
@@ -1077,7 +1314,7 @@ try {
|
|
|
1077
1314
|
assert.equal(unknownBatch.status, 400, "batch installs must reject unknown IDs before starting any command");
|
|
1078
1315
|
const oversizedBatch = await request("127.0.0.1", "/api/optional-feature-install-batch", {
|
|
1079
1316
|
method: "POST",
|
|
1080
|
-
body: { tab: tabId, revision: currentBatchRevision, featureIds: Array.from({ length:
|
|
1317
|
+
body: { tab: tabId, revision: currentBatchRevision, featureIds: Array.from({ length: 21 }, () => "aurReview") },
|
|
1081
1318
|
});
|
|
1082
1319
|
assert.equal(oversizedBatch.status, 400, "batch installs must cap raw input to the catalog size");
|
|
1083
1320
|
const staleBatch = await request("127.0.0.1", "/api/optional-feature-install-batch", {
|
|
@@ -2336,9 +2573,11 @@ try {
|
|
|
2336
2573
|
assert.equal(operationSnapshot.body?.data?.conflicts?.[0]?.preview?.hasMarkers, true, "conflict preview should detect conflict markers");
|
|
2337
2574
|
|
|
2338
2575
|
const conflictAgent = await request("127.0.0.1", "/api/git-operation/resolve-with-agent", { method: "POST", body: { tab: mergeTab }, timeoutMs: 20_000 });
|
|
2576
|
+
const conflictAgentTabId = conflictAgent.body?.data?.tab?.id;
|
|
2339
2577
|
assert.equal(conflictAgent.status, 200);
|
|
2340
2578
|
assert.equal(conflictAgent.body?.ok, true, `conflict handoff should open an agent tab: ${conflictAgent.body?.error || ""}`);
|
|
2341
|
-
assert.
|
|
2579
|
+
assert.ok(conflictAgentTabId, "conflict handoff should create a separate tab");
|
|
2580
|
+
assert.notEqual(conflictAgentTabId, mergeTab, "conflict handoff should create a separate tab");
|
|
2342
2581
|
assert.equal(conflictAgent.body?.data?.tab?.cwd, mergeRepo, "conflict agent should use the conflicted repository root");
|
|
2343
2582
|
assert.equal(conflictAgent.body?.data?.tab?.title, "Resolve merge conflicts");
|
|
2344
2583
|
assert.deepEqual(conflictAgent.body?.data?.operation?.conflicts, [{ path: "file.txt", status: "UU" }]);
|
|
@@ -2544,7 +2783,7 @@ try {
|
|
|
2544
2783
|
const pruneConfirmed = await request("127.0.0.1", "/api/git-worktrees/prune", { method: "POST", body: { tab: undoTab, confirmed: true }, timeoutMs: 20_000 });
|
|
2545
2784
|
assert.equal(pruneConfirmed.body?.ok, true, `confirmed prune should succeed: ${pruneConfirmed.body?.error || ""}`);
|
|
2546
2785
|
|
|
2547
|
-
const closeGitActionTabs = await request("127.0.0.1", "/api/tabs/close", { method: "POST", body: { ids: [gitignoreTab, lfTab, noFinalNewlineTab, crlfTab, literalTab, unsafeTab, fileDiffTab, stagingTab, truncationTab, mergeTab, abortTab, rebaseTab, bisectTab, stashTab, undoTab] }, timeoutMs: 10_000 });
|
|
2786
|
+
const closeGitActionTabs = await request("127.0.0.1", "/api/tabs/close", { method: "POST", body: { ids: [gitignoreTab, lfTab, noFinalNewlineTab, crlfTab, literalTab, unsafeTab, fileDiffTab, stagingTab, truncationTab, mergeTab, conflictAgentTabId, abortTab, rebaseTab, bisectTab, stashTab, undoTab] }, timeoutMs: 10_000 });
|
|
2548
2787
|
assert.equal(closeGitActionTabs.status, 200, "git action fixture tabs should close");
|
|
2549
2788
|
await rmWithRetry(gitFixturesRoot);
|
|
2550
2789
|
|
|
@@ -2832,7 +3071,10 @@ try {
|
|
|
2832
3071
|
nestedSearchState = await request("127.0.0.1", `/api/app-runners?tab=${encodeURIComponent(nestedSearchTabId)}`, { timeoutMs: 5_000 });
|
|
2833
3072
|
}
|
|
2834
3073
|
assert.equal(nestedSearchState.body?.data?.activeRun?.status, "done", "configured shell runner should complete");
|
|
2835
|
-
|
|
3074
|
+
const expectedShellCwd = process.platform === "win32"
|
|
3075
|
+
? cwd.replace(/\\/g, "/").replace(/^([A-Za-z]):/, (_match, drive) => `/${drive.toLowerCase()}`)
|
|
3076
|
+
: cwd;
|
|
3077
|
+
assert.match((nestedSearchState.body?.data?.activeRun?.lines || []).join("\n"), new RegExp(`configured alpha cwd=${expectedShellCwd.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`), "configured shell runners should execute at the project root");
|
|
2836
3078
|
} finally {
|
|
2837
3079
|
if (nestedSearchTabId) await request("127.0.0.1", "/api/tabs/close", { method: "POST", body: { ids: [nestedSearchTabId] }, timeoutMs: 10_000 });
|
|
2838
3080
|
}
|
|
@@ -3454,6 +3696,15 @@ try {
|
|
|
3454
3696
|
const remoteWorkflowPolicyRead = await request(lan, "/api/workflow-policy");
|
|
3455
3697
|
assert.equal(remoteWorkflowPolicyRead.status, 403, "workflow policy reads must be localhost-only");
|
|
3456
3698
|
|
|
3699
|
+
const remoteUpdatePlan = await request(lan, "/api/update/plan", { method: "POST", body: { targets: ["pi"] } });
|
|
3700
|
+
assert.equal(remoteUpdatePlan.status, 403, "update plans must be localhost-only before target resolution");
|
|
3701
|
+
const remoteUpdateApply = await request(lan, "/api/update/apply", { method: "POST", body: { transactionId: "remote", planDigest: "a".repeat(64) } });
|
|
3702
|
+
assert.equal(remoteUpdateApply.status, 403, "update apply must be localhost-only before journal lookup");
|
|
3703
|
+
const remoteUpdateTransaction = await request(lan, "/api/update/transactions/remote");
|
|
3704
|
+
assert.equal(remoteUpdateTransaction.status, 403, "update transaction receipts must be localhost-only");
|
|
3705
|
+
const remoteUpdateRollback = await request(lan, "/api/update/rollback", { method: "POST", body: { transactionId: "remote", planDigest: "a".repeat(64) } });
|
|
3706
|
+
assert.equal(remoteUpdateRollback.status, 403, "update rollback must be localhost-only before pointer mutation");
|
|
3707
|
+
|
|
3457
3708
|
const remoteWorkflowPolicySave = await request(lan, "/api/workflow-policy", {
|
|
3458
3709
|
method: "POST",
|
|
3459
3710
|
body: { policy: workflowPolicyToSave, expectedRevision: savedWorkflowPolicy.body?.data?.revision },
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
|
+
const [app, css, html, serviceWorker, packageJson] = await Promise.all([
|
|
8
|
+
readFile(join(root, "public", "app.js"), "utf8"),
|
|
9
|
+
readFile(join(root, "public", "styles.css"), "utf8"),
|
|
10
|
+
readFile(join(root, "public", "index.html"), "utf8"),
|
|
11
|
+
readFile(join(root, "public", "service-worker.js"), "utf8"),
|
|
12
|
+
readFile(join(root, "package.json"), "utf8"),
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
assert.match(app, /import \{ installMiddleButtonDragScroll \} from "\.\/middle-button-drag-scroll\.mjs";/, "the app should load the delegated drag-scroll controller");
|
|
16
|
+
assert.match(app, /installMiddleButtonDragScroll\(\{[\s\S]*onDirection: \(\{ target, offsetY \}\)[\s\S]*noteChatUserScrollIntent\(\{ type: "middle-drag", deltaY: offsetY \}\)/, "chat auto-scroll direction should feed the existing follow/pause intent state");
|
|
17
|
+
assert.match(app, /event\?\.type === "middle-drag"\) return event\.deltaY > 0;/, "moving below the press point should be recognized as intent to read later chat output");
|
|
18
|
+
assert.match(css, /body\.middle-button-auto-scrolling,[\s\S]*cursor: all-scroll !important;[\s\S]*user-select: none !important;/, "active automatic scrolling should expose a directional-scroll affordance and suppress accidental selection");
|
|
19
|
+
assert.match(html, /styles\.css\?v=104/, "changed drag-scroll styles should advance the stylesheet revision");
|
|
20
|
+
assert.match(html, /app\.js\?v=120/, "changed drag-scroll wiring should advance the app revision");
|
|
21
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v81";[\s\S]*"\/middle-button-drag-scroll\.mjs"/, "offline PWA installs should refresh and cache the new controller module");
|
|
22
|
+
assert.match(JSON.parse(packageJson).scripts.check, /node --check public\/middle-button-drag-scroll\.mjs/, "the package check should parse the startup-critical controller module");
|
|
23
|
+
|
|
24
|
+
console.log("middle-button-drag-scroll-static.test.mjs passed");
|