@firstpick/pi-package-webui 0.9.1 → 0.9.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 (107) hide show
  1. package/README.md +31 -9
  2. package/bin/pi-webui-launcher.mjs +23 -12
  3. package/bin/pi-webui.mjs +729 -93
  4. package/index.ts +266 -1
  5. package/lib/agent-run-adapters.mjs +500 -0
  6. package/lib/agent-run-protocol.mjs +262 -0
  7. package/lib/agent-run-registry.mjs +339 -0
  8. package/lib/git-workflow-preferences.mjs +18 -28
  9. package/lib/intercom-conversations.mjs +491 -0
  10. package/lib/intercom-transcript-filter.mjs +99 -0
  11. package/lib/resource-selection.mjs +140 -0
  12. package/lib/trust-boundaries.mjs +2 -0
  13. package/lib/ui-layout-settings.mjs +172 -28
  14. package/lib/update/package-layout.mjs +50 -0
  15. package/lib/update/plan.mjs +11 -0
  16. package/package.json +2 -2
  17. package/public/app.js +2276 -419
  18. package/public/index.html +142 -72
  19. package/public/service-worker.js +2 -1
  20. package/public/stream-output-controller.mjs +15 -0
  21. package/public/styles.css +764 -92
  22. package/public/syntax-highlight.mjs +622 -0
  23. package/tests/agent-run-adapters.test.mjs +217 -0
  24. package/tests/agent-run-launcher.test.mjs +41 -0
  25. package/tests/agent-run-protocol.test.mjs +82 -0
  26. package/tests/agent-run-registry.test.mjs +102 -0
  27. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  28. package/tests/browser/control-deck-side-panels.spec.mjs +354 -0
  29. package/tests/browser/controls-layout.spec.mjs +122 -0
  30. package/tests/browser/file-tree-git-ignored.spec.mjs +113 -0
  31. package/tests/browser/interaction-continuity.spec.mjs +161 -0
  32. package/tests/browser/intercom-conversation-viewer.spec.mjs +355 -0
  33. package/tests/browser/mobile-foundation.spec.mjs +26 -0
  34. package/tests/browser/model-search-focus.spec.mjs +96 -0
  35. package/tests/browser/optimistic-prompt.spec.mjs +22 -0
  36. package/tests/browser/persistent-ui-layout.spec.mjs +285 -66
  37. package/tests/browser/resource-profiles.spec.mjs +200 -0
  38. package/tests/browser/subagent-observability.spec.mjs +116 -0
  39. package/tests/codex-fast-mode-static.test.mjs +7 -6
  40. package/tests/common-options-submenus-interaction-static.test.mjs +2 -0
  41. package/tests/common-options-submenus-markup-static.test.mjs +1 -0
  42. package/tests/component-update-api-static.test.mjs +2 -1
  43. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  44. package/tests/composer-skill-tag-layout.test.mjs +32 -2
  45. package/tests/control-deck-component-updates-static.test.mjs +6 -0
  46. package/tests/control-deck-side-panels-static.test.mjs +68 -0
  47. package/tests/controls-layout-static.test.mjs +22 -0
  48. package/tests/fast-mode-client-static.test.mjs +2 -2
  49. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  50. package/tests/feature-system-prompt-optional-feature-static.test.mjs +5 -5
  51. package/tests/file-tree-git-ignored-static.test.mjs +152 -0
  52. package/tests/file-tree-search-layout-static.test.mjs +2 -1
  53. package/tests/file-viewer-image-static.test.mjs +69 -0
  54. package/tests/fixtures/fake-pi.mjs +147 -12
  55. package/tests/foreground-transcript-catch-up-static.test.mjs +1 -1
  56. package/tests/git-panel-file-preview-static.test.mjs +5 -5
  57. package/tests/git-panel-live-updates-static.test.mjs +3 -3
  58. package/tests/git-workflow-preferences.test.mjs +55 -6
  59. package/tests/http-endpoints-harness.test.mjs +295 -14
  60. package/tests/intercom-conversation-viewer-static.test.mjs +105 -0
  61. package/tests/intercom-conversations-http.test.mjs +252 -0
  62. package/tests/intercom-conversations.test.mjs +374 -0
  63. package/tests/intercom-main-transcript-suppression-static.test.mjs +52 -0
  64. package/tests/intercom-tag-layout-static.test.mjs +46 -0
  65. package/tests/intercom-transcript-filter.test.mjs +98 -0
  66. package/tests/main-output-loading-static.test.mjs +59 -0
  67. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  68. package/tests/mobile-compact-layout.test.mjs +2 -3
  69. package/tests/mobile-continuity-tablet-static.test.mjs +6 -6
  70. package/tests/mobile-foundation-static.test.mjs +3 -3
  71. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  72. package/tests/mobile-static.test.mjs +76 -42
  73. package/tests/native-parity.test.mjs +8 -7
  74. package/tests/open-issue-wizard-static.test.mjs +2 -2
  75. package/tests/optional-feature-migration-frontend.test.mjs +5 -5
  76. package/tests/optional-feature-resource-setup-static.test.mjs +29 -0
  77. package/tests/persistent-ui-layout-static.test.mjs +13 -13
  78. package/tests/questionnaire-dialog.test.mjs +3 -3
  79. package/tests/remote-auth-settings-harness.test.mjs +1 -1
  80. package/tests/resource-defaults-helper.test.mjs +60 -6
  81. package/tests/resource-selection.test.mjs +114 -0
  82. package/tests/resource-tui-extension.test.mjs +23 -0
  83. package/tests/session-sampling-ui-static.test.mjs +3 -3
  84. package/tests/side-panel-context-menu-static.test.mjs +1 -1
  85. package/tests/side-panel-resize-static.test.mjs +26 -16
  86. package/tests/side-panel-section-height-removal-static.test.mjs +4 -4
  87. package/tests/side-panel-section-reorder-static.test.mjs +16 -70
  88. package/tests/stream-output-controller.test.mjs +8 -0
  89. package/tests/stream-output-isolation-static.test.mjs +2 -2
  90. package/tests/streaming-ui-coupling.test.mjs +5 -0
  91. package/tests/subagent-gate-visibility.test.mjs +2 -1
  92. package/tests/subagent-launch-slots.test.mjs +1 -1
  93. package/tests/subagent-observability-static.test.mjs +32 -0
  94. package/tests/subagent-reliability-integration.test.mjs +183 -0
  95. package/tests/subagent-workflow-section-static.test.mjs +67 -0
  96. package/tests/subagents-helper.test.mjs +548 -5
  97. package/tests/syntax-highlight.test.mjs +235 -0
  98. package/tests/syntax-highlighting-static.test.mjs +84 -0
  99. package/tests/terminal-tabs-resize-static.test.mjs +35 -0
  100. package/tests/theme-customizer-static.test.mjs +5 -5
  101. package/tests/thinking-format-parser.test.mjs +64 -0
  102. package/tests/ui-layout-settings.test.mjs +104 -32
  103. package/tests/update-api-harness.test.mjs +24 -10
  104. package/tests/update-package-layout.test.mjs +38 -0
  105. package/tests/update-plan.test.mjs +11 -1
  106. package/tests/webui-settings-locking.test.mjs +33 -3
  107. package/webui-rpc-helper.mjs +700 -89
@@ -0,0 +1,374 @@
1
+ import assert from "node:assert/strict";
2
+ import { projectIntercomConversations } from "../lib/intercom-conversations.mjs";
3
+
4
+ function customEntry(customType, data, id, timestamp, parentId = null) {
5
+ return { type: "custom", customType, data, id, parentId, timestamp };
6
+ }
7
+
8
+ function customMessage(customType, details, content, id, timestamp, parentId = null) {
9
+ return { type: "custom_message", customType, details, content, display: true, id, parentId, timestamp };
10
+ }
11
+
12
+ function assistantToolCall(toolCallId, argumentsValue, id, timestamp) {
13
+ return {
14
+ type: "message",
15
+ id,
16
+ parentId: null,
17
+ timestamp,
18
+ message: {
19
+ role: "assistant",
20
+ timestamp: Date.parse(timestamp),
21
+ content: [{ type: "toolCall", id: toolCallId, toolName: "subagent_supervisor", arguments: argumentsValue }],
22
+ },
23
+ };
24
+ }
25
+
26
+ function toolResult(toolCallId, details, id, timestamp, isError = false) {
27
+ return {
28
+ type: "message",
29
+ id,
30
+ parentId: null,
31
+ timestamp,
32
+ message: {
33
+ role: "toolResult",
34
+ toolCallId,
35
+ toolName: "subagent_supervisor",
36
+ content: [{ type: "text", text: "untrusted result text must not be projected" }],
37
+ details,
38
+ isError,
39
+ timestamp: Date.parse(timestamp),
40
+ },
41
+ };
42
+ }
43
+
44
+ function projection(entries, options = {}) {
45
+ return projectIntercomConversations(entries, { localSessionId: "local-session", localName: "Local Agent", ...options });
46
+ }
47
+
48
+ function detail(entries, summaryOptions = {}, detailOptions = {}) {
49
+ const summary = projection(entries, summaryOptions);
50
+ assert.ok(summary.conversations[0]?.id, "fixture must produce a conversation summary");
51
+ return projection(entries, { ...summaryOptions, ...detailOptions, conversationId: summary.conversations[0].id }).conversation;
52
+ }
53
+
54
+ {
55
+ const entries = [
56
+ customMessage("intercom_message", {
57
+ from: { id: "peer-1", name: "Agent Alpha", cwd: "/private/peer/path" },
58
+ message: {
59
+ id: "message-in-1",
60
+ timestamp: 1_700_000_000_000,
61
+ content: { text: "Hello from Alpha", attachments: [{ name: "secret.txt", content: "ATTACHMENT_SECRET" }] },
62
+ },
63
+ bodyText: "BODY_TEXT_SECRET",
64
+ }, "rendered message containing PARSED_PROSE_SECRET", "entry-1", "2023-11-14T22:13:20.000Z"),
65
+ customEntry("intercom_sent", {
66
+ to: "Agent Alpha",
67
+ message: { text: "Hello back", replyTo: "message-in-1", attachments: [{ name: "reply.txt", content: "OUTBOUND_ATTACHMENT_SECRET" }] },
68
+ messageId: "message-out-1",
69
+ timestamp: 1_700_000_001_000,
70
+ }, "entry-2", "2023-11-14T22:13:21.000Z"),
71
+ customEntry("intercom_received", {
72
+ from: "Agent Alpha",
73
+ message: { text: "A direct received reply" },
74
+ messageId: "message-received-1",
75
+ timestamp: 1_700_000_002_000,
76
+ }, "entry-3", "2023-11-14T22:13:22.000Z"),
77
+ customMessage("intercom_message", {
78
+ from: { id: "peer-1", name: "Agent Alpha" },
79
+ message: { id: "message-received-1", timestamp: 1_700_000_002_000, content: { text: "A direct received reply" } },
80
+ }, "duplicate rendered prose", "entry-4", "2023-11-14T22:13:22.000Z"),
81
+ customMessage("intercom_message", {
82
+ from: { id: "subagent-result", name: "subagent-result" },
83
+ message: { id: "synthetic-1", timestamp: 1_700_000_003_000, content: { text: "SYNTHETIC_SECRET" } },
84
+ }, "synthetic", "entry-5", "2023-11-14T22:13:23.000Z"),
85
+ customEntry("unrelated_extension", { text: "UNRELATED_CUSTOM_SECRET" }, "entry-6", "2023-11-14T22:13:24.000Z"),
86
+ {
87
+ type: "message",
88
+ id: "entry-7",
89
+ parentId: null,
90
+ timestamp: "2023-11-14T22:13:25.000Z",
91
+ message: { role: "toolResult", toolName: "bash", content: [{ type: "text", text: "TOOL_RESULT_SECRET" }], isError: false },
92
+ },
93
+ ];
94
+
95
+ const summary = projection(entries);
96
+ assert.equal(summary.conversations.length, 1, "all direct events for one stable peer should create one conversation");
97
+ assert.equal(summary.conversations[0].messageCount, 3, "canonical message IDs should deduplicate received representations");
98
+ assert.deepEqual(summary.conversations[0].participants, {
99
+ local: { id: "local-session", name: "Local Agent" },
100
+ peer: { id: "peer-1", name: "Agent Alpha" },
101
+ });
102
+ assert.equal(summary.conversation, null, "summary projection must not expose transcript text");
103
+
104
+ const conversation = projection(entries, { conversationId: summary.conversations[0].id }).conversation;
105
+ assert.deepEqual(conversation.messages.map(({ direction, text }) => [direction, text]), [
106
+ ["peer", "Hello from Alpha"],
107
+ ["local", "Hello back"],
108
+ ["peer", "A direct received reply"],
109
+ ]);
110
+ const serialized = JSON.stringify(conversation);
111
+ for (const forbidden of [
112
+ "/private/peer/path",
113
+ "ATTACHMENT_SECRET",
114
+ "OUTBOUND_ATTACHMENT_SECRET",
115
+ "BODY_TEXT_SECRET",
116
+ "PARSED_PROSE_SECRET",
117
+ "SYNTHETIC_SECRET",
118
+ "UNRELATED_CUSTOM_SECRET",
119
+ "TOOL_RESULT_SECRET",
120
+ ]) assert.equal(serialized.includes(forbidden), false, `projection must not expose ${forbidden}`);
121
+ }
122
+
123
+ {
124
+ const entries = [
125
+ customEntry("intercom_sent", {
126
+ to: "Retry Peer",
127
+ message: { text: "same delivery text" },
128
+ messageId: "retry-original",
129
+ timestamp: 1000,
130
+ }, "retry-entry-1", "1970-01-01T00:00:01.000Z"),
131
+ customEntry("intercom_sent", {
132
+ to: "Retry Peer",
133
+ message: { text: "same delivery text", retryOf: "retry-original", supersedes: "retry-original" },
134
+ messageId: "retry-new",
135
+ timestamp: 2000,
136
+ }, "retry-entry-2", "1970-01-01T00:00:02.000Z"),
137
+ ];
138
+ const conversation = detail(entries);
139
+ assert.equal(conversation.messageCount, 2, "distinct protocol IDs must preserve retries and superseding messages even when text matches");
140
+ assert.deepEqual(conversation.messages.map(({ text }) => text), ["same delivery text", "same delivery text"]);
141
+ }
142
+
143
+ {
144
+ const entries = [
145
+ customMessage("intercom_message", {
146
+ from: { id: "peer-a", name: "Duplicate Name", startedAt: 500 },
147
+ message: { id: "a-1", timestamp: 1000, content: { text: "from A" } },
148
+ }, "a", "a", "1970-01-01T00:00:01.000Z"),
149
+ customMessage("intercom_message", {
150
+ from: { id: "peer-b", name: "Duplicate Name", startedAt: 600 },
151
+ message: { id: "b-1", timestamp: 2000, content: { text: "from B" } },
152
+ }, "b", "b", "1970-01-01T00:00:02.000Z"),
153
+ customEntry("intercom_sent", {
154
+ to: "Duplicate Name",
155
+ message: { text: "ambiguous outbound" },
156
+ messageId: "ambiguous-1",
157
+ timestamp: 3000,
158
+ }, "c", "1970-01-01T00:00:03.000Z"),
159
+ ];
160
+ const summary = projection(entries);
161
+ assert.equal(summary.conversations.length, 3, "ambiguous duplicate names must not be guessed into a stable peer conversation");
162
+ assert.deepEqual(new Set(summary.conversations.map(({ participants }) => participants.peer.id)), new Set(["peer-a", "peer-b", null]));
163
+ }
164
+
165
+ {
166
+ const entries = [
167
+ customEntry("intercom_sent", {
168
+ to: "Reused Name",
169
+ message: { text: "sent before the name was reused" },
170
+ messageId: "name-only-old",
171
+ timestamp: 1000,
172
+ }, "name-only-entry", "1970-01-01T00:00:01.000Z"),
173
+ customMessage("intercom_message", {
174
+ from: { id: "new-peer-id", name: "Reused Name", startedAt: 1500 },
175
+ message: { id: "stable-new", timestamp: 2000, content: { text: "new session using the old display name" } },
176
+ }, "new peer", "stable-new-entry", "1970-01-01T00:00:02.000Z"),
177
+ ];
178
+ const summary = projection(entries);
179
+ assert.equal(summary.conversations.length, 2, "name reuse without replyTo evidence must keep the old label-only conversation separate");
180
+ assert.deepEqual(new Set(summary.conversations.map(({ participants }) => participants.peer.id)), new Set(["new-peer-id", null]));
181
+ }
182
+
183
+ {
184
+ const peerId = "01a00abc-1234-5678-9abc-def012345678";
185
+ const entries = [
186
+ customEntry("intercom_sent", {
187
+ to: "01a00abc",
188
+ message: { text: "sent to the short session ID" },
189
+ messageId: "alias-out-1",
190
+ timestamp: 2000,
191
+ }, "alias-out-entry-1", "1970-01-01T00:00:02.000Z"),
192
+ customMessage("intercom_message", {
193
+ from: { id: peerId, name: "Alias Peer", startedAt: 1000 },
194
+ message: { id: "alias-in-1", timestamp: 3000, content: { text: "reply from the full session ID" } },
195
+ }, "alias inbound", "alias-in-entry-1", "1970-01-01T00:00:03.000Z"),
196
+ customEntry("intercom_sent", {
197
+ to: "subagent-chat-01a00abc-1234-5678",
198
+ message: { text: "sent through a generated session label" },
199
+ messageId: "alias-out-2",
200
+ timestamp: 4000,
201
+ }, "alias-out-entry-2", "1970-01-01T00:00:04.000Z"),
202
+ customMessage("intercom_message", {
203
+ from: { id: peerId, name: "Alias Peer", startedAt: 1000 },
204
+ message: { id: "alias-in-2", timestamp: 5000, content: { text: "second reply from the same agent" } },
205
+ }, "alias inbound", "alias-in-entry-2", "1970-01-01T00:00:05.000Z"),
206
+ ];
207
+ const summary = projection(entries);
208
+ assert.equal(summary.conversations.length, 1, "short IDs and generated labels must resolve to the same two-agent conversation as the full peer ID");
209
+ assert.equal(summary.conversations[0].messageCount, 4);
210
+ assert.deepEqual(summary.conversations[0].participants.peer, { id: peerId, name: "Alias Peer" });
211
+ }
212
+
213
+ {
214
+ const entries = [
215
+ customMessage("intercom_message", {
216
+ from: { id: "named-peer-id", name: "Named Peer", startedAt: 500 },
217
+ message: { id: "named-in", timestamp: 1000, content: { text: "identity-bearing inbound" } },
218
+ }, "named inbound", "named-in-entry", "1970-01-01T00:00:01.000Z"),
219
+ customEntry("intercom_sent", {
220
+ to: "Named Peer",
221
+ message: { text: "independent outbound by display name" },
222
+ messageId: "named-out",
223
+ timestamp: 2000,
224
+ }, "named-out-entry", "1970-01-01T00:00:02.000Z"),
225
+ ];
226
+ const summary = projection(entries);
227
+ assert.equal(summary.conversations.length, 1, "a display name should resolve when exactly one already-started peer session owns it");
228
+ assert.equal(summary.conversations[0].messageCount, 2);
229
+ assert.deepEqual(summary.conversations[0].participants.peer, { id: "named-peer-id", name: "Named Peer" });
230
+ }
231
+
232
+ {
233
+ const entries = [
234
+ customMessage("intercom_message", {
235
+ from: { id: "renamed-peer", name: "Current Name" },
236
+ message: { id: "rename-in", timestamp: 1000, content: { text: "identity anchor" } },
237
+ }, "anchor", "rename-anchor", "1970-01-01T00:00:01.000Z"),
238
+ customEntry("intercom_sent", {
239
+ to: "Previous Name",
240
+ message: { text: "explicitly linked reply", replyTo: "rename-in" },
241
+ messageId: "rename-out",
242
+ timestamp: 2000,
243
+ }, "rename-reply", "1970-01-01T00:00:02.000Z"),
244
+ ];
245
+ const conversation = detail(entries);
246
+ assert.equal(conversation.participants.peer.id, "renamed-peer", "replyTo remains sufficient evidence to propagate a stable peer ID across a rename");
247
+ assert.equal(conversation.messageCount, 2);
248
+ }
249
+
250
+ {
251
+ const requestId = "native-request-1";
252
+ const entries = [
253
+ customMessage("subagent_supervisor_request", {
254
+ id: requestId,
255
+ reason: "need_decision",
256
+ expectsReply: true,
257
+ runId: "run-1",
258
+ agent: "implementation-worker",
259
+ childIndex: 2,
260
+ }, `Choose the safe option.\n\nReply with: subagent_supervisor({ action: "reply", replyTo: "${requestId}", message: "..." })`, "native-request-entry", "2026-08-15T10:00:00.000Z"),
261
+ assistantToolCall("native-call-1", { action: "reply", replyTo: requestId, message: "Use the bounded implementation." }, "native-call-entry", "2026-08-15T10:00:01.000Z"),
262
+ toolResult("native-call-1", { replyTo: requestId, runId: "run-1", agent: "implementation-worker" }, "native-result-entry", "2026-08-15T10:00:02.000Z"),
263
+ toolResult("native-call-1", { replyTo: requestId, runId: "run-1", agent: "implementation-worker" }, "native-result-duplicate", "2026-08-15T10:00:02.500Z"),
264
+ assistantToolCall("native-call-failed", { action: "reply", replyTo: requestId, message: "FAILED_REPLY_SECRET" }, "failed-call-entry", "2026-08-15T10:00:03.000Z"),
265
+ toolResult("native-call-failed", { replyTo: requestId, runId: "run-1", agent: "implementation-worker" }, "failed-result-entry", "2026-08-15T10:00:04.000Z", true),
266
+ assistantToolCall("native-call-mismatch", { action: "reply", replyTo: requestId, message: "MISMATCH_REPLY_SECRET" }, "mismatch-call-entry", "2026-08-15T10:00:05.000Z"),
267
+ toolResult("native-call-mismatch", { replyTo: requestId, runId: "other-run", agent: "implementation-worker" }, "mismatch-result-entry", "2026-08-15T10:00:06.000Z"),
268
+ ];
269
+
270
+ const conversation = detail(entries);
271
+ assert.deepEqual(conversation.participants.peer, { id: "run-1:2", name: "implementation-worker" });
272
+ assert.deepEqual(conversation.messages.map(({ direction, text }) => [direction, text]), [
273
+ ["peer", "Choose the safe option."],
274
+ ["local", "Use the bounded implementation."],
275
+ ], "duplicate successful native tool results must still produce one reply event");
276
+ assert.equal(conversation.messageCount, 2, "native request/reply identity should remain deduplicated");
277
+ assert.equal(JSON.stringify(conversation).includes("Reply with:"), false, "native transport reply instructions are not chat text");
278
+ assert.equal(JSON.stringify(conversation).includes("FAILED_REPLY_SECRET"), false, "failed native replies must be excluded");
279
+ assert.equal(JSON.stringify(conversation).includes("MISMATCH_REPLY_SECRET"), false, "mismatched native replies must be excluded");
280
+ }
281
+
282
+ {
283
+ const entries = [];
284
+ for (let index = 0; index < 5; index++) {
285
+ entries.push(customMessage("intercom_message", {
286
+ from: { id: "bounded-peer", name: "Bounded Peer" },
287
+ message: { id: `bounded-${index}`, timestamp: 1000 + index, content: { text: `${index}:${"é".repeat(100)}` } },
288
+ }, "bounded", `bounded-entry-${index}`, new Date(1000 + index).toISOString()));
289
+ }
290
+ const summaryOptions = { maxMessagesPerConversation: 2, maxMessageTextBytes: 12 };
291
+ const conversation = detail(entries, summaryOptions);
292
+ assert.equal(conversation.messageCount, 5, "summary count should retain the total before display truncation");
293
+ assert.equal(conversation.messages.length, 2, "oldest messages should be dropped at the configured conversation limit");
294
+ assert.equal(conversation.truncatedBefore, true);
295
+ assert.deepEqual(conversation.messages.map(({ text }) => text.slice(0, 2)), ["3:", "4:"], "newest bounded messages should remain ordered");
296
+ assert.ok(conversation.messages.every(({ text, truncatedText }) => Buffer.byteLength(text, "utf8") <= 12 && truncatedText), "message text must be byte-bounded and marked");
297
+
298
+ const tightSummary = projection(entries, { maxResponseBytes: 400 });
299
+ const tightProjection = projection(entries, { maxResponseBytes: 400, conversationId: tightSummary.conversations[0].id });
300
+ assert.ok(Buffer.byteLength(JSON.stringify(tightProjection), "utf8") <= 400, "the complete projected response should respect the serialized response bound");
301
+ assert.equal(tightProjection.conversation.truncatedBefore, true, "response-size trimming must be explicit");
302
+ }
303
+
304
+ {
305
+ const entries = Array.from({ length: 6 }, (_, index) => customMessage("intercom_message", {
306
+ from: { id: "source-bounded-peer", name: "Source Bounded Peer" },
307
+ message: { id: `source-bounded-${index}`, timestamp: 1000 + index, content: { text: `source ${index}` } },
308
+ }, "source", `source-entry-${index}`, new Date(1000 + index).toISOString()));
309
+
310
+ const sourceBounded = detail(entries, { maxSourceEntries: 3 });
311
+ assert.deepEqual(sourceBounded.messages.map(({ text }) => text), ["source 3", "source 4", "source 5"], "source-entry bounds should retain the newest branch history");
312
+ assert.equal(sourceBounded.messageCount, 3);
313
+ assert.equal(sourceBounded.truncatedBefore, true, "dropping older source entries must surface explicit truncation");
314
+
315
+ const eventBounded = detail(entries, { maxAcceptedEvents: 2 });
316
+ assert.deepEqual(eventBounded.messages.map(({ text }) => text), ["source 4", "source 5"], "accepted-event bounds should retain newest accepted events");
317
+ assert.equal(eventBounded.messageCount, 2);
318
+ assert.equal(eventBounded.truncatedBefore, true);
319
+ }
320
+
321
+ {
322
+ const entries = ["oldest", "middle", "newest"].map((text, index) => customMessage("intercom_message", {
323
+ from: { id: "text-budget-peer", name: "Text Budget Peer" },
324
+ message: { id: `text-budget-${index}`, timestamp: 1000 + index, content: { text } },
325
+ }, "text budget", `text-budget-entry-${index}`, new Date(1000 + index).toISOString()));
326
+ const conversation = detail(entries, { maxAcceptedTextBytes: 8 });
327
+ assert.deepEqual(conversation.messages.map(({ text }) => text), ["mi", "newest"], "the text budget should retain and byte-truncate the newest possible history");
328
+ assert.equal(conversation.messages[0].truncatedText, true);
329
+ assert.equal(conversation.truncatedBefore, true);
330
+ }
331
+
332
+ {
333
+ const chainLength = 3_000;
334
+ const entries = [];
335
+ for (let index = chainLength - 1; index >= 0; index--) {
336
+ entries.push(customMessage("intercom_message", {
337
+ from: index === 0 ? { id: "chain-peer-id", name: "Chain Peer" } : { name: "Chain Peer" },
338
+ message: {
339
+ id: `chain-${index}`,
340
+ ...(index > 0 ? { replyTo: `chain-${index - 1}` } : {}),
341
+ timestamp: 1000 + index,
342
+ content: { text: `chain message ${index}` },
343
+ },
344
+ }, "chain", `chain-entry-${index}`, new Date(1000 + index).toISOString()));
345
+ }
346
+ const summary = projection(entries);
347
+ assert.equal(summary.conversations.length, 1, "a long reverse reply chain should resolve as one explicit identity component");
348
+ assert.equal(summary.conversations[0].participants.peer.id, "chain-peer-id");
349
+ assert.equal(summary.conversations[0].messageCount, chainLength);
350
+ }
351
+
352
+ {
353
+ const malformed = [
354
+ customMessage("intercom_message", { from: { id: "peer" }, message: { content: { text: "missing message ID" } } }, "unsafe content", "bad-1", "invalid"),
355
+ customEntry("intercom_sent", { to: "peer", message: { text: "missing message ID" } }, "bad-2", "invalid"),
356
+ customMessage("subagent_supervisor_request", { id: "request", runId: "run", agent: "agent", childIndex: -1 }, "invalid child", "bad-3", "invalid"),
357
+ assistantToolCall("orphan-call", { action: "reply", replyTo: "missing-request", message: "orphan" }, "bad-4", "2026-08-15T00:00:00.000Z"),
358
+ toolResult("orphan-call", { replyTo: "missing-request", runId: "run", agent: "agent" }, "bad-5", "2026-08-15T00:00:01.000Z"),
359
+ ];
360
+ assert.deepEqual(projection(malformed), { version: 1, conversations: [], conversation: null, truncatedConversations: 0 });
361
+ assert.equal(projection([], { conversationId: "conv_does-not-exist" }).conversation, null);
362
+ }
363
+
364
+ {
365
+ const entries = Array.from({ length: 4 }, (_, index) => customMessage("intercom_message", {
366
+ from: { id: `peer-${index}`, name: `Peer ${index}` },
367
+ message: { id: `message-${index}`, timestamp: 1000 + index, content: { text: `message ${index}` } },
368
+ }, "message", `entry-${index}`, new Date(1000 + index).toISOString()));
369
+ const summary = projection(entries, { maxConversations: 2 });
370
+ assert.deepEqual(summary.conversations.map(({ participants }) => participants.peer.name), ["Peer 3", "Peer 2"], "most recent conversations should win the bounded summary list");
371
+ assert.equal(summary.truncatedConversations, 2);
372
+ }
373
+
374
+ console.log("intercom-conversations: ok");
@@ -0,0 +1,52 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFile } from "node:fs/promises";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
7
+ const [server, app, filter, fakePi] = await Promise.all([
8
+ readFile(join(root, "bin", "pi-webui.mjs"), "utf8"),
9
+ readFile(join(root, "public", "app.js"), "utf8"),
10
+ readFile(join(root, "lib", "intercom-transcript-filter.mjs"), "utf8"),
11
+ readFile(join(root, "tests", "fixtures", "fake-pi.mjs"), "utf8"),
12
+ ]);
13
+
14
+ function functionSource(source, name) {
15
+ const start = source.indexOf(`function ${name}(`);
16
+ assert.ok(start >= 0, `${name} should exist`);
17
+ const next = source.slice(start + 1).match(/\n(?:async )?function [A-Za-z0-9_$]+\(/);
18
+ const end = next ? start + 1 + next.index : source.length;
19
+ return source.slice(start, end);
20
+ }
21
+
22
+ assert.match(server, /import \{ filterIntercomTranscriptMessages \} from "\.\.\/lib\/intercom-transcript-filter\.mjs";/, "the server should use the dedicated transcript-boundary filter");
23
+ assert.match(
24
+ server,
25
+ /filterSessionSummaryTranscriptMessages\(filterIntercomTranscriptMessages\(tab\.thinkingStreamRecovery\.applyToMessages\(response\.data\.messages\)\)\)/,
26
+ "thinking recovery should complete before Intercom and session-summary records are removed from the normal transcript",
27
+ );
28
+
29
+ assert.match(filter, /message\?\.role === "custom" && message\.customType === INTERCOM_CUSTOM_TYPE/, "persisted intercom_message records should be excluded structurally");
30
+ assert.match(filter, /intercomToolCallIds\.has\(id\)/, "paired Intercom results should be excluded through explicit call IDs");
31
+ assert.match(filter, /content\.some\(hasMeaningfulAssistantPart\)[\s\S]*\{ \.\.\.message, content \}/, "mixed assistant messages should preserve meaningful non-Intercom content");
32
+
33
+ const treeTextSource = functionSource(server, "sessionTreeEntryText");
34
+ assert.match(treeTextSource, /entry\.type === "custom_message" && entry\.customType === "intercom_message"\) return "Intercom message";/, "session-tree Intercom entries should use a fixed label instead of persisted prose");
35
+ assert.match(treeTextSource, /entry\.type === "custom_message"\) return extractSessionTextContent\(entry\.content\);/, "unrelated custom session-tree entries should retain their normal labels");
36
+
37
+ const toolNameSource = functionSource(app, "isIntercomTransportToolName");
38
+ const updateSource = functionSource(app, "isIntercomToolCallUpdate");
39
+ const eventSource = functionSource(app, "handleEvent");
40
+ assert.match(toolNameSource, /trim\(\)\.toLowerCase\(\) === "intercom"/, "live filtering should normalize only the explicit Intercom tool name");
41
+ assert.match(updateSource, /assistantMessageEvent[\s\S]*assistantToolCallPartFromUpdate[\s\S]*isIntercomTransportToolName/, "streamed tool-call updates should be identified before their arguments render");
42
+ assert.match(app, /applyToolCallUpdate: \(event\) => \{[\s\S]*isIntercomToolCallUpdate\(event\)[\s\S]*resetStreamingToolCallState\(\{ remove: true \}\)[\s\S]*handleMessageUpdate\(event\)/, "Intercom stream cards should be discarded while unrelated stream updates keep the normal path");
43
+ assert.match(app, /applyToolExecutionUpdate: \(event\) => \{[\s\S]*!isIntercomTransportToolName\(event\?\.toolName\)[\s\S]*applyTranscriptToolExecutionUpdate\(event\)/, "partial Intercom execution output should never create a live transcript card");
44
+ assert.match(eventSource, /case "tool_execution_start":[\s\S]*isIntercomTransportToolName\(event\.toolName\)[\s\S]*resetStreamingToolCallState\(\{ remove: true \}\)[\s\S]*break;[\s\S]*handleToolExecutionStart\(event\)/, "Intercom execution starts should bypass normal cards and event-log lines");
45
+ assert.match(eventSource, /case "tool_execution_end":[\s\S]*isIntercomTransportToolName\(event\.toolName\)[\s\S]*scheduleSemanticReconcile\(\{ messages: true, footerData: true \}, tabContext\)[\s\S]*break;[\s\S]*handleToolExecutionEnd\(event\)/, "Intercom execution completion should refresh filtered messages and conversation tags without rendering results");
46
+ assert.doesNotMatch(`${toolNameSource}\n${updateSource}`, /subagent_supervisor|contact_supervisor/, "unrelated supervisor tools should remain outside this narrowly approved filter");
47
+ assert.match(fakePi, /intercomLiveEnabled = process\.env\.FAKE_PI_INTERCOM_LIVE === "1"/, "the live Intercom fixture should be explicitly env-gated");
48
+ const liveFixtureSource = functionSource(fakePi, "runIntercomLiveScript");
49
+ assert.match(liveFixtureSource, /LIVE NORMAL OUTPUT VISIBLE/, "the live Intercom fixture should preserve unrelated normal output");
50
+ assert.match(liveFixtureSource, /toolcall_start[\s\S]*tool_execution_start[\s\S]*tool_execution_update[\s\S]*tool_execution_end/, "the isolated fixture should exercise streamed arguments, execution output, and completion");
51
+
52
+ console.log("intercom-main-transcript-suppression-static.test.mjs passed");
@@ -0,0 +1,46 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFile } from "node:fs/promises";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
7
+ const [css, app] = await Promise.all([
8
+ readFile(join(root, "public", "styles.css"), "utf8"),
9
+ readFile(join(root, "public", "app.js"), "utf8"),
10
+ ]);
11
+
12
+ function rule(selector, label) {
13
+ const start = css.indexOf(`${selector} {`);
14
+ assert.ok(start >= 0, `${label} should be present`);
15
+ const end = css.indexOf("}", start);
16
+ assert.ok(end > start, `${label} should be complete`);
17
+ return css.slice(start, end + 1);
18
+ }
19
+
20
+ const container = rule(".composer-intercom-tags", "conversation tag container styles");
21
+ const denseContainer = rule(".composer-intercom-tags.dense", "dense conversation tag container styles");
22
+ const containerRules = [...css.matchAll(/\.composer-intercom-tags(?:\.dense)?\s*\{([^}]*)\}/g)].map((match) => match[1]).join("\n");
23
+ const tag = rule(".composer-intercom-tag", "conversation tag styles");
24
+ const label = rule(".composer-intercom-tag-label", "conversation tag label styles");
25
+ const icon = rule(".composer-intercom-tag-icon", "conversation tag icon styles");
26
+ const count = rule(".composer-intercom-tag-count", "conversation tag count styles");
27
+
28
+ assert.match(container, /display:\s*grid;/, "conversation tags should use a bounded grid instead of a scroller");
29
+ assert.match(container, /grid-auto-flow:\s*column;/, "ordinary conversation counts should remain on one row");
30
+ assert.match(container, /grid-auto-columns:\s*minmax\(0,\s*1fr\);/, "ordinary conversation tags should receive equal shares of the available inline width");
31
+ assert.match(denseContainer, /grid-auto-flow:\s*row;/, "dense conversation counts should wrap into rows");
32
+ assert.match(denseContainer, /grid-template-columns:\s*repeat\(auto-fit,\s*minmax\(44px,\s*1fr\)\);/, "dense rows should retain a 44px minimum inline target");
33
+ assert.match(container, /min-width:\s*0;/, "the conversation tag container should shrink with its composer surface");
34
+ assert.doesNotMatch(containerRules, /overflow(?:-x|-inline)?\s*:[^;]*(?:auto|scroll)/, "conversation tag containers must not restore horizontal auto/scroll overflow");
35
+ assert.doesNotMatch(container, /scrollbar|overscroll-behavior-inline/, "conversation tag layout should not retain scroller-only behavior");
36
+
37
+ assert.match(tag, /width:\s*100%;[\s\S]*min-width:\s*0;[\s\S]*max-width:\s*100%;/, "each equal-share tag should fill and shrink inside its grid track");
38
+ assert.match(tag, /overflow:\s*hidden;/, "tag contents should not expand the equal-share track");
39
+ assert.match(label, /flex:\s*1 1 auto;[\s\S]*min-width:\s*0;[\s\S]*overflow:\s*hidden;[\s\S]*text-overflow:\s*ellipsis;[\s\S]*white-space:\s*nowrap;/, "long visual labels should produce a real single-line ellipsis");
40
+ assert.match(icon, /flex:\s*0 0 auto;/, "the conversation icon should stay stable while the label shrinks");
41
+ assert.match(count, /flex:\s*0 0 auto;/, "the conversation count should stay stable while the label shrinks");
42
+ assert.match(css, /@media \(max-width: 720px\)[\s\S]*?\.composer-intercom-tag \{ min-height: 44px; \}/, "narrow and coarse-pointer tags should retain a 44px activation target");
43
+ assert.match(app, /container\.classList\.toggle\("dense", orderedTags\.length > 8\);/, "the documented dense threshold should activate only above eight conversations");
44
+ assert.match(app, /const visualSignature = JSON\.stringify\(\[label, conversation\.messageCount\]\);[\s\S]*if \(tag\.dataset\.intercomVisualSignature !== visualSignature\)[\s\S]*tag\.replaceChildren\(\.\.\.children\);[\s\S]*tag\.dataset\.intercomVisualSignature = visualSignature;/, "unchanged tag visuals should retain their existing children inside the polite live region");
45
+
46
+ console.log("intercom-tag-layout-static.test.mjs passed");
@@ -0,0 +1,98 @@
1
+ import assert from "node:assert/strict";
2
+ import { filterIntercomTranscriptMessages } from "../lib/intercom-transcript-filter.mjs";
3
+
4
+ function deepFreeze(value) {
5
+ if (!value || typeof value !== "object" || Object.isFrozen(value)) return value;
6
+ Object.freeze(value);
7
+ for (const child of Object.values(value)) deepFreeze(child);
8
+ return value;
9
+ }
10
+
11
+ {
12
+ const messages = [
13
+ { role: "custom", customType: "intercom_message", content: "rendered Intercom prose" },
14
+ { role: "custom", customType: "other_extension", content: "keep custom output" },
15
+ { role: "user", content: "prose mentioning intercom is unrelated" },
16
+ ];
17
+ const result = filterIntercomTranscriptMessages(messages);
18
+ assert.deepEqual(result, messages.slice(1), "only explicitly typed intercom_message custom records should be removed");
19
+ }
20
+
21
+ {
22
+ const intercomCall = { type: "toolCall", id: "intercom-mixed", name: " interCOM ", arguments: { message: "hidden" } };
23
+ const readCall = { type: "toolCall", id: "read-mixed", toolName: "read", arguments: { path: "README.md" } };
24
+ const mixed = {
25
+ role: "assistant",
26
+ timestamp: 1234,
27
+ content: [
28
+ { type: "thinking", thinking: "retain reasoning" },
29
+ { type: "text", text: "retain answer" },
30
+ intercomCall,
31
+ { type: "image", data: "retain-image" },
32
+ readCall,
33
+ ],
34
+ };
35
+ const input = [mixed];
36
+ const before = structuredClone(input);
37
+ deepFreeze(input);
38
+ const result = filterIntercomTranscriptMessages(input);
39
+ assert.deepEqual(result, [{ ...mixed, content: mixed.content.filter((part) => part !== intercomCall) }], "mixed assistant messages should retain all non-Intercom content in order");
40
+ assert.deepEqual(input, before, "filtering must not mutate the input transcript or nested content");
41
+ assert.notEqual(result[0], mixed, "a changed assistant message should be copied");
42
+ assert.equal(result[0].content[0], mixed.content[0], "unchanged content parts should retain their references");
43
+ assert.equal(result[0].content.at(-1), readCall, "unrelated tool calls should retain their references");
44
+ }
45
+
46
+ {
47
+ const messages = [
48
+ { role: "assistant", content: [{ type: "toolCall", toolCallId: "paired-no-name", toolName: "intercom", arguments: {} }] },
49
+ { role: "toolResult", toolCallId: "paired-no-name", content: [{ type: "text", text: "hidden paired result" }] },
50
+ { role: "toolResult", toolCallId: "orphan-intercom", toolName: " InterCom ", content: [{ type: "text", text: "hidden orphan result" }] },
51
+ { role: "toolResult", toolCallId: "orphan-read", toolName: "read", content: [{ type: "text", text: "keep unrelated result" }] },
52
+ { role: "toolResult", id: "paired-no-name", toolName: "read", content: [{ type: "text", text: "record IDs are not pairing IDs" }] },
53
+ ];
54
+ assert.deepEqual(filterIntercomTranscriptMessages(messages), [messages[3], messages[4]], "paired unnamed and explicitly named orphan Intercom results should be removed only by explicit toolCallId");
55
+ }
56
+
57
+ {
58
+ const messages = [
59
+ { role: "toolCall", id: "direct-record-id", toolCallId: "direct-intercom", toolName: "intercom", arguments: { message: "hidden" } },
60
+ { role: "toolResult", toolCallId: "direct-intercom", content: "hidden direct result" },
61
+ { role: "toolCall", toolCallId: "direct-read", toolName: "read", arguments: { path: "README.md" } },
62
+ ];
63
+ assert.deepEqual(filterIntercomTranscriptMessages(messages), [messages[2]], "direct normalized Intercom tool-call records and their paired results should be removed");
64
+ }
65
+
66
+ {
67
+ const messages = [
68
+ { role: "user", content: [{ type: "text", text: "unchanged prompt" }] },
69
+ { role: "assistant", content: [{ type: "thinking", thinking: "unchanged thought" }, { type: "toolCall", id: "bash-1", name: "bash", arguments: { command: "pwd" } }] },
70
+ { role: "toolResult", toolCallId: "bash-1", toolName: "bash", content: [{ type: "text", text: "/tmp" }] },
71
+ { role: "custom", customType: "unrelated", content: "unchanged custom record" },
72
+ ];
73
+ const before = structuredClone(messages);
74
+ deepFreeze(messages);
75
+ const result = filterIntercomTranscriptMessages(messages);
76
+ assert.deepEqual(result, before, "unrelated transcript records should remain unchanged");
77
+ assert.ok(result.every((message, index) => message === messages[index]), "unchanged records should retain object identity");
78
+ assert.deepEqual(messages, before, "an unchanged frozen input must not be mutated");
79
+ }
80
+
81
+ {
82
+ const onlyIntercom = { role: "assistant", content: [{ type: "toolCall", id: "only-intercom", toolName: "intercom", arguments: {} }] };
83
+ const noMeaningAfterFilter = {
84
+ role: "assistant",
85
+ content: [
86
+ { type: "text", text: " " },
87
+ { type: "thinking", thinking: "\n" },
88
+ { type: "toolCall", id: "intercom-with-empty-parts", toolName: "intercom", arguments: {} },
89
+ ],
90
+ };
91
+ const unrelatedEmpty = { role: "assistant", content: [{ type: "text", text: "" }] };
92
+ const result = filterIntercomTranscriptMessages([onlyIntercom, noMeaningAfterFilter, unrelatedEmpty]);
93
+ assert.deepEqual(result, [unrelatedEmpty], "assistants emptied by Intercom filtering should be removed without changing unrelated empty records");
94
+ }
95
+
96
+ assert.deepEqual(filterIntercomTranscriptMessages(undefined), [], "non-array transcript input should produce an empty list");
97
+
98
+ console.log("intercom-transcript-filter.test.mjs passed");
@@ -0,0 +1,59 @@
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, readme, development] = 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
+ readFile(join(root, "README.md"), "utf8"),
13
+ readFile(join(root, "DEVELOPMENT.md"), "utf8"),
14
+ ]);
15
+
16
+ function sourceBetween(startMarker, endMarker, label) {
17
+ const start = app.indexOf(startMarker);
18
+ const end = app.indexOf(endMarker, start + startMarker.length);
19
+ assert.ok(start >= 0 && end > start, `${label} should remain an inspectable standalone block`);
20
+ return app.slice(start, end);
21
+ }
22
+
23
+ assert.match(
24
+ html,
25
+ /id="mainOutputLoading" class="main-output-loading" role="status" aria-live="polite" aria-atomic="true" aria-controls="chat" hidden>[\s\S]*?main-output-loading-spinner[\s\S]*?Loading agent output…[\s\S]*?<div id="chat" class="chat" aria-live="polite" aria-busy="false">/,
26
+ "the main output should own an inline, accessible loading status before the transcript",
27
+ );
28
+ assert.doesNotMatch(html, /<dialog[^>]+id="mainOutputLoading"/, "loading feedback must not use a popup dialog");
29
+ assert.match(app, /mainOutputLoading: \$\("#mainOutputLoading"\)/, "the browser should bind the inline status element");
30
+ assert.match(app, /const mainOutputLoadingRequests = new Set\(\);[\s\S]*MAIN_OUTPUT_LOADING_REVEAL_DELAY_MS = 120/, "loading requests should have bounded concurrent ownership and a short anti-flicker delay");
31
+
32
+ const loadingHelpers = sourceBetween("function mainOutputLoadingRequestIsCurrent(", "\nasync function refreshMessages(", "main output loading helpers");
33
+ assert.match(loadingHelpers, /isCurrentTabContext\(request\.tabContext\)/, "only the active tab generation should control visible loading feedback");
34
+ assert.match(loadingHelpers, /setAttribute\("aria-busy", active \? "true" : "false"\)/, "the transcript should expose request state immediately to assistive technology");
35
+ assert.match(loadingHelpers, /setTimeout\([\s\S]*MAIN_OUTPUT_LOADING_REVEAL_DELAY_MS/, "visible animation should be delayed to avoid flashing on fast requests");
36
+ assert.match(loadingHelpers, /mainOutputLoadingRequests\.add\(request\)/, "overlapping requests should receive independent tokens");
37
+ assert.match(loadingHelpers, /mainOutputLoadingRequests\.delete\(request\)/, "settled requests should release only their own token");
38
+ assert.doesNotMatch(loadingHelpers, /showModal|alert\(|confirm\(/, "main output loading must remain non-modal");
39
+
40
+ const refreshMessages = sourceBetween("async function refreshMessages(", "\nasync function refreshModels(", "refreshMessages");
41
+ assert.match(refreshMessages, /const loadingRequest = beginMainOutputLoading\(tabContext\);\s*try \{/, "message fetches should begin loading before awaiting transcript data");
42
+ assert.match(refreshMessages, /finally \{\s*finishMainOutputLoading\(loadingRequest\);\s*\}/, "success, failure, and stale responses should all clear their request token");
43
+ assert.match(app, /activeTabId = nextTabId;\s*renderMainOutputLoading\(\);/, "tab changes should immediately reconcile stale and current request visibility");
44
+
45
+ assert.match(css, /\.main-output-loading\[hidden\] \{ display: none !important; \}/, "hidden loading feedback should not consume layout space");
46
+ assert.match(css, /\.main-output-loading \{[\s\S]*?pointer-events: none;[\s\S]*?font-size: var\(--text-xs\)/, "the inline status should remain compact and non-blocking");
47
+ assert.match(css, /\.main-output-loading-spinner \{[\s\S]*?animation: main-output-loading-spin 780ms linear infinite/, "the status should include a visible spinner animation");
48
+ assert.match(css, /@keyframes main-output-loading-spin/, "the spinner should have a local animation contract");
49
+ assert.match(css, /@media \(prefers-reduced-motion: reduce\)[\s\S]*?animation-duration: 1ms !important;[\s\S]*?animation-iteration-count: 1 !important;/, "the existing reduced-motion policy should stop repeated spinner motion");
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
+ assert.match(css, /body\.subagent-terminal-active \.main-output-loading,/, "main-output loading feedback should stay hidden in the dedicated subagent view");
52
+
53
+ assert.match(html, /styles\.css\?v=123/, "the stylesheet cache query should advance");
54
+ assert.match(html, /app\.js\?v=146/, "the app cache query should advance");
55
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v108"/, "the PWA cache identity should advance with browser assets");
56
+ assert.match(readme, /Loading agent output/, "user documentation should describe the visible loading feedback");
57
+ assert.match(development, /main output loading/i, "developer documentation should preserve the request-ownership contract");
58
+
59
+ console.log("main output loading static tests passed");