@sixb/app 0.2.1 → 0.2.4

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 (494) hide show
  1. package/dist/agent/activity-label.d.ts.map +1 -1
  2. package/dist/agent/agent-chat.d.ts +9 -2
  3. package/dist/agent/agent-chat.d.ts.map +1 -1
  4. package/dist/agent/agent-panel.d.ts +9 -1
  5. package/dist/agent/agent-panel.d.ts.map +1 -1
  6. package/dist/agent/agent-surface.d.ts.map +1 -1
  7. package/dist/agent/artifact-card.d.ts +3 -1
  8. package/dist/agent/artifact-card.d.ts.map +1 -1
  9. package/dist/agent/artifact-panel.d.ts +7 -1
  10. package/dist/agent/artifact-panel.d.ts.map +1 -1
  11. package/dist/agent/background/background-tool-row.d.ts.map +1 -1
  12. package/dist/agent/background/interpret.d.ts +1 -1
  13. package/dist/agent/background/interpret.d.ts.map +1 -1
  14. package/dist/agent/components/composer-place.d.ts +3 -1
  15. package/dist/agent/components/composer-place.d.ts.map +1 -1
  16. package/dist/agent/components/composer.d.ts +20 -1
  17. package/dist/agent/components/composer.d.ts.map +1 -1
  18. package/dist/agent/components/context-chips.d.ts.map +1 -1
  19. package/dist/agent/components/context-meter.d.ts +1 -1
  20. package/dist/agent/components/conversation-panel.d.ts +7 -2
  21. package/dist/agent/components/conversation-panel.d.ts.map +1 -1
  22. package/dist/agent/components/message-parts.d.ts +3 -1
  23. package/dist/agent/components/message-parts.d.ts.map +1 -1
  24. package/dist/agent/components/thread-artifacts-menu.d.ts.map +1 -1
  25. package/dist/agent/components/transcript.d.ts +5 -0
  26. package/dist/agent/components/transcript.d.ts.map +1 -1
  27. package/dist/agent/composer-insertion.d.ts +24 -0
  28. package/dist/agent/composer-insertion.d.ts.map +1 -0
  29. package/dist/agent/delegation/agent-exchange.d.ts +16 -0
  30. package/dist/agent/delegation/agent-exchange.d.ts.map +1 -0
  31. package/dist/agent/delegation/child-card.d.ts +3 -3
  32. package/dist/agent/delegation/child-card.d.ts.map +1 -1
  33. package/dist/agent/delegation/child-parts.d.ts +1 -10
  34. package/dist/agent/delegation/child-parts.d.ts.map +1 -1
  35. package/dist/agent/delegation/child-work.d.ts.map +1 -1
  36. package/dist/agent/delegation/interpret.d.ts +4 -10
  37. package/dist/agent/delegation/interpret.d.ts.map +1 -1
  38. package/dist/agent/delegation/use-children.d.ts +5 -5
  39. package/dist/agent/delegation/use-children.d.ts.map +1 -1
  40. package/dist/agent/file-edits/file-edit-tool-view.d.ts +10 -0
  41. package/dist/agent/file-edits/file-edit-tool-view.d.ts.map +1 -0
  42. package/dist/agent/file-edits/interpret.d.ts +25 -0
  43. package/dist/agent/file-edits/interpret.d.ts.map +1 -0
  44. package/dist/agent/hooks/use-agent-conversation.d.ts +16 -4
  45. package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
  46. package/dist/agent/hooks/use-new-thread-place.d.ts +39 -17
  47. package/dist/agent/hooks/use-new-thread-place.d.ts.map +1 -1
  48. package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
  49. package/dist/agent/i18n/en.d.ts +59 -4
  50. package/dist/agent/i18n/en.d.ts.map +1 -1
  51. package/dist/agent/i18n/fr.d.ts.map +1 -1
  52. package/dist/agent/i18n/index.d.ts +96 -8
  53. package/dist/agent/i18n/index.d.ts.map +1 -1
  54. package/dist/agent/message-agent/interpret.d.ts +2 -2
  55. package/dist/agent/message-agent/interpret.d.ts.map +1 -1
  56. package/dist/agent/publish-artifact/interpret.d.ts +8 -2
  57. package/dist/agent/publish-artifact/interpret.d.ts.map +1 -1
  58. package/dist/agent/publish-artifact/open-artifact-tool-view.d.ts +9 -0
  59. package/dist/agent/publish-artifact/open-artifact-tool-view.d.ts.map +1 -0
  60. package/dist/agent/publish-artifact/publish-artifact-tool-view.d.ts +4 -2
  61. package/dist/agent/publish-artifact/publish-artifact-tool-view.d.ts.map +1 -1
  62. package/dist/agent/publish-artifact/use-live-publishes.d.ts +3 -3
  63. package/dist/agent/publish-artifact/use-live-publishes.d.ts.map +1 -1
  64. package/dist/agent/questions/interpret.d.ts +31 -0
  65. package/dist/agent/questions/interpret.d.ts.map +1 -0
  66. package/dist/agent/questions/question-card.d.ts +16 -0
  67. package/dist/agent/questions/question-card.d.ts.map +1 -0
  68. package/dist/agent/questions/question-composer.d.ts +15 -0
  69. package/dist/agent/questions/question-composer.d.ts.map +1 -0
  70. package/dist/agent/read/interpret.d.ts +8 -1
  71. package/dist/agent/read/interpret.d.ts.map +1 -1
  72. package/dist/agent/read/read-tool-view.d.ts.map +1 -1
  73. package/dist/agent/tool-views/built-in.d.ts.map +1 -1
  74. package/dist/agent/types.d.ts +3 -1
  75. package/dist/agent/types.d.ts.map +1 -1
  76. package/dist/agent/waits.d.ts +14 -0
  77. package/dist/agent/waits.d.ts.map +1 -0
  78. package/dist/artifacts/artifact-page.d.ts.map +1 -1
  79. package/dist/artifacts/artifact-viewer.d.ts +16 -0
  80. package/dist/artifacts/artifact-viewer.d.ts.map +1 -0
  81. package/dist/artifacts/card-details.d.ts +1 -1
  82. package/dist/artifacts/card-details.d.ts.map +1 -1
  83. package/dist/artifacts/card-preview.d.ts.map +1 -1
  84. package/dist/artifacts/comments-context.d.ts +48 -0
  85. package/dist/artifacts/comments-context.d.ts.map +1 -0
  86. package/dist/artifacts/edit-session.d.ts +17 -7
  87. package/dist/artifacts/edit-session.d.ts.map +1 -1
  88. package/dist/artifacts/file-source.d.ts.map +1 -1
  89. package/dist/artifacts/frame.d.ts +10 -2
  90. package/dist/artifacts/frame.d.ts.map +1 -1
  91. package/dist/artifacts/guest-badge.d.ts +8 -0
  92. package/dist/artifacts/guest-badge.d.ts.map +1 -0
  93. package/dist/artifacts/held-artifact.d.ts +19 -0
  94. package/dist/artifacts/held-artifact.d.ts.map +1 -0
  95. package/dist/artifacts/holders.d.ts +10 -0
  96. package/dist/artifacts/holders.d.ts.map +1 -0
  97. package/dist/artifacts/live/boards.d.ts +15 -0
  98. package/dist/artifacts/live/boards.d.ts.map +1 -0
  99. package/dist/artifacts/live/canvas.d.ts +79 -0
  100. package/dist/artifacts/live/canvas.d.ts.map +1 -0
  101. package/dist/artifacts/live/header.d.ts +29 -0
  102. package/dist/artifacts/live/header.d.ts.map +1 -0
  103. package/dist/artifacts/live/hooks.d.ts +21 -0
  104. package/dist/artifacts/live/hooks.d.ts.map +1 -0
  105. package/dist/artifacts/live/presence.d.ts +32 -0
  106. package/dist/artifacts/live/presence.d.ts.map +1 -0
  107. package/dist/artifacts/live/session.d.ts +130 -0
  108. package/dist/artifacts/live/session.d.ts.map +1 -0
  109. package/dist/artifacts/live/view.d.ts +28 -0
  110. package/dist/artifacts/live/view.d.ts.map +1 -0
  111. package/dist/artifacts/messages.d.ts +476 -14
  112. package/dist/artifacts/messages.d.ts.map +1 -1
  113. package/dist/artifacts/page-queries.d.ts +2 -2
  114. package/dist/artifacts/page-queries.d.ts.map +1 -1
  115. package/dist/artifacts/page-state.d.ts.map +1 -1
  116. package/dist/artifacts/publish-edit.d.ts +24 -14
  117. package/dist/artifacts/publish-edit.d.ts.map +1 -1
  118. package/dist/artifacts/queries.d.ts +490 -9
  119. package/dist/artifacts/queries.d.ts.map +1 -1
  120. package/dist/artifacts/references/references.d.ts.map +1 -1
  121. package/dist/artifacts/renderers/canvas/arrows.d.ts +0 -18
  122. package/dist/artifacts/renderers/canvas/arrows.d.ts.map +1 -1
  123. package/dist/artifacts/renderers/canvas/board-editor.d.ts +50 -0
  124. package/dist/artifacts/renderers/canvas/board-editor.d.ts.map +1 -0
  125. package/dist/artifacts/renderers/canvas/board-properties.d.ts +37 -0
  126. package/dist/artifacts/renderers/canvas/board-properties.d.ts.map +1 -0
  127. package/dist/artifacts/renderers/canvas/board-source.d.ts +18 -0
  128. package/dist/artifacts/renderers/canvas/board-source.d.ts.map +1 -0
  129. package/dist/artifacts/renderers/canvas/board.d.ts +77 -20
  130. package/dist/artifacts/renderers/canvas/board.d.ts.map +1 -1
  131. package/dist/artifacts/renderers/canvas/canvas.d.ts +14 -4
  132. package/dist/artifacts/renderers/canvas/canvas.d.ts.map +1 -1
  133. package/dist/artifacts/renderers/canvas/comment-pins.d.ts +84 -0
  134. package/dist/artifacts/renderers/canvas/comment-pins.d.ts.map +1 -0
  135. package/dist/artifacts/renderers/canvas/commenting.d.ts +58 -0
  136. package/dist/artifacts/renderers/canvas/commenting.d.ts.map +1 -0
  137. package/dist/artifacts/renderers/canvas/comments-panel.d.ts +27 -0
  138. package/dist/artifacts/renderers/canvas/comments-panel.d.ts.map +1 -0
  139. package/dist/artifacts/renderers/canvas/comments.d.ts +56 -0
  140. package/dist/artifacts/renderers/canvas/comments.d.ts.map +1 -0
  141. package/dist/artifacts/renderers/canvas/controls.d.ts +15 -4
  142. package/dist/artifacts/renderers/canvas/controls.d.ts.map +1 -1
  143. package/dist/artifacts/renderers/canvas/draft.d.ts +7 -6
  144. package/dist/artifacts/renderers/canvas/draft.d.ts.map +1 -1
  145. package/dist/artifacts/renderers/canvas/edit-mode.d.ts +19 -2
  146. package/dist/artifacts/renderers/canvas/edit-mode.d.ts.map +1 -1
  147. package/dist/artifacts/renderers/canvas/focus.d.ts +54 -5
  148. package/dist/artifacts/renderers/canvas/focus.d.ts.map +1 -1
  149. package/dist/artifacts/renderers/canvas/gestures.d.ts +46 -0
  150. package/dist/artifacts/renderers/canvas/gestures.d.ts.map +1 -0
  151. package/dist/artifacts/renderers/canvas/items.d.ts +47 -4
  152. package/dist/artifacts/renderers/canvas/items.d.ts.map +1 -1
  153. package/dist/artifacts/renderers/canvas/layout.d.ts +5 -8
  154. package/dist/artifacts/renderers/canvas/layout.d.ts.map +1 -1
  155. package/dist/artifacts/renderers/canvas/page-resize.d.ts +21 -0
  156. package/dist/artifacts/renderers/canvas/page-resize.d.ts.map +1 -0
  157. package/dist/artifacts/renderers/canvas/page-size-controls.d.ts +21 -0
  158. package/dist/artifacts/renderers/canvas/page-size-controls.d.ts.map +1 -0
  159. package/dist/artifacts/renderers/canvas/page-size.d.ts +93 -0
  160. package/dist/artifacts/renderers/canvas/page-size.d.ts.map +1 -0
  161. package/dist/artifacts/renderers/canvas/page-zoom.d.ts +64 -0
  162. package/dist/artifacts/renderers/canvas/page-zoom.d.ts.map +1 -0
  163. package/dist/artifacts/renderers/canvas/presence.d.ts +21 -0
  164. package/dist/artifacts/renderers/canvas/presence.d.ts.map +1 -0
  165. package/dist/artifacts/renderers/canvas/previews.d.ts +54 -0
  166. package/dist/artifacts/renderers/canvas/previews.d.ts.map +1 -0
  167. package/dist/artifacts/renderers/canvas/renderer.d.ts +11 -2
  168. package/dist/artifacts/renderers/canvas/renderer.d.ts.map +1 -1
  169. package/dist/artifacts/renderers/canvas/shown-size.d.ts +26 -0
  170. package/dist/artifacts/renderers/canvas/shown-size.d.ts.map +1 -0
  171. package/dist/artifacts/renderers/canvas/thumbnail.d.ts +5 -2
  172. package/dist/artifacts/renderers/canvas/thumbnail.d.ts.map +1 -1
  173. package/dist/artifacts/version-menu.d.ts +19 -0
  174. package/dist/artifacts/version-menu.d.ts.map +1 -0
  175. package/dist/artifacts/view-context.d.ts +43 -0
  176. package/dist/artifacts/view-context.d.ts.map +1 -0
  177. package/dist/artifacts/viewer.d.ts.map +1 -1
  178. package/dist/build.d.ts +5 -0
  179. package/dist/build.d.ts.map +1 -1
  180. package/dist/chunk-00wggsst.js +7 -0
  181. package/dist/chunk-00wggsst.js.map +10 -0
  182. package/dist/{chunk-q69001w3.js → chunk-694m74s7.js} +7 -1
  183. package/dist/{chunk-q69001w3.js.map → chunk-694m74s7.js.map} +3 -3
  184. package/dist/{chunk-7fj9cfkw.js → chunk-970s5nkn.js} +1 -1
  185. package/dist/{chunk-4mprsd2n.js → chunk-fg6thecb.js} +25 -1
  186. package/dist/chunk-fg6thecb.js.map +10 -0
  187. package/dist/{chunk-ytadd0b5.js → chunk-kymx9y5e.js} +8126 -4257
  188. package/dist/chunk-kymx9y5e.js.map +211 -0
  189. package/dist/{chunk-j8g956dt.js → chunk-pxd07kvx.js} +1 -1
  190. package/dist/{chunk-kwbw4dyk.js → chunk-ryed2jq8.js} +1 -1
  191. package/dist/chunk-yrcm1pbg.js +5975 -0
  192. package/dist/chunk-yrcm1pbg.js.map +34 -0
  193. package/dist/codegen.d.ts.map +1 -1
  194. package/dist/createCustomApp.d.ts.map +1 -1
  195. package/dist/index.d.ts +9 -1
  196. package/dist/index.d.ts.map +1 -1
  197. package/dist/index.js +932 -309
  198. package/dist/index.js.map +15 -10
  199. package/dist/locale-messages.d.ts +12 -0
  200. package/dist/locale-messages.d.ts.map +1 -1
  201. package/dist/locale.d.ts +12 -0
  202. package/dist/locale.d.ts.map +1 -1
  203. package/dist/locale.js +1 -1
  204. package/dist/metadata.d.ts +8 -0
  205. package/dist/metadata.d.ts.map +1 -1
  206. package/dist/pages/console/action-run.d.ts.map +1 -1
  207. package/dist/pages/console/data/connectors.d.ts.map +1 -1
  208. package/dist/pages/console/data/datasets.d.ts.map +1 -1
  209. package/dist/pages/console/data/lake-health.d.ts +3 -0
  210. package/dist/pages/console/data/lake-health.d.ts.map +1 -0
  211. package/dist/pages/console/data/messages.d.ts +98 -2
  212. package/dist/pages/console/data/messages.d.ts.map +1 -1
  213. package/dist/pages/console/data/pipelines.d.ts.map +1 -1
  214. package/dist/pages/console/data/projections.d.ts.map +1 -1
  215. package/dist/pages/console/data/syncs.d.ts.map +1 -1
  216. package/dist/pages/console/ontology/action-runs.d.ts.map +1 -1
  217. package/dist/pages/console/ontology/actions.d.ts.map +1 -1
  218. package/dist/pages/console/ontology/components/action-button.d.ts.map +1 -1
  219. package/dist/pages/console/ontology/components/artifact-picker.d.ts +36 -0
  220. package/dist/pages/console/ontology/components/artifact-picker.d.ts.map +1 -0
  221. package/dist/pages/console/ontology/components/object-query-bar.d.ts.map +1 -1
  222. package/dist/pages/console/ontology/lib/action-params.d.ts +2 -0
  223. package/dist/pages/console/ontology/lib/action-params.d.ts.map +1 -1
  224. package/dist/pages/console/ontology/lineage/properties-panel.d.ts +2 -1
  225. package/dist/pages/console/ontology/lineage/properties-panel.d.ts.map +1 -1
  226. package/dist/pages/console/ontology/object-page.d.ts.map +1 -1
  227. package/dist/pages/console/ontology/object-type.d.ts.map +1 -1
  228. package/dist/pages/console/ontology/object-types.d.ts.map +1 -1
  229. package/dist/pages/console/ontology/objects.d.ts.map +1 -1
  230. package/dist/pages/console/ontology/rules.d.ts.map +1 -1
  231. package/dist/pages/console/ontology/workflow.d.ts.map +1 -1
  232. package/dist/pages/console/ontology/workflows/run-input-form.d.ts.map +1 -1
  233. package/dist/pages/console/ontology/workflows/schema-shape.d.ts.map +1 -1
  234. package/dist/pages/console/ontology/workflows.d.ts.map +1 -1
  235. package/dist/pages/console/skeletons.d.ts +30 -0
  236. package/dist/pages/console/skeletons.d.ts.map +1 -0
  237. package/dist/pages/console/workflow-run.d.ts.map +1 -1
  238. package/dist/pages/section-page.d.ts +11 -1
  239. package/dist/pages/section-page.d.ts.map +1 -1
  240. package/dist/pages/section-ui.d.ts +25 -3
  241. package/dist/pages/section-ui.d.ts.map +1 -1
  242. package/dist/pages/settings/activity/calendar.d.ts.map +1 -1
  243. package/dist/pages/settings/activity/connections.d.ts.map +1 -1
  244. package/dist/pages/settings/activity/page.d.ts.map +1 -1
  245. package/dist/pages/settings/activity/thread.d.ts.map +1 -1
  246. package/dist/pages/settings/activity/timeline.d.ts +2 -0
  247. package/dist/pages/settings/activity/timeline.d.ts.map +1 -1
  248. package/dist/pages/settings/controls.d.ts +4 -0
  249. package/dist/pages/settings/controls.d.ts.map +1 -1
  250. package/dist/pages/settings/members.d.ts.map +1 -1
  251. package/dist/pages/settings/memory-history.d.ts +2 -0
  252. package/dist/pages/settings/memory-history.d.ts.map +1 -1
  253. package/dist/pages/settings/memory.d.ts.map +1 -1
  254. package/dist/pages/settings/service-accounts.d.ts.map +1 -1
  255. package/dist/pages/settings/sessions.d.ts.map +1 -1
  256. package/dist/pages/settings/usage/breakdown.d.ts.map +1 -1
  257. package/dist/pages/settings/usage/limits.d.ts.map +1 -1
  258. package/dist/pages/settings/usage/messages.d.ts +0 -2
  259. package/dist/pages/settings/usage/messages.d.ts.map +1 -1
  260. package/dist/pages/settings/usage/runs.d.ts +8 -2
  261. package/dist/pages/settings/usage/runs.d.ts.map +1 -1
  262. package/dist/pages/settings/usage/spend-chart.d.ts.map +1 -1
  263. package/dist/pages/settings/usage/spend-model.d.ts +5 -0
  264. package/dist/pages/settings/usage/spend-model.d.ts.map +1 -1
  265. package/dist/pages/values.d.ts +6 -0
  266. package/dist/pages/values.d.ts.map +1 -1
  267. package/dist/pages.d.ts +4 -0
  268. package/dist/pages.d.ts.map +1 -1
  269. package/dist/pages.js +8188 -4841
  270. package/dist/pages.js.map +56 -47
  271. package/dist/sections/catalog.d.ts.map +1 -1
  272. package/dist/sections/sections.d.ts.map +1 -1
  273. package/dist/server.js +294 -23
  274. package/dist/server.js.map +8 -7
  275. package/dist/service-worker.d.ts +39 -0
  276. package/dist/service-worker.d.ts.map +1 -0
  277. package/dist/shared-session.d.ts +25 -0
  278. package/dist/shared-session.d.ts.map +1 -0
  279. package/dist/shell/app-return.d.ts +35 -0
  280. package/dist/shell/app-return.d.ts.map +1 -0
  281. package/dist/shell/app-shell.d.ts +1 -1
  282. package/dist/shell/app-shell.d.ts.map +1 -1
  283. package/dist/shell/nav-items.d.ts +2 -0
  284. package/dist/shell/nav-items.d.ts.map +1 -1
  285. package/dist/shell/phone/back.d.ts +6 -0
  286. package/dist/shell/phone/back.d.ts.map +1 -0
  287. package/dist/shell/phone/launch.d.ts +7 -0
  288. package/dist/shell/phone/launch.d.ts.map +1 -0
  289. package/dist/shell/phone/more-sheet.d.ts +36 -0
  290. package/dist/shell/phone/more-sheet.d.ts.map +1 -0
  291. package/dist/shell/phone/phone-foundations.d.ts +9 -0
  292. package/dist/shell/phone/phone-foundations.d.ts.map +1 -0
  293. package/dist/shell/phone/pull-to-refresh.d.ts +9 -0
  294. package/dist/shell/phone/pull-to-refresh.d.ts.map +1 -0
  295. package/dist/shell/phone/routes.d.ts +12 -0
  296. package/dist/shell/phone/routes.d.ts.map +1 -0
  297. package/dist/shell/phone/screen-motion.d.ts +11 -0
  298. package/dist/shell/phone/screen-motion.d.ts.map +1 -0
  299. package/dist/shell/phone/scroll-restoration.d.ts +7 -0
  300. package/dist/shell/phone/scroll-restoration.d.ts.map +1 -0
  301. package/dist/shell/phone/startup-image.d.ts +17 -0
  302. package/dist/shell/phone/startup-image.d.ts.map +1 -0
  303. package/dist/shell/phone/tab-bar.d.ts +14 -0
  304. package/dist/shell/phone/tab-bar.d.ts.map +1 -0
  305. package/dist/shell/phone/top-bar.d.ts +24 -0
  306. package/dist/shell/phone/top-bar.d.ts.map +1 -0
  307. package/dist/shell/search-command.d.ts +3 -1
  308. package/dist/shell/search-command.d.ts.map +1 -1
  309. package/dist/shell/user-menu.d.ts +2 -0
  310. package/dist/shell/user-menu.d.ts.map +1 -1
  311. package/package.json +8 -5
  312. package/src/agent/activity-label.ts +6 -1
  313. package/src/agent/agent-chat.tsx +52 -8
  314. package/src/agent/agent-panel.tsx +12 -0
  315. package/src/agent/agent-surface.tsx +4 -0
  316. package/src/agent/artifact-card.tsx +84 -16
  317. package/src/agent/artifact-panel.tsx +63 -43
  318. package/src/agent/background/background-tool-row.tsx +24 -10
  319. package/src/agent/background/interpret.ts +60 -51
  320. package/src/agent/components/agent-message-body.tsx +1 -1
  321. package/src/agent/components/composer-place.tsx +77 -53
  322. package/src/agent/components/composer.tsx +92 -7
  323. package/src/agent/components/context-chips.tsx +72 -2
  324. package/src/agent/components/conversation-panel.tsx +30 -10
  325. package/src/agent/components/message-parts.tsx +29 -6
  326. package/src/agent/components/thread-artifacts-menu.tsx +22 -5
  327. package/src/agent/components/transcript.tsx +45 -27
  328. package/src/agent/composer-insertion.ts +36 -0
  329. package/src/agent/delegation/agent-exchange.tsx +53 -0
  330. package/src/agent/delegation/child-card.tsx +6 -40
  331. package/src/agent/delegation/child-parts.tsx +1 -84
  332. package/src/agent/delegation/child-work.tsx +19 -5
  333. package/src/agent/delegation/interpret.ts +33 -54
  334. package/src/agent/delegation/model.ts +1 -1
  335. package/src/agent/file-edits/file-edit-tool-view.tsx +126 -0
  336. package/src/agent/file-edits/interpret.ts +120 -0
  337. package/src/agent/hooks/use-agent-conversation.ts +61 -10
  338. package/src/agent/hooks/use-new-thread-place.ts +149 -25
  339. package/src/agent/i18n/en.ts +60 -4
  340. package/src/agent/i18n/fr.ts +51 -4
  341. package/src/agent/message-agent/interpret.ts +4 -3
  342. package/src/agent/publish-artifact/interpret.ts +37 -6
  343. package/src/agent/publish-artifact/open-artifact-tool-view.tsx +49 -0
  344. package/src/agent/publish-artifact/publish-artifact-tool-view.tsx +14 -8
  345. package/src/agent/publish-artifact/use-live-publishes.ts +7 -11
  346. package/src/agent/questions/interpret.ts +90 -0
  347. package/src/agent/questions/question-card.tsx +57 -0
  348. package/src/agent/questions/question-composer.tsx +257 -0
  349. package/src/agent/react-router.tsx +2 -2
  350. package/src/agent/read/interpret.ts +34 -1
  351. package/src/agent/read/read-tool-view.tsx +20 -4
  352. package/src/agent/tool-views/built-in.tsx +22 -8
  353. package/src/agent/types.ts +4 -0
  354. package/src/agent/waits.ts +50 -0
  355. package/src/artifacts/artifact-page.tsx +42 -17
  356. package/src/artifacts/artifact-viewer.tsx +56 -0
  357. package/src/artifacts/artifacts.css +116 -0
  358. package/src/artifacts/card-details.ts +2 -2
  359. package/src/artifacts/card-preview.tsx +17 -3
  360. package/src/artifacts/comments-context.ts +125 -0
  361. package/src/artifacts/edit-session.tsx +21 -7
  362. package/src/artifacts/file-source.ts +10 -3
  363. package/src/artifacts/frame.tsx +53 -14
  364. package/src/artifacts/gallery.tsx +9 -11
  365. package/src/artifacts/guest-badge.tsx +21 -0
  366. package/src/artifacts/held-artifact.tsx +241 -0
  367. package/src/artifacts/holders.tsx +170 -0
  368. package/src/artifacts/live/boards.ts +95 -0
  369. package/src/artifacts/live/canvas.ts +402 -0
  370. package/src/artifacts/live/header.tsx +137 -0
  371. package/src/artifacts/live/hooks.ts +94 -0
  372. package/src/artifacts/live/presence.ts +147 -0
  373. package/src/artifacts/live/session.ts +520 -0
  374. package/src/artifacts/live/view.ts +81 -0
  375. package/src/artifacts/messages.ts +469 -24
  376. package/src/artifacts/page-queries.ts +2 -3
  377. package/src/artifacts/page-state.ts +16 -7
  378. package/src/artifacts/publish-edit.ts +50 -22
  379. package/src/artifacts/queries.ts +108 -10
  380. package/src/artifacts/references/references.tsx +6 -9
  381. package/src/artifacts/renderers/canvas/arrows.tsx +12 -39
  382. package/src/artifacts/renderers/canvas/board-editor.tsx +839 -0
  383. package/src/artifacts/renderers/canvas/board-properties.tsx +488 -0
  384. package/src/artifacts/renderers/canvas/board-source.ts +110 -0
  385. package/src/artifacts/renderers/canvas/board.tsx +373 -35
  386. package/src/artifacts/renderers/canvas/canvas.tsx +441 -75
  387. package/src/artifacts/renderers/canvas/comment-pins.tsx +465 -0
  388. package/src/artifacts/renderers/canvas/commenting.tsx +319 -0
  389. package/src/artifacts/renderers/canvas/comments-panel.tsx +574 -0
  390. package/src/artifacts/renderers/canvas/comments.ts +225 -0
  391. package/src/artifacts/renderers/canvas/controls.tsx +64 -30
  392. package/src/artifacts/renderers/canvas/draft.ts +41 -50
  393. package/src/artifacts/renderers/canvas/edit-mode.tsx +145 -20
  394. package/src/artifacts/renderers/canvas/focus.tsx +321 -26
  395. package/src/artifacts/renderers/canvas/gestures.ts +265 -0
  396. package/src/artifacts/renderers/canvas/items.tsx +179 -52
  397. package/src/artifacts/renderers/canvas/layout.ts +99 -47
  398. package/src/artifacts/renderers/canvas/page-resize.tsx +542 -0
  399. package/src/artifacts/renderers/canvas/page-size-controls.tsx +193 -0
  400. package/src/artifacts/renderers/canvas/page-size.ts +218 -0
  401. package/src/artifacts/renderers/canvas/page-zoom.ts +280 -0
  402. package/src/artifacts/renderers/canvas/presence.tsx +184 -0
  403. package/src/artifacts/renderers/canvas/previews.ts +127 -0
  404. package/src/artifacts/renderers/canvas/renderer.tsx +87 -22
  405. package/src/artifacts/renderers/canvas/shown-size.ts +105 -0
  406. package/src/artifacts/renderers/canvas/thumbnail.tsx +56 -15
  407. package/src/artifacts/renderers/canvas/toolbar.tsx +1 -1
  408. package/src/artifacts/renderers/slides/slides.tsx +1 -1
  409. package/src/artifacts/version-menu.tsx +438 -0
  410. package/src/artifacts/view-context.ts +102 -0
  411. package/src/artifacts/viewer.tsx +219 -147
  412. package/src/build.ts +96 -11
  413. package/src/codegen.ts +83 -5
  414. package/src/createCustomApp.ts +20 -7
  415. package/src/index.ts +14 -0
  416. package/src/locale-messages.ts +24 -0
  417. package/src/metadata.ts +12 -0
  418. package/src/pages/console/action-run.tsx +20 -0
  419. package/src/pages/console/data/connectors.tsx +27 -3
  420. package/src/pages/console/data/datasets.tsx +30 -1
  421. package/src/pages/console/data/lake-health.tsx +299 -0
  422. package/src/pages/console/data/messages.ts +143 -2
  423. package/src/pages/console/data/pipelines.tsx +91 -3
  424. package/src/pages/console/data/projections.tsx +23 -4
  425. package/src/pages/console/data/syncs.tsx +39 -2
  426. package/src/pages/console/ontology/action-runs.tsx +8 -2
  427. package/src/pages/console/ontology/actions.tsx +39 -15
  428. package/src/pages/console/ontology/components/action-button.tsx +10 -0
  429. package/src/pages/console/ontology/components/artifact-picker.tsx +522 -0
  430. package/src/pages/console/ontology/components/object-query-bar.tsx +21 -5
  431. package/src/pages/console/ontology/lib/action-params.ts +10 -0
  432. package/src/pages/console/ontology/lineage/properties-panel.tsx +32 -24
  433. package/src/pages/console/ontology/object-page.tsx +2 -0
  434. package/src/pages/console/ontology/object-type.tsx +73 -14
  435. package/src/pages/console/ontology/object-types.tsx +56 -7
  436. package/src/pages/console/ontology/objects.tsx +167 -19
  437. package/src/pages/console/ontology/rules.tsx +186 -30
  438. package/src/pages/console/ontology/workflow.tsx +130 -74
  439. package/src/pages/console/ontology/workflows/run-input-form.tsx +21 -2
  440. package/src/pages/console/ontology/workflows/schema-shape.tsx +3 -0
  441. package/src/pages/console/ontology/workflows.tsx +34 -21
  442. package/src/pages/console/skeletons.tsx +99 -0
  443. package/src/pages/console/workflow-run.tsx +20 -0
  444. package/src/pages/section-page.tsx +37 -7
  445. package/src/pages/section-ui.tsx +96 -13
  446. package/src/pages/settings/activity/calendar.tsx +13 -6
  447. package/src/pages/settings/activity/connections.tsx +26 -9
  448. package/src/pages/settings/activity/page.tsx +31 -4
  449. package/src/pages/settings/activity/thread.tsx +32 -18
  450. package/src/pages/settings/activity/timeline.tsx +39 -0
  451. package/src/pages/settings/controls.tsx +19 -1
  452. package/src/pages/settings/developers.tsx +2 -2
  453. package/src/pages/settings/members.tsx +42 -9
  454. package/src/pages/settings/memory-history.tsx +76 -10
  455. package/src/pages/settings/memory.tsx +47 -5
  456. package/src/pages/settings/service-accounts.tsx +7 -2
  457. package/src/pages/settings/sessions.tsx +6 -2
  458. package/src/pages/settings/usage/breakdown.tsx +62 -2
  459. package/src/pages/settings/usage/limits.tsx +45 -3
  460. package/src/pages/settings/usage/messages.ts +0 -2
  461. package/src/pages/settings/usage/page.tsx +99 -52
  462. package/src/pages/settings/usage/runs.tsx +105 -8
  463. package/src/pages/settings/usage/spend-chart.tsx +79 -45
  464. package/src/pages/settings/usage/spend-model.ts +16 -0
  465. package/src/pages/values.tsx +72 -6
  466. package/src/pages.ts +4 -0
  467. package/src/sections/catalog.ts +6 -0
  468. package/src/sections/sections.tsx +2 -0
  469. package/src/service-worker.ts +176 -0
  470. package/src/shared-session.ts +73 -0
  471. package/src/shell/app-return.ts +115 -0
  472. package/src/shell/app-shell.tsx +125 -27
  473. package/src/shell/nav-items.tsx +2 -0
  474. package/src/shell/phone/back.ts +16 -0
  475. package/src/shell/phone/launch.ts +6 -0
  476. package/src/shell/phone/more-sheet.tsx +249 -0
  477. package/src/shell/phone/phone-foundations.tsx +43 -0
  478. package/src/shell/phone/phone.css +660 -0
  479. package/src/shell/phone/pull-to-refresh.tsx +201 -0
  480. package/src/shell/phone/routes.ts +34 -0
  481. package/src/shell/phone/screen-motion.ts +292 -0
  482. package/src/shell/phone/scroll-restoration.tsx +70 -0
  483. package/src/shell/phone/startup-image.ts +119 -0
  484. package/src/shell/phone/tab-bar.tsx +95 -0
  485. package/src/shell/phone/top-bar.tsx +195 -0
  486. package/src/shell/search-command.tsx +30 -14
  487. package/src/shell/user-menu.tsx +2 -1
  488. package/dist/chunk-4j3c3p72.js +0 -1487
  489. package/dist/chunk-4j3c3p72.js.map +0 -18
  490. package/dist/chunk-4mprsd2n.js.map +0 -10
  491. package/dist/chunk-ytadd0b5.js.map +0 -188
  492. /package/dist/{chunk-7fj9cfkw.js.map → chunk-970s5nkn.js.map} +0 -0
  493. /package/dist/{chunk-j8g956dt.js.map → chunk-pxd07kvx.js.map} +0 -0
  494. /package/dist/{chunk-kwbw4dyk.js.map → chunk-ryed2jq8.js.map} +0 -0
@@ -0,0 +1,95 @@
1
+ import { LIVE_FILES } from "@sixb/core/artifacts/live"
2
+ import type { FileRef } from "@sixb/core/blob-storage"
3
+ import { useCallback, useMemo, useSyncExternalStore } from "react"
4
+ import * as Y from "yjs"
5
+ import type { LiveArtifact } from "./session"
6
+
7
+ // A board's page as the live document holds it, read as it changes: someone typing in it, the
8
+ // Agent writing it, or the whole file replaced.
9
+
10
+ /** A board's page in the document now; null when the document holds none at that path as text. */
11
+ export function liveBoardSource(doc: Y.Doc, path: string): string | null {
12
+ const entry = doc.getMap<unknown>(LIVE_FILES).get(path)
13
+ return entry instanceof Y.Text ? entry.toString() : null
14
+ }
15
+
16
+ /** The files the document holds as stored bytes, by path: the pictures a board may show. */
17
+ export function liveStoredFiles(doc: Y.Doc): ReadonlyMap<string, FileRef> {
18
+ const files = new Map<string, FileRef>()
19
+ doc.getMap<unknown>(LIVE_FILES).forEach((entry, path) => {
20
+ if (entry instanceof Y.Text || entry instanceof Y.Map) return
21
+ if (isFileRef(entry)) files.set(path, entry)
22
+ })
23
+ return files
24
+ }
25
+
26
+ function isFileRef(value: unknown): value is FileRef {
27
+ return (
28
+ typeof value === "object" &&
29
+ value !== null &&
30
+ typeof (value as { blobId?: unknown }).blobId === "string"
31
+ )
32
+ }
33
+
34
+ /**
35
+ * Follows a board's page in a live artifact's document: the text it holds now, read again as it
36
+ * changes, and when the file at its path is replaced. Null without a document, or a page there.
37
+ */
38
+ export function useLiveBoardSource(live: LiveArtifact | null, path: string): string | null {
39
+ const subscribe = useCallback(
40
+ (listener: () => void) => {
41
+ if (!live) return () => {}
42
+
43
+ const files = live.doc.getMap<unknown>(LIVE_FILES)
44
+ let text: Y.Text | null = null
45
+ const follow = () => {
46
+ text?.unobserve(listener)
47
+ const entry = files.get(path)
48
+ text = entry instanceof Y.Text ? entry : null
49
+ text?.observe(listener)
50
+ }
51
+ const onFiles = (event: Y.YMapEvent<unknown>) => {
52
+ if (!event.keysChanged.has(path)) return
53
+ follow()
54
+ listener()
55
+ }
56
+
57
+ follow()
58
+ files.observe(onFiles)
59
+ return () => {
60
+ files.unobserve(onFiles)
61
+ text?.unobserve(listener)
62
+ }
63
+ },
64
+ [live, path]
65
+ )
66
+
67
+ return useSyncExternalStore(
68
+ subscribe,
69
+ () => (live ? liveBoardSource(live.doc, path) : null),
70
+ () => null
71
+ )
72
+ }
73
+
74
+ /** Follows the files a live artifact's document holds as stored bytes, as they are added. */
75
+ export function useLiveStoredFiles(live: LiveArtifact | null): ReadonlyMap<string, FileRef> {
76
+ const subscribe = useCallback(
77
+ (listener: () => void) => {
78
+ if (!live) return () => {}
79
+ const files = live.doc.getMap<unknown>(LIVE_FILES)
80
+ files.observe(listener)
81
+ return () => files.unobserve(listener)
82
+ },
83
+ [live]
84
+ )
85
+ const snapshot = useCallback(() => (live ? storedFilesKey(live.doc) : ""), [live])
86
+ const key = useSyncExternalStore(subscribe, snapshot, () => "")
87
+
88
+ // The key stands for the files: the map is read again only when it changes.
89
+ // biome-ignore lint/correctness/useExhaustiveDependencies: read again as the key changes.
90
+ return useMemo(() => (live ? liveStoredFiles(live.doc) : new Map()), [live, key])
91
+ }
92
+
93
+ function storedFilesKey(doc: Y.Doc): string {
94
+ return [...liveStoredFiles(doc)].map(([path, ref]) => `${path}:${ref.digest}`).join("\n")
95
+ }
@@ -0,0 +1,402 @@
1
+ import { CANVAS_FILE, type Canvas, type CanvasItem } from "@sixb/core/artifacts"
2
+ import {
3
+ applyBoardEditToText,
4
+ type BoardEdit,
5
+ canvasItemMap,
6
+ canvasItemObject,
7
+ documentCanvas,
8
+ LIVE_FILES,
9
+ mergeCanvasItem,
10
+ } from "@sixb/core/artifacts/live"
11
+ import type { FileRef } from "@sixb/core/blob-storage"
12
+ import * as Y from "yjs"
13
+ import type { CanvasChange } from "../renderers/canvas/draft"
14
+ import type { LiveArtifact } from "./session"
15
+
16
+ // A canvas as its live document holds it, read as the board draws it and changed as the board
17
+ // edits it.
18
+ //
19
+ // Reading: the canvas is kept as one `Canvas`, rebuilt as the document changes, in which an item
20
+ // nobody changed is the same object as before. The board draws an item again only when its object
21
+ // changes, so a change someone makes to one note draws that note, not the canvas. What others
22
+ // change is taken in at most once a frame, however fast it comes: the board draws once for all of
23
+ // it. This reader's own changes are taken in at once, with whatever waits.
24
+ //
25
+ // Writing: an edit stays a `CanvasChange`, one function from a canvas to the next, as the draft
26
+ // had it. What it changed is written into the document, key by key and word by word, in one
27
+ // transaction under this canvas's own origin: only those are this reader's to undo. An edit to
28
+ // what a board shows is a change to the board's page, its `Y.Text`, under the same origin, so the
29
+ // same undo takes it back.
30
+
31
+ /** The item types the board draws: anything else in a document is left out. */
32
+ const ITEM_TYPES: ReadonlySet<string> = new Set<CanvasItem["type"]>([
33
+ "board",
34
+ "section",
35
+ "note",
36
+ "text",
37
+ "shape",
38
+ "embed",
39
+ "arrow",
40
+ ])
41
+
42
+ /** The origin of a file an edit adds: kept whatever the reader undoes. */
43
+ const KEPT_FILES = Symbol("sixb-live-kept-files")
44
+
45
+ /** How long changes made one after the other are one step for undo, as typing a word is. */
46
+ const UNDO_CAPTURE_MS = 400
47
+
48
+ /** Runs `run` before the next frame is drawn; a timer standing for one where there are none. */
49
+ function requestFrame(run: () => void): () => void {
50
+ if (typeof requestAnimationFrame === "function") {
51
+ const frame = requestAnimationFrame(run)
52
+ return () => cancelAnimationFrame(frame)
53
+ }
54
+ const timer = setTimeout(run, 16)
55
+ return () => clearTimeout(timer)
56
+ }
57
+
58
+ type ItemMap = Y.Map<unknown>
59
+
60
+ const EMPTY: Canvas = { items: [] }
61
+
62
+ export class LiveCanvas {
63
+ private canvas: Canvas = EMPTY
64
+ private readonly cache = new Map<string, { readonly map: ItemMap; item: CanvasItem }>()
65
+ private structure: ReturnType<typeof documentCanvas> = null
66
+ private undoManager: Y.UndoManager | null = null
67
+ private readonly listeners = new Set<() => void>()
68
+ private history = { undo: false, redo: false }
69
+ /** A drag is under way: everything it changes is one step, however long it pauses. */
70
+ private dragging = false
71
+ /** The items others changed that wait for the next frame to be read again. */
72
+ private pending: Set<string> | null = null
73
+ private cancelFrame: (() => void) | null = null
74
+ /** The canvas the board was last told of. */
75
+ private announced: Canvas | null = null
76
+ /** The origin of this reader's own changes: the only ones its undo takes back. */
77
+ readonly origin = Symbol("sixb-live-canvas")
78
+
79
+ constructor(private readonly doc: Y.Doc) {
80
+ doc.getMap<unknown>(LIVE_FILES).observe(this.onFiles)
81
+ this.bind()
82
+ }
83
+
84
+ /**
85
+ * The canvas now, or null while the document holds none: not synced yet, or not a canvas. What
86
+ * waits for the next frame is read in first, so whoever reads it never reads behind.
87
+ */
88
+ getCanvas = (): Canvas | null => {
89
+ this.readPending()
90
+ return this.structure ? this.canvas : null
91
+ }
92
+
93
+ getHistory = (): { readonly undo: boolean; readonly redo: boolean } => this.history
94
+
95
+ subscribe = (listener: () => void): (() => void) => {
96
+ this.listeners.add(listener)
97
+ return () => this.listeners.delete(listener)
98
+ }
99
+
100
+ /** Makes an edit, as one step of this reader's undo; one that changes nothing writes nothing. */
101
+ apply(change: CanvasChange): void {
102
+ if (!this.structure) return
103
+
104
+ this.readPending()
105
+ const before = this.canvas
106
+ const after = change(before)
107
+ if (after === before) return
108
+
109
+ const { items, order } = this.structure
110
+ this.doc.transact(() => write(items, order, before, after), this.origin)
111
+ }
112
+
113
+ /**
114
+ * Makes an edit to a board's page, worked out from what it holds now, as one step of this
115
+ * reader's undo, with the files it needs added first: an image's picture, which undo leaves in
116
+ * place. False when the document holds no such page; `make` throws when the edit no longer
117
+ * applies.
118
+ */
119
+ editBoard(
120
+ path: string,
121
+ make: (source: string) => BoardEdit,
122
+ files: Readonly<Record<string, FileRef>> = {}
123
+ ): boolean {
124
+ const map = this.doc.getMap<unknown>(LIVE_FILES)
125
+ const text = map.get(path)
126
+ if (!(text instanceof Y.Text)) return false
127
+
128
+ const edit = make(text.toString())
129
+ if (edit.length === 0 && Object.keys(files).length === 0) return true
130
+
131
+ // A file joins the canvas for good, outside this reader's undo: undoing the edit puts the
132
+ // page back as it was, and leaves the file to anyone who shows it since.
133
+ if (Object.keys(files).length > 0) {
134
+ this.doc.transact(() => {
135
+ for (const [file, ref] of Object.entries(files)) map.set(file, ref)
136
+ }, KEPT_FILES)
137
+ }
138
+ applyBoardEditToText(text, edit, this.origin)
139
+ return true
140
+ }
141
+
142
+ undo(): void {
143
+ this.undoManager?.undo()
144
+ }
145
+
146
+ redo(): void {
147
+ this.undoManager?.redo()
148
+ }
149
+
150
+ /** Ends the undo step being made: what comes next, such as a new drag, is a step of its own. */
151
+ stopCapturing(): void {
152
+ this.undoManager?.stopCapturing()
153
+ }
154
+
155
+ /** A drag starts: what it changes, until it ends, is one step for undo. */
156
+ startDrag(): void {
157
+ this.stopCapturing()
158
+ this.dragging = true
159
+ if (this.undoManager) this.undoManager.captureTimeout = Number.POSITIVE_INFINITY
160
+ }
161
+
162
+ /** The drag ended: the next change is a step of its own. */
163
+ endDrag(): void {
164
+ this.dragging = false
165
+ if (this.undoManager) this.undoManager.captureTimeout = UNDO_CAPTURE_MS
166
+ this.stopCapturing()
167
+ }
168
+
169
+ destroy(): void {
170
+ this.cancelFrame?.()
171
+ this.cancelFrame = null
172
+ this.pending = null
173
+ this.doc.getMap<unknown>(LIVE_FILES).unobserve(this.onFiles)
174
+ this.unbind()
175
+ this.listeners.clear()
176
+ }
177
+
178
+ // ── Reading ─────────────────────────────────────────────────────────
179
+
180
+ /** Follows the canvas's structure: it is replaced when someone writes `canvas.json` whole. */
181
+ private onFiles = (event: Y.YMapEvent<unknown>): void => {
182
+ if (event.keysChanged.has(CANVAS_FILE)) this.bind()
183
+ }
184
+
185
+ private bind(): void {
186
+ this.cancelFrame?.()
187
+ this.cancelFrame = null
188
+ this.pending = null
189
+ this.unbind()
190
+ this.structure = documentCanvas(this.doc)
191
+ this.cache.clear()
192
+ if (this.structure) {
193
+ this.structure.items.observeDeep(this.onItems)
194
+ this.structure.order.observe(this.onOrder)
195
+ // The files hold the canvas's structure and its boards' pages: this reader's changes to any
196
+ // of them are theirs to undo.
197
+ this.undoManager = new Y.UndoManager(this.doc.getMap<unknown>(LIVE_FILES), {
198
+ trackedOrigins: new Set([this.origin]),
199
+ captureTimeout: this.dragging ? Number.POSITIVE_INFINITY : UNDO_CAPTURE_MS,
200
+ })
201
+ this.undoManager.on("stack-item-added", this.onHistory)
202
+ this.undoManager.on("stack-item-popped", this.onHistory)
203
+ this.undoManager.on("stack-cleared", this.onHistory)
204
+ }
205
+ this.rebuild(null)
206
+ this.announce()
207
+ }
208
+
209
+ private unbind(): void {
210
+ if (this.structure) {
211
+ this.structure.items.unobserveDeep(this.onItems)
212
+ this.structure.order.unobserve(this.onOrder)
213
+ }
214
+ this.undoManager?.destroy()
215
+ this.undoManager = null
216
+ this.onHistory()
217
+ }
218
+
219
+ private onItems = (
220
+ events: Y.YEvent<Y.AbstractType<unknown>>[],
221
+ transaction: Y.Transaction
222
+ ): void => {
223
+ const changed = new Set<string>()
224
+ for (const event of events) {
225
+ // The items map itself: items added or deleted; else a change inside one item, its path
226
+ // starting at its id.
227
+ if (event.path.length === 0) {
228
+ for (const key of event.changes.keys.keys()) changed.add(key)
229
+ } else {
230
+ const id = event.path[0]
231
+ if (typeof id === "string") changed.add(id)
232
+ }
233
+ }
234
+ this.taken(changed, transaction)
235
+ }
236
+
237
+ private onOrder = (_event: Y.YEvent<Y.Array<string>>, transaction: Y.Transaction): void =>
238
+ this.taken(new Set(), transaction)
239
+
240
+ /**
241
+ * Reads again what a change touched, and tells the board: at once for this reader's own, with
242
+ * whatever waits; at the next frame for the others', all of a frame's changes at once.
243
+ */
244
+ private taken(changed: ReadonlySet<string>, transaction: Y.Transaction): void {
245
+ const pending = this.pending ?? new Set<string>()
246
+ for (const id of changed) pending.add(id)
247
+ this.pending = pending
248
+
249
+ const own = transaction.origin === this.origin || transaction.origin === this.undoManager
250
+ if (own) {
251
+ this.cancelFrame?.()
252
+ this.cancelFrame = null
253
+ this.readPending()
254
+ this.announce()
255
+ return
256
+ }
257
+ this.cancelFrame ??= requestFrame(() => {
258
+ this.cancelFrame = null
259
+ this.readPending()
260
+ this.announce()
261
+ })
262
+ }
263
+
264
+ /** Reads again the items that wait, without telling anyone: a read can come while React draws. */
265
+ private readPending(): void {
266
+ const pending = this.pending
267
+ if (!pending) return
268
+
269
+ this.pending = null
270
+ this.rebuild(pending)
271
+ }
272
+
273
+ /** Tells the board of the canvas, once it is another. */
274
+ private announce(): void {
275
+ if (this.announced === this.canvas) return
276
+ this.announced = this.canvas
277
+ this.notify()
278
+ }
279
+
280
+ private onHistory = (): void => {
281
+ const next = {
282
+ undo: (this.undoManager?.undoStack.length ?? 0) > 0,
283
+ redo: (this.undoManager?.redoStack.length ?? 0) > 0,
284
+ }
285
+ if (next.undo === this.history.undo && next.redo === this.history.redo) return
286
+ this.history = next
287
+ this.notify()
288
+ }
289
+
290
+ /**
291
+ * The canvas again, its items in order, then any the order misses, and without an arrow whose
292
+ * item someone deleted meanwhile, as `canvas.json` is written. Only the items in `changed` are
293
+ * read again, all of them when it is null.
294
+ */
295
+ private rebuild(changed: ReadonlySet<string> | null): void {
296
+ const structure = this.structure
297
+ if (!structure) {
298
+ this.canvas = EMPTY
299
+ return
300
+ }
301
+
302
+ const { items, order } = structure
303
+ const ids: string[] = []
304
+ const seen = new Set<string>()
305
+ for (const id of [...order.toArray(), ...[...items.keys()].sort()]) {
306
+ if (seen.has(id) || !items.has(id)) continue
307
+ seen.add(id)
308
+ ids.push(id)
309
+ }
310
+
311
+ const next: CanvasItem[] = []
312
+ for (const id of ids) {
313
+ const map = items.get(id) as ItemMap
314
+ const cached = this.cache.get(id)
315
+ if (cached && cached.map === map && changed !== null && !changed.has(id)) {
316
+ next.push(cached.item)
317
+ continue
318
+ }
319
+ const item = readItem(map)
320
+ if (!item) continue
321
+ this.cache.set(id, { map, item })
322
+ next.push(item)
323
+ }
324
+ for (const id of this.cache.keys()) {
325
+ if (!seen.has(id)) this.cache.delete(id)
326
+ }
327
+
328
+ const kept = next.filter(
329
+ (item) => item.type !== "arrow" || (joined(item.from, seen) && joined(item.to, seen))
330
+ )
331
+ const same =
332
+ kept.length === this.canvas.items.length &&
333
+ kept.every((item, index) => item === this.canvas.items[index])
334
+ if (same && this.canvas !== EMPTY) return
335
+
336
+ this.canvas = { items: kept }
337
+ }
338
+
339
+ private notify(): void {
340
+ for (const listener of this.listeners) listener()
341
+ }
342
+ }
343
+
344
+ function joined(end: unknown, ids: ReadonlySet<string>): boolean {
345
+ return typeof end !== "string" || ids.has(end)
346
+ }
347
+
348
+ /** An item as the board reads it; null for one that is not an item of a known type. */
349
+ function readItem(map: ItemMap): CanvasItem | null {
350
+ const item = canvasItemObject(map)
351
+ if (typeof item.id !== "string" || typeof item.type !== "string" || !ITEM_TYPES.has(item.type)) {
352
+ return null
353
+ }
354
+ return item as unknown as CanvasItem
355
+ }
356
+
357
+ // ── Writing ─────────────────────────────────────────────────────────────
358
+
359
+ /** Writes into the structure what changed from `before` to `after`. */
360
+ function write(items: Y.Map<ItemMap>, order: Y.Array<string>, before: Canvas, after: Canvas): void {
361
+ const previous = new Map(before.items.map((item) => [item.id, item]))
362
+ const next = new Set<string>()
363
+
364
+ for (const item of after.items) {
365
+ next.add(item.id)
366
+ const was = previous.get(item.id)
367
+ if (was === item) continue
368
+
369
+ const map = items.get(item.id)
370
+ if (!was || !map) {
371
+ items.set(item.id, canvasItemMap(item))
372
+ continue
373
+ }
374
+ // The item as this reader last read it is what the document holds: its words go as edits.
375
+ mergeCanvasItem(map, was, item)
376
+ }
377
+ for (const id of previous.keys()) {
378
+ if (!next.has(id)) items.delete(id)
379
+ }
380
+
381
+ // An edit adds at the end and removes anywhere: the order follows, someone else's additions kept.
382
+ const ids = order.toArray()
383
+ for (let index = ids.length - 1; index >= 0; index -= 1) {
384
+ const id = ids[index] as string
385
+ if (previous.has(id) && !next.has(id)) order.delete(index, 1)
386
+ }
387
+ const ordered = new Set(order.toArray())
388
+ const added = after.items.map((item) => item.id).filter((id) => !ordered.has(id))
389
+ if (added.length > 0) order.push(added)
390
+ }
391
+
392
+ const canvases = new WeakMap<LiveArtifact, LiveCanvas>()
393
+
394
+ /** The canvas of a live artifact, one per artifact, so the board and the header share its undo. */
395
+ export function liveCanvasOf(artifact: LiveArtifact): LiveCanvas {
396
+ let canvas = canvases.get(artifact)
397
+ if (!canvas) {
398
+ canvas = new LiveCanvas(artifact.doc)
399
+ canvases.set(artifact, canvas)
400
+ }
401
+ return canvas
402
+ }
@@ -0,0 +1,137 @@
1
+ import { cn } from "@sixb/ui/lib/utils"
2
+ import { Check, CloudOff, LoaderCircle, Sparkles, TriangleAlert } from "lucide-react"
3
+ import { useArtifactMessages } from "../messages"
4
+ import { PersonAvatar } from "../person-avatar"
5
+ import { livePersonName, useLivePresence } from "./presence"
6
+ import type { LiveArtifact, LiveArtifactState } from "./session"
7
+
8
+ /** The most people the header shows faces of; the rest count in a `+N`. */
9
+ const MAX_FACES = 3
10
+
11
+ /**
12
+ * Who else is on the artifact, as faces beside the title, each ringed in the color their
13
+ * selection takes on the canvas, and the Agent while a turn changes it. Nothing when nobody is.
14
+ */
15
+ export function LiveAvatars({ live }: { readonly live: LiveArtifact }) {
16
+ const messages = useArtifactMessages()
17
+ const { people, agents } = useLivePresence(live)
18
+ const working = agents.length > 0
19
+ if (people.length === 0 && !working) return null
20
+
21
+ // A shared link's guest is named as one: the name is only what they typed.
22
+ const labels = { guest: messages.canvas.comments.guest, teamMember: messages.live.teamMember }
23
+ const nameOf = (person: (typeof people)[number]) => {
24
+ const name = livePersonName(person, labels)
25
+ return person.guest && person.name ? `${name} (${labels.guest})` : name
26
+ }
27
+ const shown = people.slice(0, MAX_FACES)
28
+ const names = [...people.map(nameOf), ...(working ? [messages.live.agent] : [])]
29
+ return (
30
+ <div
31
+ role="group"
32
+ aria-label={messages.live.here(names.join(", "))}
33
+ title={names.join(", ")}
34
+ data-live-avatars=""
35
+ className="flex shrink-0 items-center gap-0 pl-1 -space-x-1"
36
+ >
37
+ {working ? (
38
+ <span
39
+ data-live-agent=""
40
+ className="relative flex size-6 items-center justify-center rounded-full bg-[color-mix(in_oklab,var(--primary)_14%,var(--background))] text-primary ring-2 ring-background"
41
+ >
42
+ <Sparkles className="size-3.5 motion-safe:animate-pulse" aria-hidden="true" />
43
+ </span>
44
+ ) : null}
45
+ {shown.map((person) => (
46
+ <span
47
+ key={person.id}
48
+ className="relative rounded-full"
49
+ style={{ boxShadow: `0 0 0 1.5px var(--background), 0 0 0 3px ${person.color}` }}
50
+ title={nameOf(person)}
51
+ >
52
+ <PersonAvatar name={livePersonName(person, labels)} size="sm" className="bg-background" />
53
+ </span>
54
+ ))}
55
+ {people.length > shown.length ? (
56
+ <span className="relative flex size-6 items-center justify-center rounded-full bg-muted text-[10px] font-medium text-muted-foreground ring-2 ring-background">
57
+ {messages.live.more(people.length - shown.length)}
58
+ </span>
59
+ ) : null}
60
+ </div>
61
+ )
62
+ }
63
+
64
+ /** What the header says of an edit's write-back, as a document editor does. */
65
+ export type LiveSaveLabel = "saved" | "saving" | "failed" | "offline"
66
+
67
+ /**
68
+ * Where what the reader changed is: saved, being saved, kept here while the socket is down, or
69
+ * failed and tried again by the server.
70
+ */
71
+ export function liveSaveLabel(state: LiveArtifactState): LiveSaveLabel {
72
+ if (state.connection !== "online") return "offline"
73
+ if (state.save?.state === "failed") return "failed"
74
+ if (state.pending || state.save?.state === "unsaved" || state.save?.state === "saving") {
75
+ return "saving"
76
+ }
77
+ return "saved"
78
+ }
79
+
80
+ /**
81
+ * The save state, discreet beside the title: its words fold into the icon on a narrow header.
82
+ * Only a failure is announced; offline with nothing kept, it says it is reconnecting.
83
+ */
84
+ export function LiveSaveStatus({ state }: { readonly state: LiveArtifactState }) {
85
+ const messages = useArtifactMessages().live
86
+ const label = liveSaveLabel(state)
87
+ const text = label === "offline" && !state.pending ? messages.reconnecting : messages[label]
88
+ const Icon =
89
+ label === "saved"
90
+ ? Check
91
+ : label === "saving"
92
+ ? LoaderCircle
93
+ : label === "failed"
94
+ ? TriangleAlert
95
+ : CloudOff
96
+ return (
97
+ <span
98
+ role={label === "failed" ? "status" : undefined}
99
+ title={text}
100
+ data-save={label}
101
+ className={cn(
102
+ "flex h-5 shrink-0 items-center gap-1 text-xs whitespace-nowrap transition-colors",
103
+ label === "failed" ? "text-warning" : "text-muted-foreground"
104
+ )}
105
+ >
106
+ <Icon
107
+ className={cn("size-3.5", label === "saving" && "animate-spin motion-reduce:animate-none")}
108
+ aria-hidden="true"
109
+ />
110
+ <span className="sr-only @2xl:not-sr-only">{text}</span>
111
+ </span>
112
+ )
113
+ }
114
+
115
+ /** Why the reader's hold on a live artifact changed: they may only watch now, or it is gone. */
116
+ export type LiveNoticeReason = "access" | "not_shared" | "not_found"
117
+
118
+ /** Under the header, when the reader's hold on the artifact changed, saying how. */
119
+ export function LiveNotice({ reason }: { readonly reason: LiveNoticeReason }) {
120
+ const messages = useArtifactMessages().live
121
+ const text =
122
+ reason === "not_shared"
123
+ ? messages.notShared
124
+ : reason === "not_found"
125
+ ? messages.deleted
126
+ : messages.accessLost
127
+ return (
128
+ <p
129
+ role="status"
130
+ data-live-notice={reason}
131
+ className="flex shrink-0 items-center gap-2 border-b border-border/60 bg-muted/40 px-4 py-2 text-[13px] text-muted-foreground animate-in fade-in-0 duration-200"
132
+ >
133
+ <TriangleAlert className="size-4 shrink-0 text-warning" aria-hidden="true" />
134
+ {text}
135
+ </p>
136
+ )
137
+ }