@firstpick/pi-package-webui 0.9.4 → 0.9.5

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 (42) hide show
  1. package/README.md +3 -0
  2. package/lib/ui-layout-settings.mjs +37 -6
  3. package/package.json +1 -1
  4. package/public/app.js +499 -6
  5. package/public/index.html +33 -26
  6. package/public/service-worker.js +1 -1
  7. package/public/stream-output-controller.mjs +31 -2
  8. package/public/styles.css +27 -2
  9. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  10. package/tests/browser/control-deck-side-panels.spec.mjs +42 -0
  11. package/tests/browser/control-visibility.spec.mjs +396 -0
  12. package/tests/browser/persistent-ui-layout.spec.mjs +9 -9
  13. package/tests/codex-fast-mode-static.test.mjs +2 -2
  14. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  15. package/tests/control-deck-side-panels-static.test.mjs +3 -1
  16. package/tests/control-visibility-static.test.mjs +294 -0
  17. package/tests/controls-layout-static.test.mjs +3 -3
  18. package/tests/fast-mode-client-static.test.mjs +1 -1
  19. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  20. package/tests/file-viewer-image-static.test.mjs +3 -3
  21. package/tests/fixtures/streaming-workloads.mjs +131 -0
  22. package/tests/git-workflow-preferences.test.mjs +2 -2
  23. package/tests/http-endpoints-harness.test.mjs +4 -4
  24. package/tests/intercom-conversation-viewer-static.test.mjs +4 -4
  25. package/tests/main-output-loading-static.test.mjs +3 -3
  26. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  27. package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
  28. package/tests/mobile-foundation-static.test.mjs +3 -3
  29. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  30. package/tests/mobile-static.test.mjs +3 -3
  31. package/tests/open-issue-wizard-static.test.mjs +2 -2
  32. package/tests/persistent-ui-layout-static.test.mjs +6 -6
  33. package/tests/questionnaire-dialog.test.mjs +3 -3
  34. package/tests/session-sampling-ui-static.test.mjs +3 -3
  35. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  36. package/tests/stream-output-isolation-static.test.mjs +7 -0
  37. package/tests/stream-output-workloads.test.mjs +239 -0
  38. package/tests/subagent-observability-static.test.mjs +2 -2
  39. package/tests/syntax-highlighting-static.test.mjs +3 -3
  40. package/tests/theme-customizer-static.test.mjs +1 -1
  41. package/tests/ui-layout-settings.test.mjs +54 -7
  42. package/tests/webui-settings-locking.test.mjs +3 -3
@@ -0,0 +1,294 @@
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, styles, 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
+ // --- Approved stable catalog ------------------------------------------------
15
+
16
+ const catalog = [
17
+ // Workspace toolbar
18
+ ["workspace.save", "Save workspace", "#workspaceSaveButton"],
19
+ ["workspace.command-palette", "Command palette", "#commandPaletteButton"],
20
+ ["workspace.overview", "Show workspace overview", "#workspaceDashboardToggleButton"],
21
+ ["workspace.close-all-tabs", "Close all tabs", "#closeAllTabsButton"],
22
+ // Control Deck
23
+ ["control-deck.sponsor", "Sponsor", ".sponsor-link"],
24
+ ["control-deck.open-issue", "Open Issue", "#openIssueButton"],
25
+ // Composer actions
26
+ ["composer.new", "New", '[data-composer-action-id="new"]'],
27
+ ["composer.compact", "Compact", '[data-composer-action-id="compact"]'],
28
+ ["composer.guided-git", "Guided Git workflow", '[data-composer-action-id="git"]'],
29
+ ["composer.publish", "AUR/npm release dropdown", '[data-composer-action-id="publish"]'],
30
+ ["composer.tools-skills", "Tools/skills setup dropdown", '[data-composer-action-id="native-command"]'],
31
+ ["composer.common-options", "Common options", '[data-composer-action-id="options"]'],
32
+ ["composer.app-runner", "App runner", '[data-composer-action-id="app-runner"]'],
33
+ ["composer.steer", "Steer", '[data-composer-action-id="steer"]'],
34
+ ["composer.follow-up", "Follow-up", '[data-composer-action-id="follow-up"]'],
35
+ ["composer.btw", "/btw side question", '[data-composer-action-id="btw"]'],
36
+ // Prompt input-frame controls
37
+ ["input.workflow", "Workflow controls", "#workflowModeControls"],
38
+ ["input.attach-files", "Attach files", "#attachButton"],
39
+ // Prompt input-frame tag types
40
+ ["tag.prompt-behavior", "Follow-up/Steer busy-prompt behavior tag", "#busyPromptBehaviorTag"],
41
+ ["tag.skills", "Session skill tags", "#sessionSkillTags"],
42
+ ["tag.agent-conversations", "Intercom agent-conversation tags", "#intercomConversationTags"],
43
+ ["tag.feature-category", "Feature-category tag", "#featureCategoryTag"],
44
+ ["tag.voice-mode", "Natural-conversation/voice tag", "#conversationModeChip"],
45
+ ["tag.workflow-mode", "Workflow-mode tag", "#workflowModeChip"],
46
+ ];
47
+
48
+ const groupLabels = ["Workspace toolbar", "Control Deck", "Composer actions", "Input-frame controls", "Input-frame tags"];
49
+
50
+ for (const [id, label] of catalog) {
51
+ assert.ok(app.includes(`id: "${id}",`), `registry should keep the stable ${id} key`);
52
+ assert.ok(
53
+ html.includes(`data-visibility-key="${id}"`),
54
+ `the ${label} control should declare data-visibility-key="${id}" for direct hide targets`,
55
+ );
56
+ }
57
+ for (const label of groupLabels) {
58
+ assert.ok(app.includes(`"${label}"`), `the region menu should group entries under "${label}"`);
59
+ }
60
+
61
+ // --- Send exclusion ---------------------------------------------------------
62
+
63
+ assert.doesNotMatch(
64
+ app,
65
+ /composer\.send/,
66
+ "Send must never be registered as a visibility toggle",
67
+ );
68
+ assert.doesNotMatch(
69
+ html,
70
+ /data-visibility-key="[^"]*send"/i,
71
+ "the Send button must not carry a visibility key",
72
+ );
73
+ {
74
+ const sendButtonMatch = html.match(/<button id="sendButton"[^>]*>/);
75
+ assert.ok(sendButtonMatch, "the composer should keep a Send button");
76
+ assert.doesNotMatch(sendButtonMatch[0], /data-visibility-key/, "the Send markup must stay unregistered");
77
+ }
78
+
79
+ // --- Durable schema and field ------------------------------------------------
80
+
81
+ assert.match(
82
+ app,
83
+ /const UI_LAYOUT_SCHEMA_VERSION = 3;/,
84
+ "the browser controller should send schema version 3 with the control visibility field",
85
+ );
86
+ assert.match(
87
+ app,
88
+ /const UI_LAYOUT_FIELDS = \[[^\]]*"controlVisibility"[^\]]*\];/,
89
+ "controlVisibility should travel through the revision-guarded interface-preferences writer",
90
+ );
91
+ assert.match(
92
+ app,
93
+ /case "controlVisibility":[\s{]*\n?\s*return \{ hiddenIds: readStoredControlVisibilityHiddenIds\(\) \};/,
94
+ "collecting the durable field should read the bounded local hidden-id list",
95
+ );
96
+ assert.match(
97
+ app,
98
+ /function applyDurableControlVisibility\(value\)[\s\S]*writeDurableLayoutCache\(CONTROL_VISIBILITY_HIDDEN_IDS_STORAGE_KEY[\s\S]*applyControlVisibility\(\)/,
99
+ "snapshot adoption should cache the hidden-key list and reapply it immediately",
100
+ );
101
+
102
+ // --- Class-based composition with runtime gating ------------------------------
103
+
104
+ assert.match(
105
+ styles,
106
+ /\.webui-user-hidden \{\s*display: none !important;\s*\}/,
107
+ "preference hiding needs a dedicated webui-user-hidden class",
108
+ );
109
+ assert.match(
110
+ app,
111
+ /element\.classList\.toggle\("webui-user-hidden", shouldHide\)/,
112
+ "showing a control only toggles the preference class instead of the hidden attribute",
113
+ );
114
+ assert.doesNotMatch(
115
+ app.match(/function applyControlVisibility[\s\S]*?function persistControlVisibilityHiddenIds/)?.[0] || "",
116
+ /\.hidden\s*=\s*[^)]/,
117
+ "the visibility applier must not assign or clear runtime hidden state",
118
+ );
119
+
120
+ // --- Empty-region grouped menu and direct hide menu ---------------------------
121
+
122
+ assert.match(
123
+ html,
124
+ /<div id="visibilityContextMenu"[^>]*role="menu"[^>]*hidden>/,
125
+ "the visibility recovery menu should be an initially empty menu container",
126
+ );
127
+ assert.match(
128
+ app,
129
+ /const CONTROL_VISIBILITY_GROUP_LABELS = \[[\s\:]*?\["workspace", "Workspace toolbar"\]/,
130
+ "the catalog should label its host regions",
131
+ );
132
+ for (const region of ["workspace", "control-deck", "composer", "inputframe"]) {
133
+ assert.ok(
134
+ html.includes(`data-visibility-region="${region}"`),
135
+ `the ${region} empty-area region should be marked in the markup`,
136
+ );
137
+ }
138
+ assert.match(
139
+ app,
140
+ /button\.setAttribute\("role", "menuitemcheckbox"\)/,
141
+ "the empty-region menu should expose menuitemcheckbox entries",
142
+ );
143
+ assert.match(
144
+ app,
145
+ /`Hide \$\{entry\.label\}`/,
146
+ "direct targets should offer a Hide <label> action",
147
+ );
148
+ for (const action of ["show-all", "reset-defaults"]) {
149
+ assert.ok(app.includes(`"${action}"`), `recovery action ${action} should exist`);
150
+ }
151
+ assert.match(
152
+ app,
153
+ /if \(action === "show-all"\)[\s\S]*showAllControls\(\)[\s\S]*else if \(action === "reset-defaults"\)[\s\S]*resetControlVisibilityDefaults\(\)/,
154
+ "Show all and Reset defaults remain distinct actions",
155
+ );
156
+ assert.match(
157
+ app,
158
+ /function showAllControls\(\) \{\s*persistControlVisibilityHiddenIds\(\[\]\);/,
159
+ "Show all should persist an explicit empty hidden-id list",
160
+ );
161
+ assert.match(
162
+ app,
163
+ /function resetControlVisibilityDefaults\(\) \{\s*persistControlVisibilityHiddenIds\(null\);/,
164
+ "Reset defaults should clear the preference back to null",
165
+ );
166
+
167
+ // --- Specialized menu preservation --------------------------------------------
168
+
169
+ assert.match(
170
+ app,
171
+ /target\.closest\?\.\("button, input, textarea, select, \[contenteditable='true'\], a"\)/,
172
+ "non-registered buttons, inputs, links, and editable contexts keep their native menu",
173
+ );
174
+ assert.match(
175
+ app,
176
+ /if \(target\.closest\?\.\("\.file-context-menu, dialog, \.composer-publish-menu-panel"\)\) return;[\s\S]*const direct/,
177
+ "open submenus and specialized context menus stay untouched before ancestor registry lookup",
178
+ );
179
+
180
+ // --- Accessible keyboard and dismissal behavior --------------------------------
181
+
182
+ assert.match(
183
+ app,
184
+ /event\.key !== "ContextMenu" && !\(event\.shiftKey && event\.key === "F10"\)/,
185
+ "Context Menu key and Shift+F10 should be keyboard-equivalent invocations",
186
+ );
187
+ assert.match(
188
+ app,
189
+ /addEventListener\("contextmenu", handleControlVisibilityContextMenu, \{ capture: true \}\)/,
190
+ "registered target handling should preempt owners of specialized menus",
191
+ );
192
+ {
193
+ const keydownBlock = app.match(/elements\.visibilityContextMenu\?\.addEventListener\("keydown", \(event\) => \{[\s\S]*?event\.key === "Home" \? 0 : items\.length - 1[\s\S]*?\}\);/)?.[0] || "";
194
+ for (const key of ["Escape", "ArrowDown", "ArrowUp", "Home", "End"]) {
195
+ assert.ok(keydownBlock.includes(`"${key}"`), `the menu should handle ${key}`);
196
+ }
197
+ }
198
+ assert.match(
199
+ app,
200
+ /pointerdown[\s\S]*\.control-visibility-context-menu[\s\S]*closeVisibilityContextMenu\(\{ returnFocus: false \}\)/,
201
+ "outside clicks should dismiss the menu",
202
+ );
203
+ assert.match(
204
+ app,
205
+ /window\.addEventListener\("resize", \(\) => closeVisibilityContextMenu/,
206
+ "window resizing should dismiss the menu",
207
+ );
208
+ assert.match(
209
+ app,
210
+ /document\.addEventListener\("scroll",[\s\S]*closeVisibilityContextMenu\(\{ returnFocus: false \}\)/,
211
+ "document scrolling should dismiss the menu after the invocation grace period",
212
+ );
213
+ assert.match(
214
+ app,
215
+ /function positionControlVisibilityMenu\(clientX, clientY\)[\s\S]*window\.innerWidth - rect\.width[\s\S]*window\.innerHeight - rect\.height/,
216
+ "menu positioning should stay bounded inside the viewport",
217
+ );
218
+ assert.match(
219
+ app,
220
+ /wasHidden !== shouldHide && entry\.group === "composer"/,
221
+ "composer reflow detection must compare prior and next state so un-hiding also restores saved slots",
222
+ );
223
+ assert.match(
224
+ app,
225
+ /if \(composerChanged\) scheduleComposerActionSlotLayoutRestore\(\)/,
226
+ "composer action visibility changes should schedule a grid projection",
227
+ );
228
+ assert.match(
229
+ app,
230
+ /root\.classList\.contains\("webui-user-hidden"\)[\s\S]*repackComposerActionSlotLayout\(\{ persist: false \}\)/,
231
+ "hidden composer actions should project a dense grid without overwriting saved slots",
232
+ );
233
+ assert.match(
234
+ app,
235
+ /event\.key === CONTROL_VISIBILITY_HIDDEN_IDS_STORAGE_KEY\) \{\s*\/\/ [\s\S]*durableLayoutDirtyFields\.get\("controlVisibility"\)[\s\S]*applyControlVisibility\(dirtyVisibility \? dirtyVisibility\.value\?\.hiddenIds : undefined\)/,
236
+ "same-origin tabs should apply visibility cache updates immediately unless a local mutation is still pending",
237
+ );
238
+ assert.match(
239
+ app,
240
+ /durableLayoutDirtyFields\.delete\(field\);\s*if \(field === "controlVisibility"\) \{[\s\S]*writeDurableLayoutCache\(CONTROL_VISIBILITY_HIDDEN_IDS_STORAGE_KEY, JSON\.stringify\(entry\.value\?\.hiddenIds \?\? null\)\)[\s\S]*applyControlVisibility\(\)/,
241
+ "a successful visibility PUT should rewrite the acknowledged value into the same-origin cache",
242
+ );
243
+ assert.match(
244
+ styles,
245
+ /\.side-panel-context-menu-item\[aria-checked="true"\]::before \{\s*content: "✓";/,
246
+ "checked menu items should expose a visible check mark as well as aria-checked",
247
+ );
248
+
249
+ // --- Keyboard-only recovery from Send ------------------------------------------
250
+
251
+ assert.match(
252
+ app,
253
+ /const sendAnchor = entry \? null : target\.closest\?\.\("#sendButton"\);[\s\S]*if \(!entry && !sendAnchor && target\.closest\?\.\("button, input, textarea, select, \[contenteditable='true'\], a"\)\) return;/,
254
+ "Context Menu/Shift+F10 on the permanently visible Send button should open the grouped recovery menu",
255
+ );
256
+ {
257
+ const sendButtonMatch = html.match(/<button id="sendButton"[^>]*>/);
258
+ assert.ok(sendButtonMatch, "the composer should keep a Send button");
259
+ assert.match(
260
+ sendButtonMatch[0],
261
+ /aria-keyshortcuts="Alt\+ArrowLeft Alt\+ArrowRight Alt\+ArrowUp Alt\+ArrowDown ContextMenu Shift\+F10"/,
262
+ "Send should expose the keyboard recovery shortcut to assistive technology",
263
+ );
264
+ }
265
+ assert.match(
266
+ app,
267
+ /record\.id === "send"[\s\S]*"Alt\+ArrowLeft Alt\+ArrowRight Alt\+ArrowUp Alt\+ArrowDown ContextMenu Shift\+F10"/,
268
+ "the runtime composer-action shortcut wiring should keep the Send recovery shortcut",
269
+ );
270
+
271
+ // --- Focus restoration --------------------------------------------------------
272
+
273
+ assert.match(
274
+ app,
275
+ /function closeVisibilityContextMenu\(\{ returnFocus = true \} = \{\}\)[\s\S]*triggerSurvives[\s\S]*elements\.promptInput\?\.focus/,
276
+ "closing the menu should restore focus to a surviving trigger or the prompt input",
277
+ );
278
+ assert.match(
279
+ app,
280
+ /trigger\.matches\("button, a, input, select, textarea, \[tabindex\]"\)[\s\S]*\? trigger[\s\S]*: elements\.promptInput/,
281
+ "non-focusable region hosts should fall back to the prompt as the focus-restoration trigger",
282
+ );
283
+
284
+ // --- Cache identity -----------------------------------------------------------
285
+
286
+ assert.match(
287
+ serviceWorker,
288
+ /const CACHE_NAME = "pi-webui-pwa-v115";/,
289
+ "browser asset changes should advance the PWA cache identity",
290
+ );
291
+ assert.match(html, /styles\.css\?v=129/, "visibility styles should advance the stylesheet query revision");
292
+ assert.match(html, /data-app-src="\/app\.js\?v=150"/, "visibility behavior should advance the app query revision");
293
+
294
+ console.log("control-visibility-static.test.mjs passed");
@@ -15,8 +15,8 @@ assert.equal((html.match(/class="control-row-label"[^>]*data-tooltip=/g) || []).
15
15
  assert.match(app, /function initializeControlSettingTooltips\(\)[\s\S]*#sidePanelSectionControls \.control-row-label\[data-tooltip\][\s\S]*bindStyledTooltipEvents\(label\)[\s\S]*showFooterTooltip\(label\)/, "Controls help should use the viewport-safe floating tooltip for hover and keyboard access");
16
16
  assert.match(html, /class="control-row remote-auth-control-row" hidden[\s\S]*id="remoteAuthToggle"/, "optional PIN protection should retain its guarded visibility");
17
17
  assert.match(app, /remoteAuthToggle\?\.closest\("\.remote-auth-control-row"\)[\s\S]*remoteAuthRow\.hidden = false/, "loading remote status should reveal the optional PIN protection setting");
18
- assert.match(html, /styles\.css\?v=126/, "Controls stylesheet changes should advance the cache query");
19
- assert.match(html, /app\.js\?v=148/, "Controls tooltip wiring should advance the app cache query");
20
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "Controls browser assets should advance the PWA cache identity");
18
+ assert.match(html, /styles\.css\?v=129/, "Controls stylesheet changes should advance the cache query");
19
+ assert.match(html, /app\.js\?v=150/, "Controls tooltip wiring should advance the app cache query");
20
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v115"/, "Controls browser assets should advance the PWA cache identity");
21
21
 
22
22
  console.log("controls-layout-static.test.mjs passed");
@@ -156,7 +156,7 @@ assert.match(worker, /pi-webui-pwa-v\d+[\s\S]*?"\/fast-output-live\.mjs"/, "PWA
156
156
  assert.match(html, /<label for="fastOutputModeSelect">Compact mode \(Experimental\)<\/label>/, "the sidebar should mark compact mode as experimental");
157
157
  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");
158
158
  // Intent preserved: the guarded PWA entry point must advance whenever app wiring changes.
159
- assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=148"/, "the guarded PWA entry point should cache-bust browser wiring");
159
+ assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=150"/, "the guarded PWA entry point should cache-bust browser wiring");
160
160
  assert.match(JSON.parse(packageRaw).scripts.check, /node --check public\/fast-output-live\.mjs/, "package checks should parse the compact helper");
161
161
 
162
162
  const events = createFastModeOutputEvents();
@@ -166,7 +166,7 @@ assert.match(functionSource("closeTerminalTabs"), /clearFeatureDecisionStateForT
166
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
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
168
 
169
- assert.match(html, /\/styles\.css\?v=126/, "integrated stylesheet changes should advance the cache query");
170
- assert.match(html, /\/app\.js\?v=148/, "integrated app changes should advance the cache query");
169
+ assert.match(html, /\/styles\.css\?v=129/, "integrated stylesheet changes should advance the cache query");
170
+ assert.match(html, /\/app\.js\?v=150/, "integrated app changes should advance the cache query");
171
171
 
172
172
  console.log("feature decision-output popup static checks passed");
@@ -62,8 +62,8 @@ assert.match(css, /\.file-viewer-image img \{[\s\S]*max-width: 100%;[\s\S]*max-h
62
62
  assert.match(readme, /PNG, JPEG, GIF, WebP, and AVIF/i, "the Files panel guide should list supported image formats");
63
63
  assert.match(technical, /supported raster images[\s\S]*2 MiB/i, "the advanced reference should document image support and its size limit");
64
64
  assert.match(development, /kind: "image"[\s\S]*base64/i, "the contributor guide should document the image response contract");
65
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "changed viewer assets should advance the PWA cache identity");
66
- assert.match(html, /styles\.css\?v=126/, "changed image styles should advance the stylesheet revision");
67
- assert.match(html, /app\.js\?v=148/, "changed image rendering should advance the app revision");
65
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v115"/, "changed viewer assets should advance the PWA cache identity");
66
+ assert.match(html, /styles\.css\?v=129/, "changed image styles should advance the stylesheet revision");
67
+ assert.match(html, /app\.js\?v=150/, "changed image rendering should advance the app revision");
68
68
 
69
69
  console.log("file viewer image static tests passed");
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Deterministic streaming workloads for the webui-output-streaming plan
3
+ * (Phase 0 baseline). Every generator is pure and seed-free: the same call
4
+ * always produces the same event sequence, so tests and profiling runs can
5
+ * compare results across revisions byte-for-byte.
6
+ *
7
+ * Events use the same shapes the SSE transport delivers to
8
+ * `createStreamOutputController()`:
9
+ * `{ type: "message_update", assistantMessageEvent: { type, delta, ... } }`
10
+ * and `{ type: "tool_execution_update", ... }`.
11
+ */
12
+
13
+ const WORD_POOL = ["alpha", "bravo", "charlie", "delta", "echo", "foxtrot", "golf", "hotel"];
14
+
15
+ export function messageUpdateEvent(type, delta = "", extra = {}) {
16
+ return { type: "message_update", assistantMessageEvent: { type, delta, ...extra } };
17
+ }
18
+
19
+ /** 1,000-style small plain-text deltas: short deterministic words plus spaces. */
20
+ export function smallTextDeltaEvents(count = 1000) {
21
+ const events = [];
22
+ for (let index = 0; index < count; index += 1) {
23
+ events.push(messageUpdateEvent("text_delta", `${WORD_POOL[index % WORD_POOL.length]} `));
24
+ }
25
+ return events;
26
+ }
27
+
28
+ function deterministicChunk(index, chunkBytes) {
29
+ // No blank lines and no fence markers: a single growing paragraph tail.
30
+ const seed = `p${index.toString(36)} `;
31
+ return seed.repeat(Math.ceil(chunkBytes / seed.length)).slice(0, chunkBytes);
32
+ }
33
+
34
+ /** A long unbroken paragraph (no blank lines) streamed in fixed-size chunks. */
35
+ export function longParagraphDeltaEvents(totalBytes, chunkBytes = 64) {
36
+ const events = [];
37
+ let produced = 0;
38
+ let index = 0;
39
+ while (produced < totalBytes) {
40
+ const size = Math.min(chunkBytes, totalBytes - produced);
41
+ events.push(messageUpdateEvent("text_delta", deterministicChunk(index, size)));
42
+ produced += size;
43
+ index += 1;
44
+ }
45
+ return events;
46
+ }
47
+
48
+ /**
49
+ * An open fenced code block streamed in chunks. The fence is never closed, so
50
+ * every publish keeps the whole fence in the mutable Markdown tail.
51
+ * `codeBytes` under ~50,000 with short lines stays inside the syntax-highlight
52
+ * bounds (repeated tokenization case); larger sizes exercise the plain-token
53
+ * fallback plus full-tail re-render case.
54
+ */
55
+ export function openFenceDeltaEvents(codeBytes, { language = "js", chunkBytes = 64, lineLength = 40 } = {}) {
56
+ const events = [messageUpdateEvent("text_delta", "```" + language + "\n")];
57
+ let produced = 0;
58
+ let index = 0;
59
+ while (produced < codeBytes) {
60
+ const size = Math.min(chunkBytes, codeBytes - produced);
61
+ let chunk = "";
62
+ while (chunk.length < size) {
63
+ const line = `const v${index.toString(36)} = ${index % 97};`;
64
+ chunk += line.slice(0, Math.min(lineLength, size - chunk.length));
65
+ if (chunk.length < size) chunk += "\n";
66
+ index += 1;
67
+ }
68
+ events.push(messageUpdateEvent("text_delta", chunk));
69
+ produced += size;
70
+ }
71
+ return events;
72
+ }
73
+
74
+ /** A long thinking stream of deterministic reasoning-style deltas. */
75
+ export function thinkingStreamEvents(count = 500) {
76
+ const events = [messageUpdateEvent("thinking_start")];
77
+ for (let index = 0; index < count; index += 1) {
78
+ events.push(messageUpdateEvent("thinking_delta", `step ${index}: ${WORD_POOL[index % WORD_POOL.length]}. `));
79
+ }
80
+ events.push(messageUpdateEvent("thinking_end"));
81
+ return events;
82
+ }
83
+
84
+ /**
85
+ * Mixed semantic burst: interleaved thinking, text, tool-call, tool-execution,
86
+ * error, and end barriers in a fixed order for exact-order assertions.
87
+ */
88
+ export function mixedSemanticBurstEvents() {
89
+ return [
90
+ messageUpdateEvent("thinking_start"),
91
+ messageUpdateEvent("thinking_delta", "planning "),
92
+ messageUpdateEvent("thinking_delta", "steps"),
93
+ messageUpdateEvent("thinking_end"),
94
+ messageUpdateEvent("text_start"),
95
+ messageUpdateEvent("text_delta", "Running the "),
96
+ messageUpdateEvent("text_delta", "command now."),
97
+ messageUpdateEvent("toolcall_start", "", { toolCallId: "tool-1" }),
98
+ messageUpdateEvent("toolcall_delta", '{"cmd":', { toolCallId: "tool-1" }),
99
+ messageUpdateEvent("toolcall_delta", '"ls"}', { toolCallId: "tool-1" }),
100
+ messageUpdateEvent("toolcall_end", "", { toolCallId: "tool-1" }),
101
+ { type: "tool_execution_update", toolCallId: "tool-1", partialResult: { content: "file-a\n" } },
102
+ { type: "tool_execution_update", toolCallId: "tool-1", partialResult: { content: "file-a\nfile-b\n" } },
103
+ messageUpdateEvent("text_delta", " Done."),
104
+ messageUpdateEvent("error", "", { error: "deterministic-error" }),
105
+ messageUpdateEvent("text_end"),
106
+ ];
107
+ }
108
+
109
+ /**
110
+ * Queue-overflow burst: strictly alternating text/thinking deltas defeat
111
+ * adjacent coalescing, so `pairs * 2` events exercise the entry-limit path of
112
+ * the bounded frame queue.
113
+ */
114
+ export function overflowBurstEvents({ pairs = 200 } = {}) {
115
+ const events = [];
116
+ for (let index = 0; index < pairs; index += 1) {
117
+ events.push(messageUpdateEvent("text_delta", `t${index} `));
118
+ events.push(messageUpdateEvent("thinking_delta", `h${index} `));
119
+ }
120
+ return events;
121
+ }
122
+
123
+ /** Concatenate every delta of one assistant-message-event type, in order. */
124
+ export function concatenatedDeltaText(events, type = "text_delta") {
125
+ let text = "";
126
+ for (const event of events) {
127
+ const update = event?.assistantMessageEvent;
128
+ if (update?.type === type && typeof update.delta === "string") text += update.delta;
129
+ }
130
+ return text;
131
+ }
@@ -69,7 +69,7 @@ try {
69
69
  assert.equal(migrated.gitWorkflow.stagingPolicy, "review");
70
70
  assert.equal(migrated.gitWorkflow.reviewProcessEnabled, true, "legacy settings should preserve the existing review-process behavior");
71
71
  assert.equal(migrated.gitWorkflow.generation.thinkingLevel, "low");
72
- assert.equal(migrated.uiLayout.version, 2);
72
+ assert.equal(migrated.uiLayout.version, 3);
73
73
  assert.equal(migrated.uiLayout.sidePanel.placement, "right");
74
74
  assert.deepEqual(migrated.uiLayout.sidePanel.sectionLayout, { order: ["files", "controls", "git"], leftSectionIds: [] });
75
75
  assert.deepEqual(migrated.uiLayout.sidePanel.collapsedSectionIds, ["git"]);
@@ -128,7 +128,7 @@ try {
128
128
 
129
129
  const persisted = JSON.parse(await readFile(settingsFile, "utf8"));
130
130
  assert.equal(persisted.version, 8);
131
- assert.equal(persisted.uiLayout.version, 2, "the first unrelated locked write must persist the migrated v2 envelope");
131
+ assert.equal(persisted.uiLayout.version, 3, "the first unrelated locked write must persist the migrated v3 envelope");
132
132
  assert.deepEqual(persisted.uiLayout.sidePanel.sectionLayout, { order: ["files", "controls", "git"], leftSectionIds: [] });
133
133
  assert.deepEqual(persisted.uiLayout.composerActions, completeV1Layout.composerActions, "unchanged v1 composer fields must survive persistence");
134
134
  assert.deepEqual(persisted.uiLayout.terminalTabs, { ...completeV1Layout.terminalTabs, sidebarWidth: null }, "unchanged v1 terminal fields must survive persistence while new width state defaults safely");
@@ -810,7 +810,7 @@ try {
810
810
  const initialInterfacePreferences = await request("127.0.0.1", "/api/interface-preferences");
811
811
  assert.equal(initialInterfacePreferences.status, 200);
812
812
  assert.equal(initialInterfacePreferences.body?.data?.preferences?.sidePanelWidth, null, "a user without a saved width should receive the default preference");
813
- assert.equal(initialInterfacePreferences.body?.data?.layout?.version, 2);
813
+ assert.equal(initialInterfacePreferences.body?.data?.layout?.version, 3);
814
814
  assert.deepEqual(initialInterfacePreferences.body?.data?.layout?.sidePanel?.sectionLayout, { order: null, leftSectionIds: null });
815
815
  assert.match(initialInterfacePreferences.body?.data?.layoutRevision || "", /^[a-f0-9]{64}$/);
816
816
  assert.equal(Object.hasOwn(initialInterfacePreferences.body?.data || {}, "path"), false, "preference responses must not disclose the user's settings-file path");
@@ -839,7 +839,7 @@ try {
839
839
  sidePanelWidth: 620,
840
840
  expectedLayoutRevision: initialLayoutRevision,
841
841
  layout: {
842
- version: 2,
842
+ version: 3,
843
843
  sidePanel: {
844
844
  placement: "both",
845
845
  sectionLayout: { order: ["files", "controls", "git"], leftSectionIds: ["files"] },
@@ -857,7 +857,7 @@ try {
857
857
  });
858
858
  assert.equal(savedLayout.status, 200, savedLayout.body?.error);
859
859
  assert.equal(savedLayout.body?.data?.preferences?.sidePanelWidth, 620);
860
- assert.equal(savedLayout.body?.data?.layout?.sidePanel?.panelWidths?.right, 620, "one locked PUT must expose matching v2 right and legacy widths");
860
+ assert.equal(savedLayout.body?.data?.layout?.sidePanel?.panelWidths?.right, 620, "one locked PUT must expose matching v3 right and legacy widths");
861
861
  assert.deepEqual(savedLayout.body?.data?.layout?.sidePanel?.sectionLayout, { order: ["files", "controls", "git"], leftSectionIds: ["files"] });
862
862
  assert.deepEqual(savedLayout.body?.data?.layout?.composerActions?.order, ["new", "git", "send"]);
863
863
  assert.equal(savedLayout.body?.data?.layout?.terminalTabs?.layout, "left");
@@ -868,7 +868,7 @@ try {
868
868
  const persistedLayoutSettings = JSON.parse(await readFile(settingsFile, "utf8"));
869
869
  assert.equal(persistedLayoutSettings.version, 8);
870
870
  assert.equal(persistedLayoutSettings.interfacePreferences.sidePanelWidth, 620);
871
- assert.equal(persistedLayoutSettings.uiLayout.sidePanel.panelWidths.right, 620, "the v2 right width and legacy mirror must persist atomically");
871
+ assert.equal(persistedLayoutSettings.uiLayout.sidePanel.panelWidths.right, 620, "the v3 right width and legacy mirror must persist atomically");
872
872
  assert.equal(persistedLayoutSettings.uiLayout.fileViewerWidth, 560);
873
873
  assert.deepEqual(persistedLayoutSettings.uiLayout.composerActions.grid.positions, { new: 0, git: 1, send: 10 });
874
874
 
@@ -41,7 +41,7 @@ for (const id of [
41
41
 
42
42
  assert.match(
43
43
  html,
44
- /<div class="composer-context-tags">[\s\S]*<div id="intercomConversationTags" class="composer-intercom-tags" role="group" aria-label="Agent conversations" aria-live="polite" hidden><\/div>/,
44
+ /<div class="composer-context-tags">[\s\S]*<div id="intercomConversationTags" class="composer-intercom-tags" role="group" aria-label="Agent conversations" aria-live="polite" data-visibility-key="tag\.agent-conversations" hidden><\/div>/,
45
45
  "the dedicated conversation-tag list should live beneath the composer input in the existing context-tag surface",
46
46
  );
47
47
  assert.match(
@@ -95,9 +95,9 @@ assert.match(css, /\.composer-intercom-tag:hover,[\s\S]*\.composer-intercom-tag:
95
95
  assert.match(css, /\.extension-dialog\.intercom-conversation-dialog \{[\s\S]*width: min\(76rem,[\s\S]*height: min\(54rem,/, "the viewer should use a large in-app modal");
96
96
  assert.match(css, /@media \(max-width: 720px\)[\s\S]*\.composer-intercom-tag \{ min-height: 44px;[\s\S]*\.extension-dialog\.intercom-conversation-dialog[\s\S]*width: calc\(100vw - 0\.7rem\)/, "tags and the dialog should remain reachable on narrow and coarse-pointer layouts");
97
97
 
98
- assert.match(html, /\/styles\.css\?v=126/, "the stylesheet URL should advance for the bounded conversation tags");
99
- assert.match(html, /data-app-src="\/app\.js\?v=148"/, "the guarded app URL should advance for current browser wiring");
100
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "the PWA cache identity should advance with browser assets");
98
+ assert.match(html, /\/styles\.css\?v=129/, "the stylesheet URL should advance for the bounded conversation tags");
99
+ assert.match(html, /data-app-src="\/app\.js\?v=150"/, "the guarded app URL should advance for current browser wiring");
100
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v115"/, "the PWA cache identity should advance with browser assets");
101
101
 
102
102
  assert.match(readme, /one compact tag per conversation appears beneath the composer/i, "the README should explain the user-visible entry point");
103
103
  assert.match(technical, /## Agent conversation viewer[\s\S]*Attachments, tool calls and results, thinking, stdout\/stderr, filesystem paths, raw session records/i, "the advanced guide should document privacy exclusions");
@@ -50,9 +50,9 @@ assert.match(css, /@media \(prefers-reduced-motion: reduce\)[\s\S]*?animation-du
50
50
  assert.match(css, /body\.terminal-tabs-left \.main-output-loading,[\s\S]*?body\.terminal-tabs-left \.chat \{ grid-row: 4; \}/, "sidebar tab placement should keep the status inside the transcript grid row");
51
51
  assert.match(css, /body\.subagent-terminal-active \.main-output-loading,/, "main-output loading feedback should stay hidden in the dedicated subagent view");
52
52
 
53
- assert.match(html, /styles\.css\?v=126/, "the stylesheet cache query should advance");
54
- assert.match(html, /app\.js\?v=148/, "the app cache query should advance");
55
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "the PWA cache identity should advance with browser assets");
53
+ assert.match(html, /styles\.css\?v=129/, "the stylesheet cache query should advance");
54
+ assert.match(html, /app\.js\?v=150/, "the app cache query should advance");
55
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v115"/, "the PWA cache identity should advance with browser assets");
56
56
  assert.match(readme, /Loading agent output/, "user documentation should describe the visible loading feedback");
57
57
  assert.match(development, /main output loading/i, "developer documentation should preserve the request-ownership contract");
58
58
 
@@ -16,9 +16,9 @@ assert.match(app, /import \{ installMiddleButtonDragScroll \} from "\.\/middle-b
16
16
  assert.match(app, /installMiddleButtonDragScroll\(\{[\s\S]*onDirection: \(\{ target, offsetY \}\)[\s\S]*noteChatUserScrollIntent\(\{ type: "middle-drag", deltaY: offsetY \}\)/, "chat auto-scroll direction should feed the existing follow/pause intent state");
17
17
  assert.match(app, /event\?\.type === "middle-drag"\) return event\.deltaY > 0;/, "moving below the press point should be recognized as intent to read later chat output");
18
18
  assert.match(css, /body\.middle-button-auto-scrolling,[\s\S]*cursor: all-scroll !important;[\s\S]*user-select: none !important;/, "active automatic scrolling should expose a directional-scroll affordance and suppress accidental selection");
19
- assert.match(html, /styles\.css\?v=126/, "changed drag-scroll styles should advance the stylesheet revision");
20
- assert.match(html, /app\.js\?v=148/, "changed drag-scroll wiring should advance the app revision");
21
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112";[\s\S]*"\/middle-button-drag-scroll\.mjs"/, "offline PWA installs should refresh and cache the new controller module");
19
+ assert.match(html, /styles\.css\?v=129/, "changed drag-scroll styles should advance the stylesheet revision");
20
+ assert.match(html, /app\.js\?v=150/, "changed drag-scroll wiring should advance the app revision");
21
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v115";[\s\S]*"\/middle-button-drag-scroll\.mjs"/, "offline PWA installs should refresh and cache the new controller module");
22
22
  assert.match(JSON.parse(packageJson).scripts.check, /node --check public\/middle-button-drag-scroll\.mjs/, "the package check should parse the startup-critical controller module");
23
23
 
24
24
  console.log("middle-button-drag-scroll-static.test.mjs passed");
@@ -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-v112"/, "continuity/tablet assets need a coherent cache identity");
51
- assert.match(html, /styles\.css\?v=126/, "tablet CSS must have a coherent HTML revision");
52
- assert.match(html, /app\.js\?v=148/, "continuity app logic must have a coherent HTML revision");
50
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v115"/, "continuity/tablet assets need a coherent cache identity");
51
+ assert.match(html, /styles\.css\?v=129/, "tablet CSS must have a coherent HTML revision");
52
+ assert.match(html, /app\.js\?v=150/, "continuity app logic must have a coherent HTML revision");
53
53
  assert.match(technical, /tabletShell=v2[\s\S]*tabletShell=legacy/, "technical reference should document tablet preview and rollback");
54
54
 
55
55
  console.log("mobile-continuity-tablet-static.test.mjs passed");
@@ -37,9 +37,9 @@ assert.match(pkg.scripts.check, /node --check public\/transcript-renderer\.mjs/,
37
37
  assert.match(server, /STATIC_PUBLIC_FILE_EXTENSIONS[\s\S]*"\.mjs"/, "the server must serve typed startup modules from the public asset boundary");
38
38
  assert.match(serviceWorker, /"\/mobile-shell-state\.mjs"/, "the PWA shell must cache the new startup module");
39
39
  assert.match(serviceWorker, /"\/transcript-renderer\.mjs"/, "the PWA shell must cache the transcript startup module");
40
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "the cache identity must change with the startup graph");
41
- assert.match(html, /styles\.css\?v=126/, "the stylesheet revision must change with mobile/tablet CSS fixes");
42
- assert.match(html, /app\.js\?v=148/, "the app revision must change with continuity/tablet wiring");
40
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v115"/, "the cache identity must change with the startup graph");
41
+ assert.match(html, /styles\.css\?v=129/, "the stylesheet revision must change with mobile/tablet CSS fixes");
42
+ assert.match(html, /app\.js\?v=150/, "the app revision must change with continuity/tablet wiring");
43
43
  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");
44
44
  assert.match(serviceWorker, /MOBILE_NAVIGATION_MESSAGE_TYPE = "pi-webui:navigate:v1"/, "the service worker must use a versioned active-client navigation message");
45
45
  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-v112"/, "browser asset changes need a coherent cache tuple");
63
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v115"/, "browser asset changes need a coherent cache tuple");
64
64
 
65
65
  console.log("mobile-phone-experience-static.test.mjs passed");