@firstpick/pi-package-webui 0.7.8 → 0.8.0
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 +10 -4
- package/bin/pi-webui.mjs +696 -69
- package/lib/git-workflow-preferences.mjs +16 -0
- package/lib/git-worktrees.mjs +43 -4
- package/lib/queue-mutation.mjs +109 -0
- package/lib/scoped-models.mjs +19 -0
- package/lib/webui-workspaces.mjs +265 -0
- package/package.json +4 -2
- package/public/app.js +2074 -188
- package/public/index.html +105 -4
- package/public/service-worker.js +1 -1
- package/public/styles.css +618 -73
- package/public/voice-conversation.mjs +1 -1
- package/tests/boot-failure-diagnostics.test.mjs +2 -2
- package/tests/codex-fast-mode-static.test.mjs +56 -0
- package/tests/compaction-mutation-contract.test.mjs +166 -0
- package/tests/compaction-resume-harness.test.mjs +113 -2
- package/tests/compaction-static.test.mjs +5 -0
- package/tests/composer-skill-tag-layout.test.mjs +70 -0
- package/tests/cwd-footer-reliability-static.test.mjs +5 -0
- package/tests/fast-mode-client-static.test.mjs +8 -8
- package/tests/file-selection-overlay-static.test.mjs +21 -0
- package/tests/file-viewer-search-static.test.mjs +65 -0
- package/tests/fixtures/fake-pi.mjs +216 -43
- package/tests/git-panel-file-preview-static.test.mjs +20 -5
- package/tests/git-workflow-preferences.test.mjs +8 -0
- package/tests/guided-git-publication-backend-static.test.mjs +40 -0
- package/tests/http-endpoints-harness.test.mjs +422 -2
- package/tests/mobile-static.test.mjs +111 -42
- package/tests/native-parity.test.mjs +1 -1
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/queue-edit-reorder-static.test.mjs +101 -0
- package/tests/queue-mutation-contract.test.mjs +143 -0
- package/tests/scoped-models.test.mjs +42 -0
- package/tests/side-panel-resize-static.test.mjs +8 -1
- package/tests/subagents-helper.test.mjs +216 -3
- package/tests/terminal-tab-workspace-static.test.mjs +4 -2
- package/tests/webui-workspaces-harness.test.mjs +223 -0
- package/tests/webui-workspaces.test.mjs +106 -0
- package/tests/workspace-save-load-static.test.mjs +69 -0
- package/webui-rpc-helper.mjs +300 -41
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// timers, and delivery callbacks all arrive through options so Node tests can
|
|
4
4
|
// drive the full listen -> prompt -> speak -> listen loop without a browser.
|
|
5
5
|
//
|
|
6
|
-
// Turn-taking contract (see docs/webui/natural-conversation/NATURAL_CONVERSATION_MODE_PLAN.md):
|
|
6
|
+
// Turn-taking contract (see docs/planned/webui/natural-conversation/NATURAL_CONVERSATION_MODE_PLAN.md):
|
|
7
7
|
// - Final transcripts while Pi is idle are sent as normal prompts.
|
|
8
8
|
// - Transcripts while the assistant streams final text are interruptions.
|
|
9
9
|
// - Transcripts during a tool call/execution are queued until the tool phase
|
|
@@ -76,7 +76,7 @@ function makeEnvironment({ importApp, stylesheetLoaded = true, stylesheetStatus
|
|
|
76
76
|
removeEventListener(name) { listeners.delete(name); },
|
|
77
77
|
};
|
|
78
78
|
const document = {
|
|
79
|
-
currentScript: new FakeElement({ dataset: { appSrc: "/app.js?v=
|
|
79
|
+
currentScript: new FakeElement({ dataset: { appSrc: "/app.js?v=94" } }),
|
|
80
80
|
readyState: "complete",
|
|
81
81
|
querySelector(selector) {
|
|
82
82
|
return {
|
|
@@ -174,7 +174,7 @@ for (const moduleName of startupModuleNames) {
|
|
|
174
174
|
assert.ok(serviceWorker.includes(`"/${moduleName}"`), `the PWA app shell should include every app.js startup module: ${moduleName}`);
|
|
175
175
|
}
|
|
176
176
|
assert.match(serviceWorker, /pi-webui-pwa-v\d+/, "the app-shell cache should retain a versioned identity");
|
|
177
|
-
assert.ok(html.indexOf('id="webuiBootLoader"') < html.indexOf("/app.js?v=
|
|
177
|
+
assert.ok(html.indexOf('id="webuiBootLoader"') < html.indexOf("/app.js?v=94"), "the inline loader should own app module startup");
|
|
178
178
|
assert.doesNotMatch(html, /<script type="module" src="\/app\.js/, "the app module should not bypass the guarded loader");
|
|
179
179
|
|
|
180
180
|
console.log("boot-failure-diagnostics.test.mjs passed");
|
|
@@ -0,0 +1,56 @@
|
|
|
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 [server, app, html, styles, serviceWorker, readme, packageRaw, lockRaw] = await Promise.all([
|
|
8
|
+
readFile(join(root, "bin", "pi-webui.mjs"), "utf8"),
|
|
9
|
+
readFile(join(root, "public", "app.js"), "utf8"),
|
|
10
|
+
readFile(join(root, "public", "index.html"), "utf8"),
|
|
11
|
+
readFile(join(root, "public", "styles.css"), "utf8"),
|
|
12
|
+
readFile(join(root, "public", "service-worker.js"), "utf8"),
|
|
13
|
+
readFile(join(root, "README.md"), "utf8"),
|
|
14
|
+
readFile(join(root, "package.json"), "utf8"),
|
|
15
|
+
readFile(join(root, "package-lock.json"), "utf8"),
|
|
16
|
+
]);
|
|
17
|
+
const pkg = JSON.parse(packageRaw);
|
|
18
|
+
const lock = JSON.parse(lockRaw);
|
|
19
|
+
const packageName = "@firstpick/pi-extension-codex-fast-mode";
|
|
20
|
+
|
|
21
|
+
assert.equal(pkg.optionalDependencies?.[packageName], "^0.1.0", "WebUI should declare the Fast-mode companion as optional");
|
|
22
|
+
assert.ok(pkg.pi?.extensions?.includes(`node_modules/${packageName}/index.ts`), "WebUI should load the optional Fast-mode extension when installed");
|
|
23
|
+
assert.equal(lock.packages?.[""]?.optionalDependencies?.[packageName], "^0.1.0", "lock root should mirror the unpublished optional requirement without inventing a resolved artifact");
|
|
24
|
+
assert.equal(lock.packages?.[`node_modules/${packageName}`], undefined, "lockfile must not fabricate a registry resolution before the package is published");
|
|
25
|
+
|
|
26
|
+
assert.match(server, /\["codexFastMode", "@firstpick\/pi-extension-codex-fast-mode"\]/, "server should register the package in Optional Features");
|
|
27
|
+
assert.match(server, /CODEX_FAST_MODE_STATUS_KEY = "codex-fast-mode"[\s\S]*?CODEX_FAST_MODE_COMMAND_NAME = "fast-mode"/, "server should use the extension-owned status and command contracts");
|
|
28
|
+
assert.match(server, /function codexFastModeStatusState\(statusText\)[\s\S]*?text !== "on" && text !== "off"[\s\S]*?known: true, enabled: text === "on"/, "server should accept only exact published on/off states");
|
|
29
|
+
assert.match(server, /function codexFastModeSnapshot\(tab, patch = \{\}\)[\s\S]*?extensionStatusMap\(tab\)\.get\(CODEX_FAST_MODE_STATUS_KEY\)/, "server snapshots should come from remembered extension status");
|
|
30
|
+
assert.match(server, /async function codexFastModeFeatureData[\s\S]*?codexFastModeSnapshot\(tab\)[\s\S]*?tabHasActiveOutput\(tab\)[\s\S]*?CODEX_FAST_MODE_CREDIT_NOTICE/, "GET state should be tab-scoped, extension-owned, busy-aware, and disclose credit use");
|
|
31
|
+
assert.match(server, /async function waitForCodexFastModeStatus\(tab, desired\)[\s\S]*?snapshot\.statusKnown && snapshot\.enabled === desired[\s\S]*?makeHttpError\(409,[\s\S]*?did not confirm/, "server should require bounded authoritative status confirmation");
|
|
32
|
+
assert.match(server, /async function setCodexFastMode[\s\S]*?typeof body\?\.enabled !== "boolean"[\s\S]*?feature\.busy[\s\S]*?type: "prompt", message: `\/\$\{feature\.commandName\} \$\{desired \? "on" : "off"\}`[\s\S]*?waitForCodexFastModeStatus\(tab, desired\)[\s\S]*?requested: desired/, "PUT should require explicit intent, reject busy tabs, invoke the extension, and return only confirmed state");
|
|
33
|
+
assert.doesNotMatch(server, /codexFastModeSnapshot\(tab, \{ enabled: desired/, "server must not infer effective Fast state from RPC success");
|
|
34
|
+
assert.match(server, /url\.pathname === "\/api\/codex-fast-mode" && req\.method === "GET"[\s\S]*?url\.pathname === "\/api\/codex-fast-mode" && req\.method === "PUT"/, "server should expose GET and PUT routes");
|
|
35
|
+
|
|
36
|
+
assert.match(html, /<label for="fastOutputModeSelect">Compact mode \(Experimental\)<\/label>[\s\S]*?<option value="compact-v1">Compact<\/option>/, "legacy output processing should be presented as Compact mode while retaining compact-v1");
|
|
37
|
+
assert.doesNotMatch(html, /<label for="fastOutputModeSelect">Fast mode/, "legacy output processing should no longer be presented as Fast mode");
|
|
38
|
+
assert.match(html, /data-side-panel-section="codex-usage"[\s\S]*?id="codexFastModeSelect"[\s\S]*?<option value="normal">Normal<\/option>[\s\S]*?<option value="fast">Fast<\/option>[\s\S]*?id="setCodexFastModeButton"[\s\S]*?id="codexFastModeStatus"/, "Codex Usage should contain the distinct session Fast-mode control");
|
|
39
|
+
assert.match(styles, /\.codex-fast-mode-control \{[\s\S]*?border:[\s\S]*?background:/, "Codex Fast mode should have a visible control surface");
|
|
40
|
+
|
|
41
|
+
assert.match(app, /id: "codexFastMode"[\s\S]*?packageName: "@firstpick\/pi-extension-codex-fast-mode"[\s\S]*?capabilityLabel: "\/fast-mode"/, "browser Optional Features should catalog Fast mode");
|
|
42
|
+
assert.match(app, /OPTIONAL_FEATURE_DISABLE_PREREQUISITES = new Map\([\s\S]*?\["codexFastMode", \(\) => disableCodexFastModeIntegration\(\)\]/, "browser should register disable-off-first behavior");
|
|
43
|
+
assert.match(app, /if \(disabled\) \{[\s\S]*?OPTIONAL_FEATURE_DISABLE_PREREQUISITES\.get\(feature\.id\)[\s\S]*?await turnOff\(\)[\s\S]*?setOptionalFeatureDisabled\(feature\.id, disabled\)/, "Optional Features Disable should abort before hiding integration if turn-off fails");
|
|
44
|
+
assert.match(app, /function applyCodexFastModeStatus\(statusText\)[\s\S]*?status !== "on" && status !== "off"[\s\S]*?enabled: status === "on"[\s\S]*?statusKnown: true/, "browser should consume only exact extension status values");
|
|
45
|
+
assert.match(app, /async function refreshCodexFastMode\(tabContext = activeTabContext\(\)\)[\s\S]*?api\("\/api\/codex-fast-mode", \{ tabId: tabContext\.tabId \}\)[\s\S]*?!featureEnabled && data\.available[\s\S]*?enabled: false[\s\S]*?isCurrentTabContext\(tabContext\)/, "browser status refresh should stay tab-scoped and disarm restored branches while the feature is hidden");
|
|
46
|
+
assert.match(app, /async function applyCodexFastMode\(\)[\s\S]*?body: \{ enabled \}, tabId: tabContext\.tabId[\s\S]*?1\.5x faster[\s\S]*?may spend 2x credits[\s\S]*?2\.5x/, "browser should apply explicit state and disclose conditional speed/credit multipliers");
|
|
47
|
+
assert.match(app, /async function disableCodexFastModeIntegration\(\)[\s\S]*?tabs\.filter[\s\S]*?Promise\.all\(tabIds\.map[\s\S]*?data\.busy[\s\S]*?enabled: false[\s\S]*?codexFastModeConfirmedOff\(response\.data\)/, "browser-global Disable should preflight every live tab and require each mutation to confirm off");
|
|
48
|
+
assert.match(app, /refreshNaturalConversationMode\(tabContext\),[\s\S]*?refreshCodexFastMode\(tabContext\),/, "tab refreshes should reload branch-scoped Fast-mode state");
|
|
49
|
+
assert.match(app, /statusKey === CODEX_FAST_MODE_STATUS_KEY[\s\S]*?applyCodexFastModeStatus\(request\.statusText\)/, "extension status events should refresh the active-tab selector");
|
|
50
|
+
|
|
51
|
+
assert.match(readme, /### Compact live output mode[\s\S]*?select \*\*Compact\*\*[\s\S]*?`compact-v1`/, "README should document Compact mode with the stable wire identifier");
|
|
52
|
+
assert.match(readme, /### Codex subscription Fast mode[\s\S]*?service_tier: "priority"[\s\S]*?1\.5× faster[\s\S]*?2× Standard credits[\s\S]*?2\.5×/, "README should separately document subscription Fast mode and its cost semantics");
|
|
53
|
+
assert.match(serviceWorker, /pi-webui-pwa-v50/, "PWA cache identity should be bumped for changed browser assets");
|
|
54
|
+
assert.match(html, /data-app-src="\/app\.js\?v=94"/, "browser module URL should be cache-busted for Fast-mode wiring");
|
|
55
|
+
|
|
56
|
+
console.log("codex-fast-mode-static.test.mjs passed");
|
|
@@ -0,0 +1,166 @@
|
|
|
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
|
+
import vm from "node:vm";
|
|
6
|
+
|
|
7
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
|
+
const server = await readFile(join(root, "bin", "pi-webui.mjs"), "utf8");
|
|
9
|
+
|
|
10
|
+
function sourceForFunction(name) {
|
|
11
|
+
const start = server.indexOf(`function ${name}(`);
|
|
12
|
+
assert.notEqual(start, -1, `${name} should remain a server helper`);
|
|
13
|
+
const openingBrace = server.indexOf(") {", start) + 2;
|
|
14
|
+
assert.ok(openingBrace > start, `${name} should have a function body`);
|
|
15
|
+
let depth = 0;
|
|
16
|
+
let quote = "";
|
|
17
|
+
for (let index = openingBrace; index < server.length; index += 1) {
|
|
18
|
+
const character = server[index];
|
|
19
|
+
if (quote) {
|
|
20
|
+
if (character === "\\") {
|
|
21
|
+
index += 1;
|
|
22
|
+
} else if (character === quote) {
|
|
23
|
+
quote = "";
|
|
24
|
+
}
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (character === '"' || character === "'" || character === "`") {
|
|
28
|
+
quote = character;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (character === "{") depth += 1;
|
|
32
|
+
if (character === "}" && --depth === 0) return server.slice(start, index + 1);
|
|
33
|
+
}
|
|
34
|
+
assert.fail(`${name} should have a balanced function body`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function plain(value) {
|
|
38
|
+
return JSON.parse(JSON.stringify(value));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const events = [];
|
|
42
|
+
const context = {
|
|
43
|
+
broadcastTabEvent(tab, event) {
|
|
44
|
+
events.push({ tab, event });
|
|
45
|
+
},
|
|
46
|
+
tabActivitySnapshot(tab) {
|
|
47
|
+
return { tabId: tab.id };
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
vm.createContext(context);
|
|
51
|
+
const functions = [
|
|
52
|
+
"compactionQueueForTab",
|
|
53
|
+
"compactionQueueRevision",
|
|
54
|
+
"advanceCompactionQueueRevision",
|
|
55
|
+
"compactionQueueSnapshot",
|
|
56
|
+
"compactionQueueEvent",
|
|
57
|
+
"sameQueueSnapshot",
|
|
58
|
+
"compactionFollowUpSlots",
|
|
59
|
+
"mutateCompactionFollowUpQueue",
|
|
60
|
+
].map(sourceForFunction).join("\n\n");
|
|
61
|
+
vm.runInContext(`${functions}\nglobalThis.mutate = mutateCompactionFollowUpQueue;`, context);
|
|
62
|
+
|
|
63
|
+
const firstImage = { type: "image", mimeType: "image/png", data: "first-image" };
|
|
64
|
+
const secondImage = { type: "image", mimeType: "image/png", data: "second-image" };
|
|
65
|
+
const editedCommand = {
|
|
66
|
+
type: "follow_up",
|
|
67
|
+
mode: "followUp",
|
|
68
|
+
message: "first follow-up",
|
|
69
|
+
images: [firstImage],
|
|
70
|
+
metadata: { origin: "fixture", sequence: 1 },
|
|
71
|
+
};
|
|
72
|
+
const movedCommand = {
|
|
73
|
+
type: "prompt",
|
|
74
|
+
mode: "followUp",
|
|
75
|
+
message: "second follow-up",
|
|
76
|
+
images: [secondImage],
|
|
77
|
+
metadata: { origin: "fixture", sequence: 2 },
|
|
78
|
+
};
|
|
79
|
+
const tab = {
|
|
80
|
+
id: "compaction-contract-tab",
|
|
81
|
+
title: "Compaction contract",
|
|
82
|
+
compactionQueue: [
|
|
83
|
+
{ id: "steer", command: { type: "steer", mode: "steer", message: "fixed steering", metadata: { origin: "fixture" } } },
|
|
84
|
+
{ id: "edit", command: editedCommand },
|
|
85
|
+
{ id: "move", command: movedCommand },
|
|
86
|
+
],
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const edit = context.mutate(tab, {
|
|
90
|
+
source: "webui-compaction",
|
|
91
|
+
kind: "followUp",
|
|
92
|
+
revision: 0,
|
|
93
|
+
expected: { steering: ["fixed steering"], followUp: ["first follow-up", "second follow-up"] },
|
|
94
|
+
operation: { type: "edit", index: 0, expectedText: "first follow-up", text: "edited follow-up" },
|
|
95
|
+
});
|
|
96
|
+
assert.deepEqual(plain(edit), {
|
|
97
|
+
mutated: true,
|
|
98
|
+
source: "webui-compaction",
|
|
99
|
+
queue: {
|
|
100
|
+
source: "webui-compaction",
|
|
101
|
+
revision: 1,
|
|
102
|
+
steering: ["fixed steering"],
|
|
103
|
+
followUp: ["edited follow-up", "second follow-up"],
|
|
104
|
+
draining: false,
|
|
105
|
+
},
|
|
106
|
+
}, "a successful edit returns the authoritative advanced snapshot");
|
|
107
|
+
assert.strictEqual(tab.compactionQueue[1].command, editedCommand, "edit must retain the original queued command object");
|
|
108
|
+
assert.strictEqual(editedCommand.images[0], firstImage, "edit must retain the original image object");
|
|
109
|
+
assert.deepEqual(editedCommand.metadata, { origin: "fixture", sequence: 1 }, "edit must retain command metadata");
|
|
110
|
+
assert.equal(editedCommand.type, "follow_up", "edit must retain the command type");
|
|
111
|
+
assert.equal(editedCommand.mode, "followUp", "edit must retain the command mode");
|
|
112
|
+
assert.equal(events.length, 1, "a successful compaction edit emits exactly one queue update");
|
|
113
|
+
assert.deepEqual(plain(events[0].event), {
|
|
114
|
+
type: "webui_compaction_queue_update",
|
|
115
|
+
tabId: "compaction-contract-tab",
|
|
116
|
+
tabTitle: "Compaction contract",
|
|
117
|
+
queueLength: 3,
|
|
118
|
+
pendingMessageCount: 3,
|
|
119
|
+
source: "webui-compaction",
|
|
120
|
+
revision: 1,
|
|
121
|
+
steering: ["fixed steering"],
|
|
122
|
+
followUp: ["edited follow-up", "second follow-up"],
|
|
123
|
+
draining: false,
|
|
124
|
+
tabActivity: { tabId: "compaction-contract-tab" },
|
|
125
|
+
}, "the successful edit emits its one authoritative snapshot");
|
|
126
|
+
|
|
127
|
+
const stale = context.mutate(tab, {
|
|
128
|
+
source: "webui-compaction",
|
|
129
|
+
kind: "followUp",
|
|
130
|
+
revision: 0,
|
|
131
|
+
expected: { steering: ["fixed steering"], followUp: ["first follow-up", "second follow-up"] },
|
|
132
|
+
operation: { type: "move", from: 1, to: 0, expectedText: "second follow-up" },
|
|
133
|
+
});
|
|
134
|
+
assert.equal(stale.mutated, false, "a stale compaction request is rejected");
|
|
135
|
+
assert.equal(stale.reason, "queue-changed");
|
|
136
|
+
assert.equal(events.length, 1, "a rejected stale mutation emits no queue update");
|
|
137
|
+
assert.strictEqual(tab.compactionQueue[1].command, editedCommand, "a rejected stale mutation leaves command identity intact");
|
|
138
|
+
|
|
139
|
+
const move = context.mutate(tab, {
|
|
140
|
+
source: "webui-compaction",
|
|
141
|
+
kind: "followUp",
|
|
142
|
+
revision: 1,
|
|
143
|
+
expected: { steering: ["fixed steering"], followUp: ["edited follow-up", "second follow-up"] },
|
|
144
|
+
operation: { type: "move", from: 1, to: 0, expectedText: "second follow-up" },
|
|
145
|
+
});
|
|
146
|
+
assert.equal(move.mutated, true, "a current move is accepted");
|
|
147
|
+
assert.deepEqual([...move.queue.followUp], ["second follow-up", "edited follow-up"], "move uses the final follow-up index while steering remains fixed");
|
|
148
|
+
assert.strictEqual(tab.compactionQueue[1].command, movedCommand, "move keeps the full command object paired with its queue slot");
|
|
149
|
+
assert.strictEqual(movedCommand.images[0], secondImage, "move retains the moved command image object");
|
|
150
|
+
assert.deepEqual(movedCommand.metadata, { origin: "fixture", sequence: 2 }, "move retains moved command metadata");
|
|
151
|
+
assert.equal(events.length, 2, "a successful compaction move emits exactly one additional queue update");
|
|
152
|
+
|
|
153
|
+
tab.compactionQueueDraining = true;
|
|
154
|
+
const draining = context.mutate(tab, {
|
|
155
|
+
source: "webui-compaction",
|
|
156
|
+
kind: "followUp",
|
|
157
|
+
revision: 2,
|
|
158
|
+
expected: { steering: ["fixed steering"], followUp: ["second follow-up", "edited follow-up"] },
|
|
159
|
+
operation: { type: "edit", index: 0, expectedText: "second follow-up", text: "must not apply" },
|
|
160
|
+
});
|
|
161
|
+
assert.equal(draining.mutated, false, "a draining compaction queue rejects mutation");
|
|
162
|
+
assert.equal(draining.reason, "queue-draining");
|
|
163
|
+
assert.equal(events.length, 2, "a rejected draining mutation emits no queue update");
|
|
164
|
+
assert.strictEqual(tab.compactionQueue[1].command, movedCommand, "a rejected draining mutation leaves the moved command untouched");
|
|
165
|
+
|
|
166
|
+
console.log("compaction-mutation-contract.test.mjs passed");
|
|
@@ -35,6 +35,36 @@ async function request(pathname, { method = "GET", body, timeoutMs = 5_000 } = {
|
|
|
35
35
|
return { status: response.status, body: payload };
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
async function waitForSseEvent(tabId, predicate) {
|
|
39
|
+
const controller = new AbortController();
|
|
40
|
+
const timeout = setTimeout(() => controller.abort(new Error("timed out waiting for SSE event")), 8_000);
|
|
41
|
+
try {
|
|
42
|
+
const response = await fetch(`http://127.0.0.1:${port}/api/events?tab=${encodeURIComponent(tabId)}`, { signal: controller.signal });
|
|
43
|
+
assert.equal(response.status, 200, "SSE connection should open");
|
|
44
|
+
const reader = response.body.getReader();
|
|
45
|
+
const decoder = new TextDecoder();
|
|
46
|
+
let buffer = "";
|
|
47
|
+
while (true) {
|
|
48
|
+
const { done, value } = await reader.read();
|
|
49
|
+
if (done) break;
|
|
50
|
+
buffer += decoder.decode(value, { stream: true });
|
|
51
|
+
let boundary;
|
|
52
|
+
while ((boundary = buffer.indexOf("\n\n")) >= 0) {
|
|
53
|
+
const block = buffer.slice(0, boundary);
|
|
54
|
+
buffer = buffer.slice(boundary + 2);
|
|
55
|
+
const data = block.split("\n").filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trim()).join("\n");
|
|
56
|
+
if (!data) continue;
|
|
57
|
+
const event = JSON.parse(data);
|
|
58
|
+
if (predicate(event)) return { event };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
throw new Error("SSE stream ended before the expected event");
|
|
62
|
+
} finally {
|
|
63
|
+
clearTimeout(timeout);
|
|
64
|
+
controller.abort();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
38
68
|
async function waitFor(description, probe, { attempts = 60, intervalMs = 100 } = {}) {
|
|
39
69
|
let last;
|
|
40
70
|
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
|
@@ -53,6 +83,7 @@ const child = spawn(process.execPath, [serverScript, "--cwd", cwd, "--host", "12
|
|
|
53
83
|
stdio: ["ignore", "pipe", "pipe"],
|
|
54
84
|
env: { ...process.env, PI_WEBUI_SETTINGS_FILE: settingsFile },
|
|
55
85
|
});
|
|
86
|
+
const childClosed = new Promise((resolve) => child.once("close", resolve));
|
|
56
87
|
let serverOutput = "";
|
|
57
88
|
child.stdout.on("data", (chunk) => { serverOutput += String(chunk); });
|
|
58
89
|
child.stderr.on("data", (chunk) => { serverOutput += String(chunk); });
|
|
@@ -113,6 +144,85 @@ try {
|
|
|
113
144
|
assert.equal(queuedSlashPrompt.status, 202, "slash prompt sent during compaction should remain a prompt in the resume queue");
|
|
114
145
|
assert.equal(queuedSlashPrompt.body?.data?.queueLength, 4);
|
|
115
146
|
|
|
147
|
+
const compactionQueueBeforeMutation = {
|
|
148
|
+
source: "webui-compaction",
|
|
149
|
+
revision: 4,
|
|
150
|
+
steering: [RESUME_PROMPT, STEER_PROMPT],
|
|
151
|
+
followUp: [FOLLOW_UP_PROMPT, QUEUED_SLASH_PROMPT],
|
|
152
|
+
};
|
|
153
|
+
const editedFollowUp = `${FOLLOW_UP_PROMPT} edited`;
|
|
154
|
+
const compactionEdit = await request("/api/queue/mutate", {
|
|
155
|
+
method: "POST",
|
|
156
|
+
body: {
|
|
157
|
+
tab: tabId,
|
|
158
|
+
source: "webui-compaction",
|
|
159
|
+
kind: "followUp",
|
|
160
|
+
revision: compactionQueueBeforeMutation.revision,
|
|
161
|
+
expected: { steering: compactionQueueBeforeMutation.steering, followUp: compactionQueueBeforeMutation.followUp },
|
|
162
|
+
operation: { type: "edit", index: 0, expectedText: FOLLOW_UP_PROMPT, text: ` ${editedFollowUp} ` },
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
assert.equal(compactionEdit.status, 200, `compaction follow-up edits should succeed before draining: ${compactionEdit.body?.error || ""}`);
|
|
166
|
+
assert.deepEqual(compactionEdit.body?.data, {
|
|
167
|
+
mutated: true,
|
|
168
|
+
source: "webui-compaction",
|
|
169
|
+
queue: {
|
|
170
|
+
source: "webui-compaction",
|
|
171
|
+
revision: 5,
|
|
172
|
+
steering: [RESUME_PROMPT, STEER_PROMPT],
|
|
173
|
+
followUp: [editedFollowUp, QUEUED_SLASH_PROMPT],
|
|
174
|
+
draining: false,
|
|
175
|
+
},
|
|
176
|
+
}, "compaction edits return an authoritative source-tagged revisioned snapshot");
|
|
177
|
+
|
|
178
|
+
const staleCompactionMove = await request("/api/queue/mutate", {
|
|
179
|
+
method: "POST",
|
|
180
|
+
body: {
|
|
181
|
+
tab: tabId,
|
|
182
|
+
source: "webui-compaction",
|
|
183
|
+
kind: "followUp",
|
|
184
|
+
revision: compactionQueueBeforeMutation.revision,
|
|
185
|
+
expected: { steering: compactionQueueBeforeMutation.steering, followUp: compactionQueueBeforeMutation.followUp },
|
|
186
|
+
operation: { type: "move", from: 1, to: 0, expectedText: QUEUED_SLASH_PROMPT },
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
assert.equal(staleCompactionMove.status, 409, "compaction mutations reject stale revisions and snapshots");
|
|
190
|
+
assert.equal(staleCompactionMove.body?.data?.reason, "queue-changed");
|
|
191
|
+
|
|
192
|
+
const compactionMove = await request("/api/queue/mutate", {
|
|
193
|
+
method: "POST",
|
|
194
|
+
body: {
|
|
195
|
+
tab: tabId,
|
|
196
|
+
source: "webui-compaction",
|
|
197
|
+
kind: "followUp",
|
|
198
|
+
revision: 5,
|
|
199
|
+
expected: { steering: [RESUME_PROMPT, STEER_PROMPT], followUp: [editedFollowUp, QUEUED_SLASH_PROMPT] },
|
|
200
|
+
operation: { type: "move", from: 1, to: 0, expectedText: QUEUED_SLASH_PROMPT },
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
assert.equal(compactionMove.status, 200, "compaction follow-up moves should reorder among the fixed follow-up slots");
|
|
204
|
+
assert.deepEqual(compactionMove.body?.data?.queue?.followUp, [QUEUED_SLASH_PROMPT, editedFollowUp]);
|
|
205
|
+
assert.deepEqual(compactionMove.body?.data?.queue?.steering, [RESUME_PROMPT, STEER_PROMPT], "compaction reordering must leave steering slots fixed");
|
|
206
|
+
|
|
207
|
+
const drainingCompactionQueue = await waitForSseEvent(
|
|
208
|
+
tabId,
|
|
209
|
+
(event) => event.type === "webui_compaction_queue_update" && event.source === "webui-compaction" && event.draining === true,
|
|
210
|
+
);
|
|
211
|
+
const drainingMutation = await request("/api/queue/mutate", {
|
|
212
|
+
method: "POST",
|
|
213
|
+
body: {
|
|
214
|
+
tab: tabId,
|
|
215
|
+
source: "webui-compaction",
|
|
216
|
+
kind: "followUp",
|
|
217
|
+
revision: 6,
|
|
218
|
+
expected: { steering: [RESUME_PROMPT, STEER_PROMPT], followUp: [QUEUED_SLASH_PROMPT, editedFollowUp] },
|
|
219
|
+
operation: { type: "edit", index: 0, expectedText: QUEUED_SLASH_PROMPT, text: "must not apply while draining" },
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
assert.equal(drainingCompactionQueue.event.revision, 7, "draining queue transition advances the monotonic queue revision");
|
|
223
|
+
assert.equal(drainingMutation.status, 409, "compaction mutations are rejected while draining");
|
|
224
|
+
assert.equal(drainingMutation.body?.data?.reason, "queue-draining");
|
|
225
|
+
|
|
116
226
|
const messagesBeforeEnd = await request(`/api/messages?tab=${encodeURIComponent(tabId)}`);
|
|
117
227
|
assert.equal(messagesBeforeEnd.status, 200);
|
|
118
228
|
const queuedMessages = [RESUME_PROMPT, STEER_PROMPT, FOLLOW_UP_PROMPT, QUEUED_SLASH_PROMPT];
|
|
@@ -128,7 +238,7 @@ try {
|
|
|
128
238
|
const resumedMessages = await waitFor("queued prompts to resume after compaction", async () => {
|
|
129
239
|
const messages = await request(`/api/messages?tab=${encodeURIComponent(tabId)}`);
|
|
130
240
|
const entries = messages.body?.data?.messages || [];
|
|
131
|
-
const expected = [`prompt:${RESUME_PROMPT}`, `steer:${STEER_PROMPT}`, `
|
|
241
|
+
const expected = [`prompt:${RESUME_PROMPT}`, `steer:${STEER_PROMPT}`, `prompt:${QUEUED_SLASH_PROMPT}`, `follow_up:${editedFollowUp}`];
|
|
132
242
|
return expected.every((content, index) => String(entries[index]?.content || "") === content) ? messages : false;
|
|
133
243
|
}, { attempts: 80, intervalMs: 100 });
|
|
134
244
|
assert.equal(resumedMessages.status, 200);
|
|
@@ -160,7 +270,8 @@ try {
|
|
|
160
270
|
assert.notEqual(child.exitCode, null, "server should exit after /api/shutdown");
|
|
161
271
|
} finally {
|
|
162
272
|
if (child.exitCode === null) child.kill("SIGKILL");
|
|
163
|
-
await
|
|
273
|
+
await childClosed;
|
|
274
|
+
await rm(cwd, { recursive: true, force: true, maxRetries: 10, retryDelay: 200 });
|
|
164
275
|
}
|
|
165
276
|
|
|
166
277
|
console.log("compaction-resume-harness.test.mjs passed");
|
|
@@ -17,6 +17,11 @@ assert.match(server, /async function flushCompactionQueue\(tab, event = \{\}\)[\
|
|
|
17
17
|
assert.match(server, /async function flushCompactionQueue\(tab, event = \{\}\)[\s\S]*queuedPromptCommand\(item\)/, "compaction queue flush should start a new prompt when no run resumes automatically");
|
|
18
18
|
assert.match(server, /function queuedRetryCommand\(item\)[\s\S]*queuedStreamingCommand\(item\)/, "post-compaction continuation should send later queued items as steering or follow-up messages");
|
|
19
19
|
assert.match(server, /function stateWithPendingThinking\(tab, state\)[\s\S]*compactionQueueForTab\(tab\)\.length[\s\S]*pendingMessageCount/, "state responses should include Web UI compaction queue length while prompts wait to resume");
|
|
20
|
+
assert.match(server, /function eventForTabClients\(tab, event\)[\s\S]*event\?\.type === "queue_update"[\s\S]*source: "pi-runtime"/, "Pi runtime queue events should be decorated with their source at the server boundary");
|
|
21
|
+
assert.match(server, /function compactionQueueSnapshot\(tab\)[\s\S]*source: "webui-compaction"[\s\S]*revision: compactionQueueRevision\(tab\)[\s\S]*draining:/, "compaction queue snapshots should include source, monotonic revision, and draining state");
|
|
22
|
+
assert.match(server, /function mutateCompactionFollowUpQueue\(tab, request\)[\s\S]*if \(current\.draining\) return failed\("queue-draining"\)[\s\S]*request\.revision !== current\.revision[\s\S]*slots\.forEach\(\(slot, index\) => \{ queue\[slot\] = followUps\[index\]; \}\)/, "compaction mutations should reject draining/stale requests and only permute follow-up slots");
|
|
23
|
+
assert.match(server, /function mutateCompactionFollowUpQueue\(tab, request\)[\s\S]*queue\[slots\[operation\.index\]\]\.command\.message = operation\.text[\s\S]*advanceCompactionQueueRevision\(tab\)[\s\S]*broadcastTabEvent\(tab, compactionQueueEvent\(tab\)\)/, "compaction edits should preserve command metadata and emit one authoritative update after revision advancement");
|
|
24
|
+
assert.match(server, /url\.pathname === "\/api\/queue\/mutate" && req\.method === "POST"[\s\S]*request\.source === "webui-compaction"[\s\S]*mutateCompactionFollowUpQueue[\s\S]*status = data\?\.mutated === true \? 200 : conflict \? 409 : 400/, "queue mutation HTTP handling should keep compaction mutations source-specific and map conflicts to 409");
|
|
20
25
|
|
|
21
26
|
assert.match(app, /function isRunActive\(\) \{\n\s+return !!currentState\?\.isStreaming \|\| !!currentState\?\.isCompacting/, "frontend should treat compaction as an active run for composer controls");
|
|
22
27
|
assert.match(app, /const targetWasCompacting = !!currentState\?\.isCompacting;[\s\S]*const targetWasBusy = targetWasStreaming \|\| targetWasCompacting[\s\S]*if \(targetWasBusy\) body\.streamingBehavior = streamingBehavior \|\| busyBehavior/, "prompt send should use busy behavior while streaming or compacting");
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import vm from "node:vm";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
|
+
const app = await readFile(join(root, "public", "app.js"), "utf8");
|
|
9
|
+
|
|
10
|
+
function functionSource(name, nextName) {
|
|
11
|
+
const start = app.indexOf(`function ${name}(`);
|
|
12
|
+
const end = app.indexOf(`\nfunction ${nextName}(`, start);
|
|
13
|
+
assert.ok(start >= 0 && end > start, `${name} should remain a standalone frontend helper`);
|
|
14
|
+
return app.slice(start, end);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function chip(width) {
|
|
18
|
+
return {
|
|
19
|
+
hidden: false,
|
|
20
|
+
textContent: "",
|
|
21
|
+
title: "",
|
|
22
|
+
measurements: 0,
|
|
23
|
+
getBoundingClientRect() {
|
|
24
|
+
this.measurements += 1;
|
|
25
|
+
return { width };
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const tags = [chip(50), chip(60), chip(70)];
|
|
31
|
+
const overflow = chip(22);
|
|
32
|
+
const container = {
|
|
33
|
+
hidden: false,
|
|
34
|
+
clientWidth: 150,
|
|
35
|
+
querySelectorAll: (selector) => selector === "button.composer-skill-tag" ? tags : [],
|
|
36
|
+
querySelector: (selector) => selector === ".composer-skill-tag.overflow" ? overflow : null,
|
|
37
|
+
};
|
|
38
|
+
const context = {
|
|
39
|
+
elements: { sessionSkillTags: container },
|
|
40
|
+
getComputedStyle: () => ({ columnGap: "5px", gap: "5px" }),
|
|
41
|
+
};
|
|
42
|
+
vm.runInNewContext(
|
|
43
|
+
`${functionSource("fitSessionSkillTags", "scheduleSessionSkillTagLayout")}\nthis.fitSessionSkillTags = fitSessionSkillTags;`,
|
|
44
|
+
context,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
context.fitSessionSkillTags();
|
|
48
|
+
assert.deepEqual(tags.map((tag) => tag.hidden), [false, false, true], "the strip should show the maximum chip count that fits the measured width");
|
|
49
|
+
assert.equal(overflow.hidden, false, "the overflow chip should remain visible while tags are hidden");
|
|
50
|
+
assert.equal(overflow.textContent, "+1", "the overflow chip should report the current hidden count");
|
|
51
|
+
assert.equal(overflow.measurements, 1, "fitting should measure one overflow width per digit count rather than forcing layout for every candidate");
|
|
52
|
+
|
|
53
|
+
container.clientWidth = 200;
|
|
54
|
+
context.fitSessionSkillTags();
|
|
55
|
+
assert.deepEqual(tags.map((tag) => tag.hidden), [false, false, false], "widening the input should reveal every tag without rerendering the session state");
|
|
56
|
+
assert.equal(overflow.hidden, true, "the overflow chip should disappear when every tag fits");
|
|
57
|
+
|
|
58
|
+
container.clientWidth = 80;
|
|
59
|
+
context.fitSessionSkillTags();
|
|
60
|
+
assert.deepEqual(tags.map((tag) => tag.hidden), [false, true, true], "narrowing the input should compact the tag strip again");
|
|
61
|
+
assert.equal(overflow.textContent, "+2", "responsive compaction should keep the overflow count current");
|
|
62
|
+
|
|
63
|
+
container.clientWidth = 0;
|
|
64
|
+
const zeroWidthState = tags.map((tag) => tag.hidden);
|
|
65
|
+
const zeroWidthOverflowText = overflow.textContent;
|
|
66
|
+
context.fitSessionSkillTags();
|
|
67
|
+
assert.deepEqual(tags.map((tag) => tag.hidden), zeroWidthState, "a temporarily unmeasurable strip should preserve its last stable visibility state");
|
|
68
|
+
assert.equal(overflow.textContent, zeroWidthOverflowText, "a zero-width pass should not expose a stale overflow count");
|
|
69
|
+
|
|
70
|
+
console.log("composer skill tag layout tests passed");
|
|
@@ -25,6 +25,11 @@ assert.match(
|
|
|
25
25
|
/const changedTabId = response\.data\?\.tab\?\.id \|\| tab\.id;[\s\S]*?resetGitWorkflowForTab\(changedTabId\);[\s\S]*?clearGitFooterPayloadState\(changedTabId\);[\s\S]*?if \(!isCurrentTabContext\(tabContext\)\)/,
|
|
26
26
|
"a cwd change that finishes after a tab switch should invalidate that tab's old footer state",
|
|
27
27
|
);
|
|
28
|
+
assert.match(
|
|
29
|
+
app,
|
|
30
|
+
/if \(response\.data\?\.changed !== false\) closeFileViewer\(\);\s*const nextContext = setActiveTabId\(response\.data\?\.tab\?\.id \|\| activeTabId\);\s*resetActiveTabUi\(\);/,
|
|
31
|
+
"a successful cwd change should discard the old workspace viewer instead of restoring its path in the replacement workspace",
|
|
32
|
+
);
|
|
28
33
|
|
|
29
34
|
assert.match(
|
|
30
35
|
app,
|
|
@@ -95,7 +95,7 @@ assert.match(app, /case "tool_execution_end":[\s\S]*?compactLiveScheduler\.flush
|
|
|
95
95
|
assert.match(resetStream, /resetCompactLiveOutput\(\)/, "reset and tab changes should cancel compact pending work");
|
|
96
96
|
assert.match(app, /case "message_end": \{\s+if \(compactOutputActive\(\)\) finishCompactLiveOutput\(tabContext\);/, "message ends should synchronously flush compact output before reconciliation");
|
|
97
97
|
assert.match(app, /case "agent_end":\s+if \(compactOutputActive\(\)\) finishCompactLiveOutput\(tabContext\);/, "agent ends should synchronously flush compact output before reconciliation");
|
|
98
|
-
assert.match(compactTranscript, /message\.role !== "assistant"[\s\S]*?appendMarkdown\(body, output \|\| "_\[non-text output omitted in
|
|
98
|
+
assert.match(compactTranscript, /message\.role !== "assistant"[\s\S]*?appendMarkdown\(body, output \|\| "_\[non-text output omitted in compact mode\]_"\)[\s\S]*?classList\.add\("compact-transcript-text"\)/, "reconciled compact-mode assistant output should preserve Markdown and explain omitted non-text output");
|
|
99
99
|
assert.doesNotMatch(compactTranscript, /appendText|renderToolExecution|normalizeToolExecution|JSON\.stringify|appendToolOutput|appendToolDiff|appendToolImages/, "fast-mode final output must not fall back to plain text or render tool details");
|
|
100
100
|
assert.match(createMessageBubble, /compactOutputActive\(\) && !streaming[\s\S]*?renderCompactTranscriptBody\(body, message\)/, "final transcript rendering should select the compact Markdown path only for acknowledged fast mode");
|
|
101
101
|
assert.match(appendTranscriptMessage, /compactTranscript && transcriptMessage\.role !== "assistant"/, "fast-mode assistant reconciliation should defer all thinking to the aggregate transcript item and retain only final output");
|
|
@@ -127,7 +127,7 @@ assert.match(refreshMessages, /preserveCompactStream = compactLiveStreamRenderAc
|
|
|
127
127
|
assert.match(app, /const SETTINGS_OUTPUT_MODE_OPTIONS = \[[\s\S]*?value: "normal"[\s\S]*?value: "compact-v1"/, "settings should offer normal and compact-v1 server defaults");
|
|
128
128
|
assert.match(nativeSettingsDialog, /api\("\/api\/webui-output-mode", \{ scoped: false \}\)/, "opening settings should load output-mode metadata from the separate server API");
|
|
129
129
|
assert.match(nativeSettingsDialog, /outputMode: nativeSettingSelect\("Output processing", outputModeMetadata\.persistedDefault, SETTINGS_OUTPUT_MODE_OPTIONS,[\s\S]*?\{ label: "server", tone: "startup" \}\)/, "Browser workflow should expose a server-badged output-processing selector");
|
|
130
|
-
assert.match(nativeSettingsDialog, /
|
|
130
|
+
assert.match(nativeSettingsDialog, /Compact mode preserves Markdown final output, keeps live thinking expanded, groups stored thinking in one collapsed disclosure per turn, shows only the current tool status transiently, and does not change model inference or token generation\. Changes use server barriers without restarting Pi\./, "settings copy should distinguish expanded live thinking from collapsed stored thinking without changing inference semantics");
|
|
131
131
|
assert.match(nativeSettingsDialog, /nativeSettingsSection\("Browser workflow"[\s\S]*?controls\.outputMode/, "the output-mode selector should be placed in Browser workflow");
|
|
132
132
|
assert.match(outputModeMetadataText, /Persisted default:[\s\S]*?Effective mode:[\s\S]*?Source:/, "settings should display persisted default plus effective mode and source");
|
|
133
133
|
assert.match(outputModeMetadataText, /metadata\.overridden[\s\S]*?overrides the persisted setting/, "settings should display CLI/environment override state when it wins");
|
|
@@ -137,12 +137,12 @@ assert.match(nativeSettingsDialog, /method: "PUT",[\s\S]*?body: \{ outputModeDef
|
|
|
137
137
|
assert.doesNotMatch(nativeSettingsPayload, /outputMode(?:Default|Metadata|ApiDiagnostic|Changed)?/, "server-scoped output mode must stay out of the native SettingsManager payload");
|
|
138
138
|
assert.match(nativeSettingsDialog, /const response = await nativeCommandApi\("\/api\/settings", \{ method: "POST", body: \{ settings: payload, reload \} \}\);[\s\S]*?nativeSettingsChangedMessage\(response, reload\)/, "existing native settings apply behavior should remain intact");
|
|
139
139
|
|
|
140
|
-
assert.match(html, /data-side-panel-section="controls"[\s\S]*?id="outputProcessingControlsTitle">Output processing<[\s\S]*?<span class="control-scope-badge">Server<\/span>[\s\S]*?id="fastOutputModeSelect"[\s\S]*?<option value="normal">Normal<\/option>[\s\S]*?<option value="compact-v1">
|
|
140
|
+
assert.match(html, /data-side-panel-section="controls"[\s\S]*?id="outputProcessingControlsTitle">Output processing<[\s\S]*?<span class="control-scope-badge">Server<\/span>[\s\S]*?id="fastOutputModeSelect"[\s\S]*?<option value="normal">Normal<\/option>[\s\S]*?<option value="compact-v1">Compact<\/option>[\s\S]*?id="setFastOutputModeButton"[\s\S]*?id="fastOutputModeStatus"/, "Controls should expose a server-scoped normal/compact selector with apply button and live status");
|
|
141
141
|
assert.match(app, /fastOutputModeSelect: \$\("#fastOutputModeSelect"\)[\s\S]*?setFastOutputModeButton: \$\("#setFastOutputModeButton"\)[\s\S]*?fastOutputModeStatus: \$\("#fastOutputModeStatus"\)/, "sidebar fast-mode elements should be wired");
|
|
142
142
|
assert.match(sidebarOutputModeRefresh, /api\("\/api\/webui-output-mode", \{ scoped: false \}\)[\s\S]*?normalizeWebuiOutputModeMetadata\(response\.data\)/, "sidebar selector should load current server output-mode metadata");
|
|
143
143
|
assert.match(sidebarOutputModeApply, /method: "PUT"[\s\S]*?body: \{ outputModeDefault \}[\s\S]*?scoped: false[\s\S]*?await refreshSidebarOutputMode\(\)/, "sidebar selector should persist the selected mode and refresh effective metadata");
|
|
144
|
-
assert.match(sidebarOutputModeApply, /outputModeDefault === "compact-v1"[\s\S]*?
|
|
145
|
-
assert.match(sidebarOutputModeApply, /sidebarOutputModeDiagnostic = ""[\s\S]*?sidebarOutputModeNotice = `Failed to update
|
|
144
|
+
assert.match(sidebarOutputModeApply, /outputModeDefault === "compact-v1"[\s\S]*?Compact output mode enabled[\s\S]*?Normal output processing restored/, "sidebar apply feedback should distinguish enabling compact mode from restoring normal mode");
|
|
145
|
+
assert.match(sidebarOutputModeApply, /sidebarOutputModeDiagnostic = ""[\s\S]*?sidebarOutputModeNotice = `Failed to update compact mode:[\s\S]*?You can retry\.`[\s\S]*?sidebarOutputModeLoaded = true/, "a transient apply failure should remain visible without permanently disabling retry");
|
|
146
146
|
assert.match(app, /function renderSidebarOutputModeControl[\s\S]*?sidebarOutputModeNotice[\s\S]*?webuiOutputModeMetadataText\(sidebarOutputModeMetadata\)[\s\S]*?updateSidebarOutputModeApplyState\(\)/, "sidebar status should expose retry notices or persisted/effective/source metadata and apply state");
|
|
147
147
|
assert.match(styles, /\.toggle-control-hint\.warning\s*\{[\s\S]*?color: var\(--ctp-yellow\)/, "sidebar output-mode failures should use the warning palette");
|
|
148
148
|
assert.match(app, /fastOutputModeSelect\?\.addEventListener\("change", \(\) => \{[\s\S]*?sidebarOutputModeNotice = ""[\s\S]*?renderSidebarOutputModeControl\(\{ syncSelection: false \}\)[\s\S]*?setFastOutputModeButton\?\.addEventListener\("click", \(\) => applySidebarOutputMode\(\)/, "sidebar selection should clear transient failures and keep Apply retryable");
|
|
@@ -150,9 +150,9 @@ assert.match(app, /refreshSidebarOutputMode\(\)\.catch[\s\S]*?initializeTabs\(\)
|
|
|
150
150
|
|
|
151
151
|
assert.match(helper, /FAST_OUTPUT_FLUSH_INTERVAL_MS = 100/, "the live scheduler should retain the exact 100 ms sustained-output bound");
|
|
152
152
|
assert.match(worker, /pi-webui-pwa-v\d+[\s\S]*?"\/fast-output-live\.mjs"/, "PWA cache identity and app shell should include the compact helper");
|
|
153
|
-
assert.match(html, /<label for="fastOutputModeSelect">
|
|
154
|
-
assert.match(html, /Markdown final output; live thinking expanded; stored thinking grouped and collapsed/, "the sidebar should distinguish
|
|
155
|
-
assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=
|
|
153
|
+
assert.match(html, /<label for="fastOutputModeSelect">Compact mode \(Experimental\)<\/label>/, "the sidebar should mark compact mode as experimental");
|
|
154
|
+
assert.match(html, /Lightweight browser rendering; Markdown final output; live thinking expanded; stored thinking grouped and collapsed/, "the sidebar should distinguish compact rendering from model inference");
|
|
155
|
+
assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=94"/, "the guarded PWA entry point should cache-bust browser wiring");
|
|
156
156
|
assert.match(JSON.parse(packageRaw).scripts.check, /node --check public\/fast-output-live\.mjs/, "package checks should parse the compact helper");
|
|
157
157
|
|
|
158
158
|
const events = createFastModeOutputEvents();
|
|
@@ -0,0 +1,21 @@
|
|
|
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 css = await readFile(join(root, "public", "styles.css"), "utf8");
|
|
8
|
+
|
|
9
|
+
const selectionBarRule = css.match(/\.file-selection-bar \{[^}]*\}/)?.[0] || "";
|
|
10
|
+
assert.match(
|
|
11
|
+
selectionBarRule,
|
|
12
|
+
/position:\s*absolute;[^}]*right:\s*0\.72rem;[^}]*bottom:\s*1\.68rem;[^}]*left:\s*0\.72rem;[^}]*z-index:\s*7;/,
|
|
13
|
+
"the file selection comment bar should overlay the viewer instead of shifting selected text",
|
|
14
|
+
);
|
|
15
|
+
assert.doesNotMatch(
|
|
16
|
+
selectionBarRule,
|
|
17
|
+
/flex:\s*0\s+0\s+auto;/,
|
|
18
|
+
"the file selection comment bar must stay out of the viewer's flex layout",
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
console.log("file selection overlay static tests passed");
|