@firstpick/pi-package-webui 0.9.2 → 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 (77) hide show
  1. package/README.md +13 -7
  2. package/bin/pi-webui.mjs +256 -39
  3. package/index.ts +266 -1
  4. package/lib/git-workflow-preferences.mjs +8 -25
  5. package/lib/intercom-conversations.mjs +491 -0
  6. package/lib/intercom-transcript-filter.mjs +99 -0
  7. package/lib/resource-selection.mjs +140 -0
  8. package/package.json +2 -2
  9. package/public/app.js +1025 -115
  10. package/public/index.html +31 -6
  11. package/public/service-worker.js +2 -1
  12. package/public/stream-output-controller.mjs +15 -0
  13. package/public/styles.css +394 -0
  14. package/public/syntax-highlight.mjs +622 -0
  15. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  16. package/tests/browser/interaction-continuity.spec.mjs +34 -0
  17. package/tests/browser/intercom-conversation-viewer.spec.mjs +355 -0
  18. package/tests/browser/persistent-ui-layout.spec.mjs +61 -0
  19. package/tests/browser/resource-profiles.spec.mjs +200 -0
  20. package/tests/browser/subagent-observability.spec.mjs +29 -0
  21. package/tests/codex-fast-mode-static.test.mjs +7 -6
  22. package/tests/common-options-submenus-interaction-static.test.mjs +2 -0
  23. package/tests/common-options-submenus-markup-static.test.mjs +1 -0
  24. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  25. package/tests/composer-skill-tag-layout.test.mjs +32 -2
  26. package/tests/control-deck-component-updates-static.test.mjs +4 -0
  27. package/tests/controls-layout-static.test.mjs +3 -3
  28. package/tests/fast-mode-client-static.test.mjs +2 -2
  29. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  30. package/tests/feature-system-prompt-optional-feature-static.test.mjs +5 -5
  31. package/tests/file-viewer-image-static.test.mjs +69 -0
  32. package/tests/fixtures/fake-pi.mjs +105 -6
  33. package/tests/foreground-transcript-catch-up-static.test.mjs +1 -1
  34. package/tests/git-panel-file-preview-static.test.mjs +5 -5
  35. package/tests/git-panel-live-updates-static.test.mjs +3 -3
  36. package/tests/git-workflow-preferences.test.mjs +4 -4
  37. package/tests/http-endpoints-harness.test.mjs +124 -2
  38. package/tests/intercom-conversation-viewer-static.test.mjs +105 -0
  39. package/tests/intercom-conversations-http.test.mjs +252 -0
  40. package/tests/intercom-conversations.test.mjs +374 -0
  41. package/tests/intercom-main-transcript-suppression-static.test.mjs +52 -0
  42. package/tests/intercom-tag-layout-static.test.mjs +46 -0
  43. package/tests/intercom-transcript-filter.test.mjs +98 -0
  44. package/tests/main-output-loading-static.test.mjs +59 -0
  45. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  46. package/tests/mobile-compact-layout.test.mjs +2 -3
  47. package/tests/mobile-continuity-tablet-static.test.mjs +6 -6
  48. package/tests/mobile-foundation-static.test.mjs +3 -3
  49. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  50. package/tests/mobile-static.test.mjs +63 -39
  51. package/tests/native-parity.test.mjs +8 -7
  52. package/tests/open-issue-wizard-static.test.mjs +1 -1
  53. package/tests/optional-feature-migration-frontend.test.mjs +5 -5
  54. package/tests/optional-feature-resource-setup-static.test.mjs +29 -0
  55. package/tests/persistent-ui-layout-static.test.mjs +3 -3
  56. package/tests/questionnaire-dialog.test.mjs +3 -3
  57. package/tests/remote-auth-settings-harness.test.mjs +1 -1
  58. package/tests/resource-defaults-helper.test.mjs +60 -6
  59. package/tests/resource-selection.test.mjs +114 -0
  60. package/tests/resource-tui-extension.test.mjs +23 -0
  61. package/tests/session-sampling-ui-static.test.mjs +3 -3
  62. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  63. package/tests/stream-output-controller.test.mjs +8 -0
  64. package/tests/stream-output-isolation-static.test.mjs +2 -2
  65. package/tests/streaming-ui-coupling.test.mjs +5 -0
  66. package/tests/subagent-gate-visibility.test.mjs +1 -1
  67. package/tests/subagent-launch-slots.test.mjs +1 -1
  68. package/tests/subagent-observability-static.test.mjs +3 -3
  69. package/tests/subagent-reliability-integration.test.mjs +23 -1
  70. package/tests/subagent-workflow-section-static.test.mjs +67 -0
  71. package/tests/subagents-helper.test.mjs +204 -1
  72. package/tests/syntax-highlight.test.mjs +235 -0
  73. package/tests/syntax-highlighting-static.test.mjs +84 -0
  74. package/tests/theme-customizer-static.test.mjs +5 -5
  75. package/tests/thinking-format-parser.test.mjs +64 -0
  76. package/tests/webui-settings-locking.test.mjs +1 -1
  77. package/webui-rpc-helper.mjs +291 -69
@@ -0,0 +1,622 @@
1
+ export const MAX_SYNTAX_HIGHLIGHT_CHARACTERS = 50_000;
2
+ export const MAX_SYNTAX_HIGHLIGHT_LINES = 2_000;
3
+
4
+ const TOKEN_TYPES = new Set([
5
+ "plain",
6
+ "comment",
7
+ "keyword",
8
+ "function",
9
+ "variable",
10
+ "string",
11
+ "number",
12
+ "type",
13
+ "operator",
14
+ "punctuation",
15
+ ]);
16
+
17
+ const words = (value) => new Set(String(value || "").trim().split(/\s+/).filter(Boolean));
18
+ const lowerWords = (value) => new Set([...words(value)].map((word) => word.toLowerCase()));
19
+
20
+ const COMMON_JS_KEYWORDS = words(`
21
+ as async await break case catch class const continue debugger default delete do else export extends
22
+ false finally for from function get if import in instanceof let new null of return set static super
23
+ switch this throw true try typeof undefined var void while with yield
24
+ `);
25
+ const TYPESCRIPT_KEYWORDS = new Set([...COMMON_JS_KEYWORDS, ...words(`
26
+ abstract any asserts bigint boolean declare enum implements infer interface is keyof module namespace
27
+ never number object override private protected public readonly require satisfies string symbol type
28
+ unique unknown using
29
+ `)]);
30
+ const C_LIKE_KEYWORDS = words(`
31
+ alignas alignof asm auto break case catch class const constexpr continue default delete do else enum
32
+ explicit export extern false final for friend goto if inline mutable namespace new noexcept nullptr
33
+ operator override private protected public register reinterpret_cast return sizeof static struct switch
34
+ template this throw true try typedef typename union using virtual volatile while
35
+ `);
36
+ const C_LIKE_TYPES = words(`
37
+ bool byte char char16_t char32_t double float int int16_t int32_t int64_t int8_t long ptrdiff_t
38
+ short signed size_t ssize_t string uint uint16_t uint32_t uint64_t uint8_t ulong unsigned void wchar_t
39
+ `);
40
+
41
+ const PROFILES = {
42
+ python: {
43
+ keywords: words(`
44
+ False None True and as assert async await break case class continue def del elif else except finally
45
+ for from global if import in is lambda match nonlocal not or pass raise return try while with yield
46
+ `),
47
+ types: words("bool bytes complex dict float frozenset int list memoryview object range set slice str tuple type"),
48
+ lineComments: ["#"],
49
+ quotes: ["\"", "'"],
50
+ tripleQuotes: true,
51
+ },
52
+ javascript: {
53
+ keywords: COMMON_JS_KEYWORDS,
54
+ types: words("Array ArrayBuffer BigInt Boolean Date Error Function Map Number Object Promise RegExp Set String Symbol Uint8Array WeakMap WeakSet"),
55
+ lineComments: ["//"],
56
+ blockComments: [["/*", "*/"]],
57
+ quotes: ["\"", "'", "`"],
58
+ multilineQuotes: new Set(["`"]),
59
+ dollarVariables: true,
60
+ },
61
+ typescript: {
62
+ keywords: TYPESCRIPT_KEYWORDS,
63
+ types: words("Array ArrayBuffer BigInt Boolean Date Error Function Map Number Object Promise Record RegExp Set String Symbol Uint8Array WeakMap WeakSet any bigint boolean never number object string symbol unknown"),
64
+ lineComments: ["//"],
65
+ blockComments: [["/*", "*/"]],
66
+ quotes: ["\"", "'", "`"],
67
+ multilineQuotes: new Set(["`"]),
68
+ dollarVariables: true,
69
+ },
70
+ bash: {
71
+ keywords: words("break case continue coproc do done elif else esac fi for function if in select then time until while"),
72
+ lineComments: ["#"],
73
+ boundaryComments: new Set(["#"]),
74
+ quotes: ["\"", "'", "`"],
75
+ multilineQuotes: new Set(["\"", "'", "`"]),
76
+ dollarVariables: true,
77
+ },
78
+ powershell: {
79
+ keywords: lowerWords(`
80
+ begin break catch class continue data define do dynamicparam else elseif end enum exit filter finally
81
+ for foreach from function hidden if in inlineScript parallel param process return sequence switch
82
+ throw trap try until using var while workflow
83
+ `),
84
+ types: lowerWords("array bool byte char datetime decimal double float guid hashtable int int16 int32 int64 long object psobject scriptblock string switch timespan type uint uint16 uint32 uint64 xml"),
85
+ lineComments: ["#"],
86
+ blockComments: [["<#", "#>"]],
87
+ quotes: ["\"", "'", "`"],
88
+ multilineQuotes: new Set(["\"", "'", "`"]),
89
+ dollarVariables: true,
90
+ dashVariables: true,
91
+ caseInsensitive: true,
92
+ },
93
+ cmd: {
94
+ keywords: lowerWords("assoc break call cd chdir cls color copy date del dir echo else endlocal erase exit for ftype goto if md mkdir move path pause popd prompt pushd rd rem ren rename rmdir set setlocal shift start time title type ver verify vol"),
95
+ quotes: ["\""],
96
+ cmdVariables: true,
97
+ caseInsensitive: true,
98
+ cmdComments: true,
99
+ },
100
+ json: {
101
+ keywords: words("false null true"),
102
+ quotes: ["\""],
103
+ quotedKeys: true,
104
+ keySeparators: new Set([":"]),
105
+ },
106
+ jsonc: {
107
+ keywords: words("false null true"),
108
+ lineComments: ["//"],
109
+ blockComments: [["/*", "*/"]],
110
+ quotes: ["\""],
111
+ quotedKeys: true,
112
+ keySeparators: new Set([":"]),
113
+ },
114
+ ini: {
115
+ keywords: lowerWords("false no null off on true yes"),
116
+ lineComments: [";", "#"],
117
+ boundaryComments: new Set([";", "#"]),
118
+ quotes: ["\"", "'"],
119
+ keySeparators: new Set(["=", ":"]),
120
+ sections: true,
121
+ hyphenIdentifiers: true,
122
+ caseInsensitive: true,
123
+ },
124
+ toml: {
125
+ keywords: lowerWords("false inf nan true"),
126
+ lineComments: ["#"],
127
+ quotes: ["\"", "'"],
128
+ tripleQuotes: true,
129
+ keySeparators: new Set(["="]),
130
+ sections: true,
131
+ hyphenIdentifiers: true,
132
+ caseInsensitive: true,
133
+ },
134
+ yaml: {
135
+ keywords: lowerWords("false no null off on true yes"),
136
+ lineComments: ["#"],
137
+ boundaryComments: new Set(["#"]),
138
+ quotes: ["\"", "'"],
139
+ keySeparators: new Set([":"]),
140
+ hyphenIdentifiers: true,
141
+ caseInsensitive: true,
142
+ },
143
+ diff: { custom: "diff" },
144
+ sql: {
145
+ keywords: lowerWords(`
146
+ add all alter and any as asc between by case check column constraint create cross database default
147
+ delete desc distinct drop else end except exists foreign from full grant group having in index inner
148
+ insert intersect into is join left like limit not null offset on or order outer primary references
149
+ return returning revoke right select set table then union unique update using values view when where with
150
+ `),
151
+ types: lowerWords("bigint binary bit blob boolean char date datetime decimal double float int integer json numeric real text time timestamp uuid varchar"),
152
+ lineComments: ["--"],
153
+ blockComments: [["/*", "*/"]],
154
+ quotes: ["\"", "'", "`"],
155
+ caseInsensitive: true,
156
+ },
157
+ css: {
158
+ keywords: lowerWords("important inherit initial revert unset auto none block flex grid inline relative absolute fixed sticky transparent currentcolor"),
159
+ blockComments: [["/*", "*/"]],
160
+ quotes: ["\"", "'"],
161
+ keySeparators: new Set([":"]),
162
+ hyphenIdentifiers: true,
163
+ caseInsensitive: true,
164
+ },
165
+ html: { custom: "markup" },
166
+ xml: { custom: "markup" },
167
+ dockerfile: {
168
+ keywords: lowerWords("add arg cmd copy entrypoint env expose from healthcheck label maintainer onbuild run shell stopsignal user volume workdir"),
169
+ lineComments: ["#"],
170
+ boundaryComments: new Set(["#"]),
171
+ quotes: ["\"", "'", "`"],
172
+ multilineQuotes: new Set(["\"", "'", "`"]),
173
+ dollarVariables: true,
174
+ lineLeadingKeywords: true,
175
+ caseInsensitive: true,
176
+ },
177
+ c: {
178
+ keywords: C_LIKE_KEYWORDS,
179
+ types: C_LIKE_TYPES,
180
+ lineComments: ["//"],
181
+ blockComments: [["/*", "*/"]],
182
+ quotes: ["\"", "'"],
183
+ },
184
+ cpp: {
185
+ keywords: C_LIKE_KEYWORDS,
186
+ types: C_LIKE_TYPES,
187
+ lineComments: ["//"],
188
+ blockComments: [["/*", "*/"]],
189
+ quotes: ["\"", "'"],
190
+ },
191
+ java: {
192
+ keywords: words("abstract assert boolean break byte case catch char class const continue default do double else enum extends final finally float for goto if implements import instanceof int interface long native new null package private protected public return short static strictfp super switch synchronized this throw throws transient true try void volatile while false"),
193
+ types: words("BigDecimal BigInteger Boolean Byte Character Class Double Exception Float Integer Long Object Optional Short String StringBuilder Throwable Void"),
194
+ lineComments: ["//"],
195
+ blockComments: [["/*", "*/"]],
196
+ quotes: ["\"", "'"],
197
+ },
198
+ go: {
199
+ keywords: words("break case chan const continue default defer else fallthrough false for func go goto if import interface map nil package range return select struct switch true type var"),
200
+ types: words("bool byte complex128 complex64 error float32 float64 int int16 int32 int64 int8 rune string uint uint16 uint32 uint64 uint8 uintptr"),
201
+ lineComments: ["//"],
202
+ blockComments: [["/*", "*/"]],
203
+ quotes: ["\"", "'", "`"],
204
+ multilineQuotes: new Set(["`"]),
205
+ },
206
+ rust: {
207
+ keywords: words("Self as async await break const continue crate dyn else enum extern false fn for if impl in let loop match mod move mut pub ref return self static struct super trait true type unsafe use where while"),
208
+ types: words("bool char f32 f64 i128 i16 i32 i64 i8 isize str u128 u16 u32 u64 u8 usize String Vec Option Result"),
209
+ lineComments: ["//"],
210
+ blockComments: [["/*", "*/"]],
211
+ quotes: ["\"", "'"],
212
+ },
213
+ csharp: {
214
+ keywords: words("abstract as async await base bool break byte case catch char checked class const continue decimal default delegate do double else enum event explicit extern false finally fixed float for foreach goto if implicit in int interface internal is lock long namespace new null object operator out override params private protected public readonly ref return sbyte sealed short sizeof stackalloc static string struct switch this throw true try typeof uint ulong unchecked unsafe ushort using virtual void volatile while yield"),
215
+ types: words("Boolean Byte Char DateTime Decimal Double Guid Int16 Int32 Int64 Object SByte Single String UInt16 UInt32 UInt64 bool byte char decimal double float int long object sbyte short string uint ulong ushort void"),
216
+ lineComments: ["//"],
217
+ blockComments: [["/*", "*/"]],
218
+ quotes: ["\"", "'"],
219
+ dollarVariables: true,
220
+ },
221
+ };
222
+
223
+ export const SYNTAX_LANGUAGE_ALIASES = Object.freeze({
224
+ python: "python", py: "python",
225
+ javascript: "javascript", js: "javascript", jsx: "javascript", mjs: "javascript", cjs: "javascript", node: "javascript",
226
+ typescript: "typescript", ts: "typescript", tsx: "typescript",
227
+ bash: "bash", sh: "bash", shell: "bash", zsh: "bash",
228
+ powershell: "powershell", pwsh: "powershell", ps1: "powershell",
229
+ cmd: "cmd", bat: "cmd", batch: "cmd", dos: "cmd",
230
+ json: "json", jsonc: "jsonc",
231
+ ini: "ini", cfg: "ini", conf: "ini", properties: "ini",
232
+ toml: "toml",
233
+ yaml: "yaml", yml: "yaml",
234
+ diff: "diff", patch: "diff",
235
+ sql: "sql",
236
+ css: "css",
237
+ html: "html", htm: "html",
238
+ xml: "xml", svg: "xml",
239
+ dockerfile: "dockerfile", docker: "dockerfile",
240
+ c: "c", h: "c",
241
+ cpp: "cpp", "c++": "cpp", cc: "cpp", cxx: "cpp", hpp: "cpp", hxx: "cpp",
242
+ java: "java",
243
+ go: "go", golang: "go",
244
+ rust: "rust", rs: "rust",
245
+ csharp: "csharp", cs: "csharp", "c#": "csharp", dotnet: "csharp",
246
+ });
247
+
248
+ export const SUPPORTED_SYNTAX_LANGUAGES = Object.freeze(Object.keys(PROFILES));
249
+
250
+ export function normalizeSyntaxLanguage(language) {
251
+ const alias = String(language || "").trim().toLowerCase();
252
+ return Object.prototype.hasOwnProperty.call(SYNTAX_LANGUAGE_ALIASES, alias) ? SYNTAX_LANGUAGE_ALIASES[alias] : "";
253
+ }
254
+
255
+ function pushToken(tokens, type, text) {
256
+ if (!text) return;
257
+ const safeType = TOKEN_TYPES.has(type) ? type : "plain";
258
+ const previous = tokens[tokens.length - 1];
259
+ if (previous?.type === safeType) previous.text += text;
260
+ else tokens.push({ type: safeType, text });
261
+ }
262
+
263
+ function plainTokens(source) {
264
+ return source ? [{ type: "plain", text: source }] : [];
265
+ }
266
+
267
+ function exceedsHighlightBounds(source) {
268
+ if (source.length > MAX_SYNTAX_HIGHLIGHT_CHARACTERS) return true;
269
+ let lines = 1;
270
+ for (let index = 0; index < source.length; index += 1) {
271
+ if (source.charCodeAt(index) === 10 && ++lines > MAX_SYNTAX_HIGHLIGHT_LINES) return true;
272
+ }
273
+ return false;
274
+ }
275
+
276
+ function isAsciiLetter(character) {
277
+ const code = character?.charCodeAt(0) || 0;
278
+ return (code >= 65 && code <= 90) || (code >= 97 && code <= 122);
279
+ }
280
+
281
+ function isDigit(character) {
282
+ const code = character?.charCodeAt(0) || 0;
283
+ return code >= 48 && code <= 57;
284
+ }
285
+
286
+ function isIdentifierStart(character) {
287
+ return character === "_" || isAsciiLetter(character);
288
+ }
289
+
290
+ function isIdentifierPart(character, profile) {
291
+ return isIdentifierStart(character) || isDigit(character) || (profile.hyphenIdentifiers && character === "-");
292
+ }
293
+
294
+ function isWhitespace(character) {
295
+ return character === " " || character === "\t" || character === "\r" || character === "\n";
296
+ }
297
+
298
+ function nextNonWhitespace(source, start) {
299
+ let index = start;
300
+ while (index < source.length && isWhitespace(source[index])) index += 1;
301
+ return index;
302
+ }
303
+
304
+ function linePrefixIsWhitespace(source, index) {
305
+ for (let cursor = index - 1; cursor >= 0 && source[cursor] !== "\n"; cursor -= 1) {
306
+ if (source[cursor] !== " " && source[cursor] !== "\t" && source[cursor] !== "\r") return false;
307
+ }
308
+ return true;
309
+ }
310
+
311
+ function consumeQuoted(source, start, quote, profile) {
312
+ const triple = profile.tripleQuotes && (quote === "\"" || quote === "'") && source.startsWith(quote.repeat(3), start);
313
+ const delimiter = triple ? quote.repeat(3) : quote;
314
+ const multiline = triple || profile.multilineQuotes?.has(quote);
315
+ let index = start + delimiter.length;
316
+ while (index < source.length) {
317
+ if (source[index] === "\\") {
318
+ index = Math.min(source.length, index + 2);
319
+ continue;
320
+ }
321
+ if (source.startsWith(delimiter, index)) return index + delimiter.length;
322
+ if (!multiline && source[index] === "\n") return index;
323
+ index += 1;
324
+ }
325
+ return source.length;
326
+ }
327
+
328
+ function consumeNumber(source, start) {
329
+ let index = start;
330
+ if (source[index] === "0" && /[box]/i.test(source[index + 1] || "")) {
331
+ index += 2;
332
+ while (index < source.length && /[0-9a-f_]/i.test(source[index])) index += 1;
333
+ return index;
334
+ }
335
+ while (index < source.length && (isDigit(source[index]) || source[index] === "_")) index += 1;
336
+ if (source[index] === "." && isDigit(source[index + 1])) {
337
+ index += 1;
338
+ while (index < source.length && (isDigit(source[index]) || source[index] === "_")) index += 1;
339
+ }
340
+ if (/[eE]/.test(source[index] || "")) {
341
+ const exponentStart = index;
342
+ index += 1;
343
+ if (source[index] === "+" || source[index] === "-") index += 1;
344
+ const digitsStart = index;
345
+ while (index < source.length && (isDigit(source[index]) || source[index] === "_")) index += 1;
346
+ if (index === digitsStart) index = exponentStart;
347
+ }
348
+ return index;
349
+ }
350
+
351
+ function consumeDollarVariable(source, start) {
352
+ if (source[start + 1] === "{") {
353
+ const end = source.indexOf("}", start + 2);
354
+ if (end !== -1) return end + 1;
355
+ }
356
+ let index = start + 1;
357
+ if ("0123456789?*@#$!-".includes(source[index] || "")) return index + 1;
358
+ while (index < source.length && (isIdentifierPart(source[index], {}) || source[index] === ":")) index += 1;
359
+ return Math.max(start + 1, index);
360
+ }
361
+
362
+ function consumeCmdVariable(source, start) {
363
+ const delimiter = source[start];
364
+ const next = source[start + 1] || "";
365
+ if (delimiter === "%" && (isDigit(next) || "*~".includes(next))) return Math.min(source.length, start + 2);
366
+ const lineEnd = source.indexOf("\n", start + 1);
367
+ const end = source.indexOf(delimiter, start + 1);
368
+ if (end !== -1 && (lineEnd === -1 || end < lineEnd)) return end + 1;
369
+ return start + 1;
370
+ }
371
+
372
+ function commentEnd(source, start, profile) {
373
+ for (const [open, close] of profile.blockComments || []) {
374
+ if (!source.startsWith(open, start)) continue;
375
+ const end = source.indexOf(close, start + open.length);
376
+ return end === -1 ? source.length : end + close.length;
377
+ }
378
+ for (const prefix of profile.lineComments || []) {
379
+ if (!source.startsWith(prefix, start)) continue;
380
+ if (profile.boundaryComments?.has(prefix) && start > 0 && !isWhitespace(source[start - 1])) continue;
381
+ const end = source.indexOf("\n", start + prefix.length);
382
+ return end === -1 ? source.length : end;
383
+ }
384
+ if (profile.cmdComments) {
385
+ const rest = source.slice(start, start + 4).toLowerCase();
386
+ const remBoundary = rest.startsWith("rem") && (rest.length === 3 || isWhitespace(rest[3]));
387
+ const commentCandidate = source.startsWith("::", start) || remBoundary;
388
+ if (commentCandidate && linePrefixIsWhitespace(source, start)) {
389
+ const end = source.indexOf("\n", start + 2);
390
+ return end === -1 ? source.length : end;
391
+ }
392
+ }
393
+ return -1;
394
+ }
395
+
396
+ function sectionEnd(source, start, profile) {
397
+ if (!profile.sections || source[start] !== "[" || !linePrefixIsWhitespace(source, start)) return null;
398
+ const doubled = source[start + 1] === "[";
399
+ const close = doubled ? "]]" : "]";
400
+ const contentStart = start + (doubled ? 2 : 1);
401
+ const end = source.indexOf(close, contentStart);
402
+ const newline = source.indexOf("\n", contentStart);
403
+ if (end === -1 || (newline !== -1 && newline < end)) return null;
404
+ return { open: doubled ? "[[" : "[", contentStart, contentEnd: end, close, end: end + close.length };
405
+ }
406
+
407
+ function classifyIdentifier(source, start, end, profile) {
408
+ const original = source.slice(start, end);
409
+ const comparable = profile.caseInsensitive ? original.toLowerCase() : original;
410
+ if (profile.types?.has(comparable)) return "type";
411
+ if (profile.keywords?.has(comparable)) return "keyword";
412
+ if (profile.lineLeadingKeywords && linePrefixIsWhitespace(source, start)) return "keyword";
413
+ const next = nextNonWhitespace(source, end);
414
+ if (profile.keySeparators?.has(source[next])) return "variable";
415
+ if (source[next] === "(") return "function";
416
+ return "plain";
417
+ }
418
+
419
+ function tokenizeGeneric(source, profile) {
420
+ const tokens = [];
421
+ const punctuation = "(){}[],:;.@";
422
+ const operators = "+-*/%=!<>|&^~?\\";
423
+ let index = 0;
424
+
425
+ while (index < source.length) {
426
+ const commentStop = commentEnd(source, index, profile);
427
+ if (commentStop !== -1) {
428
+ pushToken(tokens, "comment", source.slice(index, commentStop));
429
+ index = commentStop;
430
+ continue;
431
+ }
432
+
433
+ const section = sectionEnd(source, index, profile);
434
+ if (section) {
435
+ pushToken(tokens, "punctuation", section.open);
436
+ pushToken(tokens, "type", source.slice(section.contentStart, section.contentEnd));
437
+ pushToken(tokens, "punctuation", section.close);
438
+ index = section.end;
439
+ continue;
440
+ }
441
+
442
+ const character = source[index];
443
+ if (profile.quotes?.includes(character)) {
444
+ const end = consumeQuoted(source, index, character, profile);
445
+ const next = nextNonWhitespace(source, end);
446
+ const type = profile.quotedKeys && profile.keySeparators?.has(source[next]) ? "variable" : "string";
447
+ pushToken(tokens, type, source.slice(index, end));
448
+ index = end;
449
+ continue;
450
+ }
451
+
452
+ if (profile.dollarVariables && character === "$" && source[index + 1] !== undefined) {
453
+ const end = consumeDollarVariable(source, index);
454
+ pushToken(tokens, "variable", source.slice(index, end));
455
+ index = end;
456
+ continue;
457
+ }
458
+
459
+ if (profile.cmdVariables && (character === "%" || character === "!")) {
460
+ const end = consumeCmdVariable(source, index);
461
+ if (end > index + 1) {
462
+ pushToken(tokens, "variable", source.slice(index, end));
463
+ index = end;
464
+ continue;
465
+ }
466
+ }
467
+
468
+ if (profile.dashVariables && character === "-" && isAsciiLetter(source[index + 1]) && (index === 0 || isWhitespace(source[index - 1]) || "(,[".includes(source[index - 1]))) {
469
+ let end = index + 2;
470
+ while (end < source.length && (isIdentifierPart(source[end], { hyphenIdentifiers: true }))) end += 1;
471
+ pushToken(tokens, "variable", source.slice(index, end));
472
+ index = end;
473
+ continue;
474
+ }
475
+
476
+ if (isDigit(character)) {
477
+ const end = consumeNumber(source, index);
478
+ pushToken(tokens, "number", source.slice(index, end));
479
+ index = end;
480
+ continue;
481
+ }
482
+
483
+ if (isIdentifierStart(character)) {
484
+ let end = index + 1;
485
+ while (end < source.length && isIdentifierPart(source[end], profile)) end += 1;
486
+ pushToken(tokens, classifyIdentifier(source, index, end, profile), source.slice(index, end));
487
+ index = end;
488
+ continue;
489
+ }
490
+
491
+ if (operators.includes(character)) {
492
+ let end = index + 1;
493
+ while (end < source.length && operators.includes(source[end])) end += 1;
494
+ pushToken(tokens, "operator", source.slice(index, end));
495
+ index = end;
496
+ continue;
497
+ }
498
+
499
+ if (punctuation.includes(character)) {
500
+ pushToken(tokens, "punctuation", character);
501
+ index += 1;
502
+ continue;
503
+ }
504
+
505
+ pushToken(tokens, "plain", character);
506
+ index += 1;
507
+ }
508
+
509
+ return tokens;
510
+ }
511
+
512
+ function tokenizeDiff(source) {
513
+ const tokens = [];
514
+ let index = 0;
515
+ while (index < source.length) {
516
+ const newline = source.indexOf("\n", index);
517
+ const end = newline === -1 ? source.length : newline + 1;
518
+ const line = source.slice(index, end);
519
+ let type = "plain";
520
+ if (line.startsWith("@@") || line.startsWith("diff ") || line.startsWith("index ")) type = "keyword";
521
+ else if (line.startsWith("+++") || line.startsWith("---")) type = "type";
522
+ else if (line.startsWith("+")) type = "string";
523
+ else if (line.startsWith("-")) type = "comment";
524
+ pushToken(tokens, type, line);
525
+ index = end;
526
+ }
527
+ return tokens;
528
+ }
529
+
530
+ function markupNameEnd(source, start) {
531
+ let index = start;
532
+ while (index < source.length && (isIdentifierPart(source[index], { hyphenIdentifiers: true }) || source[index] === ":" || source[index] === "!")) index += 1;
533
+ return index;
534
+ }
535
+
536
+ function tokenizeMarkup(source) {
537
+ const tokens = [];
538
+ let index = 0;
539
+ while (index < source.length) {
540
+ if (source.startsWith("<!--", index)) {
541
+ const close = source.indexOf("-->", index + 4);
542
+ const end = close === -1 ? source.length : close + 3;
543
+ pushToken(tokens, "comment", source.slice(index, end));
544
+ index = end;
545
+ continue;
546
+ }
547
+ if (source.startsWith("<![CDATA[", index)) {
548
+ const close = source.indexOf("]]>", index + 9);
549
+ const end = close === -1 ? source.length : close + 3;
550
+ pushToken(tokens, "string", source.slice(index, end));
551
+ index = end;
552
+ continue;
553
+ }
554
+ if (source[index] !== "<") {
555
+ const end = source.indexOf("<", index);
556
+ pushToken(tokens, "plain", source.slice(index, end === -1 ? source.length : end));
557
+ index = end === -1 ? source.length : end;
558
+ continue;
559
+ }
560
+
561
+ pushToken(tokens, "punctuation", "<");
562
+ index += 1;
563
+ if ("/?!".includes(source[index] || "")) {
564
+ pushToken(tokens, "punctuation", source[index]);
565
+ index += 1;
566
+ }
567
+ while (index < source.length && isWhitespace(source[index])) {
568
+ pushToken(tokens, "plain", source[index]);
569
+ index += 1;
570
+ }
571
+ const nameEnd = markupNameEnd(source, index);
572
+ if (nameEnd > index) {
573
+ pushToken(tokens, "type", source.slice(index, nameEnd));
574
+ index = nameEnd;
575
+ }
576
+
577
+ while (index < source.length) {
578
+ if (source.startsWith("/>", index) || source.startsWith("?>", index)) {
579
+ pushToken(tokens, "punctuation", source.slice(index, index + 2));
580
+ index += 2;
581
+ break;
582
+ }
583
+ if (source[index] === ">") {
584
+ pushToken(tokens, "punctuation", ">");
585
+ index += 1;
586
+ break;
587
+ }
588
+ const character = source[index];
589
+ if (character === "\"" || character === "'") {
590
+ const end = consumeQuoted(source, index, character, { quotes: [character] });
591
+ pushToken(tokens, "string", source.slice(index, end));
592
+ index = end;
593
+ continue;
594
+ }
595
+ if (character === "=") {
596
+ pushToken(tokens, "operator", character);
597
+ index += 1;
598
+ continue;
599
+ }
600
+ if (isIdentifierStart(character)) {
601
+ const end = markupNameEnd(source, index);
602
+ pushToken(tokens, "variable", source.slice(index, end));
603
+ index = end;
604
+ continue;
605
+ }
606
+ pushToken(tokens, isWhitespace(character) ? "plain" : "punctuation", character);
607
+ index += 1;
608
+ }
609
+ }
610
+ return tokens;
611
+ }
612
+
613
+ export function tokenizeCode(code, language) {
614
+ const source = String(code ?? "");
615
+ if (!source) return [];
616
+ const normalized = normalizeSyntaxLanguage(language);
617
+ if (!normalized || exceedsHighlightBounds(source)) return plainTokens(source);
618
+ const profile = PROFILES[normalized];
619
+ if (profile.custom === "diff") return tokenizeDiff(source);
620
+ if (profile.custom === "markup") return tokenizeMarkup(source);
621
+ return tokenizeGeneric(source, profile);
622
+ }
@@ -65,7 +65,7 @@ function makeEnvironment({
65
65
  reload: new FakeElement(),
66
66
  copyStatus: new FakeElement(),
67
67
  };
68
- const styleLink = new FakeElement({ href: "http://127.0.0.1:31415/styles.css?v=115", sheet: stylesheetLoaded ? {} : null });
68
+ const styleLink = new FakeElement({ href: "http://127.0.0.1:31415/styles.css?v=123", sheet: stylesheetLoaded ? {} : null });
69
69
  const listeners = new Map();
70
70
  const timers = new Map();
71
71
  let timerId = 0;
@@ -84,7 +84,7 @@ function makeEnvironment({
84
84
  removeEventListener(name) { listeners.delete(name); },
85
85
  };
86
86
  const document = {
87
- currentScript: new FakeElement({ dataset: { appSrc: "/app.js?v=132" } }),
87
+ currentScript: new FakeElement({ dataset: { appSrc: "/app.js?v=146" } }),
88
88
  readyState: "complete",
89
89
  querySelector(selector) {
90
90
  return {
@@ -232,7 +232,7 @@ for (const moduleName of startupModuleNames) {
232
232
  assert.ok(serviceWorker.includes(`"/${moduleName}"`), `the PWA app shell should include every app.js startup module: ${moduleName}`);
233
233
  }
234
234
  assert.match(serviceWorker, /pi-webui-pwa-v\d+/, "the app-shell cache should retain a versioned identity");
235
- assert.ok(html.indexOf('id="webuiBootLoader"') < html.indexOf("/app.js?v=132"), "the inline loader should own app module startup");
235
+ assert.ok(html.indexOf('id="webuiBootLoader"') < html.indexOf("/app.js?v=146"), "the inline loader should own app module startup");
236
236
  assert.doesNotMatch(html, /<script type="module" src="\/app\.js/, "the app module should not bypass the guarded loader");
237
237
 
238
238
  console.log("boot-failure-diagnostics.test.mjs passed");
@@ -210,6 +210,40 @@ test.afterAll(async () => {
210
210
  await rm(tempRoot, { recursive: true, force: true });
211
211
  });
212
212
 
213
+ test("main output shows non-blocking inline feedback while transcript data loads", async ({ page }) => {
214
+ await page.setViewportSize({ width: 1280, height: 800 });
215
+ let releaseMessages;
216
+ const messagesReleased = new Promise((resolve) => { releaseMessages = resolve; });
217
+ let delayedMessagesRequest = false;
218
+ const messagesPattern = "**/api/messages?*";
219
+ await page.route(messagesPattern, async (route) => {
220
+ if (!delayedMessagesRequest) {
221
+ delayedMessagesRequest = true;
222
+ await messagesReleased;
223
+ }
224
+ await route.continue();
225
+ });
226
+
227
+ try {
228
+ await page.goto(baseURL);
229
+ const loading = page.locator("#mainOutputLoading");
230
+ const chat = page.locator("#chat");
231
+ await expect(loading).toBeVisible();
232
+ await expect(loading).toContainText("Loading agent output…");
233
+ await expect(loading).toHaveCSS("pointer-events", "none");
234
+ await expect(chat).toHaveAttribute("aria-busy", "true");
235
+ await expect(page.locator("#promptInput")).toBeEnabled();
236
+ assert.equal(await page.evaluate(() => document.querySelectorAll("dialog:modal").length), 0, "loading feedback should not open a popup");
237
+
238
+ releaseMessages();
239
+ await expect(loading).toBeHidden();
240
+ await expect(chat).toHaveAttribute("aria-busy", "false");
241
+ } finally {
242
+ releaseMessages?.();
243
+ await page.unroute(messagesPattern);
244
+ }
245
+ });
246
+
213
247
  test("only hidden pages disconnect live events and resume from one authoritative snapshot", async ({ page }) => {
214
248
  await page.setViewportSize({ width: 1280, height: 800 });
215
249
  await page.goto(baseURL);