@firstpick/pi-package-webui 0.8.1 → 0.8.3
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 +21 -3
- package/bin/pi-webui.mjs +287 -32
- package/lib/component-update-state.mjs +126 -0
- package/lib/git-workflow-preferences.mjs +246 -19
- package/lib/thinking-stream-recovery.mjs +156 -0
- package/lib/trust-boundaries.mjs +1 -0
- package/lib/ui-layout-settings.mjs +254 -0
- package/package.json +5 -3
- package/public/app.js +3072 -142
- package/public/index.html +188 -39
- package/public/service-worker.js +1 -1
- package/public/styles.css +1091 -39
- package/tests/boot-failure-diagnostics.test.mjs +63 -5
- package/tests/browser/composer-action-grid-reorder.spec.mjs +303 -0
- package/tests/browser/control-deck-component-updates.spec.mjs +180 -0
- package/tests/browser/feature-decision-output-popup.spec.mjs +156 -0
- package/tests/browser/interaction-continuity.spec.mjs +187 -0
- package/tests/browser/mobile-foundation.spec.mjs +11 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +744 -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/composer-action-grid-reorder-static.test.mjs +63 -0
- package/tests/control-deck-component-updates-static.test.mjs +251 -0
- package/tests/fast-mode-client-static.test.mjs +2 -2
- package/tests/feature-decision-output-popup-static.test.mjs +172 -0
- package/tests/fixtures/fake-pi.mjs +180 -6
- package/tests/footer-provider-usage-visual-static.test.mjs +71 -0
- package/tests/git-workflow-preferences.test.mjs +4 -2
- package/tests/http-endpoints-harness.test.mjs +88 -1
- package/tests/interaction-state-stability-static.test.mjs +24 -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 +34 -16
- package/tests/native-parity-harness.test.mjs +2 -0
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/persistent-ui-layout-static.test.mjs +267 -0
- package/tests/questionnaire-dialog.test.mjs +511 -0
- package/tests/queue-edit-reorder-static.test.mjs +1 -0
- package/tests/remote-auth-settings-harness.test.mjs +1 -1
- package/tests/side-panel-resize-static.test.mjs +1 -0
- 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
- package/tests/subagent-launch-slots.test.mjs +1 -1
- package/tests/thinking-stream-recovery.test.mjs +88 -0
- package/tests/ui-layout-settings.test.mjs +92 -0
- package/tests/webui-settings-locking.test.mjs +159 -0
|
@@ -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 }));
|
|
@@ -346,14 +349,32 @@ function runTranscriptContinuityScenario(scenario) {
|
|
|
346
349
|
{ afterMs: 650, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "thinking_delta", delta: " survives" } })) },
|
|
347
350
|
);
|
|
348
351
|
finish({ role: "assistant", content: [{ type: "thinking", thinking: "thinking selection literal survives" }, { type: "text", text: "thinking final answer" }], timestamp: Date.now() }, 450);
|
|
352
|
+
} else if (scenario === "order") {
|
|
353
|
+
const toolCallId = `continuity-order-${run}`;
|
|
354
|
+
const toolCall = { type: "toolCall", id: toolCallId, name: "read", arguments: { path: "order.txt" } };
|
|
355
|
+
start();
|
|
356
|
+
steps.push(
|
|
357
|
+
{ afterMs: 120, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "thinking_delta", delta: "ordering thinking" } })) },
|
|
358
|
+
{ afterMs: 500, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta: "ordering assistant output" } })) },
|
|
359
|
+
{ afterMs: 1_000, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "toolcall_start", contentIndex: 2, name: "read", toolCall } })) },
|
|
360
|
+
{ afterMs: 100, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "toolcall_delta", contentIndex: 2, name: "read", toolCall, delta: "" } })) },
|
|
361
|
+
{ afterMs: 200, run: () => emitScriptedEvent(tagged({ type: "webui_supervisor_reconnected", supervisorScopeId: `continuity-order-${run}`, supervisorEpoch: "1", supervisorSeq: "1" })) },
|
|
362
|
+
{ afterMs: 800, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "toolcall_end", contentIndex: 2, name: "read", toolCall } })) },
|
|
363
|
+
);
|
|
364
|
+
finish({ role: "assistant", content: [{ type: "thinking", thinking: "ordering thinking" }, toolCall], timestamp: Date.now() }, 700);
|
|
349
365
|
} else if (scenario === "tool") {
|
|
350
366
|
const toolCallId = `continuity-tool-${run}`;
|
|
367
|
+
const toolOutput = (revision) => [
|
|
368
|
+
"tool selection literal",
|
|
369
|
+
`unselected revision ${revision}`,
|
|
370
|
+
...Array.from({ length: 64 }, (_, index) => `continuity output line ${String(index + 1).padStart(2, "0")} ${"x".repeat(160)}`),
|
|
371
|
+
].join("\n");
|
|
351
372
|
steps.push(
|
|
352
373
|
{ afterMs: 40, run: () => emitScriptedEvent(tagged({ type: "agent_start" })) },
|
|
353
374
|
{ 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: "
|
|
375
|
+
{ afterMs: 100, run: () => emitScriptedEvent(tagged({ type: "tool_execution_update", toolCallId, toolName: "read", partialResult: { content: [{ type: "text", text: toolOutput("one") }] } })) },
|
|
376
|
+
{ afterMs: 700, run: () => emitScriptedEvent(tagged({ type: "tool_execution_update", toolCallId, toolName: "read", partialResult: { content: [{ type: "text", text: toolOutput("two") }] } })) },
|
|
377
|
+
{ afterMs: 600, run: () => emitScriptedEvent(tagged({ type: "tool_execution_end", toolCallId, toolName: "read", isError: false, result: { content: [{ type: "text", text: toolOutput("two") }] } })) },
|
|
357
378
|
);
|
|
358
379
|
finish(null, 120);
|
|
359
380
|
} else if (scenario === "authoritative") {
|
|
@@ -406,7 +427,7 @@ function runTranscriptContinuityScenario(scenario) {
|
|
|
406
427
|
|
|
407
428
|
function handleTranscriptContinuityPrompt(command, base) {
|
|
408
429
|
if (!continuityModeEnabled) return false;
|
|
409
|
-
const match = String(command.message || "").trim().match(/^fixture transcript continuity (reverse|duplicate|pointer|thinking|tool|authoritative|cadence|dwell|mode|mermaid)$/);
|
|
430
|
+
const match = String(command.message || "").trim().match(/^fixture transcript continuity (reverse|duplicate|pointer|thinking|order|tool|authoritative|cadence|dwell|mode|mermaid)$/);
|
|
410
431
|
if (!match) return false;
|
|
411
432
|
appendDynamicMessage({ role: "user", content: String(command.message), timestamp: Date.now() });
|
|
412
433
|
respond({ ...base, data: { output: `fake transcript continuity ${match[1]} accepted`, pid: process.pid } });
|
|
@@ -447,10 +468,12 @@ function handleLargePayloadPrompt(command, base) {
|
|
|
447
468
|
}
|
|
448
469
|
|
|
449
470
|
function handleSseFloodPrompt(command, base) {
|
|
450
|
-
|
|
471
|
+
const message = String(command.message || "").trim();
|
|
472
|
+
if (!sseFloodEnabled || !["fixture sse flood", "fixture sse stall flood"].includes(message)) return false;
|
|
451
473
|
respond({ ...base, data: { output: "fake SSE flood accepted" } });
|
|
452
474
|
const payload = "s".repeat(8192);
|
|
453
|
-
|
|
475
|
+
const eventCount = message === "fixture sse stall flood" ? 4096 : 256;
|
|
476
|
+
for (let index = 0; index < eventCount; index += 1) {
|
|
454
477
|
emitEvent({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta: `${index}:${payload}` } });
|
|
455
478
|
}
|
|
456
479
|
return true;
|
|
@@ -899,6 +922,154 @@ function handleTalkPrompt(command, base) {
|
|
|
899
922
|
return true;
|
|
900
923
|
}
|
|
901
924
|
|
|
925
|
+
function statsPromptContextFixturePayload({ malformedSnapshot = false } = {}) {
|
|
926
|
+
const hostileLabel = `System <img src=x onerror="globalThis.fixturePwned=true"> & "quoted" ${"long-label-".repeat(16)}`;
|
|
927
|
+
const payload = {
|
|
928
|
+
type: "firstpick.pi-extension-stats.overlay",
|
|
929
|
+
version: 1,
|
|
930
|
+
generatedAt: Date.now(),
|
|
931
|
+
open: true,
|
|
932
|
+
scopeLabel: "fixture prompt context",
|
|
933
|
+
scope: { mode: "range", days: 14 },
|
|
934
|
+
sessionCount: 0,
|
|
935
|
+
scopedSessionCount: 0,
|
|
936
|
+
dayCount: 14,
|
|
937
|
+
activeDayCount: 0,
|
|
938
|
+
totals: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0, cost: 0 },
|
|
939
|
+
promptEstimate: {
|
|
940
|
+
total: 300, low: 270, high: 330, confidence: "fixture", calibrationMultiplier: 1,
|
|
941
|
+
calibrationSamples: 0, source: "export-html", settled: true, attempts: 0,
|
|
942
|
+
warning: null, systemPromptChars: 0, activeToolSchemas: 2,
|
|
943
|
+
},
|
|
944
|
+
promptContext: {
|
|
945
|
+
initialPrompt: {
|
|
946
|
+
totalTokens: 300,
|
|
947
|
+
lowTokens: 270,
|
|
948
|
+
highTokens: 330,
|
|
949
|
+
confidence: "fixture",
|
|
950
|
+
source: "export-html",
|
|
951
|
+
warning: null,
|
|
952
|
+
estimateMethod: "weighted-character-estimate-with-largest-remainder-calibration",
|
|
953
|
+
components: [
|
|
954
|
+
{ id: "system-prompt-1", kind: "system-prompt", label: hostileLabel, chars: null, uncalibratedTokens: 300, tokens: 300, percent: 100 },
|
|
955
|
+
{ id: "framing-1", kind: "framing", label: "Zero-token framing", chars: 0, uncalibratedTokens: 0, tokens: 0, percent: 0 },
|
|
956
|
+
],
|
|
957
|
+
},
|
|
958
|
+
snapshot: {
|
|
959
|
+
source: "export-html",
|
|
960
|
+
settled: true,
|
|
961
|
+
attempts: 0,
|
|
962
|
+
warning: null,
|
|
963
|
+
systemPromptChars: 0,
|
|
964
|
+
estimateComponents: {
|
|
965
|
+
promptText: malformedSnapshot ? "not-a-number" : 0,
|
|
966
|
+
toolSchemas: 25,
|
|
967
|
+
framing: 0,
|
|
968
|
+
calibration: { multiplier: 1, samples: 0 },
|
|
969
|
+
},
|
|
970
|
+
metadata: { currentDate: null, cwdDisplay: null, extraGuidelineCount: 0 },
|
|
971
|
+
tools: {
|
|
972
|
+
totalCount: 3,
|
|
973
|
+
omittedCount: 1,
|
|
974
|
+
items: [
|
|
975
|
+
{ name: "<script>fixture-tool</script>", description: "Text-safe <b>description</b> & symbols", parameterSummary: "0 params", estimatedTokens: 0 },
|
|
976
|
+
{ name: "read", description: null, parameterSummary: "1 param, 1 required", estimatedTokens: 25 },
|
|
977
|
+
],
|
|
978
|
+
},
|
|
979
|
+
toolPromptEntries: { totalCount: 2, omittedCount: 0, names: ["<unsafe-entry>", "read"] },
|
|
980
|
+
skills: { totalCount: 2, omittedCount: 1, items: [{ name: "fixture-skill", description: "Hostile </details> stays text" }] },
|
|
981
|
+
contextFiles: {
|
|
982
|
+
totalCount: 2,
|
|
983
|
+
omittedCount: 0,
|
|
984
|
+
items: [
|
|
985
|
+
{ displayPath: `nested/${"overflow-segment-".repeat(18)}context.md`, chars: null },
|
|
986
|
+
{ displayPath: "zero.md", chars: 0 },
|
|
987
|
+
],
|
|
988
|
+
},
|
|
989
|
+
},
|
|
990
|
+
currentContext: {
|
|
991
|
+
usage: { tokens: 0, contextWindow: null, percent: 0 },
|
|
992
|
+
breakdown: {
|
|
993
|
+
estimateMethod: "weighted-character-estimate",
|
|
994
|
+
reconstruction: "complete",
|
|
995
|
+
estimatedTotalTokens: 200,
|
|
996
|
+
actualMinusEstimatedTokens: -200,
|
|
997
|
+
sources: [
|
|
998
|
+
{ id: "user-messages-1", kind: "user-messages", label: `User ${"overflow-source-".repeat(18)}`, chars: 800, estimatedTokens: 200, percent: 100 },
|
|
999
|
+
],
|
|
1000
|
+
},
|
|
1001
|
+
},
|
|
1002
|
+
},
|
|
1003
|
+
summary: {},
|
|
1004
|
+
daily: [],
|
|
1005
|
+
models: [],
|
|
1006
|
+
expensiveSessions: [],
|
|
1007
|
+
lines: {
|
|
1008
|
+
graph: ["RAW_GRAPH_FIXTURE"],
|
|
1009
|
+
promptInjection: ["RAW_PROMPT_INJECTION <keep>& exact"],
|
|
1010
|
+
promptDetailed: ["RAW_PROMPT_DETAILED </pre> exact"],
|
|
1011
|
+
tokenBreakdown: ["RAW_CONTEXT_BREAKDOWN <raw> exact"],
|
|
1012
|
+
costTrend: ["RAW_COST_TREND"],
|
|
1013
|
+
cache: ["RAW_CACHE"],
|
|
1014
|
+
modelComparison: ["RAW_MODEL_COMPARISON"],
|
|
1015
|
+
expensiveSessions: ["RAW_EXPENSIVE_SESSIONS"],
|
|
1016
|
+
},
|
|
1017
|
+
};
|
|
1018
|
+
return payload;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
const FEATURE_DECISION_FIXTURE_REASONS = {
|
|
1022
|
+
lightweight: "One localized WebUI slice with no migration or rollout work.",
|
|
1023
|
+
complex: "Crosses the classifier extension and the WebUI status consumer.",
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
function featureDecisionFixturePayload(mode) {
|
|
1027
|
+
if (mode === "lightweight" || mode === "complex") {
|
|
1028
|
+
return {
|
|
1029
|
+
output: JSON.stringify({ kind: `feature_${mode}`, reason: FEATURE_DECISION_FIXTURE_REASONS[mode] }),
|
|
1030
|
+
category: `${mode}-feature`,
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
// Legacy exact-label payload from a classifier build that predates the structured contract.
|
|
1034
|
+
if (mode === "legacy") return { output: "feature_complex", category: "complex-feature" };
|
|
1035
|
+
// Structured decision whose kind contradicts the category; the popup must stay unavailable.
|
|
1036
|
+
if (mode === "mismatch") {
|
|
1037
|
+
return {
|
|
1038
|
+
output: JSON.stringify({ kind: "feature_lightweight", reason: FEATURE_DECISION_FIXTURE_REASONS.lightweight }),
|
|
1039
|
+
category: "complex-feature",
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
if (mode === "malformed") return { output: '{"kind":"feature_complex"}', category: "complex-feature" };
|
|
1043
|
+
return { output: undefined, category: undefined };
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
function handleFeatureDecisionFixturePrompt(command, base) {
|
|
1047
|
+
const match = String(command.message || "").trim().match(/^fixture feature decision (lightweight|complex|legacy|mismatch|malformed|clear)$/);
|
|
1048
|
+
if (!match) return false;
|
|
1049
|
+
const mode = match[1];
|
|
1050
|
+
const { output, category } = featureDecisionFixturePayload(mode);
|
|
1051
|
+
respond({ ...base, data: { output: `fake feature decision ${mode} emitted` } });
|
|
1052
|
+
emitEvent({ type: "extension_ui_request", id: randomUUID(), method: "setStatus", statusKey: "feature-decision-output", statusText: output });
|
|
1053
|
+
emitEvent({ type: "extension_ui_request", id: randomUUID(), method: "setStatus", statusKey: "feature-category", statusText: category });
|
|
1054
|
+
return true;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
function handleStatsPromptContextFixturePrompt(command, base) {
|
|
1058
|
+
if (!statsPromptContextEnabled) return false;
|
|
1059
|
+
const message = String(command.message || "").trim();
|
|
1060
|
+
const malformedSnapshot = message === "fixture stats prompt malformed";
|
|
1061
|
+
if (!malformedSnapshot && !/^\/stats-webui(?:\s|$)/.test(message)) return false;
|
|
1062
|
+
respond({ ...base, data: { output: malformedSnapshot ? "malformed stats prompt fixture emitted" : "structured stats prompt fixture emitted" } });
|
|
1063
|
+
emitEvent({
|
|
1064
|
+
type: "extension_ui_request",
|
|
1065
|
+
id: randomUUID(),
|
|
1066
|
+
method: "setStatus",
|
|
1067
|
+
statusKey: "stats-webui",
|
|
1068
|
+
statusText: JSON.stringify(statsPromptContextFixturePayload({ malformedSnapshot })),
|
|
1069
|
+
});
|
|
1070
|
+
return true;
|
|
1071
|
+
}
|
|
1072
|
+
|
|
902
1073
|
const rl = createInterface({ input: process.stdin });
|
|
903
1074
|
rl.on("line", (line) => {
|
|
904
1075
|
if (!line.trim()) return;
|
|
@@ -965,6 +1136,7 @@ rl.on("line", (line) => {
|
|
|
965
1136
|
{ name: "conversation", source: "extension", description: "Natural Conversation Mode alias" },
|
|
966
1137
|
{ name: "fast-mode", source: "extension", description: "Toggle Codex subscription Fast mode" },
|
|
967
1138
|
{ name: "workflow", source: "extension", description: "Run and inspect JavaScript workflows" },
|
|
1139
|
+
...(statsPromptContextEnabled ? [{ name: "stats-webui", source: "extension", description: "Publish fixture stats dashboard" }] : []),
|
|
968
1140
|
],
|
|
969
1141
|
},
|
|
970
1142
|
});
|
|
@@ -987,6 +1159,8 @@ rl.on("line", (line) => {
|
|
|
987
1159
|
return;
|
|
988
1160
|
}
|
|
989
1161
|
case "prompt":
|
|
1162
|
+
if (handleFeatureDecisionFixturePrompt(command, base)) return;
|
|
1163
|
+
if (handleStatsPromptContextFixturePrompt(command, base)) return;
|
|
990
1164
|
if (handleWebuiHelperPrompt(command, base)) return;
|
|
991
1165
|
if (handleFastModeFixturePrompt(command, base)) return;
|
|
992
1166
|
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");
|
|
@@ -36,7 +36,7 @@ const settingsFile = path.join(root, "settings.json");
|
|
|
36
36
|
try {
|
|
37
37
|
await writeFile(settingsFile, `${JSON.stringify({ version: 1, remoteAuthEnabled: true }, null, 2)}\n`, "utf8");
|
|
38
38
|
const migrated = await readWebuiSettings(settingsFile);
|
|
39
|
-
assert.equal(migrated.version,
|
|
39
|
+
assert.equal(migrated.version, 6);
|
|
40
40
|
assert.equal(migrated.remoteAuthEnabled, true, "legacy Remote PIN state should survive schema migration");
|
|
41
41
|
assert.equal(migrated.outputModeDefault, "normal", "legacy settings should default browser output to normal");
|
|
42
42
|
assert.equal(isGitWorkflowSetupComplete(migrated.gitWorkflow), false);
|
|
@@ -44,6 +44,8 @@ try {
|
|
|
44
44
|
assert.equal(migrated.resourceDefaults.skills.enabledSkills, null, "legacy settings should inherit Pi's normal skill defaults");
|
|
45
45
|
assert.equal(migrated.gitWorkflow.stagingPolicy, "review");
|
|
46
46
|
assert.equal(migrated.gitWorkflow.generation.thinkingLevel, "low");
|
|
47
|
+
assert.equal(migrated.uiLayout.version, 1);
|
|
48
|
+
assert.equal(migrated.uiLayout.sidePanel.sectionOrder, null);
|
|
47
49
|
|
|
48
50
|
await writeFile(settingsFile, `${JSON.stringify({ version: 4, remoteAuthEnabled: true, outputModeDefault: "unsupported" }, null, 2)}\n`, "utf8");
|
|
49
51
|
assert.equal((await readWebuiSettings(settingsFile)).outputModeDefault, "normal", "invalid persisted output modes must fail closed to normal");
|
|
@@ -76,7 +78,7 @@ try {
|
|
|
76
78
|
assert.equal(partiallyUpdated.deliveryMode, "current");
|
|
77
79
|
|
|
78
80
|
const persisted = JSON.parse(await readFile(settingsFile, "utf8"));
|
|
79
|
-
assert.equal(persisted.version,
|
|
81
|
+
assert.equal(persisted.version, 6);
|
|
80
82
|
assert.equal(persisted.remoteAuthEnabled, true);
|
|
81
83
|
assert.equal(persisted.outputModeDefault, "compact-v1", "output-mode default should persist beside existing Web UI settings");
|
|
82
84
|
assert.equal(persisted.gitWorkflow.generation.provider, "fake");
|
|
@@ -231,13 +231,19 @@ try {
|
|
|
231
231
|
const initialInterfacePreferences = await request("127.0.0.1", "/api/interface-preferences");
|
|
232
232
|
assert.equal(initialInterfacePreferences.status, 200);
|
|
233
233
|
assert.equal(initialInterfacePreferences.body?.data?.preferences?.sidePanelWidth, null, "a user without a saved width should receive the default preference");
|
|
234
|
+
assert.equal(initialInterfacePreferences.body?.data?.layout?.version, 1);
|
|
235
|
+
assert.equal(initialInterfacePreferences.body?.data?.layout?.sidePanel?.sectionOrder, null);
|
|
236
|
+
assert.match(initialInterfacePreferences.body?.data?.layoutRevision || "", /^[a-f0-9]{64}$/);
|
|
234
237
|
assert.equal(Object.hasOwn(initialInterfacePreferences.body?.data || {}, "path"), false, "preference responses must not disclose the user's settings-file path");
|
|
238
|
+
const initialLayoutRevision = initialInterfacePreferences.body.data.layoutRevision;
|
|
239
|
+
|
|
235
240
|
const savedInterfacePreferences = await request("127.0.0.1", "/api/interface-preferences", {
|
|
236
241
|
method: "PUT",
|
|
237
242
|
body: { sidePanelWidth: 612.4 },
|
|
238
243
|
});
|
|
239
244
|
assert.equal(savedInterfacePreferences.status, 200);
|
|
240
245
|
assert.equal(savedInterfacePreferences.body?.data?.preferences?.sidePanelWidth, 612, "saved side-panel widths should be normalized to whole pixels");
|
|
246
|
+
assert.equal(savedInterfacePreferences.body?.data?.layoutRevision, initialLayoutRevision, "width-only compatibility writes must not revise layout state");
|
|
241
247
|
assert.equal(JSON.parse(await readFile(settingsFile, "utf8")).interfacePreferences?.sidePanelWidth, 612, "the side-panel width should be saved in the private user settings file");
|
|
242
248
|
const reloadedInterfacePreferences = await request("127.0.0.1", "/api/interface-preferences");
|
|
243
249
|
assert.equal(reloadedInterfacePreferences.body?.data?.preferences?.sidePanelWidth, 612, "the saved width should survive subsequent user preference reads");
|
|
@@ -248,6 +254,87 @@ try {
|
|
|
248
254
|
assert.equal(invalidInterfacePreferences.status, 400, "out-of-range side-panel widths should be rejected");
|
|
249
255
|
assert.equal((await request("127.0.0.1", "/api/interface-preferences")).body?.data?.preferences?.sidePanelWidth, 612, "invalid saves must preserve the last valid user width");
|
|
250
256
|
|
|
257
|
+
const savedLayout = await request("127.0.0.1", "/api/interface-preferences", {
|
|
258
|
+
method: "PUT",
|
|
259
|
+
body: {
|
|
260
|
+
sidePanelWidth: 620,
|
|
261
|
+
expectedLayoutRevision: initialLayoutRevision,
|
|
262
|
+
layout: {
|
|
263
|
+
version: 1,
|
|
264
|
+
sidePanel: { sectionOrder: ["files", "controls", "git"], collapsedSectionIds: ["git"], hiddenSectionIds: [], collapsed: false },
|
|
265
|
+
composerActions: { order: ["new", "git", "send"], grid: { version: 2, columns: 12, positions: { new: 0, git: 1, send: 10 } } },
|
|
266
|
+
footerScopedModelOrder: ["openai-codex/gpt-5.6-sol"],
|
|
267
|
+
terminalTabs: { layout: "left", customGroups: { version: 1, groups: [{ id: "group-1", title: "Group 1", tabIds: ["tab-a", "tab-b"] }] } },
|
|
268
|
+
fileViewerWidth: 560,
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
assert.equal(savedLayout.status, 200, savedLayout.body?.error);
|
|
273
|
+
assert.equal(savedLayout.body?.data?.preferences?.sidePanelWidth, 620);
|
|
274
|
+
assert.deepEqual(savedLayout.body?.data?.layout?.composerActions?.order, ["new", "git", "send"]);
|
|
275
|
+
assert.equal(savedLayout.body?.data?.layout?.terminalTabs?.layout, "left");
|
|
276
|
+
assert.notEqual(savedLayout.body?.data?.layoutRevision, initialLayoutRevision);
|
|
277
|
+
assert.equal(JSON.stringify(savedLayout.body).includes(settingsFile), false, "successful layout responses must not disclose the settings path");
|
|
278
|
+
const savedLayoutRevision = savedLayout.body.data.layoutRevision;
|
|
279
|
+
const persistedLayoutSettings = JSON.parse(await readFile(settingsFile, "utf8"));
|
|
280
|
+
assert.equal(persistedLayoutSettings.version, 6);
|
|
281
|
+
assert.equal(persistedLayoutSettings.uiLayout.fileViewerWidth, 560);
|
|
282
|
+
assert.deepEqual(persistedLayoutSettings.uiLayout.composerActions.grid.positions, { new: 0, git: 1, send: 10 });
|
|
283
|
+
|
|
284
|
+
const staleLayout = await request("127.0.0.1", "/api/interface-preferences", {
|
|
285
|
+
method: "PUT",
|
|
286
|
+
body: { expectedLayoutRevision: initialLayoutRevision, layout: { sidePanel: { collapsed: true } } },
|
|
287
|
+
});
|
|
288
|
+
assert.equal(staleLayout.status, 409, "stale layout revisions must be rejected without mutation");
|
|
289
|
+
assert.equal(JSON.stringify(staleLayout.body).includes(settingsFile), false, "conflict errors must not disclose the settings path");
|
|
290
|
+
assert.equal((await request("127.0.0.1", "/api/interface-preferences")).body?.data?.layout?.sidePanel?.collapsed, false);
|
|
291
|
+
|
|
292
|
+
const partialLayout = await request("127.0.0.1", "/api/interface-preferences", {
|
|
293
|
+
method: "PUT",
|
|
294
|
+
body: { expectedLayoutRevision: savedLayoutRevision, layout: { sidePanel: { collapsed: true }, fileViewerWidth: null } },
|
|
295
|
+
});
|
|
296
|
+
assert.equal(partialLayout.status, 200, partialLayout.body?.error);
|
|
297
|
+
assert.equal(partialLayout.body?.data?.layout?.sidePanel?.collapsed, true);
|
|
298
|
+
assert.deepEqual(partialLayout.body?.data?.layout?.sidePanel?.sectionOrder, ["files", "controls", "git"], "partial layout patches must preserve omitted fields");
|
|
299
|
+
assert.equal(partialLayout.body?.data?.layout?.fileViewerWidth, null);
|
|
300
|
+
assert.deepEqual(partialLayout.body?.data?.layout?.composerActions?.order, ["new", "git", "send"]);
|
|
301
|
+
|
|
302
|
+
const invalidLayoutBodies = [
|
|
303
|
+
{ layout: { sidePanel: { collapsed: false } } },
|
|
304
|
+
{ expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { composerActions: { order: ["send"] } } },
|
|
305
|
+
{ expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { unknown: true } },
|
|
306
|
+
{ expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { terminalTabs: { layout: "bottom" } } },
|
|
307
|
+
{ expectedLayoutRevision: partialLayout.body.data.layoutRevision, layout: { fileViewerWidth: 1 } },
|
|
308
|
+
{ sidePanelWidth: 700, unexpected: true },
|
|
309
|
+
{},
|
|
310
|
+
];
|
|
311
|
+
for (const body of invalidLayoutBodies) {
|
|
312
|
+
const invalid = await request("127.0.0.1", "/api/interface-preferences", { method: "PUT", body });
|
|
313
|
+
assert.equal(invalid.status, 400, `invalid layout input must fail closed: ${JSON.stringify(body)}`);
|
|
314
|
+
}
|
|
315
|
+
const afterInvalidLayout = await request("127.0.0.1", "/api/interface-preferences");
|
|
316
|
+
assert.equal(afterInvalidLayout.body?.data?.layoutRevision, partialLayout.body.data.layoutRevision, "invalid requests must not mutate layout state");
|
|
317
|
+
assert.equal(afterInvalidLayout.body?.data?.preferences?.sidePanelWidth, 620, "invalid mixed requests must not mutate width state");
|
|
318
|
+
|
|
319
|
+
const wrongContentType = await fetch(`http://127.0.0.1:${port}/api/interface-preferences`, {
|
|
320
|
+
method: "PUT",
|
|
321
|
+
headers: { "content-type": "text/plain" },
|
|
322
|
+
body: JSON.stringify({ sidePanelWidth: 700 }),
|
|
323
|
+
});
|
|
324
|
+
assert.equal(wrongContentType.status, 415, "non-JSON layout writes must be rejected");
|
|
325
|
+
const malformedJson = await fetch(`http://127.0.0.1:${port}/api/interface-preferences`, {
|
|
326
|
+
method: "PUT",
|
|
327
|
+
headers: { "content-type": "application/json" },
|
|
328
|
+
body: "{",
|
|
329
|
+
});
|
|
330
|
+
assert.equal(malformedJson.status, 400, "malformed JSON must be rejected as client input");
|
|
331
|
+
const oversizedLayout = await fetch(`http://127.0.0.1:${port}/api/interface-preferences`, {
|
|
332
|
+
method: "PUT",
|
|
333
|
+
headers: { "content-type": "application/json" },
|
|
334
|
+
body: JSON.stringify({ padding: "x".repeat(33 * 1024) }),
|
|
335
|
+
});
|
|
336
|
+
assert.equal(oversizedLayout.status, 413, "layout request bodies over 32 KiB must be rejected before validation");
|
|
337
|
+
|
|
251
338
|
// Workflow policy setup is server-scoped: missing policy reads as canonical
|
|
252
339
|
// deny-default state without creating PI_CODING_AGENT_DIR or its policy file.
|
|
253
340
|
const missingWorkflowPolicy = await request("127.0.0.1", "/api/workflow-policy");
|
|
@@ -546,7 +633,7 @@ try {
|
|
|
546
633
|
assert.equal(savedUserLaunchSlots.body?.data?.reloadRequired, true, "a changed save must require active-tab reload before helper guidance changes");
|
|
547
634
|
assert.deepEqual(savedUserLaunchSlots.body?.data?.roles?.reviewer, userLaunchDraft.reviewer, "same-role launch slots must retain independent explicit model specs");
|
|
548
635
|
const persistedLaunchSlots = JSON.parse(await readFile(settingsFile, "utf8"));
|
|
549
|
-
assert.equal(persistedLaunchSlots.version,
|
|
636
|
+
assert.equal(persistedLaunchSlots.version, 6, "launch-slot persistence should retain the current private WebUI settings envelope");
|
|
550
637
|
assert.deepEqual(persistedLaunchSlots.subagentLaunchSlots?.user?.roles?.reviewer, userLaunchDraft.reviewer);
|
|
551
638
|
|
|
552
639
|
const inheritedProjectLaunchSlots = await request("127.0.0.1", `/api/subagents/config?tab=${encodeURIComponent(tabId)}&scope=project`);
|
|
@@ -58,8 +58,16 @@ 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");
|
|
70
|
+
const restoreStreamRender = functionBody("restoreStreamRenderAfterChatRebuild");
|
|
63
71
|
const captureMobileSurface = functionBody("captureMobileSurfaceRenderFocus");
|
|
64
72
|
const restoreMobileSurface = functionBody("restoreMobileSurfaceRenderFocus");
|
|
65
73
|
const captureAppRunnerInput = functionBody("captureAppRunnerInputFocus");
|
|
@@ -121,18 +129,30 @@ assert.match(app, /dataset\.mobileContinuityKey = "context:paste-text"[\s\S]*dat
|
|
|
121
129
|
assert.match(captureMobileSurface, /mobileDraftAuthority === "dom"[\s\S]*selectionDirection:[\s\S]*scrollTop:[\s\S]*scrollLeft:/, "mobile DOM drafts must capture selection and scroll state");
|
|
122
130
|
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
131
|
|
|
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]*
|
|
132
|
+
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");
|
|
133
|
+
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");
|
|
134
|
+
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
135
|
assert.match(renderStreamingMarkdown, /captureChatTextSelection\(block\)[\s\S]*restoreChatTextSelection\(selectionSnapshot\)/, "streaming Markdown tail replacement must preserve a still-valid browser Range");
|
|
128
136
|
assert.match(renderAllMessages, /captureChatTextSelection\(\)[\s\S]*restoreChatTextSelection\(selectionSnapshot\)/, "authoritative transcript rerenders must preserve a still-valid main-output Range");
|
|
137
|
+
assert.doesNotMatch(renderAllMessages, /applyToolOutputExpansionToDom\(|captureTranscriptToolInteractionState\(|restoreTranscriptToolInteractionState\(/, "routine transcript rerenders must not scan or overwrite every historical tool disclosure");
|
|
138
|
+
assert.match(app, /const INTERACTED_TOOL_BUBBLE_LIMIT = 16;/, "interacted tool continuity must stay tightly bounded");
|
|
139
|
+
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");
|
|
140
|
+
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");
|
|
141
|
+
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");
|
|
142
|
+
assert.match(renderAllMessages, /captureInteractedToolInteractionState\(\)[\s\S]*restoreInteractedToolInteractionState\(toolInteractionSnapshots\)/, "routine transcript renders must restore only explicitly interacted tool cards");
|
|
143
|
+
assert.match(bindToolDetailsScrollMode, /dataset\.toolScrollMode \|\|= "position"[\s\S]*ensureToolInteractionDelegation\(\)/, "tool scroll surfaces must use delegated reader-mode tracking rather than per-node listeners");
|
|
144
|
+
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");
|
|
145
|
+
assert.doesNotMatch(captureToolDetailsInteraction, /scrollHeight|clientHeight|getBoundingClientRect/, "live tool state capture must avoid synchronous layout reads");
|
|
146
|
+
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");
|
|
147
|
+
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
148
|
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");
|
|
149
|
+
assert.match(restoreStreamRender, /streamOutputMounted[\s\S]*thinkingOutputMounted[\s\S]*toolCallOutputMounted/, "stream restoration must distinguish preserved live-tail nodes from surfaces that were actually detached");
|
|
150
|
+
assert.match(restoreStreamRender, /if \(!streamOutputMounted\)[\s\S]*streamBubble = null[\s\S]*if \(!thinkingOutputMounted\)[\s\S]*streamThinkingBubble = null[\s\S]*if \(!toolCallOutputMounted\)[\s\S]*streamToolCallBubble = null/, "authoritative refreshes must retain mounted live assistant, thinking, and tool-call bubbles instead of orphaning and duplicating them");
|
|
130
151
|
|
|
131
152
|
// --- Transcript mutation coordinator contracts (keyed DOM ownership) ---
|
|
132
153
|
|
|
133
154
|
const renderThinkingMarkdown = functionBody("renderThinkingMarkdown");
|
|
134
155
|
const flushCompactLiveOutput = functionBody("flushCompactLiveOutput");
|
|
135
|
-
const updateLiveToolCard = functionBody("updateLiveToolCard");
|
|
136
156
|
const renderLiveToolRun = functionBody("renderLiveToolRun");
|
|
137
157
|
const renderMermaidDiagram = functionBody("renderMermaidDiagram");
|
|
138
158
|
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-v71"/, "continuity/tablet assets need a coherent cache identity");
|
|
51
|
+
assert.match(html, /styles\.css\?v=98/, "tablet CSS must have a coherent HTML revision");
|
|
52
|
+
assert.match(html, /app\.js\?v=112/, "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-v71"/, "the cache identity must change with the startup graph");
|
|
42
|
+
assert.match(html, /styles\.css\?v=98/, "the stylesheet revision must change with mobile/tablet CSS fixes");
|
|
43
|
+
assert.match(html, /app\.js\?v=112/, "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-v71"/, "browser asset changes need a coherent cache tuple");
|
|
64
64
|
|
|
65
65
|
console.log("mobile-phone-experience-static.test.mjs passed");
|