@zeyos/zx 5.7.0 → 5.8.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.
Files changed (330) hide show
  1. package/CHANGELOG.md +330 -0
  2. package/README.md +47 -9
  3. package/dist/types/components/activity-item/activity-item.d.ts +14 -3
  4. package/dist/types/components/agent-avatar/agent-avatar.d.ts +165 -0
  5. package/dist/types/components/agent-avatar/agent-face.d.ts +93 -0
  6. package/dist/types/components/agent-thread/ag-ui.d.ts +21 -9
  7. package/dist/types/components/agent-thread/agent-thread.d.ts +26 -0
  8. package/dist/types/components/agent-thread/ui-message-stream.d.ts +3 -1
  9. package/dist/types/components/approval-card/approval-card.d.ts +31 -2
  10. package/dist/types/components/aurora/aurora.d.ts +31 -5
  11. package/dist/types/components/calendar/calendar.d.ts +39 -26
  12. package/dist/types/components/chart/chart.d.ts +250 -20
  13. package/dist/types/components/chart/color.d.ts +66 -0
  14. package/dist/types/components/chart/svg-adapter.d.ts +103 -0
  15. package/dist/types/components/chart/svg-geometry.d.ts +203 -0
  16. package/dist/types/components/check-button/check-button.d.ts +1 -4
  17. package/dist/types/components/checklist/checklist.d.ts +48 -5
  18. package/dist/types/components/code-editor/code-editor.d.ts +55 -1
  19. package/dist/types/components/composer/composer.d.ts +41 -6
  20. package/dist/types/components/context-menu/context-menu.d.ts +36 -8
  21. package/dist/types/components/copy/copy-button.d.ts +6 -0
  22. package/dist/types/components/copy/copy-input.d.ts +1 -0
  23. package/dist/types/components/date-picker/date-picker.d.ts +14 -0
  24. package/dist/types/components/date-picker/time-picker.d.ts +26 -17
  25. package/dist/types/components/datebox/datebox.d.ts +8 -4
  26. package/dist/types/components/dialog/dialog.d.ts +15 -4
  27. package/dist/types/components/empty-state/empty-state.d.ts +10 -1
  28. package/dist/types/components/field/field.d.ts +4 -2
  29. package/dist/types/components/form/form.d.ts +2 -1
  30. package/dist/types/components/kanban-view/kanban-card.d.ts +7 -0
  31. package/dist/types/components/kanban-view/kanban-view.d.ts +15 -3
  32. package/dist/types/components/launcher/launcher.d.ts +26 -0
  33. package/dist/types/components/master-panel/master-panel.d.ts +9 -4
  34. package/dist/types/components/menu-button/menu-button.d.ts +29 -5
  35. package/dist/types/components/message/message.d.ts +308 -5
  36. package/dist/types/components/modal/modal.d.ts +45 -8
  37. package/dist/types/components/modal/native-dialog.d.ts +40 -0
  38. package/dist/types/components/module-bar/module-bar.d.ts +9 -2
  39. package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +5 -4
  40. package/dist/types/components/number-field/number-field.d.ts +31 -1
  41. package/dist/types/components/pagination/pagination.d.ts +341 -19
  42. package/dist/types/components/run-status/run-status.d.ts +26 -0
  43. package/dist/types/components/run-trace/run-trace.d.ts +10 -6
  44. package/dist/types/components/search/search.d.ts +16 -4
  45. package/dist/types/components/select/select.d.ts +19 -1
  46. package/dist/types/components/sheet/sheet.d.ts +20 -6
  47. package/dist/types/components/slider/slider.d.ts +2 -1
  48. package/dist/types/components/stat-tile/stat-tile.d.ts +20 -3
  49. package/dist/types/components/stepper/stepper.d.ts +17 -4
  50. package/dist/types/components/surface/catalog.d.ts +61 -17
  51. package/dist/types/components/surface/surface.d.ts +6 -4
  52. package/dist/types/components/table/table.d.ts +207 -5
  53. package/dist/types/components/table/window.d.ts +25 -1
  54. package/dist/types/components/toggle/toggle.d.ts +38 -6
  55. package/dist/types/components/tooltip/tooltip.d.ts +5 -4
  56. package/dist/types/components/tree/tree.d.ts +43 -6
  57. package/dist/types/components/truncate/truncate.d.ts +4 -2
  58. package/dist/types/components/value-list/value-list.d.ts +9 -2
  59. package/dist/types/core/date.d.ts +2 -1
  60. package/dist/types/core/dom.d.ts +14 -0
  61. package/dist/types/core/drag-axis.d.ts +10 -5
  62. package/dist/types/core/export.d.ts +2 -2
  63. package/dist/types/core/format.d.ts +3 -1
  64. package/dist/types/core/icons.d.ts +36 -3
  65. package/dist/types/core/keyboard.d.ts +7 -3
  66. package/dist/types/core/messages.d.ts +3 -0
  67. package/dist/types/core/storage.d.ts +4 -3
  68. package/dist/types/core/util.d.ts +3 -1
  69. package/dist/types/elements/define.d.ts +5 -2
  70. package/dist/types/index.d.ts +6 -4
  71. package/dist/types/internal/agent-model.d.ts +99 -0
  72. package/dist/types/internal/app-rail.d.ts +37 -2
  73. package/dist/types/internal/collections.d.ts +18 -0
  74. package/dist/types/internal/menu-items.d.ts +27 -0
  75. package/dist/types/internal/overlay-content.d.ts +23 -0
  76. package/dist/types/internal/presence-loop.d.ts +5 -2
  77. package/dist/types/locales/index.d.ts +3 -0
  78. package/dist/types/zeyos/calendar.d.ts +43 -7
  79. package/dist/types/zeyos/connect.d.ts +4 -0
  80. package/dist/types/zeyos/form.d.ts +13 -5
  81. package/dist/types/zeyos/select.d.ts +5 -2
  82. package/dist/types/zeyos/table.d.ts +16 -8
  83. package/dist/types/zeyos/view.d.ts +2 -1
  84. package/dist/zx-zeyos.esm.js +3161 -515
  85. package/dist/zx-zeyos.esm.min.js +4 -4
  86. package/dist/zx.core.css +4 -0
  87. package/dist/zx.core.min.css +1 -1
  88. package/dist/zx.css +970 -57
  89. package/dist/zx.esm.js +6405 -2249
  90. package/dist/zx.esm.min.js +26 -26
  91. package/dist/zx.global.js +6405 -2249
  92. package/dist/zx.global.min.js +26 -26
  93. package/dist/zx.layered.css +972 -57
  94. package/dist/zx.layered.min.css +1 -1
  95. package/dist/zx.min.css +1 -1
  96. package/docs/agent-catalog.json +159 -1
  97. package/docs/agent-surfaces.md +21 -21
  98. package/docs/api.json +3154 -518
  99. package/docs/components/account-menu.md +24 -0
  100. package/docs/components/activity-item.md +23 -0
  101. package/docs/components/activity-list.md +28 -0
  102. package/docs/components/agent-avatar.md +59 -0
  103. package/docs/components/agent-thread.md +275 -0
  104. package/docs/components/app-icon.md +36 -0
  105. package/docs/components/app-sidebar.md +92 -0
  106. package/docs/components/approval-card.md +71 -0
  107. package/docs/components/aurora.md +34 -0
  108. package/docs/components/avatar.md +37 -0
  109. package/docs/components/badge.md +36 -0
  110. package/docs/components/block-view.md +34 -0
  111. package/docs/components/breadcrumb.md +20 -0
  112. package/docs/components/button.md +23 -0
  113. package/docs/components/calendar.md +68 -0
  114. package/docs/components/card-view.md +73 -0
  115. package/docs/components/card.md +25 -0
  116. package/docs/components/chart.md +109 -0
  117. package/docs/components/check-button.md +16 -0
  118. package/docs/components/checklist.md +19 -0
  119. package/docs/components/code-editor.md +38 -0
  120. package/docs/components/composer.md +107 -0
  121. package/docs/components/context-menu.md +32 -0
  122. package/docs/components/copy.md +37 -0
  123. package/docs/components/data-filter.md +16 -0
  124. package/docs/components/date-picker.md +31 -0
  125. package/docs/components/date-range.md +21 -0
  126. package/docs/components/datebox.md +31 -0
  127. package/docs/components/dialog.md +25 -0
  128. package/docs/components/dock.md +57 -0
  129. package/docs/components/dropdown.md +39 -0
  130. package/docs/components/elements.md +63 -0
  131. package/docs/components/empty-state.md +17 -0
  132. package/docs/components/entity-ref.md +26 -0
  133. package/docs/components/field-upload.md +18 -0
  134. package/docs/components/file-item.md +27 -0
  135. package/docs/components/file-list.md +23 -0
  136. package/docs/components/filter-panel.md +45 -0
  137. package/docs/components/filter.md +47 -0
  138. package/docs/components/finder.md +25 -0
  139. package/docs/components/form-widgets.md +42 -0
  140. package/docs/components/form.md +80 -0
  141. package/docs/components/grid.md +26 -0
  142. package/docs/components/groupbox.md +11 -0
  143. package/docs/components/helpers.md +359 -0
  144. package/docs/components/icons.md +87 -0
  145. package/docs/components/index.md +99 -0
  146. package/docs/components/kanban-view.md +42 -0
  147. package/docs/components/kbd.md +23 -0
  148. package/docs/components/kernel.md +41 -0
  149. package/docs/components/launcher.md +66 -0
  150. package/docs/components/layout.md +33 -0
  151. package/docs/components/list-toolbar.md +38 -0
  152. package/docs/components/loading.md +48 -0
  153. package/docs/components/menu-button.md +47 -0
  154. package/docs/components/message.md +76 -0
  155. package/docs/components/modal.md +27 -0
  156. package/docs/components/module-bar.md +71 -0
  157. package/docs/components/multi-value-editor.md +16 -0
  158. package/docs/components/navigation-bar.md +22 -0
  159. package/docs/components/number-field.md +34 -0
  160. package/docs/components/pagination.md +73 -0
  161. package/docs/components/panel.md +28 -0
  162. package/docs/components/prompt-starters.md +40 -0
  163. package/docs/components/prose.md +38 -0
  164. package/docs/components/questionnaire.md +115 -0
  165. package/docs/components/rating.md +19 -0
  166. package/docs/components/run-status.md +50 -0
  167. package/docs/components/run-trace.md +72 -0
  168. package/docs/components/search.md +11 -0
  169. package/docs/components/select.md +129 -0
  170. package/docs/components/sheet-stack.md +39 -0
  171. package/docs/components/sheet.md +77 -0
  172. package/docs/components/skeleton.md +27 -0
  173. package/docs/components/slider.md +29 -0
  174. package/docs/components/sort-control.md +21 -0
  175. package/docs/components/source-list.md +30 -0
  176. package/docs/components/split-view.md +12 -0
  177. package/docs/components/stat-tile.md +49 -0
  178. package/docs/components/stepper.md +27 -0
  179. package/docs/components/surface.md +152 -0
  180. package/docs/components/tabbox.md +33 -0
  181. package/docs/components/table-view.md +43 -0
  182. package/docs/components/table.md +232 -0
  183. package/docs/components/tag-picker.md +39 -0
  184. package/docs/components/timebox.md +16 -0
  185. package/docs/components/toggle.md +21 -0
  186. package/docs/components/tokens.md +82 -0
  187. package/docs/components/toolbar.md +26 -0
  188. package/docs/components/tooltip.md +16 -0
  189. package/docs/components/tree.md +48 -0
  190. package/docs/components/truncate.md +21 -0
  191. package/docs/components/value-list.md +14 -0
  192. package/docs/components/view-settings.md +56 -0
  193. package/docs/components/workspace-switcher.md +42 -0
  194. package/docs/components/zeyos.md +196 -0
  195. package/docs/llms-small.txt +299 -0
  196. package/docs/llms.md +725 -109
  197. package/docs/llms.txt +46 -19
  198. package/package.json +9 -4
  199. package/src/components/activity-item/activity-item.js +21 -2
  200. package/src/components/agent-avatar/agent-avatar.css +195 -0
  201. package/src/components/agent-avatar/agent-avatar.js +333 -0
  202. package/src/components/agent-avatar/agent-face.js +292 -0
  203. package/src/components/agent-thread/ag-ui.js +44 -11
  204. package/src/components/agent-thread/agent-thread.js +103 -11
  205. package/src/components/agent-thread/ui-message-stream.js +3 -1
  206. package/src/components/app-rail/app-rail.css +5 -0
  207. package/src/components/app-sidebar/app-sidebar.css +3 -0
  208. package/src/components/app-sidebar/app-sidebar.js +4 -3
  209. package/src/components/approval-card/approval-card.css +6 -0
  210. package/src/components/approval-card/approval-card.js +55 -7
  211. package/src/components/aurora/aurora.css +149 -14
  212. package/src/components/aurora/aurora.js +49 -6
  213. package/src/components/button/button.css +24 -11
  214. package/src/components/calendar/calendar.css +6 -2
  215. package/src/components/calendar/calendar.js +127 -47
  216. package/src/components/card-view/card-view.js +5 -6
  217. package/src/components/chart/chart.css +159 -1
  218. package/src/components/chart/chart.js +450 -62
  219. package/src/components/chart/color.js +297 -0
  220. package/src/components/chart/svg-adapter.js +576 -0
  221. package/src/components/chart/svg-geometry.js +323 -0
  222. package/src/components/check-button/check-button.js +3 -18
  223. package/src/components/checklist/checklist.css +9 -1
  224. package/src/components/checklist/checklist.js +105 -20
  225. package/src/components/checklist/field-adapter.js +6 -12
  226. package/src/components/code-editor/code-editor.css +33 -0
  227. package/src/components/code-editor/code-editor.js +97 -8
  228. package/src/components/code-editor/field-adapter.js +3 -0
  229. package/src/components/composer/composer.css +3 -0
  230. package/src/components/composer/composer.js +100 -22
  231. package/src/components/context-menu/context-menu.js +41 -5
  232. package/src/components/copy/copy-button.js +9 -1
  233. package/src/components/copy/copy-input.js +5 -0
  234. package/src/components/data-filter/filter-core.js +0 -1
  235. package/src/components/date-picker/date-picker.css +8 -0
  236. package/src/components/date-picker/date-picker.js +47 -8
  237. package/src/components/date-picker/date-range-picker.js +1 -1
  238. package/src/components/date-picker/month-picker.js +19 -3
  239. package/src/components/date-picker/time-picker.js +54 -19
  240. package/src/components/datebox/date-range-box.js +7 -3
  241. package/src/components/datebox/datebox.js +32 -6
  242. package/src/components/dialog/dialog.css +6 -0
  243. package/src/components/dialog/dialog.js +24 -33
  244. package/src/components/dropdown/dropdown.js +1 -18
  245. package/src/components/empty-state/empty-state.js +21 -2
  246. package/src/components/field/field.js +19 -3
  247. package/src/components/fieldset/fieldset.js +3 -1
  248. package/src/components/filter/filter.js +9 -0
  249. package/src/components/form/form.js +19 -2
  250. package/src/components/kanban-view/kanban-card.js +15 -2
  251. package/src/components/kanban-view/kanban-view.css +21 -0
  252. package/src/components/kanban-view/kanban-view.js +29 -16
  253. package/src/components/launcher/launcher.css +14 -0
  254. package/src/components/launcher/launcher.js +54 -9
  255. package/src/components/master-panel/master-panel.js +24 -22
  256. package/src/components/menu-button/menu-button.js +26 -4
  257. package/src/components/message/message.css +228 -29
  258. package/src/components/message/message.js +664 -30
  259. package/src/components/modal/modal.js +129 -30
  260. package/src/components/modal/native-dialog.js +91 -0
  261. package/src/components/module-bar/module-bar.css +3 -0
  262. package/src/components/module-bar/module-bar.js +17 -4
  263. package/src/components/multi-value-editor/multi-value-editor.css +7 -2
  264. package/src/components/multi-value-editor/multi-value-editor.js +3 -2
  265. package/src/components/navigation-bar/navigation-bar.js +13 -1
  266. package/src/components/number-field/field-adapter.js +3 -0
  267. package/src/components/number-field/number-field.js +70 -16
  268. package/src/components/pagination/pagination.css +26 -2
  269. package/src/components/pagination/pagination.js +551 -65
  270. package/src/components/prose/prose.js +7 -1
  271. package/src/components/rating/field-adapter.js +3 -0
  272. package/src/components/run-status/run-status.js +43 -3
  273. package/src/components/run-trace/run-trace.js +15 -7
  274. package/src/components/search/search.js +3 -18
  275. package/src/components/select/field-adapter.js +8 -1
  276. package/src/components/select/select.js +68 -13
  277. package/src/components/sheet/sheet.js +39 -13
  278. package/src/components/slider/field-adapter.js +3 -0
  279. package/src/components/slider/slider.js +4 -6
  280. package/src/components/stat-tile/stat-tile.js +24 -9
  281. package/src/components/stepper/stepper.css +15 -0
  282. package/src/components/stepper/stepper.js +34 -2
  283. package/src/components/surface/catalog.js +185 -28
  284. package/src/components/surface/surface.js +10 -5
  285. package/src/components/tabbox/tabbox.js +13 -1
  286. package/src/components/table/table.css +160 -2
  287. package/src/components/table/table.js +479 -52
  288. package/src/components/table/window.js +46 -4
  289. package/src/components/table-view/table-view.js +1 -10
  290. package/src/components/tag-picker/field-adapter.js +3 -0
  291. package/src/components/tag-picker/tag-picker.js +2 -0
  292. package/src/components/timebox/field-adapter.js +3 -0
  293. package/src/components/toggle/toggle.js +51 -27
  294. package/src/components/tooltip/tooltip.js +21 -14
  295. package/src/components/tree/tree.js +87 -14
  296. package/src/components/truncate/truncate.js +21 -5
  297. package/src/components/value-list/value-list.js +37 -9
  298. package/src/components/view-settings/view-settings.js +1 -5
  299. package/src/core/component.js +34 -2
  300. package/src/core/date.js +5 -4
  301. package/src/core/dom.js +45 -2
  302. package/src/core/drag-axis.js +24 -7
  303. package/src/core/export.js +4 -4
  304. package/src/core/fontawesome.js +34 -3
  305. package/src/core/format.js +3 -1
  306. package/src/core/http.js +23 -11
  307. package/src/core/icons.js +60 -8
  308. package/src/core/keyboard.js +83 -9
  309. package/src/core/messages.js +3 -0
  310. package/src/core/position.js +4 -3
  311. package/src/core/storage.js +80 -31
  312. package/src/core/util.js +16 -5
  313. package/src/elements/define.js +82 -47
  314. package/src/elements/kit.js +46 -35
  315. package/src/index.js +8 -4
  316. package/src/internal/agent-model.js +152 -0
  317. package/src/internal/app-rail.js +53 -2
  318. package/src/internal/collections.js +25 -0
  319. package/src/internal/menu-items.js +59 -0
  320. package/src/internal/overlay-content.js +35 -0
  321. package/src/internal/presence-loop.js +61 -14
  322. package/src/locales/de.js +3 -0
  323. package/src/zeyos/calendar.js +81 -19
  324. package/src/zeyos/connect.js +5 -1
  325. package/src/zeyos/form.js +29 -10
  326. package/src/zeyos/select.js +36 -12
  327. package/src/zeyos/table.js +43 -11
  328. package/src/zeyos/view.js +2 -1
  329. package/styles/tokens/semantic.css +7 -1
  330. package/styles/zx.css +1 -0
@@ -11,6 +11,7 @@
11
11
  *
12
12
  * The module imports nothing that needs a DOM; the thread it is given does the drawing.
13
13
  */
14
+ import { uid } from '../../core/util.js';
14
15
  import { formatDuration } from '../../internal/agent-model.js';
15
16
  import { applyPatch } from '../../internal/json-patch.js';
16
17
  import { assertCatalog, CATALOG } from '../surface/catalog.js';
@@ -102,10 +103,13 @@ const MAX_TOKEN = 512;
102
103
  /**
103
104
  * @typedef {Object} AgUiOptions
104
105
  * @property {{update: (values: Record<string, unknown>) => unknown}|null} [runStatus=null] A
105
- * RunStatus the run's lifecycle drives: `running` when it starts, `done`, `waiting` (an
106
+ * RunStatus the run's lifecycle drives — its `agent` face, set by the application, takes each
107
+ * state's expression: `running` when it starts, `done`, `waiting` (an
106
108
  * interrupt, or calls of the run still without a result), `stopped` (cancelled) or `failed`.
107
109
  * @property {Record<string, Author>} [authors={}] The thread's authors. A text message whose
108
- * `name` is one of their keys is written by that author; every other item by `agent`.
110
+ * `name` is one of their keys is written by that author; every other item by `agent`. The thread
111
+ * draws them from its own `authors`, so an agent given a `face` there is drawn as its AgentAvatar
112
+ * in every item the adapter writes; the stream itself can never set or change a face.
109
113
  * @property {string|null} [agent=null] The author key of the agent's output; the thread's first
110
114
  * agent when null.
111
115
  * @property {((call: ToolCall) => unknown)|null} [requiresApproval=null] Asked once a call's
@@ -204,12 +208,13 @@ const OPEN_STATES = new Set(['queued', 'running', 'waiting']);
204
208
 
205
209
  /**
206
210
  * @typedef {Object} Message
207
- * @property {string} id
211
+ * @property {string} id Its first answer item: the message id, or an id of its own when the thread
212
+ * already holds that one.
208
213
  * @property {Run} run
209
214
  * @property {boolean} open
210
215
  * @property {boolean} ignored A message of a role the thread does not draw.
211
216
  * @property {string|null} author
212
- * @property {string[]} segments Its answer items: the message id, then `<id>#2`, `<id>#3`…
217
+ * @property {string[]} segments Its answer items: `id`, then `<id>#2`, `<id>#3`…
213
218
  * @property {Set<string>} written Segments that received text.
214
219
  * @property {boolean} afterFence A fence's lines came since the last prose.
215
220
  * @property {Set<string>} pending Surfaces its fences began and did not end.
@@ -254,10 +259,14 @@ const OPEN_STATES = new Set(['queued', 'running', 'waiting']);
254
259
  * interrupt is the application's: the event goes to `onunknown`. A result that arrives before
255
260
  * the decision is drawn as it is, the card expires, and no decision is sent for that call; a
256
261
  * surface still waiting is cancelled the same way.
257
- * - A message id is the answer's item id. A start for a closed message or call reopens it, in this
258
- * run or a later one, and its content continues: a reopened call is asked about again once its
259
- * arguments are complete. A start for an id still open, or for a call already decided or
260
- * answered, is ignored and reported: `ontoolresult` fires once for a call, and a receipt stays.
262
+ * - A message id is the answer's item id. What already holds that id in the thread is never
263
+ * overwritten: an answer the adapter did not draw is taken over, and its content continues as a
264
+ * reopened message's does; anything else — a person's message, a card, a piece of another
265
+ * message — leaves the message an id of its own. A start for a closed message or call reopens
266
+ * it, in this run or a later one, and its content continues: a reopened call is asked about
267
+ * again once its arguments are complete. A start for an id still open, or for a call already
268
+ * decided or answered, is ignored and reported: `ontoolresult` fires once for a call, and a
269
+ * receipt stays.
261
270
  * - A surface is the thread item `surface:<runId>/<surface>`, so a model reusing `s1` in every
262
271
  * run gets a new surface each run. Its token is the application's for a custom event, the tool
263
272
  * call id for a surface tool, and the run id for an inline surface.
@@ -356,6 +365,18 @@ export function connectAgUi(thread, options = {}) {
356
365
  lastPlaced = String(item.id);
357
366
  };
358
367
 
368
+ /** @param {string} id @returns {boolean} Whether the item is an answer piece of a message. */
369
+ const drawnAnswer = (id) => [...messages.values()].some((message) => message.segments.includes(id));
370
+
371
+ /**
372
+ * The id an answer piece goes under: the one asked for while the thread does not hold it,
373
+ * otherwise one of its own, so a stream never overwrites a person's message, a card, or another
374
+ * message's text.
375
+ * @param {string} id
376
+ * @returns {string}
377
+ */
378
+ const freeId = (id) => (thread.get(id) ? uid('zx-ag-ui-message') : id);
379
+
359
380
  /**
360
381
  * The item a call's next item goes after: the last item drawn for this call or an earlier call
361
382
  * of the same trace, else the trace itself.
@@ -722,7 +743,7 @@ export function connectAgUi(thread, options = {}) {
722
743
  rest = rest.replace(/^\s+/, '');
723
744
  if (!rest) return;
724
745
  message.afterFence = false;
725
- const id = `${message.id}#${message.segments.length + 1}`;
746
+ const id = freeId(`${message.id}#${message.segments.length + 1}`);
726
747
  message.segments.push(id);
727
748
  place(/** @type {ThreadItem} */ ({ id, type: 'answer', ...by(message.author), blocks: [], streaming: true }));
728
749
  }
@@ -967,9 +988,13 @@ export function connectAgUi(thread, options = {}) {
967
988
  if (reserved) report('not-allowed', `Message id "${id}" uses a prefix the adapter keeps for its own items; the message was dropped`, { event });
968
989
  const role = event.role ?? 'assistant';
969
990
  const name = typeof event.name === 'string' && Object.hasOwn(authors, event.name) ? event.name : null;
991
+ const ignored = reserved || role !== 'assistant';
992
+ const taken = ignored ? null : /** @type {any} */ (thread.get(id));
993
+ const adopted = taken?.type === 'answer' && !drawnAnswer(id);
994
+ const itemId = taken && !adopted ? uid('zx-ag-ui-message') : id;
970
995
  /** @type {Message} */
971
996
  const message = {
972
- id, run, open: true, ignored: reserved || role !== 'assistant', author: name ?? agent, segments: [id], written: new Set(),
997
+ id: itemId, run, open: true, ignored, author: name ?? agent, segments: [itemId], written: new Set(),
973
998
  afterFence: false, pending: new Set(), surfaces: 0, splitter: null
974
999
  };
975
1000
  messages.set(id, message);
@@ -977,8 +1002,16 @@ export function connectAgUi(thread, options = {}) {
977
1002
  if (!reserved) unknown(event);
978
1003
  return;
979
1004
  }
1005
+ if (adopted) {
1006
+ // An answer already in the thread — from an earlier connection, say — goes on where it
1007
+ // stands, as a reopened message does. Only that answer: an item named like one of its pieces
1008
+ // (`m1#2`) may be another answer altogether, so nothing else is taken over with it.
1009
+ message.written.add(itemId);
1010
+ reopenMessage(message, run);
1011
+ return;
1012
+ }
980
1013
  if (inlineSurfaces) message.splitter = splitterFor(message);
981
- place(/** @type {ThreadItem} */ ({ id, type: 'answer', ...by(message.author), blocks: [], streaming: true }));
1014
+ place(/** @type {ThreadItem} */ ({ id: itemId, type: 'answer', ...by(message.author), blocks: [], streaming: true }));
982
1015
  };
983
1016
 
984
1017
  /** @param {AgUiEvent} event */
@@ -4,9 +4,10 @@ import { h, restoreTarget, snapshotTarget } from '../../core/dom.js';
4
4
  import { formatFileSize } from '../../core/format.js';
5
5
  import { icon } from '../../core/icons.js';
6
6
  import { isEditableTarget } from '../../core/keyboard.js';
7
- import { escapeRegExp, uid } from '../../core/util.js';
8
- import { AGENT_MESSAGES, initialsOf } from '../../internal/agent-model.js';
7
+ import { uid } from '../../core/util.js';
8
+ import { AGENT_MESSAGES, agentAvatarOptions, authorFace, initialsOf, mentionPattern } from '../../internal/agent-model.js';
9
9
  import { ApprovalCard } from '../approval-card/approval-card.js';
10
+ import { AgentAvatar } from '../agent-avatar/agent-avatar.js';
10
11
  import { Avatar } from '../avatar/avatar.js';
11
12
  import { BlockView } from '../block-view/block-view.js';
12
13
  import { copyButton } from '../copy/copy-button.js';
@@ -260,7 +261,25 @@ export class AgentThread extends Component {
260
261
  this._scrollHost = null;
261
262
  /** @type {EventTarget|null} */
262
263
  this._scrollTarget = null;
263
- this._onScroll = () => { if (this._atEnd()) this._latestButton.hidden = true; };
264
+ this._onScroll = () => {
265
+ const end = this._atEnd();
266
+ const top = this._scrollHost?.scrollTop ?? 0;
267
+ // Only scrolling back lets go of the end. A scroll toward it — the thread's own, or the
268
+ // browser keeping the view anchored while content grows — never does, though it may land
269
+ // short of the end until the growth is followed.
270
+ if (end) this._stick = true;
271
+ else if (top < this._lastTop) this._stick = false;
272
+ this._lastTop = top;
273
+ if (end) this._latestButton.hidden = true;
274
+ };
275
+ /** Whether the reader stays with the end: set by their scrolling and by every follow. */
276
+ this._stick = true;
277
+ /** Where the scroller stood at the last scroll, to tell scrolling back from scrolling on. */
278
+ this._lastTop = 0;
279
+ /** @type {ResizeObserver|null} Watches the surfaces still being streamed into, while they grow. */
280
+ this._growth = null;
281
+ /** @type {Map<Element, number>} Each watched surface's height when it was last measured. */
282
+ this._heights = new Map();
264
283
  /** @type {string|null} */
265
284
  this._latestAnswer = null;
266
285
  /** @type {Map<string, {expanded?: boolean|null, controls?: string|null}>} Artifact open states, for answers drawn later. */
@@ -586,6 +605,7 @@ export class AgentThread extends Component {
586
605
  const scroller = this._scroller();
587
606
  if (scroller) scroller.scrollTop = scroller.scrollHeight;
588
607
  this._latestButton.hidden = true;
608
+ this._stick = true;
589
609
  return this;
590
610
  }
591
611
 
@@ -594,6 +614,9 @@ export class AgentThread extends Component {
594
614
  if (this._destroyed) return;
595
615
  this._destroyed = true;
596
616
  clearTimeout(this._announceTimer);
617
+ this._growth?.disconnect();
618
+ this._growth = null;
619
+ this._heights.clear();
597
620
  this._scrollTarget?.removeEventListener('scroll', this._onScroll);
598
621
  this._scrollTarget = null;
599
622
  this._scrollHost = null;
@@ -1122,13 +1145,14 @@ export class AgentThread extends Component {
1122
1145
  own(surface);
1123
1146
  if (!kept) {
1124
1147
  this._contain(surface, ['reply', 'error', 'change', 'ready', 'end']);
1125
- // A streamed surface says what it is only once it begins.
1148
+ // A streamed surface says what it is only once it begins, and grows as its operations arrive.
1126
1149
  if (!item.document) {
1127
1150
  surface.on('ready', () => {
1128
1151
  if (!surface.getReply() && asksForAnswer(surface.toDocument()?.intent)) {
1129
1152
  this._announce(this.msg('agentThread.needsAnswer', this._authorName(item)), true);
1130
1153
  }
1131
1154
  });
1155
+ this._watchGrowth(surface);
1132
1156
  }
1133
1157
  surface.on('reply', (event) => {
1134
1158
  if (this._answeredElsewhere.has(surface)) return;
@@ -1152,11 +1176,20 @@ export class AgentThread extends Component {
1152
1176
  _avatar(item, own) {
1153
1177
  const author = this._author(item);
1154
1178
  if (!author) return null;
1155
- if (author.icon) {
1179
+ const face = authorFace(author);
1180
+ if (!face && author.icon) {
1156
1181
  return h('span', { class: 'zx-agent-thread__avatar' },
1157
1182
  h('span', { class: 'zx-agent-thread__mark', dataset: { tone: author.tone ?? null, kind: author.kind ?? 'agent' }, 'aria-hidden': 'true' },
1158
1183
  icon(String(author.icon), { size: 14 })));
1159
1184
  }
1185
+ if (face) {
1186
+ // Only the face's own traits are read from the author, which may be an agent's data; how
1187
+ // the avatar is drawn and named belongs to the thread: still, decorative, beside the byline.
1188
+ const agent = own(new AgentAvatar(null, agentAvatarOptions(face, {
1189
+ name: author.name, size: 'sm', label: null, animate: false, activity: author.activity ?? null
1190
+ }, { fallback: { tone: author.tone ?? null } })));
1191
+ return h('span', { class: 'zx-agent-thread__avatar' }, agent.toElement());
1192
+ }
1160
1193
  const avatar = own(new Avatar(null, {
1161
1194
  name: author.name, initials: author.initials ?? initialsOf(author.name), tone: /** @type {any} */ (author.tone ?? null),
1162
1195
  size: 'sm', shape: author.kind === 'person' ? 'circle' : 'rounded', activity: author.activity ?? null
@@ -1394,6 +1427,7 @@ export class AgentThread extends Component {
1394
1427
  this._scrollTarget?.removeEventListener('scroll', this._onScroll);
1395
1428
  this._scrollHost = node;
1396
1429
  this._scrollTarget = target;
1430
+ this._lastTop = node?.scrollTop ?? 0;
1397
1431
  if (target) this.listen(target, 'scroll', this._onScroll, { passive: true });
1398
1432
  }
1399
1433
  return this._scrollHost;
@@ -1413,11 +1447,71 @@ export class AgentThread extends Component {
1413
1447
  * @returns {void}
1414
1448
  */
1415
1449
  _follow(change) {
1450
+ // A streamed surface that grew since it was last measured is followed first, so a reader who
1451
+ // was at the end still is when this change is measured.
1452
+ for (const element of [...this._heights.keys()]) this._grown(element);
1416
1453
  const follow = this.options.followOutput && this.el.isConnected && this._atEnd();
1417
1454
  change();
1418
1455
  if (!this.options.followOutput || !this.el.isConnected) return;
1419
- if (follow) this.scrollToEnd();
1420
- else if (!this._atEnd()) this._latestButton.hidden = false;
1456
+ if (follow) {
1457
+ this.scrollToEnd();
1458
+ return;
1459
+ }
1460
+ this._stick = this._atEnd();
1461
+ if (!this._stick) this._latestButton.hidden = false;
1462
+ }
1463
+
1464
+ /**
1465
+ * Follows a surface streamed into through `surface(id)` as the thread's own updates are followed:
1466
+ * what its operations add keeps the end in view while the reader is reading it, and offers
1467
+ * "Jump to latest" otherwise. The surface says nothing per operation, and is fed from outside
1468
+ * the thread, so its size is watched rather than the calls. Watching stops once its `end` has
1469
+ * arrived or it has replied: what changes it after that is the reader's doing, and stays where
1470
+ * they put it.
1471
+ * @private
1472
+ * @param {Surface} surface
1473
+ * @returns {void}
1474
+ */
1475
+ _watchGrowth(surface) {
1476
+ if (!this.options.followOutput || typeof ResizeObserver !== 'function') return;
1477
+ const element = surface.toElement();
1478
+ this._growth ??= new ResizeObserver((entries) => {
1479
+ for (const entry of entries) this._grown(entry.target);
1480
+ });
1481
+ // Drawn into a thread on the page, the surface grows from nothing; drawn before the thread is
1482
+ // placed, it is measured first when it is.
1483
+ this._heights.set(element, this.el.isConnected ? 0 : Number.NaN);
1484
+ this._growth.observe(element);
1485
+ const unwatch = () => {
1486
+ this._heights.delete(element);
1487
+ this._growth?.unobserve(element);
1488
+ };
1489
+ // The last operation's growth is taken at once, before the observer lets go.
1490
+ surface.on('end', () => {
1491
+ this._grown(element);
1492
+ unwatch();
1493
+ });
1494
+ surface.on('reply', unwatch);
1495
+ }
1496
+
1497
+ /**
1498
+ * A watched surface may have grown since it was last measured. The reader was at the end if,
1499
+ * measured now, nothing but the growth lies past what they see, and they had not scrolled away.
1500
+ * @private
1501
+ * @param {Element} element
1502
+ * @returns {void}
1503
+ */
1504
+ _grown(element) {
1505
+ const before = this._heights.get(element);
1506
+ if (before === undefined || this._destroyed) return;
1507
+ const height = /** @type {HTMLElement} */ (element).offsetHeight;
1508
+ this._heights.set(element, height);
1509
+ if (Number.isNaN(before) || height <= before || !this.options.followOutput || !this.el.isConnected) return;
1510
+ const scroller = this._scroller();
1511
+ if (!scroller) return;
1512
+ const gap = scroller.scrollHeight - scroller.scrollTop - scroller.clientHeight;
1513
+ if (this._stick && gap - (height - before) <= END_SLACK) this.scrollToEnd();
1514
+ else if (gap > END_SLACK) this._latestButton.hidden = false;
1421
1515
  }
1422
1516
 
1423
1517
  /** @private @returns {HTMLElement|null} */
@@ -1584,10 +1678,8 @@ function withMentions(text, mentions) {
1584
1678
  const name = String(typeof mention === 'object' && mention ? mention.name ?? '' : mention ?? '').trim();
1585
1679
  if (name) tones.set(name, typeof mention === 'object' && mention?.tone ? String(mention.tone) : null);
1586
1680
  }
1587
- const names = [...tones.keys()];
1588
- if (!names.length) return [text];
1589
- const escaped = names.sort((a, b) => b.length - a.length).map((name) => escapeRegExp(name));
1590
- const pattern = new RegExp(`@(?:${escaped.join('|')})(?![\\w])`, 'g');
1681
+ const pattern = mentionPattern(tones.keys());
1682
+ if (!pattern) return [text];
1591
1683
  /** @type {Array<Node|string>} */
1592
1684
  const out = [];
1593
1685
  let from = 0;
@@ -44,7 +44,9 @@ export const UI_MESSAGE_STREAM_VERSION = 'v1';
44
44
  * @typedef {Object} UiMessageStreamOptions
45
45
  * @property {RunStatus|null} [runStatus=null] A run status to keep up to date.
46
46
  * @property {Record<string, Author>} [authors={}] Who writes; its first author who is not a person
47
- * is the agent when `agent` is not given.
47
+ * is the agent when `agent` is not given. The thread draws authors from its own `authors`, so an
48
+ * agent given a `face` there is drawn as its AgentAvatar in every item the stream writes; the
49
+ * stream itself can never set or change a face.
48
50
  * @property {string|null} [agent=null] Author key of the assistant's output.
49
51
  * @property {Record<string, (call: ToolCall) => ThreadItem|null>} [tools={}] Tiles by tool name: the
50
52
  * application's renderer for a tool's calls, called at each status change. Its item joins the
@@ -82,6 +82,9 @@
82
82
 
83
83
  .zx-app-rail__item-label { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); }
84
84
  .zx-app-rail__item-icon { display: inline-flex; }
85
+
86
+ /* An agent item draws its AgentAvatar at the size of an icon slot. */
87
+ .zx-app-rail__item-icon > .zx-agent-avatar { --zx-agent-avatar-size: var(--zx-space-6); }
85
88
  .zx-app-rail__item-badge {
86
89
  position: absolute;
87
90
  inset-inline-end: 1px;
@@ -206,6 +209,8 @@
206
209
  color: inherit;
207
210
  }
208
211
 
212
+ .zx-app-rail__flyout-item-icon > .zx-agent-avatar { --zx-agent-avatar-size: var(--zx-app-rail-icon); }
213
+
209
214
  .zx-app-rail__flyout-item-label {
210
215
  grid-column: 2;
211
216
  min-inline-size: 0;
@@ -257,6 +257,9 @@
257
257
  color: inherit;
258
258
  }
259
259
 
260
+ /* An agent item draws its AgentAvatar at the size of the icon column. */
261
+ .zx-app-sidebar__item-icon > .zx-agent-avatar { --zx-agent-avatar-size: var(--zx-app-sidebar-icon); }
262
+
260
263
  /* No nowrap and no ellipsis: the row grows instead. `hyphens` is what makes that bearable for a
261
264
  German compound — where the document declares a language the browser breaks "Rechnungsausgang"
262
265
  at a syllable, and `overflow-wrap` is only the last resort behind it for a word that fits
@@ -5,7 +5,7 @@ import { ICON_SIZE, icon } from '../../core/icons.js';
5
5
  import { uid } from '../../core/util.js';
6
6
  import { renderRowActions, rowActionMenu, setRowActionsTabbable } from '../../internal/row-actions.js';
7
7
  import {
8
- AppRailPresenter as MinimizedPresenter, appNavIcon, normalizeAppItems
8
+ AppRailPresenter as MinimizedPresenter, appNavAgentWord, appNavIcon, appNavName, normalizeAppItems
9
9
  } from '../../internal/app-rail.js';
10
10
  import { ModuleBar, liftSections, moduleOf } from '../module-bar/module-bar.js';
11
11
  import { Tooltip } from '../tooltip/tooltip.js';
@@ -930,8 +930,8 @@ export class AppSidebar extends Component {
930
930
  if (!item || item.badge == null) continue;
931
931
  const count = String(item.badge);
932
932
  badge.dataset.zxBadge = count.length > 2 ? 'dot' : 'count';
933
- control.setAttribute('aria-label',
934
- this._message('appSidebar.itemBadge', '%1 (%2)', item.label, count));
933
+ const name = appNavName(item, control.querySelector(':scope > .zx-app-rail__item-icon > .zx-agent-avatar'));
934
+ control.setAttribute('aria-label', this._message('appSidebar.itemBadge', '%1 (%2)', name, count));
935
935
  }
936
936
  }
937
937
 
@@ -1245,6 +1245,7 @@ function navControl(item, disclosure, expanded, controls, visual) {
1245
1245
  type: tag === 'button' ? 'button' : null,
1246
1246
  href: tag === 'a' ? item.href : null,
1247
1247
  target: tag === 'a' ? item.target ?? null : null,
1248
+ ariaLabel: appNavAgentWord(visual) ? appNavName(item, visual, true) : null,
1248
1249
  ariaDisabled: item.disabled ? 'true' : null,
1249
1250
  ariaExpanded: disclosure ? String(expanded) : null,
1250
1251
  ariaControls: controls,
@@ -71,6 +71,12 @@
71
71
  .zx-approval-card__tile[data-tone="pink"] { background: var(--zx-color-tone-pink-bg); color: var(--zx-color-tone-pink-fg); }
72
72
  .zx-approval-card__tile[data-tone="violet"] { background: var(--zx-color-tone-violet-bg); color: var(--zx-color-tone-violet-fg); }
73
73
 
74
+ /* An agent's face stands on its own: no tile behind it. */
75
+ .zx-approval-card__tile[data-agent] {
76
+ border-radius: 0;
77
+ background: none;
78
+ }
79
+
74
80
  .zx-approval-card__titles {
75
81
  display: grid;
76
82
  grid-area: titles;
@@ -6,7 +6,8 @@ import { translate } from '../../core/i18n.js';
6
6
  import { icon } from '../../core/icons.js';
7
7
  import { isEditableTarget } from '../../core/keyboard.js';
8
8
  import { uid } from '../../core/util.js';
9
- import { STATUS } from '../../internal/agent-model.js';
9
+ import { RUN_ACTIVITY, STATUS, agentAvatarOptions } from '../../internal/agent-model.js';
10
+ import { AgentAvatar } from '../agent-avatar/agent-avatar.js';
10
11
  import { renderBlocks } from '../block-view/block-view.js';
11
12
  import { button } from '../button/button.js';
12
13
  import { Dialog } from '../dialog/dialog.js';
@@ -16,6 +17,7 @@ import { statusIcon } from '../select/glyphs.js';
16
17
 
17
18
  /** @typedef {import('../../internal/agent-model.js').Block} Block */
18
19
  /** @typedef {import('../field/field.js').FieldOptions} FieldOptions */
20
+ /** @typedef {import('../../internal/agent-model.js').AgentFace} AgentFace */
19
21
 
20
22
  /**
21
23
  * Where a request stands: waiting for an answer, or answered — approved, rejected, or expired
@@ -48,6 +50,12 @@ import { statusIcon } from '../select/glyphs.js';
48
50
  * @property {string} [description=''] One line under the title: what follows from approving.
49
51
  * @property {string|null} [icon=null] Icon name for the tile beside the title; none when null.
50
52
  * @property {ApprovalTone} [tone='blue'] Categorical tone of the icon tile.
53
+ * @property {AgentFace|true|null} [agent=null] The agent that asks, drawn as its AgentAvatar face in
54
+ * place of the icon tile: its traits and name, or `true` to derive the face from the title. The
55
+ * face is keyed by the agent's `seed`, else its `name`; without either it is named after the
56
+ * title it is given with, and a later title never changes it. The face looks up at you while
57
+ * the request waits and rests once it is answered; it is decorative, so the title and
58
+ * description say what is asked.
51
59
  * @property {2|3|4|5|6} [headingLevel=3] Element level of the title heading.
52
60
  * @property {ApprovalStatus} [status='pending'] Where the request stands.
53
61
  * @property {Node|Block[]|null} [details=null] What will happen — recipients, amounts, records —
@@ -86,7 +94,7 @@ import { statusIcon } from '../select/glyphs.js';
86
94
  /**
87
95
  * What `update()` changes: any of these options, the rest staying as they are. The status goes
88
96
  * through `setStatus()`.
89
- * @typedef {Pick<ApprovalCardOptions, 'title'|'description'|'icon'|'tone'|'details'|'preview'
97
+ * @typedef {Pick<ApprovalCardOptions, 'title'|'description'|'icon'|'tone'|'agent'|'details'|'preview'
90
98
  * |'fields'|'values'|'confirmText'|'reason'|'edited'|'editedKeys'>} ApprovalCardUpdate
91
99
  */
92
100
 
@@ -191,6 +199,7 @@ export class ApprovalCard extends Component {
191
199
  description: '',
192
200
  icon: null,
193
201
  tone: 'blue',
202
+ agent: null,
194
203
  headingLevel: 3,
195
204
  status: 'pending',
196
205
  details: null,
@@ -245,6 +254,12 @@ export class ApprovalCard extends Component {
245
254
  /** @type {string|null} */
246
255
  this._icon = textOrNull(options.icon);
247
256
  this._tone = normalizeTone(options.tone);
257
+ /** @type {Record<string, any>|null} The face asked for, as traits; it wins over the icon. */
258
+ this._face = agentAvatarOptions(options.agent);
259
+ /** What names a face that has no seed or name: the title it was given with. */
260
+ this._faceName = this._title;
261
+ /** @type {AgentAvatar|null} */
262
+ this._avatar = null;
248
263
  this._confirmText = confirmTextOf(options.confirmText);
249
264
  /** @type {unknown} What `details` was drawn from, to compare an update against. */
250
265
  this._details = null;
@@ -348,12 +363,15 @@ export class ApprovalCard extends Component {
348
363
  this._drawDescription();
349
364
  }
350
365
  }
351
- if (has('icon') || has('tone')) {
366
+ if (has('icon') || has('tone') || has('agent')) {
352
367
  const name = has('icon') ? textOrNull(partial.icon) : this._icon;
353
368
  const tone = has('tone') ? normalizeTone(partial.tone) : this._tone;
354
- if (name !== this._icon || tone !== this._tone) {
369
+ const face = has('agent') ? agentAvatarOptions(partial.agent) : this._face;
370
+ if (name !== this._icon || tone !== this._tone || !sameValue(face, this._face)) {
355
371
  this._icon = name;
356
372
  this._tone = tone;
373
+ if (!sameValue(face, this._face)) this._faceName = this._title;
374
+ this._face = face;
357
375
  this._drawTile();
358
376
  }
359
377
  }
@@ -502,6 +520,8 @@ export class ApprovalCard extends Component {
502
520
  this._destroyed = true;
503
521
  this._confirm?.destroy();
504
522
  this._confirm = null;
523
+ this._avatar?.destroy();
524
+ this._avatar = null;
505
525
  if (this._editor) {
506
526
  this._editor.fieldset.destroy();
507
527
  this._editor.dialog.destroy();
@@ -812,17 +832,34 @@ export class ApprovalCard extends Component {
812
832
  return this._by ?? this.msg('approvalCard.you');
813
833
  }
814
834
 
815
- /** @private @returns {void} Draws the icon tile, or takes it away when there is no icon. */
835
+ /**
836
+ * Draws the icon tile — or the agent's face, which takes its place — or takes it away when there
837
+ * is neither.
838
+ * @private
839
+ * @returns {void}
840
+ */
816
841
  _drawTile() {
817
842
  const name = this._icon;
818
- if (!name) {
843
+ const face = this._face;
844
+ this._avatar?.destroy();
845
+ this._avatar = null;
846
+ if (!name && !face) {
819
847
  this._tileEl?.remove();
820
848
  this._tileEl = null;
821
849
  return;
822
850
  }
823
851
  const tile = this._tileEl ?? h('span', { class: 'zx-approval-card__tile', 'aria-hidden': 'true' });
824
852
  tile.dataset.tone = this._tone;
825
- tile.replaceChildren(icon(name, { size: 14 }));
853
+ if (face) {
854
+ tile.dataset.agent = '';
855
+ this._avatar = new AgentAvatar(null, agentAvatarOptions(face, {
856
+ size: 'sm', label: null, indicator: false, animate: false, activity: this._faceActivity()
857
+ }, { fallback: { name: this._faceName } }));
858
+ tile.replaceChildren(this._avatar.toElement());
859
+ } else {
860
+ delete tile.dataset.agent;
861
+ tile.replaceChildren(icon(/** @type {string} */ (name), { size: 14 }));
862
+ }
826
863
  if (!this._tileEl) this._headEl.prepend(tile);
827
864
  this._tileEl = tile;
828
865
  }
@@ -913,6 +950,17 @@ export class ApprovalCard extends Component {
913
950
  _sync() {
914
951
  this._drawState();
915
952
  this._drawChanges();
953
+ this._avatar?.setActivity(this._faceActivity());
954
+ }
955
+
956
+ /**
957
+ * The expression of the agent's face: the one a run takes in the state the status is drawn as —
958
+ * looking up at you while the request waits, at rest once it is answered.
959
+ * @private
960
+ * @returns {import('../../internal/agent-model.js').AgentActivity}
961
+ */
962
+ _faceActivity() {
963
+ return RUN_ACTIVITY[APPROVAL_STATES[this._status]];
916
964
  }
917
965
 
918
966
  /**