@celljs/ta-glance 4.16.0 → 4.17.0

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.
@@ -1,4 +1,5 @@
1
1
  // ../ta-protocol/esm/common/ta-extension-host.js
2
+ var TA_WEBHOOK_MAX_BYTES = 256 * 1024;
2
3
  var TA_HOST_EVENT = "ta:host";
3
4
  var TaHostUtil;
4
5
  (function(TaHostUtil2) {
@@ -95,6 +96,7 @@ var TaAskUtil;
95
96
  var GlanceJson;
96
97
  ((GlanceJson) => {
97
98
  const TRIES = 40;
99
+ const CONTROLS = { "\n": "\\n", "\r": "\\r", "\t": "\\t" };
98
100
  function parse(text, partial) {
99
101
  const source = text.trim().replace(/,\s*([}\]])/g, "$1");
100
102
  if (!source) {
@@ -157,6 +159,9 @@ var GlanceJson;
157
159
  escaped = true;
158
160
  } else if (char === '"') {
159
161
  inString = false;
162
+ } else if (char < " ") {
163
+ out += CONTROLS[char] ?? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`;
164
+ continue;
160
165
  }
161
166
  } else if (char === '"') {
162
167
  inString = true;
@@ -213,6 +218,7 @@ var GLANCE_ICONS = [
213
218
 
214
219
  // web-src/glance-spec.ts
215
220
  var ITEMS = 12;
221
+ var FOLDED = 40;
216
222
  var POINTS = 24;
217
223
  var SERIES = 4;
218
224
  var BLOCKS = 8;
@@ -364,6 +370,12 @@ function isPath(value) {
364
370
  }
365
371
  var LABELS = { before: "Before", after: "After" };
366
372
  function block(item, partial, labels) {
373
+ const made = blockOf(item, partial, labels);
374
+ const fold = object(item)?.fold;
375
+ const words = fold === true ? "" : text(fold, 40);
376
+ return made && words !== undefined ? { ...made, fold: words } : made;
377
+ }
378
+ function blockOf(item, partial, labels) {
367
379
  const value = object(item);
368
380
  const type = typeof value?.type === "string" ? value.type.trim().toLowerCase() : undefined;
369
381
  const unit = text(value?.unit, 16);
@@ -379,7 +391,7 @@ function block(item, partial, labels) {
379
391
  const list2 = items(raw, point);
380
392
  return list2.length ? { type: "notes", items: list2 } : undefined;
381
393
  }
382
- const list = items(value?.items, change);
394
+ const list = items(value?.items, change, FOLDED);
383
395
  return list.length ? { type, items: list } : undefined;
384
396
  }
385
397
  case "steps": {
@@ -408,7 +420,7 @@ function block(item, partial, labels) {
408
420
  return rows.length ? { type: "table", columns: ["", labels.before, labels.after], rows } : undefined;
409
421
  }
410
422
  case "bars": {
411
- const list = items(value?.items, amount);
423
+ const list = items(value?.items, amount, FOLDED);
412
424
  return list.length ? { type, items: list, ...unit ? { unit } : {} } : undefined;
413
425
  }
414
426
  case "line": {
@@ -432,8 +444,8 @@ function block(item, partial, labels) {
432
444
  return mermaid ? { type, mermaid } : undefined;
433
445
  }
434
446
  case "table": {
435
- const columns = strings(value?.columns, 6);
436
- const rows = items(value?.rows, (row) => Array.isArray(row) ? columns.map((_, index) => text(row[index]) ?? "") : undefined);
447
+ const columns = items(value?.columns, (column) => text(column) ?? (typeof column === "string" ? "" : undefined), 6);
448
+ const rows = items(value?.rows, (row) => Array.isArray(row) ? columns.map((_, index) => text(row[index]) ?? "") : undefined, FOLDED);
437
449
  return columns.length && rows.length ? { type, columns, rows } : undefined;
438
450
  }
439
451
  case "options": {
@@ -469,6 +481,13 @@ function loose(card) {
469
481
  return out;
470
482
  }
471
483
  var LISTS = ["stats", "changes", "steps", "flow", "options", "notes", "next"];
484
+ var PLACE = { stats: -1, notes: 1, next: 2, details: 3 };
485
+ function place(block2) {
486
+ return block2.fold !== undefined ? 3 : PLACE[block2.type] ?? 0;
487
+ }
488
+ function placed(blocks) {
489
+ return blocks.map((block2, index) => ({ block: block2, index })).sort((a, b) => place(a.block) - place(b.block) || a.index - b.index).map((entry) => entry.block);
490
+ }
472
491
  var GlanceSpec;
473
492
  ((GlanceSpec) => {
474
493
  function read(value, partial = false, labels = LABELS) {
@@ -478,7 +497,7 @@ var GlanceSpec;
478
497
  }
479
498
  const status = oneOf(card.status, STATUSES);
480
499
  const title = text(card.title);
481
- const blocks = items(Array.isArray(card.blocks) ? card.blocks : loose(card), (entry) => block(entry, partial, labels)).slice(0, BLOCKS);
500
+ const blocks = placed(items(Array.isArray(card.blocks) ? card.blocks : loose(card), (entry) => block(entry, partial, labels)).slice(0, BLOCKS));
482
501
  if (!blocks.length && !title) {
483
502
  return;
484
503
  }
@@ -577,8 +596,8 @@ How to reply:
577
596
 
578
597
  The card: {"status": "done" | "partial" | "failed" | "blocked" | "info", "title"?: string, "blocks": [...]}
579
598
  status: done = finished, partial = done in part, failed, blocked = waiting for the user, info = an answer, no work. Leave out title: the first line already says it.
580
- Blocks, 1 to 4 of them, the most important first, each with only the fields shown. Every text a few words, in the user's language; inline Markdown works (**bold**, \`path/to/file\` opens the file).
581
- - {"type":"stats","items":[{"label":"Tests","value":"128/128","tone":"good"},{"label":"Startup","value":"210 ms","delta":"-34%","tone":"good","trend":[320,290,210]}]}: key numbers, at most 6; tone good | bad | warn; trend, its values over time when known, draws a small line.
599
+ Blocks, 1 to 4 of them, the most important first (Ta puts stats on top and notes, next and details at the bottom), each with only the fields shown. A block few need but some may want (the full list, how it was measured, the rest of a comparison) may have "fold": "a few words": Ta draws it folded under them, opened by a tap; it does not count in the 4. Long lists are folded by Ta after their first items, so give them whole. Every text a few words, in the user's language; inline Markdown works (**bold**, \`path/to/file\` opens the file).
600
+ - {"type":"stats","items":[{"label":"Tests","value":"128/128","tone":"good"},{"label":"Startup","value":"210 ms","delta":"-34%","tone":"good","trend":[320,290,210]}]}: key numbers, at most 6, each value a number with its unit (a fact in words goes in notes); tone good | bad | warn; trend, its values over time when known, draws a small line.
582
601
  - {"type":"changes","items":[{"path":"src/a.ts","kind":"edit","add":12,"del":3,"note":"why, in a few words"}]}: files changed, a path each (what changed without a file goes in notes); kind add | edit | delete.
583
602
  - {"type":"steps","items":[{"text":"...","status":"done"}]}: progress or a plan; status done | doing | todo | failed | skipped.
584
603
  - {"type":"compare","unit":"ms","better":"lower","items":[{"label":"Startup","before":320,"after":210}]}: before and after, numbers only (words go in a table).
@@ -587,7 +606,7 @@ Blocks, 1 to 4 of them, the most important first, each with only the fields show
587
606
  - {"type":"share","unit":"MB","items":[{"label":"pi","value":129},{"label":"ta","value":66}]}: the parts of a whole.
588
607
  - {"type":"flow","items":["Request",{"text":"Gateway","icon":"Server"},"Session","Model"]}: a sequence or a path.
589
608
  - {"type":"diagram","mermaid":"graph LR; A-->B"}: relations a flow cannot show, under 12 nodes.
590
- - {"type":"table","columns":["",""],"rows":[["",""]]}: a few rows that compare things on several points.
609
+ - {"type":"table","columns":["",""],"rows":[["",""]]}: a few rows that compare things on several points, the first column naming each row (columns ["", "Before", "After"] for before and after in words).
591
610
  - {"type":"options","question":"Which one?","items":[{"label":"A","detail":"one line","pros":["..."],"cons":["..."],"recommended":true}]}: when the user must choose; each is a button that answers with its label.
592
611
  - {"type":"notes","items":[{"text":"...","tone":"risk"}]}: risks, caveats, what the user must do; tone risk | info | todo.
593
612
  - {"type":"next","items":["Run the e2e tests"]}: at most 3 things the user may well ask next, each a button that sends it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-glance",
3
- "version": "4.16.0",
3
+ "version": "4.17.0",
4
4
  "description": "A pi package for Ta: replies lead with the answer, short, and show results as cards (key numbers, files, steps, comparisons, choices) rather than paragraphs",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -26,8 +26,8 @@
26
26
  "watch": "tsc -b -w --preserveWatchOutput"
27
27
  },
28
28
  "devDependencies": {
29
- "@celljs/ta-protocol": "4.16.0",
30
- "@celljs/ta-web": "4.16.0",
29
+ "@celljs/ta-protocol": "4.17.0",
30
+ "@celljs/ta-web": "4.17.0",
31
31
  "@types/react": "^19.3.0"
32
32
  },
33
33
  "publishConfig": {
@@ -50,6 +50,7 @@
50
50
  "web": [
51
51
  "./web/index.js"
52
52
  ],
53
+ "shared": true,
53
54
  "extensions": [
54
55
  "./extension/index.mjs"
55
56
  ]
package/web/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  var GlanceJson;
3
3
  ((GlanceJson) => {
4
4
  const TRIES = 40;
5
+ const CONTROLS = { "\n": "\\n", "\r": "\\r", "\t": "\\t" };
5
6
  function parse(text, partial) {
6
7
  const source = text.trim().replace(/,\s*([}\]])/g, "$1");
7
8
  if (!source) {
@@ -64,6 +65,9 @@ var GlanceJson;
64
65
  escaped = true;
65
66
  } else if (char === '"') {
66
67
  inString = false;
68
+ } else if (char < " ") {
69
+ out += CONTROLS[char] ?? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`;
70
+ continue;
67
71
  }
68
72
  } else if (char === '"') {
69
73
  inString = true;
@@ -83,6 +87,7 @@ var GlanceJson;
83
87
 
84
88
  // web-src/glance-spec.ts
85
89
  var ITEMS = 12;
90
+ var FOLDED = 40;
86
91
  var POINTS = 24;
87
92
  var SERIES = 4;
88
93
  var BLOCKS = 8;
@@ -234,6 +239,12 @@ function isPath(value) {
234
239
  }
235
240
  var LABELS = { before: "Before", after: "After" };
236
241
  function block(item, partial, labels) {
242
+ const made = blockOf(item, partial, labels);
243
+ const fold = object(item)?.fold;
244
+ const words = fold === true ? "" : text(fold, 40);
245
+ return made && words !== undefined ? { ...made, fold: words } : made;
246
+ }
247
+ function blockOf(item, partial, labels) {
237
248
  const value = object(item);
238
249
  const type = typeof value?.type === "string" ? value.type.trim().toLowerCase() : undefined;
239
250
  const unit = text(value?.unit, 16);
@@ -249,7 +260,7 @@ function block(item, partial, labels) {
249
260
  const list2 = items(raw, point);
250
261
  return list2.length ? { type: "notes", items: list2 } : undefined;
251
262
  }
252
- const list = items(value?.items, change);
263
+ const list = items(value?.items, change, FOLDED);
253
264
  return list.length ? { type, items: list } : undefined;
254
265
  }
255
266
  case "steps": {
@@ -278,7 +289,7 @@ function block(item, partial, labels) {
278
289
  return rows.length ? { type: "table", columns: ["", labels.before, labels.after], rows } : undefined;
279
290
  }
280
291
  case "bars": {
281
- const list = items(value?.items, amount);
292
+ const list = items(value?.items, amount, FOLDED);
282
293
  return list.length ? { type, items: list, ...unit ? { unit } : {} } : undefined;
283
294
  }
284
295
  case "line": {
@@ -302,8 +313,8 @@ function block(item, partial, labels) {
302
313
  return mermaid ? { type, mermaid } : undefined;
303
314
  }
304
315
  case "table": {
305
- const columns = strings(value?.columns, 6);
306
- const rows = items(value?.rows, (row) => Array.isArray(row) ? columns.map((_, index) => text(row[index]) ?? "") : undefined);
316
+ const columns = items(value?.columns, (column) => text(column) ?? (typeof column === "string" ? "" : undefined), 6);
317
+ const rows = items(value?.rows, (row) => Array.isArray(row) ? columns.map((_, index) => text(row[index]) ?? "") : undefined, FOLDED);
307
318
  return columns.length && rows.length ? { type, columns, rows } : undefined;
308
319
  }
309
320
  case "options": {
@@ -339,6 +350,13 @@ function loose(card) {
339
350
  return out;
340
351
  }
341
352
  var LISTS = ["stats", "changes", "steps", "flow", "options", "notes", "next"];
353
+ var PLACE = { stats: -1, notes: 1, next: 2, details: 3 };
354
+ function place(block2) {
355
+ return block2.fold !== undefined ? 3 : PLACE[block2.type] ?? 0;
356
+ }
357
+ function placed(blocks) {
358
+ return blocks.map((block2, index) => ({ block: block2, index })).sort((a, b) => place(a.block) - place(b.block) || a.index - b.index).map((entry) => entry.block);
359
+ }
342
360
  var GlanceSpec;
343
361
  ((GlanceSpec) => {
344
362
  function read(value, partial = false, labels = LABELS) {
@@ -348,7 +366,7 @@ var GlanceSpec;
348
366
  }
349
367
  const status = oneOf(card.status, STATUSES);
350
368
  const title = text(card.title);
351
- const blocks = items(Array.isArray(card.blocks) ? card.blocks : loose(card), (entry) => block(entry, partial, labels)).slice(0, BLOCKS);
369
+ const blocks = placed(items(Array.isArray(card.blocks) ? card.blocks : loose(card), (entry) => block(entry, partial, labels)).slice(0, BLOCKS));
352
370
  if (!blocks.length && !title) {
353
371
  return;
354
372
  }
@@ -436,8 +454,13 @@ var EN = {
436
454
  pick: "I choose: {label}",
437
455
  details: "Details",
438
456
  hide: "Hide",
457
+ more: "{count} more",
439
458
  files: "{count} files",
440
- writing: "Drawing the summary…"
459
+ writing: "Drawing the summary…",
460
+ spokenChoices: "You can choose: {labels}.",
461
+ spokenRecommended: "I suggest {label}.",
462
+ spokenFailed: "{text}: failed.",
463
+ spokenJoin: ", "
441
464
  };
442
465
  var ZH = {
443
466
  status: { done: "已完成", partial: "部分完成", failed: "失败", blocked: "需要你", info: "" },
@@ -449,8 +472,13 @@ var ZH = {
449
472
  pick: "我选:{label}",
450
473
  details: "详情",
451
474
  hide: "收起",
475
+ more: "还有 {count} 项",
452
476
  files: "{count} 个文件",
453
- writing: "正在整理摘要…"
477
+ writing: "正在整理摘要…",
478
+ spokenChoices: "可以选:{labels}。",
479
+ spokenRecommended: "推荐{label}。",
480
+ spokenFailed: "{text}失败了。",
481
+ spokenJoin: "、"
454
482
  };
455
483
  var ZH_TW = {
456
484
  status: { done: "已完成", partial: "部分完成", failed: "失敗", blocked: "需要你", info: "" },
@@ -462,8 +490,13 @@ var ZH_TW = {
462
490
  pick: "我選:{label}",
463
491
  details: "詳情",
464
492
  hide: "收起",
493
+ more: "還有 {count} 項",
465
494
  files: "{count} 個檔案",
466
- writing: "正在整理摘要…"
495
+ writing: "正在整理摘要…",
496
+ spokenChoices: "可以選:{labels}。",
497
+ spokenRecommended: "推薦{label}。",
498
+ spokenFailed: "{text}失敗了。",
499
+ spokenJoin: "、"
467
500
  };
468
501
  var JA = {
469
502
  status: { done: "完了", partial: "部分完了", failed: "失敗", blocked: "要対応", info: "" },
@@ -475,8 +508,13 @@ var JA = {
475
508
  pick: "私が選んだ:{label}",
476
509
  details: "詳細",
477
510
  hide: "隠す",
511
+ more: "ほか {count} 件",
478
512
  files: "{count} 個のファイル",
479
- writing: "サマリーを作成中…"
513
+ writing: "サマリーを作成中…",
514
+ spokenChoices: "選択肢:{labels}。",
515
+ spokenRecommended: "オススメは{label}です。",
516
+ spokenFailed: "{text}は失敗しました。",
517
+ spokenJoin: "、"
480
518
  };
481
519
  var WORDS = { "zh-CN": ZH, "zh-TW": ZH_TW, "en-US": EN, "ja-JP": JA };
482
520
  var GlanceWords;
@@ -506,6 +544,7 @@ function bind(react) {
506
544
  var MARKS = /[*_`[\]$\\]/;
507
545
  var SQUARES = 5;
508
546
  var LINES = 20;
547
+ var SHOWN = { changes: 5, rows: 5, bars: 6 };
509
548
  var WIDTH = 300;
510
549
  var HEIGHT = 100;
511
550
  function fileName(path) {
@@ -537,6 +576,34 @@ function glanceCard(pi) {
537
576
  strokeWidth: 2
538
577
  }) : null;
539
578
  }
579
+ function Toggle({ open, label, opened, words, onToggle }) {
580
+ return /* @__PURE__ */ React.createElement("button", {
581
+ type: "button",
582
+ className: "tag-details-toggle",
583
+ "aria-expanded": open,
584
+ onClick: onToggle
585
+ }, /* @__PURE__ */ React.createElement(Icon, {
586
+ name: "ChevronRight",
587
+ size: 14
588
+ }), /* @__PURE__ */ React.createElement("span", null, open ? opened ?? words.hide : label));
589
+ }
590
+ function useMore(count2, shown, words) {
591
+ const [open, setOpen] = React.useState(false);
592
+ if (count2 <= shown + 1) {
593
+ return { limit: count2, toggle: null };
594
+ }
595
+ return {
596
+ limit: open ? count2 : shown,
597
+ toggle: /* @__PURE__ */ React.createElement("div", {
598
+ className: "tag-more"
599
+ }, /* @__PURE__ */ React.createElement(Toggle, {
600
+ open,
601
+ label: GlanceWords.format(words.more, { count: count2 - shown }),
602
+ words,
603
+ onToggle: () => setOpen(!open)
604
+ }))
605
+ };
606
+ }
540
607
  const has = (name) => !!name && !!icons[name];
541
608
  function Polyline({
542
609
  values,
@@ -675,7 +742,8 @@ function glanceCard(pi) {
675
742
  }, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("div", {
676
743
  key: index,
677
744
  className: "tag-stat",
678
- "data-tone": item.tone
745
+ "data-tone": item.tone,
746
+ "data-words": !/\d/.test(item.value) || undefined
679
747
  }, /* @__PURE__ */ React.createElement("div", {
680
748
  className: "tag-stat-value"
681
749
  }, /* @__PURE__ */ React.createElement(Text, {
@@ -718,6 +786,7 @@ function glanceCard(pi) {
718
786
  const add = block2.items.reduce((sum, item) => sum + (item.add ?? 0), 0);
719
787
  const del = block2.items.reduce((sum, item) => sum + (item.del ?? 0), 0);
720
788
  const largest = Math.max(LINES, ...block2.items.map((item) => (item.add ?? 0) + (item.del ?? 0)));
789
+ const more = useMore(block2.items.length, SHOWN.changes, words);
721
790
  return /* @__PURE__ */ React.createElement("div", {
722
791
  className: "tag-changes"
723
792
  }, /* @__PURE__ */ React.createElement("div", {
@@ -726,7 +795,7 @@ function glanceCard(pi) {
726
795
  className: "tag-add"
727
796
  }, "+", add), del > 0 && /* @__PURE__ */ React.createElement("span", {
728
797
  className: "tag-del"
729
- }, "−", del)), block2.items.map((item, index) => /* @__PURE__ */ React.createElement("div", {
798
+ }, "−", del)), block2.items.slice(0, more.limit).map((item, index) => /* @__PURE__ */ React.createElement("div", {
730
799
  key: index,
731
800
  className: "tag-change"
732
801
  }, /* @__PURE__ */ React.createElement("span", {
@@ -756,7 +825,7 @@ function glanceCard(pi) {
756
825
  }, "−", item.del) : null, /* @__PURE__ */ React.createElement(Squares, {
757
826
  change: item,
758
827
  largest
759
- })))));
828
+ })))), more.toggle);
760
829
  }
761
830
  const STEP_ICON = { done: "Check", failed: "X", skipped: "Minus", doing: undefined, todo: undefined };
762
831
  function Steps({ block: block2 }) {
@@ -819,12 +888,13 @@ function glanceCard(pi) {
819
888
  })));
820
889
  }));
821
890
  }
822
- function Bars({ block: block2 }) {
891
+ function Bars({ block: block2, words }) {
823
892
  const largest = Math.max(...block2.items.map((item) => Math.abs(item.value)), 0) || 1;
824
893
  const unit = block2.unit ? ` ${block2.unit}` : "";
825
- return /* @__PURE__ */ React.createElement("div", {
894
+ const more = useMore(block2.items.length, SHOWN.bars, words);
895
+ return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", {
826
896
  className: "tag-bars"
827
- }, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("div", {
897
+ }, block2.items.slice(0, more.limit).map((item, index) => /* @__PURE__ */ React.createElement("div", {
828
898
  key: index,
829
899
  className: "tag-bar"
830
900
  }, /* @__PURE__ */ React.createElement("span", {
@@ -837,7 +907,7 @@ function glanceCard(pi) {
837
907
  style: { width: `${Math.abs(item.value) / largest * 100}%` }
838
908
  })), /* @__PURE__ */ React.createElement("span", {
839
909
  className: "tag-bar-value"
840
- }, count(item.value), unit))));
910
+ }, count(item.value), unit)))), more.toggle);
841
911
  }
842
912
  function Flow({ block: block2 }) {
843
913
  return /* @__PURE__ */ React.createElement("div", {
@@ -862,20 +932,21 @@ function glanceCard(pi) {
862
932
  text: item.text
863
933
  })))));
864
934
  }
865
- function Table({ block: block2 }) {
866
- return /* @__PURE__ */ React.createElement("div", {
935
+ function Table({ block: block2, words }) {
936
+ const more = useMore(block2.rows.length, SHOWN.rows, words);
937
+ return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", {
867
938
  className: "ta-table tag-table"
868
939
  }, /* @__PURE__ */ React.createElement("table", null, /* @__PURE__ */ React.createElement("thead", null, /* @__PURE__ */ React.createElement("tr", null, block2.columns.map((column, index) => /* @__PURE__ */ React.createElement("th", {
869
940
  key: index
870
941
  }, /* @__PURE__ */ React.createElement(Text, {
871
942
  text: column
872
- }))))), /* @__PURE__ */ React.createElement("tbody", null, block2.rows.map((row, index) => /* @__PURE__ */ React.createElement("tr", {
943
+ }))))), /* @__PURE__ */ React.createElement("tbody", null, block2.rows.slice(0, more.limit).map((row, index) => /* @__PURE__ */ React.createElement("tr", {
873
944
  key: index
874
945
  }, row.map((cell, column) => /* @__PURE__ */ React.createElement("td", {
875
946
  key: column
876
947
  }, /* @__PURE__ */ React.createElement(Text, {
877
948
  text: cell
878
- }))))))));
949
+ })))))))), more.toggle);
879
950
  }
880
951
  function Options({ block: block2, words, closed }) {
881
952
  const [tapped, setChosen] = React.useState();
@@ -954,7 +1025,7 @@ function glanceCard(pi) {
954
1025
  }), /* @__PURE__ */ React.createElement("span", null, picked ? words.chosen : words.choose)));
955
1026
  })));
956
1027
  }
957
- const NOTE_ICON = { risk: "CircleAlert", info: "Info", todo: "Square" };
1028
+ const NOTE_ICON = { risk: "CircleAlert", info: "Info", todo: "CircleArrowRight" };
958
1029
  function Notes({ block: block2 }) {
959
1030
  return /* @__PURE__ */ React.createElement("ul", {
960
1031
  className: "tag-notes"
@@ -1027,7 +1098,8 @@ function glanceCard(pi) {
1027
1098
  });
1028
1099
  case "bars":
1029
1100
  return /* @__PURE__ */ React.createElement(Bars, {
1030
- block: block2
1101
+ block: block2,
1102
+ words
1031
1103
  });
1032
1104
  case "line":
1033
1105
  return /* @__PURE__ */ React.createElement(Line, {
@@ -1049,7 +1121,8 @@ ${block2.mermaid}
1049
1121
  }) : null;
1050
1122
  case "table":
1051
1123
  return /* @__PURE__ */ React.createElement(Table, {
1052
- block: block2
1124
+ block: block2,
1125
+ words
1053
1126
  });
1054
1127
  case "options":
1055
1128
  return /* @__PURE__ */ React.createElement(Options, {
@@ -1073,8 +1146,26 @@ ${block2.mermaid}
1073
1146
  });
1074
1147
  }
1075
1148
  }
1149
+ function Folded({ block: block2, words, closed }) {
1150
+ const [open, setOpen] = React.useState(false);
1151
+ return /* @__PURE__ */ React.createElement("div", {
1152
+ className: "tag-details"
1153
+ }, /* @__PURE__ */ React.createElement(Toggle, {
1154
+ open,
1155
+ label: block2.fold || words.details,
1156
+ opened: block2.fold || words.details,
1157
+ words,
1158
+ onToggle: () => setOpen(!open)
1159
+ }), open && /* @__PURE__ */ React.createElement("div", {
1160
+ className: "tag-folded-body"
1161
+ }, /* @__PURE__ */ React.createElement(Part, {
1162
+ block: block2,
1163
+ words,
1164
+ closed
1165
+ })));
1166
+ }
1076
1167
  function Head({ card, words }) {
1077
- const status = card.status && words.status[card.status];
1168
+ const status = card.status && (card.status !== "done" || card.title) ? words.status[card.status] : undefined;
1078
1169
  if (!status && !card.title) {
1079
1170
  return null;
1080
1171
  }
@@ -1113,6 +1204,7 @@ ${code}
1113
1204
  value: answer
1114
1205
  }, /* @__PURE__ */ React.createElement("div", {
1115
1206
  className: "tag-card",
1207
+ "data-status": card.status,
1116
1208
  "data-streaming": !closed || undefined
1117
1209
  }, /* @__PURE__ */ React.createElement(Head, {
1118
1210
  card,
@@ -1120,8 +1212,13 @@ ${code}
1120
1212
  }), card.blocks.map((block2, index) => /* @__PURE__ */ React.createElement("div", {
1121
1213
  key: index,
1122
1214
  className: "tag-part",
1123
- "data-type": block2.type
1124
- }, /* @__PURE__ */ React.createElement(Part, {
1215
+ "data-type": block2.type,
1216
+ "data-fold": block2.fold !== undefined || undefined
1217
+ }, block2.fold !== undefined ? /* @__PURE__ */ React.createElement(Folded, {
1218
+ block: block2,
1219
+ words,
1220
+ closed
1221
+ }) : /* @__PURE__ */ React.createElement(Part, {
1125
1222
  block: block2,
1126
1223
  words,
1127
1224
  closed
@@ -1133,6 +1230,40 @@ ${code}
1133
1230
  var LANGUAGE = "ta-glance";
1134
1231
  var ALIASES = ["glance", "glance-choice"];
1135
1232
 
1233
+ // web-src/glance-speech.ts
1234
+ var GlanceSpeech;
1235
+ ((GlanceSpeech) => {
1236
+ function of(card, words) {
1237
+ const said = [];
1238
+ for (const block2 of card.blocks) {
1239
+ if (block2.type === "options" && block2.items.length) {
1240
+ if (block2.question) {
1241
+ said.push(sentence(block2.question));
1242
+ }
1243
+ said.push(GlanceWords.format(words.spokenChoices, { labels: block2.items.map((item) => item.label).join(words.spokenJoin) }));
1244
+ const suggested = block2.items.find((item) => item.recommended);
1245
+ if (suggested) {
1246
+ said.push(GlanceWords.format(words.spokenRecommended, { label: suggested.label }));
1247
+ }
1248
+ } else if (block2.type === "steps") {
1249
+ for (const step2 of block2.items.filter((item) => item.status === "failed")) {
1250
+ said.push(GlanceWords.format(words.spokenFailed, { text: step2.text }));
1251
+ }
1252
+ } else if (block2.type === "notes") {
1253
+ for (const note2 of block2.items.filter((item) => item.tone !== "info")) {
1254
+ said.push(sentence(note2.text));
1255
+ }
1256
+ }
1257
+ }
1258
+ return said.length ? said.join(" ") : undefined;
1259
+ }
1260
+ GlanceSpeech.of = of;
1261
+ function sentence(text2) {
1262
+ const trimmed = text2.trim();
1263
+ return /[.!?。!?::]$/.test(trimmed) ? trimmed : /[\u3000-\u9fff]/.test(trimmed) ? `${trimmed}。` : `${trimmed}.`;
1264
+ }
1265
+ })(GlanceSpeech ||= {});
1266
+
1136
1267
  // web-src/style.ts
1137
1268
  var STYLE = `
1138
1269
  /*
@@ -1184,7 +1315,7 @@ var STYLE = `
1184
1315
  .tag-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: var(--tag-y) var(--tag-x) 0; }
1185
1316
  .tag-card > .tag-head + .tag-part { border-top: 0; padding-top: 8px; }
1186
1317
  /* A table or a diagram reaches the edges: under the head it keeps the hairline, a gap above it */
1187
- .tag-card > .tag-head + .tag-part:is([data-type='table'], [data-type='diagram']) { margin-top: var(--tag-y); padding-top: 0; border-top: 1px solid var(--tag-line); }
1318
+ .tag-card > .tag-head + .tag-part:is([data-type='table'], [data-type='diagram']):not([data-fold]) { margin-top: var(--tag-y); padding-top: 0; border-top: 1px solid var(--tag-line); }
1188
1319
  .tag-title { flex: 1 1 14em; min-width: 0; font-weight: 600; font-size: calc(14px * var(--tag-s)); line-height: 1.45; color: var(--ta-text); }
1189
1320
  .tag-status { --tag-tone: var(--ta-muted); flex: none; display: inline-flex; align-items: center; gap: 6px; height: calc(22px * var(--tag-s)); padding: 0 9px; border-radius: 999px; font-size: var(--tag-small); font-weight: 600; line-height: 1; white-space: nowrap; color: var(--tag-tone); background: color-mix(in srgb, var(--tag-tone) 12%, transparent); }
1190
1321
  .tag-status i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
@@ -1193,6 +1324,8 @@ var STYLE = `
1193
1324
  /* Needs you: the blue of what waits for the user, as the ? of the list of chats. */
1194
1325
  .tag-status[data-status='blocked'] { --tag-tone: var(--ta-blue); }
1195
1326
  .tag-status[data-status='failed'] { --tag-tone: var(--ta-red); }
1327
+ /* Done without a title has no row of its own: a green edge at the top of the card says it */
1328
+ .tag-card[data-status='done']:not(:has(> .tag-head))::before { content: ''; position: absolute; z-index: 1; inset: 0 0 auto; height: 2px; background: var(--ta-green); pointer-events: none; }
1196
1329
 
1197
1330
  /* What a part is about, in small muted type above it */
1198
1331
  .tag-section-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 6px; color: var(--ta-muted); font-size: var(--tag-small); line-height: 1.4; }
@@ -1215,6 +1348,9 @@ var STYLE = `
1215
1348
  .tag-stat { min-width: 0; padding: 10px 12px; border-radius: 8px; background: var(--ta-raised); }
1216
1349
  .tag-stat-value { font-size: calc(20px * var(--tag-s)); font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; color: var(--ta-text); }
1217
1350
  @container tag-card (max-width: 400px) { .tag-stat-value { font-size: calc(18px * var(--tag-s)); } }
1351
+ /* A value in words (Included) is not a number to read from afar: body size, on the line of the numbers beside it */
1352
+ .tag-stat[data-words] > .tag-stat-value { font-size: calc(15px * var(--tag-s)); line-height: calc(25px * var(--tag-s)); letter-spacing: 0; }
1353
+ @container tag-card (max-width: 400px) { .tag-stat[data-words] > .tag-stat-value { font-size: calc(14px * var(--tag-s)); line-height: calc(22.5px * var(--tag-s)); } }
1218
1354
  /* Its icon, name and change wrap as wholes, so that a narrow box does not break the name */
1219
1355
  .tag-stat-label { display: flex; flex-wrap: wrap; align-items: center; margin-top: 2px; color: var(--ta-muted); font-size: var(--tag-small); line-height: 1.4; }
1220
1356
  /* The icon an item names: before its label, in the color of its tone where it has one */
@@ -1370,6 +1506,9 @@ var STYLE = `
1370
1506
  .tag-card .tag-table th:first-child, .tag-card .tag-table td:first-child { padding-left: var(--tag-x); }
1371
1507
  .tag-card .tag-table th:last-child, .tag-card .tag-table td:last-child { padding-right: var(--tag-x); }
1372
1508
  .tag-card .tag-table th { font-size: var(--tag-small); color: var(--ta-secondary); }
1509
+ /* The columns before the last keep to what they hold, the names of the rows close to their values; the last takes the rest and wraps */
1510
+ .tag-card .tag-table th:last-child:not(:first-child) { width: 100%; }
1511
+ .tag-card .tag-table td:last-child:not(:first-child) { min-width: 8em; white-space: normal; }
1373
1512
  .tag-card .ta-mermaid { margin: 0; border: 0; border-radius: 0; background: transparent; }
1374
1513
  .tag-card .ta-mermaid .ta-code-bar { padding-left: var(--tag-x); padding-right: calc(var(--tag-x) - 4px); }
1375
1514
  .tag-card .ta-markdown:has(> .ta-mermaid) { margin: 0; }
@@ -1415,8 +1554,14 @@ var STYLE = `
1415
1554
  .tag-chip:disabled { opacity: 0.5; cursor: default; }
1416
1555
  .tag-part[data-type='next'] { padding-top: calc(var(--tag-y) - 2px); padding-bottom: calc(var(--tag-y) - 2px); }
1417
1556
 
1418
- /* Details, folded */
1419
- .tag-part[data-type='details'] { padding-top: 8px; padding-bottom: 8px; }
1557
+ /* Details, folded; a block the model folded, under its words; the rest of a long list */
1558
+ .tag-part[data-type='details'], .tag-card > .tag-part[data-fold] { padding: 8px var(--tag-x); }
1559
+ .tag-folded-body { margin-top: 6px; padding-bottom: 4px; animation: ta-in 180ms var(--ta-ease, ease); }
1560
+ /* A table or a diagram opened in a fold still reaches the edges of the card */
1561
+ .tag-folded-body > :is(div, .ta-markdown):has(> .tag-table, > .ta-mermaid) { margin: 0 calc(-1 * var(--tag-x)) -12px; }
1562
+ .tag-folded-body .tag-table { border-top: 1px solid var(--tag-line); }
1563
+ .tag-more { margin-top: 4px; }
1564
+ .tag-table + .tag-more { padding: 4px var(--tag-x) 6px; border-top: 1px solid var(--tag-line); margin-top: 0; }
1420
1565
  .tag-details-toggle { display: inline-flex; align-items: center; gap: 4px; min-height: calc(24px * var(--tag-s)); margin-left: -4px; padding: 0 6px 0 4px; border: 0; border-radius: 6px; background: none; color: var(--ta-muted); font-size: var(--tag-small); cursor: pointer; transition: color 120ms, background 120ms; }
1421
1566
  .tag-details-toggle svg { width: calc(14px * var(--tag-s)); height: calc(14px * var(--tag-s)); transition: transform 150ms var(--ta-ease, ease); }
1422
1567
  .tag-details-toggle[aria-expanded='true'] svg { transform: rotate(90deg); }
@@ -1451,8 +1596,13 @@ function activate(pi) {
1451
1596
  }
1452
1597
  const removeStyle = injectStyle();
1453
1598
  const card = glanceCard(pi);
1599
+ const spoken = (code) => {
1600
+ const words = GlanceWords.of(pi.ui.language);
1601
+ const glance = GlanceSpec.read(GlanceJson.parse(code, false), false, words);
1602
+ return glance && GlanceSpeech.of(glance, words);
1603
+ };
1454
1604
  for (const language of [LANGUAGE, ...ALIASES]) {
1455
- pi.registerCodeRenderer(language, card);
1605
+ pi.registerCodeRenderer(language, card, { spoken });
1456
1606
  }
1457
1607
  return removeStyle;
1458
1608
  }