@firstpick/pi-package-webui 0.8.2 → 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.
Files changed (38) hide show
  1. package/README.md +9 -3
  2. package/bin/pi-webui.mjs +97 -12
  3. package/lib/git-workflow-preferences.mjs +246 -19
  4. package/lib/thinking-stream-recovery.mjs +156 -0
  5. package/lib/ui-layout-settings.mjs +254 -0
  6. package/package.json +5 -3
  7. package/public/app.js +1618 -41
  8. package/public/index.html +35 -14
  9. package/public/service-worker.js +1 -1
  10. package/public/styles.css +324 -1
  11. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  12. package/tests/browser/composer-action-grid-reorder.spec.mjs +303 -0
  13. package/tests/browser/feature-decision-output-popup.spec.mjs +156 -0
  14. package/tests/browser/interaction-continuity.spec.mjs +29 -0
  15. package/tests/browser/persistent-ui-layout.spec.mjs +744 -0
  16. package/tests/codex-fast-mode-static.test.mjs +2 -2
  17. package/tests/composer-action-grid-reorder-static.test.mjs +63 -0
  18. package/tests/fast-mode-client-static.test.mjs +2 -2
  19. package/tests/feature-decision-output-popup-static.test.mjs +172 -0
  20. package/tests/fixtures/fake-pi.mjs +51 -1
  21. package/tests/git-workflow-preferences.test.mjs +4 -2
  22. package/tests/http-endpoints-harness.test.mjs +88 -1
  23. package/tests/interaction-state-stability-static.test.mjs +3 -0
  24. package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
  25. package/tests/mobile-foundation-static.test.mjs +3 -3
  26. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  27. package/tests/mobile-static.test.mjs +32 -15
  28. package/tests/open-issue-wizard-static.test.mjs +1 -1
  29. package/tests/persistent-ui-layout-static.test.mjs +267 -0
  30. package/tests/questionnaire-dialog.test.mjs +511 -0
  31. package/tests/queue-edit-reorder-static.test.mjs +1 -0
  32. package/tests/remote-auth-settings-harness.test.mjs +1 -1
  33. package/tests/side-panel-resize-static.test.mjs +1 -0
  34. package/tests/side-panel-section-reorder-static.test.mjs +3 -3
  35. package/tests/subagent-launch-slots.test.mjs +1 -1
  36. package/tests/thinking-stream-recovery.test.mjs +88 -0
  37. package/tests/ui-layout-settings.test.mjs +92 -0
  38. package/tests/webui-settings-locking.test.mjs +159 -0
@@ -53,7 +53,7 @@ assert.match(app, /statusKey === CODEX_FAST_MODE_STATUS_KEY[\s\S]*?applyCodexFas
53
53
  assert.match(readme, /### Compact live output mode[\s\S]*?select \*\*Compact\*\*[\s\S]*?`compact-v1`/, "README should document Compact mode with the stable wire identifier");
54
54
  assert.match(readme, /### Codex subscription Fast mode[\s\S]*?service_tier: "priority"[\s\S]*?1\.5× faster[\s\S]*?2× Standard credits[\s\S]*?2\.5×/, "README should separately document subscription Fast mode and its cost semantics");
55
55
  // Intent preserved: browser-asset changes must advance the coherent cache tuple.
56
- assert.match(serviceWorker, /pi-webui-pwa-v62/, "PWA cache identity should be bumped for changed browser assets");
57
- assert.match(html, /data-app-src="\/app\.js\?v=104"/, "browser module URL should be cache-busted for Fast-mode wiring");
56
+ assert.match(serviceWorker, /pi-webui-pwa-v71/, "PWA cache identity should be bumped for changed browser assets");
57
+ assert.match(html, /data-app-src="\/app\.js\?v=112"/, "browser module URL should be cache-busted for Fast-mode wiring");
58
58
 
59
59
  console.log("codex-fast-mode-static.test.mjs passed");
@@ -0,0 +1,63 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFile } from "node:fs/promises";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
7
+ const [html, app, css, serviceWorker] = await Promise.all([
8
+ readFile(join(root, "public", "index.html"), "utf8"),
9
+ readFile(join(root, "public", "app.js"), "utf8"),
10
+ readFile(join(root, "public", "styles.css"), "utf8"),
11
+ readFile(join(root, "public", "service-worker.js"), "utf8"),
12
+ ]);
13
+
14
+ assert.match(html, /id="newSessionButton"[^>]*data-composer-action-id="new"[^>]*data-composer-action-span="1"/, "New should occupy one composer grid cell");
15
+ for (const [id, label] of [
16
+ ["compact", "Compact"],
17
+ ["app-runner", "App runner"],
18
+ ["steer", "Steer"],
19
+ ["follow-up", "Follow-up"],
20
+ ["abort", "Abort"],
21
+ ["send", "Send"],
22
+ ]) {
23
+ assert.match(html, new RegExp(`data-composer-action-id="${id}"[^>]*data-composer-action-span="2"`), `${label} should occupy two composer grid cells`);
24
+ }
25
+ for (const id of ["git", "publish", "native-command", "options", "btw"]) {
26
+ assert.match(html, new RegExp(`data-composer-action-id="${id}"[^>]*data-composer-action-span="1"`), `${id} should occupy one composer grid cell`);
27
+ }
28
+ assert.match(html, /id="composerActionGridGuide"[^>]*class="composer-action-grid-guide"[^>]*aria-hidden="true"[^>]*hidden/, "the composer should provide a decorative drag-only grid guide");
29
+ assert.match(html, /id="composerActionOrderStatus"[^>]*role="status"[^>]*aria-live="polite"/, "reordering should have a polite live-region announcement");
30
+
31
+ assert.match(
32
+ css,
33
+ /body\.composer-action-grid-enabled \.composer-row\s*\{[\s\S]*--composer-action-cell-min-width:\s*3\.2rem[\s\S]*display:\s*grid[\s\S]*grid-template-columns:\s*repeat\(auto-fill, minmax\(var\(--composer-action-cell-min-width\), 1fr\)\)[\s\S]*grid-auto-flow:\s*dense/,
34
+ "the desktop composer should use wider dense responsive grid cells",
35
+ );
36
+ assert.match(css, /grid-column:\s*var\(--composer-action-grid-column, auto\) \/ span var\(--composer-action-grid-span\)/, "actions should support explicit sparse grid columns");
37
+ assert.match(css, /\[data-composer-action-span="2"\]\s*\{\s*--composer-action-grid-span:\s*2;/, "wide actions should span exactly two cells");
38
+ assert.match(css, /body\.composer-action-grid-enabled \.composer-row \[data-composer-action-id\]\.composer-publish-menu:hover,[\s\S]*\.composer-publish-menu:focus-within,[\s\S]*\.composer-publish-menu\.open \{\s*z-index:\s*100;/, "open composer dropdowns should stack above prompt tags and neighboring grid controls");
39
+ assert.match(css, /#newSessionButton\s*\{[\s\S]*display:\s*grid[\s\S]*place-items:\s*center[\s\S]*padding-inline:\s*0\.4rem[\s\S]*text-align:\s*center/, "New should center its label inside the one-cell button");
40
+ assert.match(css, /composer-action-drag-active[\s\S]*composer-action-grid-guide:not\(\[hidden\]\)[\s\S]*position:\s*absolute[\s\S]*inset:\s*0[\s\S]*grid-template-columns:\s*repeat\(auto-fill, minmax\(var\(--composer-action-cell-min-width\), 1fr\)\)[\s\S]*gap:\s*0\.5rem/, "the drag-only guide should cover the complete composer row with the same responsive tracks");
41
+ assert.match(css, /\.composer-action-grid-cell\s*\{[\s\S]*min-width:\s*0[\s\S]*border:[\s\S]*background:/, "empty guide cells should render as full grid cells");
42
+ assert.match(css, /composer-action-dragging[\s\S]*cursor:\s*grabbing[\s\S]*composer-action-drag-before[\s\S]*composer-action-drag-after/, "dragging and occupied drop targets should have visible affordances");
43
+ assert.match(css, /composer-action-grid-cell-target[\s\S]*border-color:\s*var\(--ctp-teal\)/, "empty-cell drop targets should have a visible affordance");
44
+
45
+ assert.match(app, /const COMPOSER_ACTION_ORDER_STORAGE_KEY = "pi-webui-composer-action-order-v1";[\s\S]*const COMPOSER_ACTION_LAYOUT_STORAGE_KEY = "pi-webui-composer-action-layout-v2";[\s\S]*const COMPOSER_ACTION_POINTER_DRAG_THRESHOLD_PX = 6;/, "composer order and sparse layout should use versioned storage with a bounded drag threshold");
46
+ assert.match(app, /function readStoredComposerActionOrder\(\)[\s\S]*localStorage\.getItem\(COMPOSER_ACTION_ORDER_STORAGE_KEY\)[\s\S]*new Set[\s\S]*function persistComposerActionOrder\(\)[\s\S]*localStorage\.setItem\(COMPOSER_ACTION_ORDER_STORAGE_KEY/, "stored order should be validated, deduplicated, and persisted");
47
+ assert.match(app, /function applyComposerActionOrder\(orderIds\)[\s\S]*knownIds[\s\S]*completeOrder[\s\S]*--composer-action-order/, "new actions should append safely when restoring an older order");
48
+ assert.match(app, /function showComposerActionGridGuide\(\)[\s\S]*composerActionGridColumnCount\(\)[\s\S]*top - groups\.at\(-1\) > 4[\s\S]*columnCount \* rowCount[\s\S]*composer-action-drag-active[\s\S]*function hideComposerActionGridGuide/, "dragging should materialize every full-row guide cell without splitting near-equal action tops into false rows");
49
+ assert.match(app, /function composerActionGridColumnCount\(\)[\s\S]*--composer-action-cell-min-width[\s\S]*row\.clientWidth[\s\S]*Math\.floor\(\(availableWidth \+ gap\) \/ \(minWidth \+ gap\)\)/, "column counts should derive from the visible row width instead of overflow-created implicit tracks");
50
+ assert.match(app, /function readStoredComposerActionLayout\(\)[\s\S]*COMPOSER_ACTION_LAYOUT_STORAGE_KEY[\s\S]*function composerActionSlotCanFit[\s\S]*function persistComposerActionSlotLayout[\s\S]*positions:\s*Object\.fromEntries/, "sparse cell positions should be validated and persisted independently from order");
51
+ assert.match(app, /function remapComposerActionSlot\(record, slot, sourceColumns, targetColumns\)[\s\S]*relativeColumn[\s\S]*function nearestAvailableComposerActionSlot[\s\S]*function restoreComposerActionSlotLayout\(\)[\s\S]*stored\.columns === columns[\s\S]*remapComposerActionSlot/, "saved sparse positions should project into changed responsive grid widths instead of being cleared");
52
+ assert.doesNotMatch(app, /if \(!stored \|\| stored\.columns !== columns\)/, "column-count changes should not discard saved sparse positions");
53
+ assert.match(app, /function captureComposerActionSlotLayout\(\)[\s\S]*composerActionGridGuide[\s\S]*function moveComposerActionToGridCell\(actionId, cell\)[\s\S]*composerActionSlotCanFit[\s\S]*composer-action-grid-cell-target/, "empty grid cells should capture and retain exact action slots");
54
+ assert.match(app, /function composerActionRootFromPoint\(clientX, clientY\)[\s\S]*elementFromPoint[\s\S]*function updateComposerActionPointerDrag\(event\)[\s\S]*Math\.hypot[\s\S]*COMPOSER_ACTION_POINTER_DRAG_THRESHOLD_PX[\s\S]*showComposerActionGridGuide\(\)[\s\S]*captureComposerActionSlotLayout\(\)[\s\S]*composerActionGridCellFromPoint[\s\S]*moveComposerActionToGridCell/, "pointer dragging should activate after the threshold and distinguish occupied from empty grid cells");
55
+ assert.match(app, /function initializeComposerActionOrdering\(\)[\s\S]*MutationObserver[\s\S]*ResizeObserver[\s\S]*observedRowWidth[\s\S]*scheduleComposerActionSlotLayoutRestore[\s\S]*aria-keyshortcuts[\s\S]*ArrowLeft[\s\S]*ArrowRight[\s\S]*moveComposerActionByOffset[\s\S]*pointerdown/, "keyboard and pointer reordering should stay synchronized with dynamic action visibility and composer width");
56
+ assert.match(app, /event\.key === COMPOSER_ACTION_ORDER_STORAGE_KEY\) restoreComposerActionOrder\(\)[\s\S]*event\.key === COMPOSER_ACTION_LAYOUT_STORAGE_KEY\) restoreComposerActionSlotLayout\(\)/, "other tabs should apply persisted composer order and sparse-layout changes");
57
+ assert.match(app, /initializeComposerActionOrdering\(\);[\s\S]*restoreSidePanelSectionOrder\(\);/, "composer ordering should initialize during guarded app startup");
58
+
59
+ assert.match(html, /styles\.css\?v=98/, "changed composer styles should advance the stylesheet revision");
60
+ assert.match(html, /app\.js\?v=112/, "changed composer behavior should advance the app revision");
61
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v71"/, "changed browser assets should advance the PWA cache identity");
62
+
63
+ console.log("composer-action-grid-reorder-static.test.mjs passed");
@@ -123,7 +123,7 @@ assert.match(styles, /\.compact-tool-shell \.compact-tool-status\s*\{[\s\S]*?dis
123
123
  assert.match(styles, /\.compact-tool-shell\.tool-running \.compact-tool-status[\s\S]*?\.compact-tool-shell\.tool-success \.compact-tool-status[\s\S]*?\.compact-tool-shell\.tool-error \.compact-tool-status/, "running, success, and failure tool states should have distinct visual tones");
124
124
  assert.match(compactUpdate, /compactLiveState = reduced\.state;\s+clearCompactToolShells\(\)/, "new assistant or tool-call deltas should clear the preceding transient tool shell");
125
125
  assert.match(compactLiveStreamActive, /messageOutputActive = streamMessageActive && Boolean\([\s\S]*?compactLiveState\.text[\s\S]*?compactLiveState\.thinking[\s\S]*?compactOutputActive\(\) && currentState\?\.isStreaming === true && Boolean\(compactToolShells\.size \|\| messageOutputActive\)/, "mid-stream reconciliation should preserve active compact message output or a current tool shell, but not completed final text");
126
- assert.match(restoreCompactStream, /compactTextBubble = null[\s\S]*?compactThinkingBubble = null[\s\S]*?if \(streamMessageActive\) flushCompactLiveOutput\(\)[\s\S]*?compactToolShells\.values\(\)[\s\S]*?appendChatMessageBubble\(shell\.bubble\)/, "compact message state should be restored only while its message is active, while the current shell can survive between messages");
126
+ assert.match(restoreCompactStream, /compactTextBubble = null[\s\S]*?compactThinkingBubble = null[\s\S]*?if \(streamMessageActive\) flushCompactLiveOutput\(\)[\s\S]*?compactToolShells\.values\(\)[\s\S]*?appendChatMessageBubble\(shell\.bubble, \{ liveTail: true \}\)/, "compact message state should be restored only while its message is active, while the current shell survives in chronological live-tail order between messages");
127
127
  assert.match(refreshMessages, /preserveCompactStream = compactLiveStreamRenderActive\(\)[\s\S]*?!preserveCompactStream && !preserveNormalStream[\s\S]*?renderMessages\(latestMessages\)[\s\S]*?preserveCompactStream\) restoreCompactLiveOutputAfterChatRebuild\(\)/, "message refreshes must not reset active compact output before rebuilding the transcript");
128
128
 
129
129
  assert.match(app, /const SETTINGS_OUTPUT_MODE_OPTIONS = \[[\s\S]*?value: "normal"[\s\S]*?value: "compact-v1"/, "settings should offer normal and compact-v1 server defaults");
@@ -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=104"/, "the guarded PWA entry point should cache-bust browser wiring");
158
+ assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=112"/, "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();
@@ -0,0 +1,172 @@
1
+ import assert from "node:assert/strict";
2
+ import vm from "node:vm";
3
+ import { readFile } from "node:fs/promises";
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, app, css] = await Promise.all([
9
+ readFile(join(root, "public", "index.html"), "utf8"),
10
+ readFile(join(root, "public", "app.js"), "utf8"),
11
+ readFile(join(root, "public", "styles.css"), "utf8"),
12
+ ]);
13
+
14
+ function functionSource(name) {
15
+ const start = app.indexOf(`function ${name}(`);
16
+ assert.ok(start >= 0, `${name} should exist`);
17
+ const next = app.slice(start + 1).match(/\nfunction [A-Za-z0-9_$]+\(/);
18
+ const end = next ? start + 1 + next.index : app.length;
19
+ return app.slice(start, end);
20
+ }
21
+
22
+ assert.match(
23
+ html,
24
+ /<button id="featureCategoryTag"[^>]*type="button"[^>]*aria-haspopup="dialog"[^>]*aria-controls="featureDecisionDialog"[^>]*disabled hidden><\/button>/,
25
+ "the category tag should be a native dialog-triggering button and remain unavailable until exact output arrives",
26
+ );
27
+ assert.match(
28
+ html,
29
+ /<dialog id="featureDecisionDialog" class="extension-dialog feature-decision-dialog" aria-labelledby="featureDecisionDialogTitle">[\s\S]*<h2 id="featureDecisionDialogTitle">Classifier output<\/h2>[\s\S]*<pre id="featureDecisionDialogOutput"[\s\S]*<button id="featureDecisionDialogCloseButton" type="submit" value="close">Close<\/button>/,
30
+ "the popup should use a labelled native dialog, plain-text output container, and explicit close control",
31
+ );
32
+ assert.match(html, /<form method="dialog">[\s\S]*id="featureDecisionDialogCloseButton"/, "the popup close button should use native dialog close semantics");
33
+ assert.doesNotMatch(app, /featureDecisionDialog\?\.addEventListener\("cancel"/, "Escape should retain native dialog cancellation behavior");
34
+ assert.match(css, /\.composer-feature-category-tag:hover:not\(:disabled\),\s*\.composer-feature-category-tag:focus-visible/, "the category button should expose hover and keyboard focus styling");
35
+ assert.match(css, /\.feature-decision-dialog-output \{[\s\S]*white-space:\s*pre-wrap;/, "exact output should render as wrapping preformatted plain text");
36
+
37
+ assert.match(app, /const FEATURE_DECISION_OUTPUT_STATUS_KEY = "feature-decision-output";/, "the consumer should use the approved dedicated status key");
38
+ assert.match(app, /const featureCategoryByTab = new Map\(\);\s*const featureDecisionOutputByTab = new Map\(\);/, "category and decision output should remain isolated in separate per-tab maps");
39
+ assert.match(app, /const FEATURE_DECISION_PAYLOAD_MAX_CHARS = \d+;/, "the consumer should bound the accepted status payload size");
40
+ assert.match(app, /const FEATURE_DECISION_REASON_MAX_CHARS = \d+;/, "the consumer should bound the rendered classifier reason");
41
+
42
+ const context = vm.createContext({ Map, JSON });
43
+ vm.runInContext(`
44
+ const FEATURE_DECISION_PAYLOAD_MAX_CHARS = ${/const FEATURE_DECISION_PAYLOAD_MAX_CHARS = (\d+);/.exec(app)[1]};
45
+ const FEATURE_DECISION_REASON_MAX_CHARS = ${/const FEATURE_DECISION_REASON_MAX_CHARS = (\d+);/.exec(app)[1]};
46
+ ${functionSource("normalizeFeatureCategory")}
47
+ ${functionSource("normalizeFeatureDecisionKind")}
48
+ ${functionSource("normalizeFeatureDecisionReason")}
49
+ ${functionSource("parseFeatureDecisionPayload")}
50
+ ${functionSource("featureDecisionKindLabel")}
51
+ ${functionSource("formatFeatureDecisionText")}
52
+ const featureCategoryByTab = new Map();
53
+ const featureDecisionOutputByTab = new Map();
54
+ ${functionSource("featureDecisionForTab")}
55
+ ${functionSource("featureDecisionOutputForTab")}
56
+ `, context);
57
+ assert.equal(context.normalizeFeatureCategory("lightweight-feature"), "lightweight-feature");
58
+ assert.equal(context.normalizeFeatureCategory("complex-feature"), "complex-feature");
59
+ assert.equal(context.normalizeFeatureCategory(" lightweight-feature"), "", "category validation must not trim payloads");
60
+ assert.equal(context.normalizeFeatureDecisionKind("feature_lightweight"), "feature_lightweight");
61
+ assert.equal(context.normalizeFeatureDecisionKind("feature_complex"), "feature_complex");
62
+ for (const invalid of ["feature_lightweight\n", "feature-lightweight", "lightweight-feature", "", null, undefined]) {
63
+ assert.equal(context.normalizeFeatureDecisionKind(invalid), "", `decision kind should reject ${String(invalid)}`);
64
+ }
65
+
66
+ // The parser runs inside the sandbox realm, so compare plain field copies rather than prototypes.
67
+ function parsePayload(payload) {
68
+ const decision = context.parseFeatureDecisionPayload(payload);
69
+ return decision ? { kind: decision.kind, reason: decision.reason } : decision;
70
+ }
71
+
72
+ assert.deepEqual(
73
+ parsePayload(JSON.stringify({ kind: "feature_complex", reason: "Crosses two packages." })),
74
+ { kind: "feature_complex", reason: "Crosses two packages." },
75
+ "the structured classifier payload should be accepted",
76
+ );
77
+ assert.deepEqual(
78
+ parsePayload(JSON.stringify({ reason: " Collapses\n\tuntrusted\u0007 whitespace and \u202espoofed direction. ", kind: "feature_lightweight" })),
79
+ { kind: "feature_lightweight", reason: "Collapses untrusted whitespace and spoofed direction." },
80
+ "reason text should strip control and bidi formatting characters and collapse whitespace regardless of key order",
81
+ );
82
+ assert.deepEqual(
83
+ parsePayload("feature_complex"),
84
+ { kind: "feature_complex", reason: "" },
85
+ "the legacy exact label should stay accepted for rolling compatibility",
86
+ );
87
+ assert.equal(
88
+ parsePayload(JSON.stringify({ kind: "feature_complex", reason: "x".repeat(900) }))?.reason.length,
89
+ 500,
90
+ "an oversized reason should be bounded rather than rendered in full",
91
+ );
92
+ for (const invalid of [
93
+ undefined,
94
+ null,
95
+ 42,
96
+ "",
97
+ "feature-lightweight",
98
+ "lightweight-feature",
99
+ '["feature_complex","reason"]',
100
+ "{not json",
101
+ JSON.stringify({ kind: "feature_complex" }),
102
+ JSON.stringify({ kind: "feature_complex", reason: "" }),
103
+ JSON.stringify({ kind: "feature_complex", reason: " " }),
104
+ JSON.stringify({ kind: "feature_complex", reason: 7 }),
105
+ JSON.stringify({ kind: "bug", reason: "Restores documented behavior." }),
106
+ JSON.stringify({ kind: "feature_complex", reason: "Extra fields are rejected.", extra: true }),
107
+ JSON.stringify({ kind: "feature_complex", reason: "y".repeat(6000) }),
108
+ ]) {
109
+ assert.equal(parsePayload(invalid), null, `payload should fail closed: ${String(invalid).slice(0, 60)}`);
110
+ }
111
+
112
+ assert.equal(
113
+ context.formatFeatureDecisionText({ kind: "feature_complex", reason: "Crosses two packages." }),
114
+ "Decision: Complex feature (feature_complex)\nReason: Crosses two packages.",
115
+ "the dialog text should read as a decision plus reason, not only the machine label",
116
+ );
117
+ assert.equal(
118
+ context.formatFeatureDecisionText({ kind: "feature_lightweight", reason: "" }),
119
+ "Decision: Lightweight feature (feature_lightweight)\nReason: The classifier reported feature_lightweight without a reason.",
120
+ "a legacy label should render a deterministic readable fallback reason",
121
+ );
122
+ assert.equal(context.formatFeatureDecisionText(null), "", "absent decisions should render no dialog text");
123
+
124
+ vm.runInContext(`
125
+ featureCategoryByTab.set("light", "lightweight-feature");
126
+ featureDecisionOutputByTab.set("light", { kind: "feature_lightweight", reason: "One localized slice." });
127
+ featureCategoryByTab.set("complex", "complex-feature");
128
+ featureDecisionOutputByTab.set("complex", { kind: "feature_complex", reason: "Crosses two packages." });
129
+ featureCategoryByTab.set("legacy", "complex-feature");
130
+ featureDecisionOutputByTab.set("legacy", { kind: "feature_complex", reason: "" });
131
+ featureCategoryByTab.set("mismatch", "complex-feature");
132
+ featureDecisionOutputByTab.set("mismatch", { kind: "feature_lightweight", reason: "One localized slice." });
133
+ `, context);
134
+ assert.equal(
135
+ context.featureDecisionOutputForTab("light"),
136
+ "Decision: Lightweight feature (feature_lightweight)\nReason: One localized slice.",
137
+ "lightweight output should stay readable and tab-scoped",
138
+ );
139
+ assert.equal(
140
+ context.featureDecisionOutputForTab("complex"),
141
+ "Decision: Complex feature (feature_complex)\nReason: Crosses two packages.",
142
+ "complex output should stay readable and tab-scoped",
143
+ );
144
+ assert.equal(
145
+ context.featureDecisionOutputForTab("legacy"),
146
+ "Decision: Complex feature (feature_complex)\nReason: The classifier reported feature_complex without a reason.",
147
+ "legacy exact-label state should render the deterministic fallback reason",
148
+ );
149
+ assert.equal(context.featureDecisionOutputForTab("mismatch"), "", "a category/decision mismatch must not open a popup");
150
+ assert.equal(context.featureDecisionOutputForTab("missing"), "", "a tab must not inherit another tab's decision");
151
+
152
+ const openSource = functionSource("openFeatureDecisionDialog");
153
+ assert.match(openSource, /const tabId = activeTabId;[\s\S]*featureDecisionOutputForTab\(tabId\)[\s\S]*textContent = output;[\s\S]*dialog\.showModal\(\)/, "popup opening should resolve and render only the active tab's exact output");
154
+ assert.doesNotMatch(app, /featureDecisionDialogOutput\.innerHTML/, "classifier reason text must never reach innerHTML");
155
+ assert.match(functionSource("handleFeatureDecisionOutputStatus"), /parseFeatureDecisionPayload\(statusText\)[\s\S]*featureDecisionOutputByTab\.set\(tabId, decision\);\s*else featureDecisionOutputByTab\.delete\(tabId\)/, "status handling should store only parsed decisions and drop rejected payloads");
156
+ assert.match(openSource, /featureDecisionDialogCloseButton\?\.focus/, "popup opening should place focus on its explicit close control");
157
+ assert.match(app, /elements\.featureCategoryTag\?\.addEventListener\("click", openFeatureDecisionDialog\)/, "native click and keyboard button activation should open the popup");
158
+ assert.match(app, /function installDialogModalPrimitive\(dialog\)[\s\S]*trigger\.focus\(\{ preventScroll: true \}\)/, "native dialog close should return focus to the triggering category button");
159
+
160
+ const clearSource = functionSource("clearFeatureDecisionStateForTab");
161
+ assert.match(clearSource, /featureCategoryByTab\.delete\(tabId\);\s*featureDecisionOutputByTab\.delete\(tabId\);[\s\S]*closeFeatureDecisionDialog\(\{ restoreFocus: false \}\)/, "lifecycle cleanup should clear both maps and close the affected popup");
162
+ assert.match(functionSource("handleFeatureCategoryStatus"), /else clearFeatureDecisionStateForTab\(tabId\)/, "clearing or rejecting a category should defensively clear exact output");
163
+ assert.match(functionSource("setActiveTabId"), /nextTabId !== activeTabId[\s\S]*closeFeatureDecisionDialog\(\{ restoreFocus: false \}\)/, "switching tabs should close the prior tab popup");
164
+ assert.match(functionSource("syncTabMetadata"), /clearFeatureDecisionStateForTab\(tabId\)/, "closed-tab metadata cleanup should remove decision state");
165
+ assert.match(functionSource("closeTerminalTabs"), /clearFeatureDecisionStateForTab\(id\)/, "explicit tab closure should remove decision state");
166
+ assert.match(app, /case "webui_connected":[\s\S]*clearFeatureDecisionStateForTab\(connectedTabId, \{ render: true \}\)[\s\S]*scheduleForegroundReconcile\("event stream reconnect", 0\)/, "reconnect should clear local state before authoritative replay");
167
+ assert.match(app, /statusKey === FEATURE_DECISION_OUTPUT_STATUS_KEY[\s\S]*handleFeatureDecisionOutputStatus[\s\S]*return;[\s\S]*statusKey === FEATURE_CATEGORY_STATUS_KEY[\s\S]*return;[\s\S]*statusEntries\.set/, "both feature statuses should be intercepted before generic footer storage while preserving category handling");
168
+
169
+ assert.match(html, /\/styles\.css\?v=98/, "integrated stylesheet changes should advance the cache query");
170
+ assert.match(html, /\/app\.js\?v=112/, "integrated app changes should advance the cache query");
171
+
172
+ console.log("feature decision-output popup static checks passed");
@@ -349,6 +349,19 @@ function runTranscriptContinuityScenario(scenario) {
349
349
  { afterMs: 650, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "thinking_delta", delta: " survives" } })) },
350
350
  );
351
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);
352
365
  } else if (scenario === "tool") {
353
366
  const toolCallId = `continuity-tool-${run}`;
354
367
  const toolOutput = (revision) => [
@@ -414,7 +427,7 @@ function runTranscriptContinuityScenario(scenario) {
414
427
 
415
428
  function handleTranscriptContinuityPrompt(command, base) {
416
429
  if (!continuityModeEnabled) return false;
417
- 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)$/);
418
431
  if (!match) return false;
419
432
  appendDynamicMessage({ role: "user", content: String(command.message), timestamp: Date.now() });
420
433
  respond({ ...base, data: { output: `fake transcript continuity ${match[1]} accepted`, pid: process.pid } });
@@ -1005,6 +1018,42 @@ function statsPromptContextFixturePayload({ malformedSnapshot = false } = {}) {
1005
1018
  return payload;
1006
1019
  }
1007
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
+
1008
1057
  function handleStatsPromptContextFixturePrompt(command, base) {
1009
1058
  if (!statsPromptContextEnabled) return false;
1010
1059
  const message = String(command.message || "").trim();
@@ -1110,6 +1159,7 @@ rl.on("line", (line) => {
1110
1159
  return;
1111
1160
  }
1112
1161
  case "prompt":
1162
+ if (handleFeatureDecisionFixturePrompt(command, base)) return;
1113
1163
  if (handleStatsPromptContextFixturePrompt(command, base)) return;
1114
1164
  if (handleWebuiHelperPrompt(command, base)) return;
1115
1165
  if (handleFastModeFixturePrompt(command, base)) return;
@@ -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, 4);
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, 4);
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, 5, "launch-slot persistence should upgrade the private WebUI settings envelope");
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`);
@@ -67,6 +67,7 @@ const restoreToolDetailsInteraction = functionBody("restoreToolDetailsInteractio
67
67
  const updateLiveToolCard = functionBody("updateLiveToolCard");
68
68
  const renderStreamingMarkdown = functionBody("renderStreamingMarkdown");
69
69
  const refreshMessages = functionBody("refreshMessages");
70
+ const restoreStreamRender = functionBody("restoreStreamRenderAfterChatRebuild");
70
71
  const captureMobileSurface = functionBody("captureMobileSurfaceRenderFocus");
71
72
  const restoreMobileSurface = functionBody("restoreMobileSurfaceRenderFocus");
72
73
  const captureAppRunnerInput = functionBody("captureAppRunnerInputFocus");
@@ -145,6 +146,8 @@ assert.doesNotMatch(captureToolDetailsInteraction, /scrollHeight|clientHeight|ge
145
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");
146
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");
147
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");
148
151
 
149
152
  // --- Transcript mutation coordinator contracts (keyed DOM ownership) ---
150
153
 
@@ -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-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");
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-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");
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");
@@ -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-v62"/, "browser asset changes need a coherent cache tuple");
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");