@firstpick/pi-package-webui 0.8.1 → 0.8.2
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 +12 -0
- package/bin/pi-webui.mjs +190 -20
- package/lib/component-update-state.mjs +126 -0
- package/lib/trust-boundaries.mjs +1 -0
- package/package.json +1 -1
- package/public/app.js +1454 -101
- package/public/index.html +155 -27
- package/public/service-worker.js +1 -1
- package/public/styles.css +731 -2
- package/tests/boot-failure-diagnostics.test.mjs +63 -5
- package/tests/browser/control-deck-component-updates.spec.mjs +180 -0
- package/tests/browser/interaction-continuity.spec.mjs +158 -0
- package/tests/browser/mobile-foundation.spec.mjs +11 -0
- package/tests/browser/side-panel-section-reorder.spec.mjs +101 -0
- package/tests/browser/stats-overlay.spec.mjs +265 -0
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/component-update-api-static.test.mjs +67 -0
- package/tests/component-update-state.test.mjs +80 -0
- package/tests/control-deck-component-updates-static.test.mjs +251 -0
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/fixtures/fake-pi.mjs +129 -5
- package/tests/footer-provider-usage-visual-static.test.mjs +71 -0
- package/tests/interaction-state-stability-static.test.mjs +21 -4
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +6 -4
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +2 -1
- package/tests/native-parity-harness.test.mjs +2 -0
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/side-panel-section-reorder-static.test.mjs +68 -0
- package/tests/sse-backpressure-harness.test.mjs +51 -12
- package/tests/stats-dashboard-static.test.mjs +266 -0
|
@@ -0,0 +1,251 @@
|
|
|
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 [html, css, app, server, readme] = await Promise.all([
|
|
9
|
+
readFile(join(root, "public", "index.html"), "utf8"),
|
|
10
|
+
readFile(join(root, "public", "styles.css"), "utf8"),
|
|
11
|
+
readFile(join(root, "public", "app.js"), "utf8"),
|
|
12
|
+
readFile(join(root, "bin", "pi-webui.mjs"), "utf8"),
|
|
13
|
+
readFile(join(root, "README.md"), "utf8"),
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
function functionSource(name, nextName) {
|
|
17
|
+
const start = app.indexOf(`function ${name}(`);
|
|
18
|
+
const end = app.indexOf(`\nfunction ${nextName}(`, start);
|
|
19
|
+
assert.ok(start >= 0 && end > start, `${name} should remain a standalone frontend helper`);
|
|
20
|
+
return app.slice(start, end);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const piDialog = html.match(/<dialog id="piReleaseNotesDialog"[\s\S]*?<\/dialog>/)?.[0] || "";
|
|
24
|
+
assert.match(piDialog, /aria-labelledby="piReleaseNotesTitle"/, "the Pi version tag should keep its accessible release-notes dialog");
|
|
25
|
+
assert.match(piDialog, /id="piComponentUpdateStatus"[^>]*role="status"[^>]*aria-live="polite"/, "the Pi dialog should announce component update state");
|
|
26
|
+
assert.match(piDialog, /id="piComponentUpdateButton"[^>]*>Update Pi<\/button>/, "the Pi dialog should expose a targeted update action");
|
|
27
|
+
|
|
28
|
+
const webuiDialog = html.match(/<dialog id="webuiPackageDialog"[\s\S]*?<\/dialog>/)?.[0] || "";
|
|
29
|
+
assert.match(html, /id="webuiVersionButton"[^>]*aria-haspopup="dialog"[^>]*aria-controls="webuiPackageDialog"/, "the Web UI version tag should control its dedicated package dialog");
|
|
30
|
+
assert.match(webuiDialog, /aria-labelledby="webuiPackageTitle"/, "the Web UI package dialog should have an accessible title");
|
|
31
|
+
assert.match(webuiDialog, /<dt>Installed<\/dt>[\s\S]*id="webuiPackageCurrentVersion"[\s\S]*<dt>Latest on npm<\/dt>[\s\S]*id="webuiPackageLatestVersion"/, "the Web UI dialog should show installed and latest versions");
|
|
32
|
+
assert.match(webuiDialog, /id="webuiPackageNpmButton"[^>]*>View on npm<\/button>/, "the Web UI dialog should retain the npm package action");
|
|
33
|
+
assert.match(webuiDialog, /id="webuiComponentUpdateStatus"[^>]*role="status"[^>]*aria-live="polite"/, "the Web UI dialog should announce component update state");
|
|
34
|
+
assert.match(webuiDialog, /id="webuiComponentUpdateButton"[^>]*>Update Web UI<\/button>/, "the Web UI dialog should expose a targeted update action");
|
|
35
|
+
assert.match(app, /webuiPackageNpmButton\?\.addEventListener\("click", \(\) => \{[\s\S]*confirmOpenWebuiNpmPage\(\)/, "the package dialog npm action should reuse the guarded external-link flow");
|
|
36
|
+
|
|
37
|
+
for (const state of ["available", "running", "succeeded", "failed"]) {
|
|
38
|
+
assert.match(css, new RegExp(`\\.pi-version-button\\[data-update-state="${state}"\\]::after[\\s\\S]*\\.webui-version-button\\[data-update-state="${state}"\\]::after`), `both component tags should render the ${state} indicator`);
|
|
39
|
+
}
|
|
40
|
+
assert.match(css, /prefers-reduced-motion: reduce[\s\S]*data-update-state="running"/, "the running indicator should respect reduced-motion preferences");
|
|
41
|
+
|
|
42
|
+
const renderPiVersionButtonSource = functionSource("renderPiVersionButton", "renderWebuiVersionButton");
|
|
43
|
+
const renderWebuiVersionButtonSource = functionSource("renderWebuiVersionButton", "renderWebuiDevBadge");
|
|
44
|
+
assert.match(renderPiVersionButtonSource, /componentUpdateTagState\("pi"\)[\s\S]*setAttribute\("aria-label", stateText/, "the Pi tag should use Pi-only state in its accessible name");
|
|
45
|
+
assert.match(renderWebuiVersionButtonSource, /componentUpdateTagState\("webui"\)[\s\S]*setAttribute\("aria-label", stateText/, "the Web UI tag should use Web-UI-only state in its accessible name");
|
|
46
|
+
|
|
47
|
+
const componentBlockStart = app.indexOf('const COMPONENT_UPDATE_TARGETS = ["pi", "webui"];');
|
|
48
|
+
const componentBlockEnd = app.indexOf("\nfunction initializeUpdateNotifications()", componentBlockStart);
|
|
49
|
+
assert.ok(componentBlockStart >= 0 && componentBlockEnd > componentBlockStart, "component update helpers should remain a focused frontend block");
|
|
50
|
+
const componentBlock = app.slice(componentBlockStart, componentBlockEnd);
|
|
51
|
+
|
|
52
|
+
const calls = [];
|
|
53
|
+
const events = [];
|
|
54
|
+
const scheduled = [];
|
|
55
|
+
const cleared = [];
|
|
56
|
+
const makeButton = () => ({
|
|
57
|
+
hidden: false,
|
|
58
|
+
textContent: "",
|
|
59
|
+
title: "",
|
|
60
|
+
disabled: false,
|
|
61
|
+
dataset: {},
|
|
62
|
+
attributes: {},
|
|
63
|
+
setAttribute(name, value) { this.attributes[name] = value; },
|
|
64
|
+
});
|
|
65
|
+
const makeStatus = () => ({ textContent: "", hidden: false, dataset: {} });
|
|
66
|
+
const elements = {
|
|
67
|
+
piVersionButton: makeButton(),
|
|
68
|
+
webuiVersionButton: makeButton(),
|
|
69
|
+
piComponentUpdateStatus: makeStatus(),
|
|
70
|
+
piComponentUpdateButton: makeButton(),
|
|
71
|
+
webuiComponentUpdateStatus: makeStatus(),
|
|
72
|
+
webuiComponentUpdateButton: makeButton(),
|
|
73
|
+
webuiPackageCurrentVersion: makeStatus(),
|
|
74
|
+
webuiPackageLatestVersion: makeStatus(),
|
|
75
|
+
webuiPackageDialog: { open: false, showModal() { this.open = true; } },
|
|
76
|
+
};
|
|
77
|
+
let nextTimer = 1;
|
|
78
|
+
let refreshShouldFail = false;
|
|
79
|
+
const context = {
|
|
80
|
+
elements,
|
|
81
|
+
console,
|
|
82
|
+
setTimeout(callback, delay) {
|
|
83
|
+
const id = nextTimer++;
|
|
84
|
+
scheduled.push({ id, callback, delay });
|
|
85
|
+
return id;
|
|
86
|
+
},
|
|
87
|
+
clearTimeout(id) { cleared.push(id); },
|
|
88
|
+
formatWebuiVersion(value) {
|
|
89
|
+
const text = String(value || "").trim();
|
|
90
|
+
return text ? (text.startsWith("v") ? text : `v${text}`) : "";
|
|
91
|
+
},
|
|
92
|
+
packageUpdateText(label, status = {}) {
|
|
93
|
+
return `${label} ${status.currentVersion || ""} → ${status.latestVersion || ""}`.trim();
|
|
94
|
+
},
|
|
95
|
+
appConfirmText: async (_message, options) => {
|
|
96
|
+
calls.push({ kind: "confirm", options });
|
|
97
|
+
return true;
|
|
98
|
+
},
|
|
99
|
+
api: async (path, options) => {
|
|
100
|
+
calls.push({ kind: "api", path, options });
|
|
101
|
+
return { data: { target: options.body.target, state: "running", canStart: false, message: "Update is running." } };
|
|
102
|
+
},
|
|
103
|
+
addEvent(message, level) { events.push({ message, level }); },
|
|
104
|
+
refreshUpdateStatus: async () => {
|
|
105
|
+
if (refreshShouldFail) throw new Error("temporary status failure");
|
|
106
|
+
return null;
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
vm.runInNewContext(`
|
|
110
|
+
let latestUpdateStatus = null;
|
|
111
|
+
let piVersion = "0.83.0";
|
|
112
|
+
let webuiVersion = "0.8.1";
|
|
113
|
+
let componentUpdatePollTimer = null;
|
|
114
|
+
let componentUpdateStartInProgress = false;
|
|
115
|
+
let updateRequestInProgress = false;
|
|
116
|
+
const COMPONENT_UPDATE_POLL_MS = 1000;
|
|
117
|
+
${renderPiVersionButtonSource}
|
|
118
|
+
${renderWebuiVersionButtonSource}
|
|
119
|
+
${componentBlock}
|
|
120
|
+
globalThis.componentHarness = {
|
|
121
|
+
setStatus(value) { latestUpdateStatus = value; },
|
|
122
|
+
getStatus() { return latestUpdateStatus; },
|
|
123
|
+
tagState: componentUpdateTagState,
|
|
124
|
+
statusText: componentUpdateStatusText,
|
|
125
|
+
buttonState: componentUpdateButtonState,
|
|
126
|
+
renderIndicators: renderComponentUpdateIndicators,
|
|
127
|
+
renderDialogs: renderComponentUpdateDialogs,
|
|
128
|
+
syncPolling: syncComponentUpdatePolling,
|
|
129
|
+
pollTimer() { return componentUpdatePollTimer; },
|
|
130
|
+
start: startComponentUpdate,
|
|
131
|
+
};
|
|
132
|
+
`, context);
|
|
133
|
+
const harness = context.componentHarness;
|
|
134
|
+
|
|
135
|
+
harness.setStatus({
|
|
136
|
+
updateInProgress: false,
|
|
137
|
+
pi: { currentVersion: "0.83.0", latestVersion: "0.84.0", updateAvailable: true },
|
|
138
|
+
webui: { currentVersion: "0.8.1", latestVersion: "0.8.1", updateAvailable: false, checked: true },
|
|
139
|
+
componentUpdates: {
|
|
140
|
+
pi: { target: "pi", state: "idle", canStart: true },
|
|
141
|
+
webui: { target: "webui", state: "idle", canStart: true },
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
harness.renderIndicators();
|
|
145
|
+
assert.equal(elements.piVersionButton.dataset.updateState, "available", "Pi availability should mark only the Pi tag");
|
|
146
|
+
assert.equal(elements.piVersionButton.attributes["aria-label"], "View Pi v0.83.0 release notes, update available", "Pi availability should be present in the accessible name");
|
|
147
|
+
assert.equal(elements.webuiVersionButton.dataset.updateState, undefined, "Pi availability should not mark the Web UI tag");
|
|
148
|
+
assert.doesNotMatch(elements.webuiVersionButton.attributes["aria-label"], /update available/, "Pi availability should not leak into the Web UI accessible name");
|
|
149
|
+
|
|
150
|
+
harness.setStatus({
|
|
151
|
+
updateInProgress: false,
|
|
152
|
+
pi: { updateAvailable: true },
|
|
153
|
+
webui: { updateAvailable: true },
|
|
154
|
+
componentUpdates: {
|
|
155
|
+
pi: { state: "succeeded", canStart: true, message: "Pi update completed." },
|
|
156
|
+
webui: { state: "failed", canStart: true, message: "Web UI update failed.", error: "bounded failure" },
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
assert.equal(harness.tagState("pi"), "succeeded", "terminal Pi success should outrank stale availability");
|
|
160
|
+
assert.equal(harness.tagState("webui"), "failed", "terminal Web UI failure should outrank stale availability");
|
|
161
|
+
assert.match(harness.statusText("pi").text, /New or reloaded Pi sessions use the update; already-running tabs keep their current runtime/, "Pi success should explain activation without interrupting active tabs");
|
|
162
|
+
assert.match(harness.statusText("webui").text, /bounded failure[\s\S]*retry the update/, "Web UI failure should remain visible and permit retry");
|
|
163
|
+
assert.equal(harness.buttonState("webui").label, "Retry Web UI update", "a failed Web UI update should expose retry");
|
|
164
|
+
assert.equal(harness.buttonState("webui").disabled, false, "retry should be enabled when no update is running");
|
|
165
|
+
|
|
166
|
+
harness.setStatus({
|
|
167
|
+
updateInProgress: false,
|
|
168
|
+
webui: { currentVersion: "0.8.1", latestVersion: "0.8.2", updateAvailable: true },
|
|
169
|
+
componentUpdates: {
|
|
170
|
+
pi: { state: "idle", canStart: true },
|
|
171
|
+
webui: { state: "idle", canStart: false, unavailableReason: "Automatic Web UI update is unavailable from a source or development checkout." },
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
assert.equal(harness.buttonState("webui").disabled, true, "source/development Web UI self-update should be disabled");
|
|
175
|
+
assert.match(harness.statusText("webui").text, /source or development checkout/, "source/development refusal should be explained in the live status");
|
|
176
|
+
|
|
177
|
+
harness.setStatus({
|
|
178
|
+
updateInProgress: true,
|
|
179
|
+
pi: { updateAvailable: true },
|
|
180
|
+
webui: { updateAvailable: true },
|
|
181
|
+
componentUpdates: {
|
|
182
|
+
pi: { state: "running", canStart: false, message: "Updating Pi…" },
|
|
183
|
+
webui: { state: "idle", canStart: false },
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
assert.equal(harness.buttonState("pi").disabled, true, "the running target should reject duplicate starts");
|
|
187
|
+
assert.equal(harness.buttonState("webui").disabled, true, "a running Pi update should disable the conflicting Web UI start");
|
|
188
|
+
harness.syncPolling();
|
|
189
|
+
assert.equal(scheduled.length, 1, "a running update should create one short polling timer");
|
|
190
|
+
assert.equal(scheduled[0].delay, 1000, "running status should poll at the bounded one-second interval");
|
|
191
|
+
harness.syncPolling();
|
|
192
|
+
assert.equal(scheduled.length, 1, "re-rendering while running should not create duplicate poll timers");
|
|
193
|
+
refreshShouldFail = true;
|
|
194
|
+
scheduled[0].callback();
|
|
195
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
196
|
+
assert.equal(scheduled.length, 2, "a transient status failure should re-arm polling while the last known job remains running");
|
|
197
|
+
assert.match(events.at(-1)?.message || "", /status check failed/i, "a transient polling failure should remain visible in the event log");
|
|
198
|
+
refreshShouldFail = false;
|
|
199
|
+
const rearmedTimer = harness.pollTimer();
|
|
200
|
+
harness.setStatus({
|
|
201
|
+
updateInProgress: false,
|
|
202
|
+
componentUpdates: {
|
|
203
|
+
pi: { state: "succeeded", canStart: true },
|
|
204
|
+
webui: { state: "idle", canStart: true },
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
harness.syncPolling();
|
|
208
|
+
assert.deepEqual(cleared, [rearmedTimer], "terminal state should clear the re-armed running poll");
|
|
209
|
+
assert.equal(harness.pollTimer(), null, "terminal state should release the polling timer reference");
|
|
210
|
+
|
|
211
|
+
calls.length = 0;
|
|
212
|
+
harness.setStatus({
|
|
213
|
+
updateInProgress: false,
|
|
214
|
+
pi: { currentVersion: "0.83.0", latestVersion: "0.84.0", updateAvailable: true },
|
|
215
|
+
webui: { updateAvailable: false },
|
|
216
|
+
componentUpdates: {
|
|
217
|
+
pi: { state: "idle", canStart: true },
|
|
218
|
+
webui: { state: "idle", canStart: true },
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
await harness.start("pi");
|
|
222
|
+
const piStartCall = calls.find((call) => call.kind === "api");
|
|
223
|
+
assert.equal(piStartCall?.path, "/api/component-update", "the Pi dialog should use the component-update endpoint");
|
|
224
|
+
assert.equal(piStartCall?.options.method, "POST", "component update starts should use POST");
|
|
225
|
+
assert.equal(piStartCall?.options.scoped, false, "component update starts should not inherit a Pi tab scope");
|
|
226
|
+
assert.equal(JSON.stringify(piStartCall?.options.body), '{"target":"pi"}', "the Pi dialog should send only the exact Pi target");
|
|
227
|
+
assert.equal(harness.getStatus().componentUpdates.pi.state, "running", "the accepted 202-shaped state should render immediately as running");
|
|
228
|
+
assert.equal(harness.buttonState("pi").disabled, true, "the accepted job should immediately disable duplicate starts");
|
|
229
|
+
assert.match(componentBlock, /statusElement\.hidden = false;[\s\S]*statusElement\.textContent = text;/, "component live regions should remain rendered before their status text changes");
|
|
230
|
+
assert.match(app, /openPiReleaseNotes\(\)[\s\S]*refreshUpdateStatus\(\{ notify: false \}\)/, "opening Pi details should refresh component status even when cached state exists");
|
|
231
|
+
|
|
232
|
+
assert.match(
|
|
233
|
+
server,
|
|
234
|
+
/url\.pathname === "\/api\/component-update" && req\.method === "POST"[\s\S]*requireLocalhostRoute\(req, url\.pathname\)[\s\S]*validateComponentUpdateRequest\(body\)[\s\S]*sendJson\(res, 202/,
|
|
235
|
+
"the server should keep exact validation, localhost restriction, and 202 acceptance for component starts",
|
|
236
|
+
);
|
|
237
|
+
assert.match(
|
|
238
|
+
app,
|
|
239
|
+
/async function runPiUpdateAndRestart\([\s\S]*api\(all \? "\/api\/update\?all=1" : "\/api\/update", \{ method: "POST", scoped: false \}\)[\s\S]*waitForServerRestart\(\)/,
|
|
240
|
+
"the legacy browser update-and-restart flow should remain compatible",
|
|
241
|
+
);
|
|
242
|
+
assert.match(
|
|
243
|
+
server,
|
|
244
|
+
/url\.pathname === "\/api\/update" && req\.method === "POST"[\s\S]*runPiUpdateAndPrepareRestart\(\{ all: queryAll \|\| bodyAll \}\)[\s\S]*sendJson\(res, 200[\s\S]*shutdown\("api update", \{ preserveSessions: true \}\)/,
|
|
245
|
+
"the legacy server route should retain update-all selection, completion response, restart, and managed-session preservation",
|
|
246
|
+
);
|
|
247
|
+
assert.match(readme, /Control Deck component updates[\s\S]*component-specific `available`, `running`, `succeeded`, or `failed` status/, "README should explain the component-specific tag indicators");
|
|
248
|
+
assert.match(readme, /Update Pi[\s\S]*does not restart the Web UI or interrupt managed Pi tabs[\s\S]*Update Web UI[\s\S]*restart the Web UI after success/, "README should explain Pi and Web UI activation behavior");
|
|
249
|
+
assert.match(readme, /only from localhost[\s\S]*disabled for source\/development checkouts[\s\S]*verify the installed version before retrying[\s\S]*broader legacy behavior/, "README should document security, source refusal, recovery, and legacy compatibility");
|
|
250
|
+
|
|
251
|
+
console.log("control deck component update static tests passed");
|
|
@@ -155,7 +155,7 @@ assert.match(worker, /pi-webui-pwa-v\d+[\s\S]*?"\/fast-output-live\.mjs"/, "PWA
|
|
|
155
155
|
assert.match(html, /<label for="fastOutputModeSelect">Compact mode \(Experimental\)<\/label>/, "the sidebar should mark compact mode as experimental");
|
|
156
156
|
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");
|
|
157
157
|
// Intent preserved: the guarded PWA entry point must advance whenever app wiring changes.
|
|
158
|
-
assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=
|
|
158
|
+
assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=104"/, "the guarded PWA entry point should cache-bust browser wiring");
|
|
159
159
|
assert.match(JSON.parse(packageRaw).scripts.check, /node --check public\/fast-output-live\.mjs/, "package checks should parse the compact helper");
|
|
160
160
|
|
|
161
161
|
const events = createFastModeOutputEvents();
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
// assistant turns are appended to a dynamic transcript returned by
|
|
16
16
|
// get_messages AFTER the three baseline messages, and get_state reports
|
|
17
17
|
// isStreaming=true while a scripted flow runs.
|
|
18
|
+
// - FAKE_PI_STATS_PROMPT_CONTEXT=1: advertise /stats-webui and publish deterministic
|
|
19
|
+
// structured or malformed-subsection Prompt/context dashboard payloads.
|
|
18
20
|
import { createInterface } from "node:readline";
|
|
19
21
|
import { randomUUID } from "node:crypto";
|
|
20
22
|
import { appendFileSync } from "node:fs";
|
|
@@ -47,6 +49,7 @@ const voiceScriptsEnabled = process.env.FAKE_PI_VOICE_SCRIPTS === "1";
|
|
|
47
49
|
const continuityModeEnabled = process.env.FAKE_PI_CONTINUITY_MODE === "1";
|
|
48
50
|
const largePayloadsEnabled = process.env.FAKE_PI_LARGE_PAYLOADS === "1";
|
|
49
51
|
const sseFloodEnabled = process.env.FAKE_PI_SSE_FLOOD === "1";
|
|
52
|
+
const statsPromptContextEnabled = process.env.FAKE_PI_STATS_PROMPT_CONTEXT === "1";
|
|
50
53
|
const commandLogFile = process.env.FAKE_PI_LOG_FILE || "";
|
|
51
54
|
const largeRpcText = "large-rpc-payload:" + "λ".repeat(70_000);
|
|
52
55
|
const largeTokenSamples = Array.from({ length: 300 }, (_, index) => ({ index, input: index + 1, output: index + 2 }));
|
|
@@ -348,12 +351,17 @@ function runTranscriptContinuityScenario(scenario) {
|
|
|
348
351
|
finish({ role: "assistant", content: [{ type: "thinking", thinking: "thinking selection literal survives" }, { type: "text", text: "thinking final answer" }], timestamp: Date.now() }, 450);
|
|
349
352
|
} else if (scenario === "tool") {
|
|
350
353
|
const toolCallId = `continuity-tool-${run}`;
|
|
354
|
+
const toolOutput = (revision) => [
|
|
355
|
+
"tool selection literal",
|
|
356
|
+
`unselected revision ${revision}`,
|
|
357
|
+
...Array.from({ length: 64 }, (_, index) => `continuity output line ${String(index + 1).padStart(2, "0")} ${"x".repeat(160)}`),
|
|
358
|
+
].join("\n");
|
|
351
359
|
steps.push(
|
|
352
360
|
{ afterMs: 40, run: () => emitScriptedEvent(tagged({ type: "agent_start" })) },
|
|
353
361
|
{ afterMs: 70, run: () => emitScriptedEvent(tagged({ type: "tool_execution_start", toolCallId, toolName: "read", args: { path: "continuity.txt" } })) },
|
|
354
|
-
{ afterMs: 100, run: () => emitScriptedEvent(tagged({ type: "tool_execution_update", toolCallId, toolName: "read", partialResult: { content: [{ type: "text", text: "
|
|
355
|
-
{ afterMs: 700, run: () => emitScriptedEvent(tagged({ type: "tool_execution_update", toolCallId, toolName: "read", partialResult: { content: [{ type: "text", text: "
|
|
356
|
-
{ afterMs: 600, run: () => emitScriptedEvent(tagged({ type: "tool_execution_end", toolCallId, toolName: "read", isError: false, result: { content: [{ type: "text", text: "
|
|
362
|
+
{ afterMs: 100, run: () => emitScriptedEvent(tagged({ type: "tool_execution_update", toolCallId, toolName: "read", partialResult: { content: [{ type: "text", text: toolOutput("one") }] } })) },
|
|
363
|
+
{ afterMs: 700, run: () => emitScriptedEvent(tagged({ type: "tool_execution_update", toolCallId, toolName: "read", partialResult: { content: [{ type: "text", text: toolOutput("two") }] } })) },
|
|
364
|
+
{ afterMs: 600, run: () => emitScriptedEvent(tagged({ type: "tool_execution_end", toolCallId, toolName: "read", isError: false, result: { content: [{ type: "text", text: toolOutput("two") }] } })) },
|
|
357
365
|
);
|
|
358
366
|
finish(null, 120);
|
|
359
367
|
} else if (scenario === "authoritative") {
|
|
@@ -447,10 +455,12 @@ function handleLargePayloadPrompt(command, base) {
|
|
|
447
455
|
}
|
|
448
456
|
|
|
449
457
|
function handleSseFloodPrompt(command, base) {
|
|
450
|
-
|
|
458
|
+
const message = String(command.message || "").trim();
|
|
459
|
+
if (!sseFloodEnabled || !["fixture sse flood", "fixture sse stall flood"].includes(message)) return false;
|
|
451
460
|
respond({ ...base, data: { output: "fake SSE flood accepted" } });
|
|
452
461
|
const payload = "s".repeat(8192);
|
|
453
|
-
|
|
462
|
+
const eventCount = message === "fixture sse stall flood" ? 4096 : 256;
|
|
463
|
+
for (let index = 0; index < eventCount; index += 1) {
|
|
454
464
|
emitEvent({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta: `${index}:${payload}` } });
|
|
455
465
|
}
|
|
456
466
|
return true;
|
|
@@ -899,6 +909,118 @@ function handleTalkPrompt(command, base) {
|
|
|
899
909
|
return true;
|
|
900
910
|
}
|
|
901
911
|
|
|
912
|
+
function statsPromptContextFixturePayload({ malformedSnapshot = false } = {}) {
|
|
913
|
+
const hostileLabel = `System <img src=x onerror="globalThis.fixturePwned=true"> & "quoted" ${"long-label-".repeat(16)}`;
|
|
914
|
+
const payload = {
|
|
915
|
+
type: "firstpick.pi-extension-stats.overlay",
|
|
916
|
+
version: 1,
|
|
917
|
+
generatedAt: Date.now(),
|
|
918
|
+
open: true,
|
|
919
|
+
scopeLabel: "fixture prompt context",
|
|
920
|
+
scope: { mode: "range", days: 14 },
|
|
921
|
+
sessionCount: 0,
|
|
922
|
+
scopedSessionCount: 0,
|
|
923
|
+
dayCount: 14,
|
|
924
|
+
activeDayCount: 0,
|
|
925
|
+
totals: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0, cost: 0 },
|
|
926
|
+
promptEstimate: {
|
|
927
|
+
total: 300, low: 270, high: 330, confidence: "fixture", calibrationMultiplier: 1,
|
|
928
|
+
calibrationSamples: 0, source: "export-html", settled: true, attempts: 0,
|
|
929
|
+
warning: null, systemPromptChars: 0, activeToolSchemas: 2,
|
|
930
|
+
},
|
|
931
|
+
promptContext: {
|
|
932
|
+
initialPrompt: {
|
|
933
|
+
totalTokens: 300,
|
|
934
|
+
lowTokens: 270,
|
|
935
|
+
highTokens: 330,
|
|
936
|
+
confidence: "fixture",
|
|
937
|
+
source: "export-html",
|
|
938
|
+
warning: null,
|
|
939
|
+
estimateMethod: "weighted-character-estimate-with-largest-remainder-calibration",
|
|
940
|
+
components: [
|
|
941
|
+
{ id: "system-prompt-1", kind: "system-prompt", label: hostileLabel, chars: null, uncalibratedTokens: 300, tokens: 300, percent: 100 },
|
|
942
|
+
{ id: "framing-1", kind: "framing", label: "Zero-token framing", chars: 0, uncalibratedTokens: 0, tokens: 0, percent: 0 },
|
|
943
|
+
],
|
|
944
|
+
},
|
|
945
|
+
snapshot: {
|
|
946
|
+
source: "export-html",
|
|
947
|
+
settled: true,
|
|
948
|
+
attempts: 0,
|
|
949
|
+
warning: null,
|
|
950
|
+
systemPromptChars: 0,
|
|
951
|
+
estimateComponents: {
|
|
952
|
+
promptText: malformedSnapshot ? "not-a-number" : 0,
|
|
953
|
+
toolSchemas: 25,
|
|
954
|
+
framing: 0,
|
|
955
|
+
calibration: { multiplier: 1, samples: 0 },
|
|
956
|
+
},
|
|
957
|
+
metadata: { currentDate: null, cwdDisplay: null, extraGuidelineCount: 0 },
|
|
958
|
+
tools: {
|
|
959
|
+
totalCount: 3,
|
|
960
|
+
omittedCount: 1,
|
|
961
|
+
items: [
|
|
962
|
+
{ name: "<script>fixture-tool</script>", description: "Text-safe <b>description</b> & symbols", parameterSummary: "0 params", estimatedTokens: 0 },
|
|
963
|
+
{ name: "read", description: null, parameterSummary: "1 param, 1 required", estimatedTokens: 25 },
|
|
964
|
+
],
|
|
965
|
+
},
|
|
966
|
+
toolPromptEntries: { totalCount: 2, omittedCount: 0, names: ["<unsafe-entry>", "read"] },
|
|
967
|
+
skills: { totalCount: 2, omittedCount: 1, items: [{ name: "fixture-skill", description: "Hostile </details> stays text" }] },
|
|
968
|
+
contextFiles: {
|
|
969
|
+
totalCount: 2,
|
|
970
|
+
omittedCount: 0,
|
|
971
|
+
items: [
|
|
972
|
+
{ displayPath: `nested/${"overflow-segment-".repeat(18)}context.md`, chars: null },
|
|
973
|
+
{ displayPath: "zero.md", chars: 0 },
|
|
974
|
+
],
|
|
975
|
+
},
|
|
976
|
+
},
|
|
977
|
+
currentContext: {
|
|
978
|
+
usage: { tokens: 0, contextWindow: null, percent: 0 },
|
|
979
|
+
breakdown: {
|
|
980
|
+
estimateMethod: "weighted-character-estimate",
|
|
981
|
+
reconstruction: "complete",
|
|
982
|
+
estimatedTotalTokens: 200,
|
|
983
|
+
actualMinusEstimatedTokens: -200,
|
|
984
|
+
sources: [
|
|
985
|
+
{ id: "user-messages-1", kind: "user-messages", label: `User ${"overflow-source-".repeat(18)}`, chars: 800, estimatedTokens: 200, percent: 100 },
|
|
986
|
+
],
|
|
987
|
+
},
|
|
988
|
+
},
|
|
989
|
+
},
|
|
990
|
+
summary: {},
|
|
991
|
+
daily: [],
|
|
992
|
+
models: [],
|
|
993
|
+
expensiveSessions: [],
|
|
994
|
+
lines: {
|
|
995
|
+
graph: ["RAW_GRAPH_FIXTURE"],
|
|
996
|
+
promptInjection: ["RAW_PROMPT_INJECTION <keep>& exact"],
|
|
997
|
+
promptDetailed: ["RAW_PROMPT_DETAILED </pre> exact"],
|
|
998
|
+
tokenBreakdown: ["RAW_CONTEXT_BREAKDOWN <raw> exact"],
|
|
999
|
+
costTrend: ["RAW_COST_TREND"],
|
|
1000
|
+
cache: ["RAW_CACHE"],
|
|
1001
|
+
modelComparison: ["RAW_MODEL_COMPARISON"],
|
|
1002
|
+
expensiveSessions: ["RAW_EXPENSIVE_SESSIONS"],
|
|
1003
|
+
},
|
|
1004
|
+
};
|
|
1005
|
+
return payload;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
function handleStatsPromptContextFixturePrompt(command, base) {
|
|
1009
|
+
if (!statsPromptContextEnabled) return false;
|
|
1010
|
+
const message = String(command.message || "").trim();
|
|
1011
|
+
const malformedSnapshot = message === "fixture stats prompt malformed";
|
|
1012
|
+
if (!malformedSnapshot && !/^\/stats-webui(?:\s|$)/.test(message)) return false;
|
|
1013
|
+
respond({ ...base, data: { output: malformedSnapshot ? "malformed stats prompt fixture emitted" : "structured stats prompt fixture emitted" } });
|
|
1014
|
+
emitEvent({
|
|
1015
|
+
type: "extension_ui_request",
|
|
1016
|
+
id: randomUUID(),
|
|
1017
|
+
method: "setStatus",
|
|
1018
|
+
statusKey: "stats-webui",
|
|
1019
|
+
statusText: JSON.stringify(statsPromptContextFixturePayload({ malformedSnapshot })),
|
|
1020
|
+
});
|
|
1021
|
+
return true;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
902
1024
|
const rl = createInterface({ input: process.stdin });
|
|
903
1025
|
rl.on("line", (line) => {
|
|
904
1026
|
if (!line.trim()) return;
|
|
@@ -965,6 +1087,7 @@ rl.on("line", (line) => {
|
|
|
965
1087
|
{ name: "conversation", source: "extension", description: "Natural Conversation Mode alias" },
|
|
966
1088
|
{ name: "fast-mode", source: "extension", description: "Toggle Codex subscription Fast mode" },
|
|
967
1089
|
{ name: "workflow", source: "extension", description: "Run and inspect JavaScript workflows" },
|
|
1090
|
+
...(statsPromptContextEnabled ? [{ name: "stats-webui", source: "extension", description: "Publish fixture stats dashboard" }] : []),
|
|
968
1091
|
],
|
|
969
1092
|
},
|
|
970
1093
|
});
|
|
@@ -987,6 +1110,7 @@ rl.on("line", (line) => {
|
|
|
987
1110
|
return;
|
|
988
1111
|
}
|
|
989
1112
|
case "prompt":
|
|
1113
|
+
if (handleStatsPromptContextFixturePrompt(command, base)) return;
|
|
990
1114
|
if (handleWebuiHelperPrompt(command, base)) return;
|
|
991
1115
|
if (handleFastModeFixturePrompt(command, base)) return;
|
|
992
1116
|
if (handleTransportFixturePrompt(command, base)) return;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
|
|
4
|
+
const [app, css, producer, parser] = await Promise.all([
|
|
5
|
+
readFile(new URL("../public/app.js", import.meta.url), "utf8"),
|
|
6
|
+
readFile(new URL("../public/styles.css", import.meta.url), "utf8"),
|
|
7
|
+
readFile(new URL("../../pi-extension-git-footer-status/index.ts", import.meta.url), "utf8"),
|
|
8
|
+
readFile(new URL("../../pi-extension-git-footer-status/provider-usage.ts", import.meta.url), "utf8"),
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const between = (source, start, end) => {
|
|
12
|
+
const startIndex = source.indexOf(start);
|
|
13
|
+
assert.notEqual(startIndex, -1, `missing section start: ${start}`);
|
|
14
|
+
const endIndex = source.indexOf(end, startIndex + start.length);
|
|
15
|
+
assert.notEqual(endIndex, -1, `missing section end: ${end}`);
|
|
16
|
+
return source.slice(startIndex, endIndex);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const normalizeChip = between(app, "function normalizeFooterPayloadChip", "function currentGitFooterCacheCwd");
|
|
20
|
+
const usageNormalization = normalizeChip.slice(normalizeChip.indexOf("if (value.usageWindows"));
|
|
21
|
+
const applyUsage = between(app, "function applyFooterUsageWindows", "const FOOTER_MIDDLE_TRUNCATION_END_CHARS");
|
|
22
|
+
const shapeKey = between(app, "function gitFooterChipShapeKey", "function footerBranchPickerRenderKey");
|
|
23
|
+
const inPlaceUpdate = between(app, "function updateGitFooterChipNodeValue", "let gitFooterRenderCache");
|
|
24
|
+
|
|
25
|
+
assert.match(parser, /x-codex-primary-window-minutes/, "Codex parser should read the primary window duration");
|
|
26
|
+
assert.match(parser, /x-codex-secondary-window-minutes/, "Codex parser should read the secondary window duration");
|
|
27
|
+
assert.match(parser, /windowMinutes === 10_080\) return "weekly"/, "Codex weekly windows should have a truthful compact label");
|
|
28
|
+
assert.match(parser, /return fallback;/, "missing Codex durations should use neutral labels rather than guessed 5h\/7d labels");
|
|
29
|
+
assert.match(parser, /usage\.primary\.label[\s\S]*usage\.secondary\.label/, "formatted text should use snapshot labels");
|
|
30
|
+
|
|
31
|
+
assert.match(producer, /usageWindows\?:\s*\{\s*primaryPercent:\s*number;\s*secondaryPercent:\s*number;/s, "producer should type the optional usageWindows contract");
|
|
32
|
+
assert.match(producer, /usageWindows:\s*\{\s*primaryPercent:\s*providerUsage\.primary\.usedPercent,\s*secondaryPercent:\s*providerUsage\.secondary\.usedPercent,/s, "Usage chip should publish both normalized window percentages");
|
|
33
|
+
assert.match(app, /usage:\s*"Provider subscription usage\.[^"]*provider-reported primary and secondary rate windows\./, "Usage tooltip should explain both provider-reported windows rather than using generic fallback copy");
|
|
34
|
+
|
|
35
|
+
assert.match(usageNormalization, /value\.usageWindows\.primaryPercent/, "consumer should read structured primary metadata");
|
|
36
|
+
assert.match(usageNormalization, /value\.usageWindows\.secondaryPercent/, "consumer should read structured secondary metadata");
|
|
37
|
+
assert.match(usageNormalization, /Number\.isFinite\(primaryPercent\)\s*&&\s*Number\.isFinite\(secondaryPercent\)/, "consumer should require both finite window values");
|
|
38
|
+
assert.match(usageNormalization, /chip\.usageWindows\s*=\s*\{\s*primaryPercent,\s*secondaryPercent\s*\}/, "consumer should preserve the two structured values");
|
|
39
|
+
assert.doesNotMatch(usageNormalization, /chip\.value|value\.value|5h.*match|7d.*match/s, "usage-window normalization must not parse display text");
|
|
40
|
+
|
|
41
|
+
assert.match(app, /if \(chip\.usageWindows\) applyFooterUsageWindows\(node, chip\.usageWindows\);/, "initial rendering should apply Usage visuals");
|
|
42
|
+
assert.match(applyUsage, /Math\.min\(100, Math\.max\(0, primaryPercent\)\)/, "primary visual should clamp defensively");
|
|
43
|
+
assert.match(applyUsage, /Math\.min\(100, Math\.max\(0, secondaryPercent\)\)/, "secondary visual should clamp defensively");
|
|
44
|
+
assert.match(applyUsage, /--usage-primary/, "primary should have an independent CSS width variable");
|
|
45
|
+
assert.match(applyUsage, /--usage-secondary/, "secondary should have an independent CSS width variable");
|
|
46
|
+
assert.doesNotMatch(applyUsage, /\.value|5h.*match|7d.*match/s, "visual application must not parse display text");
|
|
47
|
+
assert.match(shapeKey, /key === "title" && chip\?\.key === "usage"/, "dynamic Usage titles should not force a full footer rebuild");
|
|
48
|
+
assert.match(shapeKey, /key === "usageWindows"[\s\S]*shape\.usageWindows = value \? true : false/, "shape key should track visual capability, not changing percentages");
|
|
49
|
+
assert.match(inPlaceUpdate, /chip\.key === "usage"[\s\S]*gitFooterPayloadTooltip\(chip\)/, "in-place Usage updates should rebuild the complete dynamic tooltip");
|
|
50
|
+
assert.match(inPlaceUpdate, /setAttribute\("aria-label", nextTooltip\.replace/, "in-place tooltip updates should keep the aria-label current");
|
|
51
|
+
assert.match(inPlaceUpdate, /if \(chip\.usageWindows\) applyFooterUsageWindows\(node, chip\.usageWindows\);/, "live updates should refresh both widths in place");
|
|
52
|
+
|
|
53
|
+
const sharedOverlay = css.match(/\.footer-usage-card\.has-usage-windows::before,\s*\.footer-usage-card\.has-usage-windows::after\s*\{([^}]+)\}/s)?.[1] ?? "";
|
|
54
|
+
const primaryLane = css.match(/\.footer-usage-card\.has-usage-windows::before\s*\{([^}]+)\}/s)?.[1] ?? "";
|
|
55
|
+
const secondaryLane = [...css.matchAll(/\.footer-usage-card\.has-usage-windows::after\s*\{([^}]+)\}/gs)]
|
|
56
|
+
.map((match) => match[1] ?? "")
|
|
57
|
+
.find((body) => /bottom:\s*0/.test(body)) ?? "";
|
|
58
|
+
const foreground = css.match(/\.footer-usage-card > \*\s*\{([^}]+)\}/s)?.[1] ?? "";
|
|
59
|
+
|
|
60
|
+
assert.match(sharedOverlay, /height:\s*50%/, "each usage lane should occupy half the chip height");
|
|
61
|
+
assert.match(sharedOverlay, /background:\s*var\(--context-card-gradient\)/, "usage lanes should reuse the Context gradient");
|
|
62
|
+
assert.match(sharedOverlay, /opacity:\s*0\.34/, "usage lanes should retain Context-like translucent contrast");
|
|
63
|
+
assert.match(primaryLane, /top:\s*0/, "primary lane should be the top lane");
|
|
64
|
+
assert.match(primaryLane, /border-bottom:\s*1px solid/, "the two lanes should have a subtle visual separator");
|
|
65
|
+
assert.match(primaryLane, /var\(--usage-primary\)/, "top lane width should use the primary percentage");
|
|
66
|
+
assert.match(secondaryLane, /bottom:\s*0/, "secondary lane should be the bottom lane");
|
|
67
|
+
assert.match(secondaryLane, /var\(--usage-secondary\)/, "bottom lane width should use the secondary percentage");
|
|
68
|
+
assert.match(foreground, /position:\s*relative/, "Usage content should establish foreground positioning");
|
|
69
|
+
assert.match(foreground, /z-index:\s*1/, "Usage text should stay above both overlays");
|
|
70
|
+
|
|
71
|
+
console.log("footer provider usage visual static tests passed");
|
|
@@ -58,6 +58,13 @@ const captureChatText = functionBody("captureChatTextSelection");
|
|
|
58
58
|
const matchChatText = functionBody("chatTextSelectionMatch");
|
|
59
59
|
const restoreChatText = functionBody("restoreChatTextSelection");
|
|
60
60
|
const renderAllMessages = functionBody("renderAllMessages");
|
|
61
|
+
const bindToolDetailsScrollMode = functionBody("bindToolDetailsScrollMode");
|
|
62
|
+
const markInteractedToolBubble = functionBody("markInteractedToolBubble");
|
|
63
|
+
const ensureToolInteractionDelegation = functionBody("ensureToolInteractionDelegation");
|
|
64
|
+
const captureInteractedToolInteraction = functionBody("captureInteractedToolInteractionState");
|
|
65
|
+
const captureToolDetailsInteraction = functionBody("captureToolDetailsInteractionState");
|
|
66
|
+
const restoreToolDetailsInteraction = functionBody("restoreToolDetailsInteractionState");
|
|
67
|
+
const updateLiveToolCard = functionBody("updateLiveToolCard");
|
|
61
68
|
const renderStreamingMarkdown = functionBody("renderStreamingMarkdown");
|
|
62
69
|
const refreshMessages = functionBody("refreshMessages");
|
|
63
70
|
const captureMobileSurface = functionBody("captureMobileSurfaceRenderFocus");
|
|
@@ -121,18 +128,28 @@ assert.match(app, /dataset\.mobileContinuityKey = "context:paste-text"[\s\S]*dat
|
|
|
121
128
|
assert.match(captureMobileSurface, /mobileDraftAuthority === "dom"[\s\S]*selectionDirection:[\s\S]*scrollTop:[\s\S]*scrollLeft:/, "mobile DOM drafts must capture selection and scroll state");
|
|
122
129
|
assert.match(restoreMobileSurface, /target\.dataset\.mobileDraftAuthority === "dom"[\s\S]*target\.value = snapshot\.value[\s\S]*setSelectionRange[\s\S]*target\.focus\(\{ preventScroll: true \}\)/, "mobile DOM drafts must restore value, selection, scroll, and focus");
|
|
123
130
|
|
|
124
|
-
assert.match(captureChatText, /selection\.isCollapsed[\s\S]
|
|
125
|
-
assert.match(matchChatText, /
|
|
126
|
-
assert.match(restoreChatText, /snapshot\.contextKey !== chatTextSelectionContextKey\(\)[\s\S]*chatTextSelectionCandidates\(snapshot\)[\s\S]*
|
|
131
|
+
assert.match(captureChatText, /selection\.isCollapsed[\s\S]*!anchorSurface \|\| !focusSurface[\s\S]*chatTextSelectionEndpoint\(anchorSurface[\s\S]*chatTextSelectionEndpoint\(focusSurface[\s\S]*chatTextSelectionContextKey\(\)[\s\S]*anchor,[\s\S]*focus,[\s\S]*text,/, "main-output selection capture must retain distinct semantic anchor/focus endpoints, context, direction, and exact text");
|
|
132
|
+
assert.match(matchChatText, /chatTextSelectionEndpointPoint\(anchorSurface, snapshot\.anchor\)[\s\S]*chatTextSelectionEndpointPoint\(focusSurface, snapshot\.focus\)[\s\S]*chatTextSelectionSpansSurfaces\(snapshot\) \|\| text === snapshot\.text/, "main-output selection restoration must validate exact semantic endpoints while allowing harmless intermediate UI text changes across surfaces");
|
|
133
|
+
assert.match(restoreChatText, /snapshot\.contextKey !== chatTextSelectionContextKey\(\)[\s\S]*chatTextSelectionCandidates\(snapshot, "anchor"\)[\s\S]*chatTextSelectionCandidates\(snapshot, "focus"\)[\s\S]*anchorCandidates\.includes\(currentAnchorSurface\)[\s\S]*focusCandidates\.includes\(currentFocusSurface\)[\s\S]*currentText && currentAnchorSurface && currentFocusSurface[\s\S]*setBaseAndExtent/, "main-output selection restoration must reject stale contexts and meaningful newer selections while preserving cross-surface anchor direction");
|
|
127
134
|
assert.match(renderStreamingMarkdown, /captureChatTextSelection\(block\)[\s\S]*restoreChatTextSelection\(selectionSnapshot\)/, "streaming Markdown tail replacement must preserve a still-valid browser Range");
|
|
128
135
|
assert.match(renderAllMessages, /captureChatTextSelection\(\)[\s\S]*restoreChatTextSelection\(selectionSnapshot\)/, "authoritative transcript rerenders must preserve a still-valid main-output Range");
|
|
136
|
+
assert.doesNotMatch(renderAllMessages, /applyToolOutputExpansionToDom\(|captureTranscriptToolInteractionState\(|restoreTranscriptToolInteractionState\(/, "routine transcript rerenders must not scan or overwrite every historical tool disclosure");
|
|
137
|
+
assert.match(app, /const INTERACTED_TOOL_BUBBLE_LIMIT = 16;/, "interacted tool continuity must stay tightly bounded");
|
|
138
|
+
assert.match(markInteractedToolBubble, /interactedToolBubbles\.delete\(bubble\)[\s\S]*interactedToolBubbles\.add\(bubble\)[\s\S]*size > INTERACTED_TOOL_BUBBLE_LIMIT/, "interacted tool continuity must use a bounded recency set");
|
|
139
|
+
assert.match(ensureToolInteractionDelegation, /toolInteractionDelegationBound[\s\S]*elements\.chat\.addEventListener\("toggle"[\s\S]*elements\.chat\.addEventListener\("focusin"[\s\S]*elements\.chat\.addEventListener\("scroll"[\s\S]*scrollHeight - node\.clientHeight/, "tool interaction tracking must use one delegated listener set and measure layout only on actual scroll events");
|
|
140
|
+
assert.match(captureInteractedToolInteraction, /for \(const bubble of \[\.\.\.interactedToolBubbles\]\)[\s\S]*!bubble\.isConnected[\s\S]*captureToolDetailsInteractionState\(bubble\)/, "transcript reconciliation must inspect only bounded, previously interacted tool cards");
|
|
141
|
+
assert.match(renderAllMessages, /captureInteractedToolInteractionState\(\)[\s\S]*restoreInteractedToolInteractionState\(toolInteractionSnapshots\)/, "routine transcript renders must restore only explicitly interacted tool cards");
|
|
142
|
+
assert.match(bindToolDetailsScrollMode, /dataset\.toolScrollMode \|\|= "position"[\s\S]*ensureToolInteractionDelegation\(\)/, "tool scroll surfaces must use delegated reader-mode tracking rather than per-node listeners");
|
|
143
|
+
assert.match(captureToolDetailsInteraction, /if \(details\.open\)[\s\S]*mode: node\.dataset\.toolScrollMode \|\| "position"[\s\S]*scrollTop:[\s\S]*scrollLeft:[\s\S]*open: details\.open[\s\S]*summaryFocused:/, "one live tool snapshot must retain open state, summary focus, reader mode, and both scroll axes without reading layout");
|
|
144
|
+
assert.doesNotMatch(captureToolDetailsInteraction, /scrollHeight|clientHeight|getBoundingClientRect/, "live tool state capture must avoid synchronous layout reads");
|
|
145
|
+
assert.match(restoreToolDetailsInteraction, /details\.open = snapshot\.open[\s\S]*focus\(\{ preventScroll: true \}\)[\s\S]*requestAnimationFrame[\s\S]*scrollSnapshot\.mode === "follow-end"[\s\S]*node\.scrollLeft = Math\.min/, "tool disclosure restoration must preserve keyboard focus and bounded reader scroll after layout");
|
|
146
|
+
assert.match(updateLiveToolCard, /captureToolDetailsInteractionState\(body\)[\s\S]*transcriptRenderer\.replaceChildren\(body\)[\s\S]*restoreToolDetailsInteractionState\(body, detailsInteractionState\)/, "live tool updates must restore only their local disclosure interaction state around body replacement");
|
|
129
147
|
assert.match(refreshMessages, /const selectionSnapshot = captureChatTextSelection\(\);[\s\S]*adoptedOutput = adoptLiveAssistantBubble\(latestMessages\)[\s\S]*resetStreamBubble\(\{ preserveCompact: adoptedOutput === "compact" \}\)[\s\S]*restoreStreamRenderAfterChatRebuild\(\)[\s\S]*restoreChatTextSelection\(selectionSnapshot\)/, "stream settlement must adopt matching normal or compact output before reset and retain exact fallback selection");
|
|
130
148
|
|
|
131
149
|
// --- Transcript mutation coordinator contracts (keyed DOM ownership) ---
|
|
132
150
|
|
|
133
151
|
const renderThinkingMarkdown = functionBody("renderThinkingMarkdown");
|
|
134
152
|
const flushCompactLiveOutput = functionBody("flushCompactLiveOutput");
|
|
135
|
-
const updateLiveToolCard = functionBody("updateLiveToolCard");
|
|
136
153
|
const renderLiveToolRun = functionBody("renderLiveToolRun");
|
|
137
154
|
const renderMermaidDiagram = functionBody("renderMermaidDiagram");
|
|
138
155
|
const renderStreamingToolCallCard = functionBody("renderStreamingToolCallCard");
|
|
@@ -47,9 +47,9 @@ assert.match(css, /html\[data-tablet-shell="v2"\] \.mobile-shell-nav[\s\S]*?widt
|
|
|
47
47
|
assert.match(css, /html\[data-tablet-shell="v2"\] \.mobile-shell-surface[\s\S]*?width: min\(30rem, 72vw\)/, "tablet inspector must be a bounded right-side sheet");
|
|
48
48
|
assert.match(css, /html\[data-tablet-shell="v2"\] \.file-viewer-pane[\s\S]*?position: fixed[\s\S]*?inset: 0/, "tablet files must default to full-screen replacement");
|
|
49
49
|
assert.match(css, /and \(pointer: coarse\)[\s\S]*?min-height: 44px/, "coarse tablet pointers must retain the 44px target floor");
|
|
50
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
51
|
-
assert.match(html, /styles\.css\?v=
|
|
52
|
-
assert.match(html, /app\.js\?v=
|
|
50
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v62"/, "continuity/tablet assets need a coherent cache identity");
|
|
51
|
+
assert.match(html, /styles\.css\?v=93/, "tablet CSS must have a coherent HTML revision");
|
|
52
|
+
assert.match(html, /app\.js\?v=104/, "continuity app logic must have a coherent HTML revision");
|
|
53
53
|
assert.match(readme, /tabletShell=v2/, "tablet preview and rollback must be documented");
|
|
54
54
|
|
|
55
55
|
console.log("mobile-continuity-tablet-static.test.mjs passed");
|
|
@@ -38,9 +38,9 @@ assert.match(server, /"mobile-shell-state\.mjs"/, "the server allowlist must ser
|
|
|
38
38
|
assert.match(server, /"transcript-renderer\.mjs"/, "the server allowlist must serve the transcript startup module");
|
|
39
39
|
assert.match(serviceWorker, /"\/mobile-shell-state\.mjs"/, "the PWA shell must cache the new startup module");
|
|
40
40
|
assert.match(serviceWorker, /"\/transcript-renderer\.mjs"/, "the PWA shell must cache the transcript startup module");
|
|
41
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
42
|
-
assert.match(html, /styles\.css\?v=
|
|
43
|
-
assert.match(html, /app\.js\?v=
|
|
41
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v62"/, "the cache identity must change with the startup graph");
|
|
42
|
+
assert.match(html, /styles\.css\?v=93/, "the stylesheet revision must change with mobile/tablet CSS fixes");
|
|
43
|
+
assert.match(html, /app\.js\?v=104/, "the app revision must change with continuity/tablet wiring");
|
|
44
44
|
assert.match(serviceWorker, /const APP_SHELL_NETWORK_TIMEOUT_MS = 8_000;[\s\S]*?event\.waitUntil\([\s\S]*?cache\.put\(request, response\.clone\(\)\)[\s\S]*?return networkResponse;/, "runtime cache writes must extend the event lifetime without blocking bounded network responses");
|
|
45
45
|
assert.match(serviceWorker, /MOBILE_NAVIGATION_MESSAGE_TYPE = "pi-webui:navigate:v1"/, "the service worker must use a versioned active-client navigation message");
|
|
46
46
|
assert.match(serviceWorker, /client\.postMessage\(\{ type: MOBILE_NAVIGATION_MESSAGE_TYPE, target \}\)/, "existing clients must receive only a validated target message");
|
|
@@ -58,8 +58,10 @@ assert.match(server, /requestId was already used for a different prompt/, "reque
|
|
|
58
58
|
assert.match(server, /runId: null/, "tab activity must expose an opaque parent-run field");
|
|
59
59
|
assert.match(server, /activity\.runId = randomUUID\(\)/, "parent-run IDs must be server-issued opaque values");
|
|
60
60
|
assert.match(server, /function markTabFailed\([\s\S]*?activity\.status = "failed"[\s\S]*?activity\.completionSerial/, "failed parent turns must be represented distinctly from successful completion");
|
|
61
|
-
assert.match(server, /
|
|
61
|
+
assert.match(server, /SSE_BACKPRESSURE_MAX_PENDING_BYTES = 512 \* 1024/, "SSE backpressure buffering must remain explicitly bounded");
|
|
62
|
+
assert.match(server, /res\.once\("drain", \(\) => flushSseClient\(client\)\)/, "healthy SSE clients must resume after transient write backpressure");
|
|
62
63
|
assert.match(server, /client\.tab\?\.sseClients\?\.delete\(client\)/, "eviction must remove only the slow client");
|
|
64
|
+
assert.match(server, /client\.res\?\.end\(\)/, "slow-client eviction must finish chunked SSE responses gracefully");
|
|
63
65
|
assert.match(css, /\.terminal-tabs-toggle-button \{[\s\S]*?min-height: 44px/, "phone tab targets must meet the 44px floor");
|
|
64
66
|
assert.match(css, /\.composer-attach-button \{[\s\S]*?width: 44px;[\s\S]*?min-height: 44px/, "phone attachment target must meet the 44px floor");
|
|
65
67
|
assert.match(css, /\.composer-row button \{\n width: 100%;\n min-height: 44px/, "phone composer controls must meet the 44px floor");
|
|
@@ -60,6 +60,6 @@ assert.match(css, /data-mobile-presentation="essential"/, "Essential presentatio
|
|
|
60
60
|
assert.match(css, /html\[data-mobile-shell="v2"\] body\.mobile-keyboard-open \.widget-area,[\s\S]*?\.composer-actions-button \{ display: block !important; \}/, "v2 keyboard mode must keep run widgets and the actions entry available");
|
|
61
61
|
assert.match(css, /@media \(prefers-reduced-motion: reduce\)/, "reduced-motion behavior is required");
|
|
62
62
|
assert.match(css, /@media \(forced-colors: active\)/, "forced-color affordances are required");
|
|
63
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
63
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v62"/, "browser asset changes need a coherent cache tuple");
|
|
64
64
|
|
|
65
65
|
console.log("mobile-phone-experience-static.test.mjs passed");
|