@sixb/app 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (422) hide show
  1. package/dist/agent/agent-chat.d.ts +9 -2
  2. package/dist/agent/agent-chat.d.ts.map +1 -1
  3. package/dist/agent/agent-panel.d.ts +9 -1
  4. package/dist/agent/agent-panel.d.ts.map +1 -1
  5. package/dist/agent/agent-surface.d.ts.map +1 -1
  6. package/dist/agent/artifact-card.d.ts +3 -1
  7. package/dist/agent/artifact-card.d.ts.map +1 -1
  8. package/dist/agent/artifact-panel.d.ts +7 -1
  9. package/dist/agent/artifact-panel.d.ts.map +1 -1
  10. package/dist/agent/components/composer-place.d.ts +3 -1
  11. package/dist/agent/components/composer-place.d.ts.map +1 -1
  12. package/dist/agent/components/composer.d.ts +20 -1
  13. package/dist/agent/components/composer.d.ts.map +1 -1
  14. package/dist/agent/components/context-chips.d.ts.map +1 -1
  15. package/dist/agent/components/context-meter.d.ts +1 -1
  16. package/dist/agent/components/conversation-panel.d.ts +3 -1
  17. package/dist/agent/components/conversation-panel.d.ts.map +1 -1
  18. package/dist/agent/components/message-parts.d.ts +3 -1
  19. package/dist/agent/components/message-parts.d.ts.map +1 -1
  20. package/dist/agent/components/thread-artifacts-menu.d.ts.map +1 -1
  21. package/dist/agent/composer-insertion.d.ts +24 -0
  22. package/dist/agent/composer-insertion.d.ts.map +1 -0
  23. package/dist/agent/delegation/use-children.d.ts +5 -5
  24. package/dist/agent/delegation/use-children.d.ts.map +1 -1
  25. package/dist/agent/hooks/use-agent-conversation.d.ts +10 -4
  26. package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
  27. package/dist/agent/hooks/use-new-thread-place.d.ts +39 -17
  28. package/dist/agent/hooks/use-new-thread-place.d.ts.map +1 -1
  29. package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
  30. package/dist/agent/i18n/en.d.ts +14 -0
  31. package/dist/agent/i18n/en.d.ts.map +1 -1
  32. package/dist/agent/i18n/fr.d.ts.map +1 -1
  33. package/dist/agent/i18n/index.d.ts +20 -0
  34. package/dist/agent/i18n/index.d.ts.map +1 -1
  35. package/dist/agent/publish-artifact/interpret.d.ts +8 -2
  36. package/dist/agent/publish-artifact/interpret.d.ts.map +1 -1
  37. package/dist/agent/publish-artifact/open-artifact-tool-view.d.ts +9 -0
  38. package/dist/agent/publish-artifact/open-artifact-tool-view.d.ts.map +1 -0
  39. package/dist/agent/publish-artifact/publish-artifact-tool-view.d.ts +4 -2
  40. package/dist/agent/publish-artifact/publish-artifact-tool-view.d.ts.map +1 -1
  41. package/dist/agent/publish-artifact/use-live-publishes.d.ts +3 -3
  42. package/dist/agent/publish-artifact/use-live-publishes.d.ts.map +1 -1
  43. package/dist/agent/tool-views/built-in.d.ts.map +1 -1
  44. package/dist/agent/types.d.ts +3 -1
  45. package/dist/agent/types.d.ts.map +1 -1
  46. package/dist/artifacts/artifact-page.d.ts.map +1 -1
  47. package/dist/artifacts/artifact-viewer.d.ts +16 -0
  48. package/dist/artifacts/artifact-viewer.d.ts.map +1 -0
  49. package/dist/artifacts/card-details.d.ts +1 -1
  50. package/dist/artifacts/card-details.d.ts.map +1 -1
  51. package/dist/artifacts/card-preview.d.ts.map +1 -1
  52. package/dist/artifacts/comments-context.d.ts +48 -0
  53. package/dist/artifacts/comments-context.d.ts.map +1 -0
  54. package/dist/artifacts/edit-session.d.ts +6 -6
  55. package/dist/artifacts/edit-session.d.ts.map +1 -1
  56. package/dist/artifacts/file-source.d.ts.map +1 -1
  57. package/dist/artifacts/frame.d.ts +10 -2
  58. package/dist/artifacts/frame.d.ts.map +1 -1
  59. package/dist/artifacts/guest-badge.d.ts +8 -0
  60. package/dist/artifacts/guest-badge.d.ts.map +1 -0
  61. package/dist/artifacts/held-artifact.d.ts +19 -0
  62. package/dist/artifacts/held-artifact.d.ts.map +1 -0
  63. package/dist/artifacts/holders.d.ts +10 -0
  64. package/dist/artifacts/holders.d.ts.map +1 -0
  65. package/dist/artifacts/live/boards.d.ts +15 -0
  66. package/dist/artifacts/live/boards.d.ts.map +1 -0
  67. package/dist/artifacts/live/canvas.d.ts +79 -0
  68. package/dist/artifacts/live/canvas.d.ts.map +1 -0
  69. package/dist/artifacts/live/header.d.ts +29 -0
  70. package/dist/artifacts/live/header.d.ts.map +1 -0
  71. package/dist/artifacts/live/hooks.d.ts +21 -0
  72. package/dist/artifacts/live/hooks.d.ts.map +1 -0
  73. package/dist/artifacts/live/presence.d.ts +32 -0
  74. package/dist/artifacts/live/presence.d.ts.map +1 -0
  75. package/dist/artifacts/live/session.d.ts +130 -0
  76. package/dist/artifacts/live/session.d.ts.map +1 -0
  77. package/dist/artifacts/live/view.d.ts +28 -0
  78. package/dist/artifacts/live/view.d.ts.map +1 -0
  79. package/dist/artifacts/messages.d.ts +424 -14
  80. package/dist/artifacts/messages.d.ts.map +1 -1
  81. package/dist/artifacts/page-queries.d.ts +2 -2
  82. package/dist/artifacts/page-queries.d.ts.map +1 -1
  83. package/dist/artifacts/page-state.d.ts.map +1 -1
  84. package/dist/artifacts/publish-edit.d.ts +24 -14
  85. package/dist/artifacts/publish-edit.d.ts.map +1 -1
  86. package/dist/artifacts/queries.d.ts +490 -9
  87. package/dist/artifacts/queries.d.ts.map +1 -1
  88. package/dist/artifacts/references/references.d.ts.map +1 -1
  89. package/dist/artifacts/renderers/canvas/arrows.d.ts +0 -18
  90. package/dist/artifacts/renderers/canvas/arrows.d.ts.map +1 -1
  91. package/dist/artifacts/renderers/canvas/board-editor.d.ts +43 -0
  92. package/dist/artifacts/renderers/canvas/board-editor.d.ts.map +1 -0
  93. package/dist/artifacts/renderers/canvas/board-properties.d.ts +37 -0
  94. package/dist/artifacts/renderers/canvas/board-properties.d.ts.map +1 -0
  95. package/dist/artifacts/renderers/canvas/board-source.d.ts +18 -0
  96. package/dist/artifacts/renderers/canvas/board-source.d.ts.map +1 -0
  97. package/dist/artifacts/renderers/canvas/board.d.ts +64 -19
  98. package/dist/artifacts/renderers/canvas/board.d.ts.map +1 -1
  99. package/dist/artifacts/renderers/canvas/canvas.d.ts +13 -4
  100. package/dist/artifacts/renderers/canvas/canvas.d.ts.map +1 -1
  101. package/dist/artifacts/renderers/canvas/comment-pins.d.ts +84 -0
  102. package/dist/artifacts/renderers/canvas/comment-pins.d.ts.map +1 -0
  103. package/dist/artifacts/renderers/canvas/commenting.d.ts +58 -0
  104. package/dist/artifacts/renderers/canvas/commenting.d.ts.map +1 -0
  105. package/dist/artifacts/renderers/canvas/comments-panel.d.ts +27 -0
  106. package/dist/artifacts/renderers/canvas/comments-panel.d.ts.map +1 -0
  107. package/dist/artifacts/renderers/canvas/comments.d.ts +56 -0
  108. package/dist/artifacts/renderers/canvas/comments.d.ts.map +1 -0
  109. package/dist/artifacts/renderers/canvas/draft.d.ts +7 -6
  110. package/dist/artifacts/renderers/canvas/draft.d.ts.map +1 -1
  111. package/dist/artifacts/renderers/canvas/edit-mode.d.ts +19 -2
  112. package/dist/artifacts/renderers/canvas/edit-mode.d.ts.map +1 -1
  113. package/dist/artifacts/renderers/canvas/focus.d.ts +40 -5
  114. package/dist/artifacts/renderers/canvas/focus.d.ts.map +1 -1
  115. package/dist/artifacts/renderers/canvas/items.d.ts +47 -4
  116. package/dist/artifacts/renderers/canvas/items.d.ts.map +1 -1
  117. package/dist/artifacts/renderers/canvas/layout.d.ts +5 -8
  118. package/dist/artifacts/renderers/canvas/layout.d.ts.map +1 -1
  119. package/dist/artifacts/renderers/canvas/presence.d.ts +21 -0
  120. package/dist/artifacts/renderers/canvas/presence.d.ts.map +1 -0
  121. package/dist/artifacts/renderers/canvas/previews.d.ts +54 -0
  122. package/dist/artifacts/renderers/canvas/previews.d.ts.map +1 -0
  123. package/dist/artifacts/renderers/canvas/renderer.d.ts +11 -2
  124. package/dist/artifacts/renderers/canvas/renderer.d.ts.map +1 -1
  125. package/dist/artifacts/renderers/canvas/thumbnail.d.ts +5 -2
  126. package/dist/artifacts/renderers/canvas/thumbnail.d.ts.map +1 -1
  127. package/dist/artifacts/version-menu.d.ts +19 -0
  128. package/dist/artifacts/version-menu.d.ts.map +1 -0
  129. package/dist/artifacts/view-context.d.ts +43 -0
  130. package/dist/artifacts/view-context.d.ts.map +1 -0
  131. package/dist/artifacts/viewer.d.ts.map +1 -1
  132. package/dist/build.d.ts +5 -0
  133. package/dist/build.d.ts.map +1 -1
  134. package/dist/{chunk-ytadd0b5.js → chunk-001c4gnk.js} +6871 -3756
  135. package/dist/chunk-001c4gnk.js.map +204 -0
  136. package/dist/chunk-00wggsst.js +7 -0
  137. package/dist/chunk-00wggsst.js.map +10 -0
  138. package/dist/chunk-5crvhjp2.js +4704 -0
  139. package/dist/chunk-5crvhjp2.js.map +28 -0
  140. package/dist/{chunk-q69001w3.js → chunk-694m74s7.js} +7 -1
  141. package/dist/{chunk-q69001w3.js.map → chunk-694m74s7.js.map} +3 -3
  142. package/dist/{chunk-4mprsd2n.js → chunk-fg6thecb.js} +25 -1
  143. package/dist/chunk-fg6thecb.js.map +10 -0
  144. package/dist/{chunk-j8g956dt.js → chunk-fwb9mxwm.js} +1 -1
  145. package/dist/{chunk-7fj9cfkw.js → chunk-kes4ygmz.js} +1 -1
  146. package/dist/{chunk-kwbw4dyk.js → chunk-ryed2jq8.js} +1 -1
  147. package/dist/codegen.d.ts.map +1 -1
  148. package/dist/createCustomApp.d.ts.map +1 -1
  149. package/dist/index.d.ts +7 -1
  150. package/dist/index.d.ts.map +1 -1
  151. package/dist/index.js +930 -309
  152. package/dist/index.js.map +15 -10
  153. package/dist/locale-messages.d.ts +12 -0
  154. package/dist/locale-messages.d.ts.map +1 -1
  155. package/dist/locale.d.ts +12 -0
  156. package/dist/locale.d.ts.map +1 -1
  157. package/dist/locale.js +1 -1
  158. package/dist/metadata.d.ts +8 -0
  159. package/dist/metadata.d.ts.map +1 -1
  160. package/dist/pages/console/action-run.d.ts.map +1 -1
  161. package/dist/pages/console/data/connectors.d.ts.map +1 -1
  162. package/dist/pages/console/data/datasets.d.ts.map +1 -1
  163. package/dist/pages/console/data/lake-health.d.ts +3 -0
  164. package/dist/pages/console/data/lake-health.d.ts.map +1 -0
  165. package/dist/pages/console/data/messages.d.ts +98 -2
  166. package/dist/pages/console/data/messages.d.ts.map +1 -1
  167. package/dist/pages/console/data/pipelines.d.ts.map +1 -1
  168. package/dist/pages/console/data/projections.d.ts.map +1 -1
  169. package/dist/pages/console/data/syncs.d.ts.map +1 -1
  170. package/dist/pages/console/ontology/action-runs.d.ts.map +1 -1
  171. package/dist/pages/console/ontology/actions.d.ts.map +1 -1
  172. package/dist/pages/console/ontology/components/action-button.d.ts.map +1 -1
  173. package/dist/pages/console/ontology/components/artifact-picker.d.ts +36 -0
  174. package/dist/pages/console/ontology/components/artifact-picker.d.ts.map +1 -0
  175. package/dist/pages/console/ontology/components/object-query-bar.d.ts.map +1 -1
  176. package/dist/pages/console/ontology/lib/action-params.d.ts +2 -0
  177. package/dist/pages/console/ontology/lib/action-params.d.ts.map +1 -1
  178. package/dist/pages/console/ontology/lineage/properties-panel.d.ts +2 -1
  179. package/dist/pages/console/ontology/lineage/properties-panel.d.ts.map +1 -1
  180. package/dist/pages/console/ontology/object-page.d.ts.map +1 -1
  181. package/dist/pages/console/ontology/object-type.d.ts.map +1 -1
  182. package/dist/pages/console/ontology/object-types.d.ts.map +1 -1
  183. package/dist/pages/console/ontology/objects.d.ts.map +1 -1
  184. package/dist/pages/console/ontology/rules.d.ts.map +1 -1
  185. package/dist/pages/console/ontology/workflow.d.ts.map +1 -1
  186. package/dist/pages/console/ontology/workflows/run-input-form.d.ts.map +1 -1
  187. package/dist/pages/console/ontology/workflows/schema-shape.d.ts.map +1 -1
  188. package/dist/pages/console/ontology/workflows.d.ts.map +1 -1
  189. package/dist/pages/console/skeletons.d.ts +30 -0
  190. package/dist/pages/console/skeletons.d.ts.map +1 -0
  191. package/dist/pages/console/workflow-run.d.ts.map +1 -1
  192. package/dist/pages/section-page.d.ts +11 -1
  193. package/dist/pages/section-page.d.ts.map +1 -1
  194. package/dist/pages/section-ui.d.ts +25 -3
  195. package/dist/pages/section-ui.d.ts.map +1 -1
  196. package/dist/pages/settings/activity/calendar.d.ts.map +1 -1
  197. package/dist/pages/settings/activity/connections.d.ts.map +1 -1
  198. package/dist/pages/settings/activity/page.d.ts.map +1 -1
  199. package/dist/pages/settings/activity/thread.d.ts.map +1 -1
  200. package/dist/pages/settings/activity/timeline.d.ts +2 -0
  201. package/dist/pages/settings/activity/timeline.d.ts.map +1 -1
  202. package/dist/pages/settings/controls.d.ts +4 -0
  203. package/dist/pages/settings/controls.d.ts.map +1 -1
  204. package/dist/pages/settings/members.d.ts.map +1 -1
  205. package/dist/pages/settings/memory-history.d.ts +2 -0
  206. package/dist/pages/settings/memory-history.d.ts.map +1 -1
  207. package/dist/pages/settings/memory.d.ts.map +1 -1
  208. package/dist/pages/settings/service-accounts.d.ts.map +1 -1
  209. package/dist/pages/settings/sessions.d.ts.map +1 -1
  210. package/dist/pages/settings/usage/breakdown.d.ts.map +1 -1
  211. package/dist/pages/settings/usage/limits.d.ts.map +1 -1
  212. package/dist/pages/settings/usage/messages.d.ts +0 -2
  213. package/dist/pages/settings/usage/messages.d.ts.map +1 -1
  214. package/dist/pages/settings/usage/runs.d.ts +8 -2
  215. package/dist/pages/settings/usage/runs.d.ts.map +1 -1
  216. package/dist/pages/settings/usage/spend-chart.d.ts.map +1 -1
  217. package/dist/pages/settings/usage/spend-model.d.ts +5 -0
  218. package/dist/pages/settings/usage/spend-model.d.ts.map +1 -1
  219. package/dist/pages/values.d.ts +6 -0
  220. package/dist/pages/values.d.ts.map +1 -1
  221. package/dist/pages.d.ts +4 -0
  222. package/dist/pages.d.ts.map +1 -1
  223. package/dist/pages.js +8188 -4841
  224. package/dist/pages.js.map +56 -47
  225. package/dist/sections/catalog.d.ts.map +1 -1
  226. package/dist/sections/sections.d.ts.map +1 -1
  227. package/dist/server.js +294 -23
  228. package/dist/server.js.map +8 -7
  229. package/dist/service-worker.d.ts +39 -0
  230. package/dist/service-worker.d.ts.map +1 -0
  231. package/dist/shared-session.d.ts +25 -0
  232. package/dist/shared-session.d.ts.map +1 -0
  233. package/dist/shell/app-return.d.ts +35 -0
  234. package/dist/shell/app-return.d.ts.map +1 -0
  235. package/dist/shell/app-shell.d.ts +1 -1
  236. package/dist/shell/app-shell.d.ts.map +1 -1
  237. package/dist/shell/nav-items.d.ts +2 -0
  238. package/dist/shell/nav-items.d.ts.map +1 -1
  239. package/dist/shell/phone/back.d.ts +6 -0
  240. package/dist/shell/phone/back.d.ts.map +1 -0
  241. package/dist/shell/phone/launch.d.ts +7 -0
  242. package/dist/shell/phone/launch.d.ts.map +1 -0
  243. package/dist/shell/phone/more-sheet.d.ts +36 -0
  244. package/dist/shell/phone/more-sheet.d.ts.map +1 -0
  245. package/dist/shell/phone/phone-foundations.d.ts +9 -0
  246. package/dist/shell/phone/phone-foundations.d.ts.map +1 -0
  247. package/dist/shell/phone/pull-to-refresh.d.ts +9 -0
  248. package/dist/shell/phone/pull-to-refresh.d.ts.map +1 -0
  249. package/dist/shell/phone/routes.d.ts +12 -0
  250. package/dist/shell/phone/routes.d.ts.map +1 -0
  251. package/dist/shell/phone/screen-motion.d.ts +11 -0
  252. package/dist/shell/phone/screen-motion.d.ts.map +1 -0
  253. package/dist/shell/phone/scroll-restoration.d.ts +7 -0
  254. package/dist/shell/phone/scroll-restoration.d.ts.map +1 -0
  255. package/dist/shell/phone/startup-image.d.ts +17 -0
  256. package/dist/shell/phone/startup-image.d.ts.map +1 -0
  257. package/dist/shell/phone/tab-bar.d.ts +14 -0
  258. package/dist/shell/phone/tab-bar.d.ts.map +1 -0
  259. package/dist/shell/phone/top-bar.d.ts +24 -0
  260. package/dist/shell/phone/top-bar.d.ts.map +1 -0
  261. package/dist/shell/search-command.d.ts +3 -1
  262. package/dist/shell/search-command.d.ts.map +1 -1
  263. package/dist/shell/user-menu.d.ts +2 -0
  264. package/dist/shell/user-menu.d.ts.map +1 -1
  265. package/package.json +8 -5
  266. package/src/agent/agent-chat.tsx +51 -8
  267. package/src/agent/agent-panel.tsx +12 -0
  268. package/src/agent/agent-surface.tsx +4 -0
  269. package/src/agent/artifact-card.tsx +84 -16
  270. package/src/agent/artifact-panel.tsx +63 -43
  271. package/src/agent/components/agent-message-body.tsx +1 -1
  272. package/src/agent/components/composer-place.tsx +77 -53
  273. package/src/agent/components/composer.tsx +92 -7
  274. package/src/agent/components/context-chips.tsx +72 -2
  275. package/src/agent/components/conversation-panel.tsx +3 -2
  276. package/src/agent/components/message-parts.tsx +6 -1
  277. package/src/agent/components/thread-artifacts-menu.tsx +22 -5
  278. package/src/agent/composer-insertion.ts +36 -0
  279. package/src/agent/hooks/use-agent-conversation.ts +41 -10
  280. package/src/agent/hooks/use-new-thread-place.ts +149 -25
  281. package/src/agent/i18n/en.ts +14 -0
  282. package/src/agent/i18n/fr.ts +12 -0
  283. package/src/agent/publish-artifact/interpret.ts +27 -5
  284. package/src/agent/publish-artifact/open-artifact-tool-view.tsx +49 -0
  285. package/src/agent/publish-artifact/publish-artifact-tool-view.tsx +14 -8
  286. package/src/agent/publish-artifact/use-live-publishes.ts +7 -11
  287. package/src/agent/react-router.tsx +2 -2
  288. package/src/agent/tool-views/built-in.tsx +3 -0
  289. package/src/agent/types.ts +4 -0
  290. package/src/artifacts/artifact-page.tsx +42 -17
  291. package/src/artifacts/artifact-viewer.tsx +56 -0
  292. package/src/artifacts/artifacts.css +80 -0
  293. package/src/artifacts/card-details.ts +2 -2
  294. package/src/artifacts/card-preview.tsx +17 -3
  295. package/src/artifacts/comments-context.ts +125 -0
  296. package/src/artifacts/edit-session.tsx +6 -6
  297. package/src/artifacts/file-source.ts +10 -3
  298. package/src/artifacts/frame.tsx +50 -12
  299. package/src/artifacts/gallery.tsx +9 -11
  300. package/src/artifacts/guest-badge.tsx +21 -0
  301. package/src/artifacts/held-artifact.tsx +241 -0
  302. package/src/artifacts/holders.tsx +170 -0
  303. package/src/artifacts/live/boards.ts +95 -0
  304. package/src/artifacts/live/canvas.ts +402 -0
  305. package/src/artifacts/live/header.tsx +137 -0
  306. package/src/artifacts/live/hooks.ts +94 -0
  307. package/src/artifacts/live/presence.ts +147 -0
  308. package/src/artifacts/live/session.ts +520 -0
  309. package/src/artifacts/live/view.ts +81 -0
  310. package/src/artifacts/messages.ts +415 -24
  311. package/src/artifacts/page-queries.ts +2 -3
  312. package/src/artifacts/page-state.ts +16 -7
  313. package/src/artifacts/publish-edit.ts +50 -22
  314. package/src/artifacts/queries.ts +108 -10
  315. package/src/artifacts/references/references.tsx +6 -9
  316. package/src/artifacts/renderers/canvas/arrows.tsx +12 -39
  317. package/src/artifacts/renderers/canvas/board-editor.tsx +817 -0
  318. package/src/artifacts/renderers/canvas/board-properties.tsx +488 -0
  319. package/src/artifacts/renderers/canvas/board-source.ts +110 -0
  320. package/src/artifacts/renderers/canvas/board.tsx +309 -33
  321. package/src/artifacts/renderers/canvas/canvas.tsx +387 -72
  322. package/src/artifacts/renderers/canvas/comment-pins.tsx +465 -0
  323. package/src/artifacts/renderers/canvas/commenting.tsx +319 -0
  324. package/src/artifacts/renderers/canvas/comments-panel.tsx +574 -0
  325. package/src/artifacts/renderers/canvas/comments.ts +225 -0
  326. package/src/artifacts/renderers/canvas/draft.ts +41 -50
  327. package/src/artifacts/renderers/canvas/edit-mode.tsx +145 -20
  328. package/src/artifacts/renderers/canvas/focus.tsx +175 -24
  329. package/src/artifacts/renderers/canvas/items.tsx +179 -52
  330. package/src/artifacts/renderers/canvas/layout.ts +99 -47
  331. package/src/artifacts/renderers/canvas/presence.tsx +184 -0
  332. package/src/artifacts/renderers/canvas/previews.ts +127 -0
  333. package/src/artifacts/renderers/canvas/renderer.tsx +87 -22
  334. package/src/artifacts/renderers/canvas/thumbnail.tsx +56 -15
  335. package/src/artifacts/renderers/canvas/toolbar.tsx +1 -1
  336. package/src/artifacts/renderers/slides/slides.tsx +1 -1
  337. package/src/artifacts/version-menu.tsx +438 -0
  338. package/src/artifacts/view-context.ts +102 -0
  339. package/src/artifacts/viewer.tsx +205 -147
  340. package/src/build.ts +96 -11
  341. package/src/codegen.ts +83 -5
  342. package/src/createCustomApp.ts +20 -7
  343. package/src/index.ts +12 -0
  344. package/src/locale-messages.ts +24 -0
  345. package/src/metadata.ts +12 -0
  346. package/src/pages/console/action-run.tsx +20 -0
  347. package/src/pages/console/data/connectors.tsx +27 -3
  348. package/src/pages/console/data/datasets.tsx +30 -1
  349. package/src/pages/console/data/lake-health.tsx +299 -0
  350. package/src/pages/console/data/messages.ts +143 -2
  351. package/src/pages/console/data/pipelines.tsx +91 -3
  352. package/src/pages/console/data/projections.tsx +23 -4
  353. package/src/pages/console/data/syncs.tsx +39 -2
  354. package/src/pages/console/ontology/action-runs.tsx +8 -2
  355. package/src/pages/console/ontology/actions.tsx +39 -15
  356. package/src/pages/console/ontology/components/action-button.tsx +10 -0
  357. package/src/pages/console/ontology/components/artifact-picker.tsx +522 -0
  358. package/src/pages/console/ontology/components/object-query-bar.tsx +21 -5
  359. package/src/pages/console/ontology/lib/action-params.ts +10 -0
  360. package/src/pages/console/ontology/lineage/properties-panel.tsx +32 -24
  361. package/src/pages/console/ontology/object-page.tsx +2 -0
  362. package/src/pages/console/ontology/object-type.tsx +73 -14
  363. package/src/pages/console/ontology/object-types.tsx +56 -7
  364. package/src/pages/console/ontology/objects.tsx +167 -19
  365. package/src/pages/console/ontology/rules.tsx +186 -30
  366. package/src/pages/console/ontology/workflow.tsx +130 -74
  367. package/src/pages/console/ontology/workflows/run-input-form.tsx +21 -2
  368. package/src/pages/console/ontology/workflows/schema-shape.tsx +3 -0
  369. package/src/pages/console/ontology/workflows.tsx +34 -21
  370. package/src/pages/console/skeletons.tsx +99 -0
  371. package/src/pages/console/workflow-run.tsx +20 -0
  372. package/src/pages/section-page.tsx +37 -7
  373. package/src/pages/section-ui.tsx +96 -13
  374. package/src/pages/settings/activity/calendar.tsx +13 -6
  375. package/src/pages/settings/activity/connections.tsx +26 -9
  376. package/src/pages/settings/activity/page.tsx +31 -4
  377. package/src/pages/settings/activity/thread.tsx +32 -18
  378. package/src/pages/settings/activity/timeline.tsx +39 -0
  379. package/src/pages/settings/controls.tsx +19 -1
  380. package/src/pages/settings/developers.tsx +2 -2
  381. package/src/pages/settings/members.tsx +42 -9
  382. package/src/pages/settings/memory-history.tsx +76 -10
  383. package/src/pages/settings/memory.tsx +47 -5
  384. package/src/pages/settings/service-accounts.tsx +7 -2
  385. package/src/pages/settings/sessions.tsx +6 -2
  386. package/src/pages/settings/usage/breakdown.tsx +62 -2
  387. package/src/pages/settings/usage/limits.tsx +45 -3
  388. package/src/pages/settings/usage/messages.ts +0 -2
  389. package/src/pages/settings/usage/page.tsx +99 -52
  390. package/src/pages/settings/usage/runs.tsx +105 -8
  391. package/src/pages/settings/usage/spend-chart.tsx +79 -45
  392. package/src/pages/settings/usage/spend-model.ts +16 -0
  393. package/src/pages/values.tsx +72 -6
  394. package/src/pages.ts +4 -0
  395. package/src/sections/catalog.ts +6 -0
  396. package/src/sections/sections.tsx +2 -0
  397. package/src/service-worker.ts +176 -0
  398. package/src/shared-session.ts +73 -0
  399. package/src/shell/app-return.ts +115 -0
  400. package/src/shell/app-shell.tsx +125 -27
  401. package/src/shell/nav-items.tsx +2 -0
  402. package/src/shell/phone/back.ts +16 -0
  403. package/src/shell/phone/launch.ts +6 -0
  404. package/src/shell/phone/more-sheet.tsx +249 -0
  405. package/src/shell/phone/phone-foundations.tsx +43 -0
  406. package/src/shell/phone/phone.css +660 -0
  407. package/src/shell/phone/pull-to-refresh.tsx +201 -0
  408. package/src/shell/phone/routes.ts +34 -0
  409. package/src/shell/phone/screen-motion.ts +292 -0
  410. package/src/shell/phone/scroll-restoration.tsx +70 -0
  411. package/src/shell/phone/startup-image.ts +119 -0
  412. package/src/shell/phone/tab-bar.tsx +95 -0
  413. package/src/shell/phone/top-bar.tsx +195 -0
  414. package/src/shell/search-command.tsx +30 -14
  415. package/src/shell/user-menu.tsx +2 -1
  416. package/dist/chunk-4j3c3p72.js +0 -1487
  417. package/dist/chunk-4j3c3p72.js.map +0 -18
  418. package/dist/chunk-4mprsd2n.js.map +0 -10
  419. package/dist/chunk-ytadd0b5.js.map +0 -188
  420. /package/dist/{chunk-j8g956dt.js.map → chunk-fwb9mxwm.js.map} +0 -0
  421. /package/dist/{chunk-7fj9cfkw.js.map → chunk-kes4ygmz.js.map} +0 -0
  422. /package/dist/{chunk-kwbw4dyk.js.map → chunk-ryed2jq8.js.map} +0 -0
@@ -1,4 +1,5 @@
1
- import type { Canvas, CanvasArrow, CanvasEnd, CanvasItem } from "@sixb/core/artifacts"
1
+ import type { Canvas, CanvasArrow, CanvasEnd, CanvasItem, CanvasNote } from "@sixb/core/artifacts"
2
+ import { ARTIFACT_LIMITS, CANVAS_TEXT_PIXELS, canvasNoteFontSize } from "@sixb/core/artifacts"
2
3
  import type { Edge, Node } from "@xyflow/react"
3
4
 
4
5
  /** What a node on the board draws: one of the canvas's items, or an arrow's end at a point. */
@@ -22,11 +23,26 @@ export interface Box {
22
23
  readonly height: number
23
24
  }
24
25
 
26
+ /** Over every item: an arrow to a point on a board shows on it. */
27
+ const ARROW_Z_INDEX = ARTIFACT_LIMITS.maxCanvasItems + 1
28
+
29
+ /** What an item drew as, at the place it had in the canvas's order. */
30
+ interface Drawn {
31
+ readonly order: number
32
+ readonly nodes: readonly CanvasFlowNode[]
33
+ readonly edges: readonly CanvasFlowEdge[]
34
+ }
35
+
36
+ const drawn = new WeakMap<CanvasItem, Drawn>()
37
+
25
38
  /**
26
39
  * The canvas as React Flow's nodes and edges. Each item is a node of its type at its place and
27
40
  * size; a note and a text without a width are measured once drawn. Sections draw
28
41
  * behind everything, the rest in the order the canvas lists them. An arrow is an edge between two
29
42
  * items, drawn over them all, and its end at a bare point is an invisible node there.
43
+ *
44
+ * An item that is the same object as before, at the same place in the order, draws as the same
45
+ * nodes and edge: React Flow draws again only what changed.
30
46
  */
31
47
  export function canvasGraph(canvas: Canvas): {
32
48
  readonly nodes: CanvasFlowNode[]
@@ -35,59 +51,79 @@ export function canvasGraph(canvas: Canvas): {
35
51
  const nodes: CanvasFlowNode[] = []
36
52
  const edges: CanvasFlowEdge[] = []
37
53
  canvas.items.forEach((item, order) => {
38
- if (item.type === "arrow") {
39
- const end = (side: "from" | "to", value: CanvasEnd) => {
40
- if (typeof value === "string") return value
41
- const id = `${item.id}:${side}`
42
- nodes.push({
43
- id,
44
- type: "point",
45
- position: { x: value.x, y: value.y },
46
- width: 1,
47
- height: 1,
48
- data: { item: null },
49
- selectable: false,
50
- focusable: false,
51
- })
52
- return id
53
- }
54
- edges.push({
55
- id: item.id,
56
- type: "floating",
57
- source: end("from", item.from),
58
- target: end("to", item.to),
59
- data: { ...(item.label ? { label: item.label } : {}), dashed: item.dashed },
60
- // Over every item: an arrow to a point on a board shows on it.
61
- zIndex: canvas.items.length,
62
- focusable: false,
54
+ let entry = drawn.get(item)
55
+ if (!entry || entry.order !== order) {
56
+ entry = { order, ...itemGraph(item, order) }
57
+ drawn.set(item, entry)
58
+ }
59
+ nodes.push(...entry.nodes)
60
+ edges.push(...entry.edges)
61
+ })
62
+ return { nodes, edges }
63
+ }
64
+
65
+ /** One item's nodes and edges. */
66
+ function itemGraph(
67
+ item: CanvasItem,
68
+ order: number
69
+ ): { readonly nodes: CanvasFlowNode[]; readonly edges: CanvasFlowEdge[] } {
70
+ const nodes: CanvasFlowNode[] = []
71
+ const edges: CanvasFlowEdge[] = []
72
+ if (item.type === "arrow") {
73
+ const end = (side: "from" | "to", value: CanvasEnd) => {
74
+ if (typeof value === "string") return value
75
+ const id = `${item.id}:${side}`
76
+ nodes.push({
77
+ id,
78
+ type: "point",
79
+ position: { x: value.x, y: value.y },
80
+ width: 1,
81
+ height: 1,
82
+ data: { item: null },
63
83
  selectable: false,
84
+ focusable: false,
64
85
  })
65
- return
86
+ return id
66
87
  }
67
- // A note grows to hold its text, its height only the least it takes: it is measured.
68
- const height = "h" in item && item.type !== "note" ? item.h : undefined
69
- const width = "w" in item ? item.w : undefined
70
- nodes.push({
88
+ edges.push({
71
89
  id: item.id,
72
- type: item.type,
73
- position: { x: item.x, y: item.y },
74
- ...(width === undefined ? {} : { width }),
75
- ...(height === undefined ? {} : { height }),
76
- data: { item },
77
- zIndex: item.type === "section" ? -1 : order,
78
- draggable: false,
79
- connectable: false,
90
+ type: "floating",
91
+ source: end("from", item.from),
92
+ target: end("to", item.to),
93
+ data: { ...(item.label ? { label: item.label } : {}), dashed: item.dashed },
94
+ zIndex: ARROW_Z_INDEX,
95
+ focusable: false,
80
96
  selectable: false,
81
- // Boards are the items a reader opens; the rest are read where they lie.
82
- focusable: item.type === "board",
83
97
  })
98
+ return { nodes, edges }
99
+ }
100
+ // A note grows to hold its text, its height only the least it takes: it is measured.
101
+ const height = "h" in item && item.type !== "note" ? item.h : undefined
102
+ const width = "w" in item ? item.w : undefined
103
+ nodes.push({
104
+ id: item.id,
105
+ type: item.type,
106
+ position: { x: item.x, y: item.y },
107
+ ...(width === undefined ? {} : { width }),
108
+ ...(height === undefined ? {} : { height }),
109
+ data: { item },
110
+ zIndex: item.type === "section" ? -1 : order,
111
+ draggable: false,
112
+ connectable: false,
113
+ selectable: false,
114
+ // Boards are the items a reader opens; the rest are read where they lie. React Flow lets an
115
+ // item it can't select or drag take no pointer, so a board takes it back: a double-click
116
+ // reaches it, and a drag across it still pans.
117
+ focusable: item.type === "board",
118
+ ...(item.type === "board" ? { style: { pointerEvents: "all" } } : {}),
84
119
  })
85
120
  return { nodes, edges }
86
121
  }
87
122
 
88
123
  /**
89
124
  * The extent of every item with a size, for a picture of the whole canvas. Notes without a
90
- * height count as square, and texts as a line of their size, near enough for a thumbnail.
125
+ * height count as tall as their words, and texts as a line of their size, near enough for a
126
+ * thumbnail.
91
127
  */
92
128
  export function canvasExtent(canvas: Canvas): Box {
93
129
  let left = Number.POSITIVE_INFINITY
@@ -107,16 +143,13 @@ export function canvasExtent(canvas: Canvas): Box {
107
143
  : { x: 0, y: 0, width: 1, height: 1 }
108
144
  }
109
145
 
110
- /** The size a text of each size draws at, in pixels. */
111
- export const TEXT_SIZES = { s: 14, m: 18, l: 28, xl: 44 } as const
112
-
113
146
  /** An item's box as a thumbnail draws it, before anything is measured. */
114
147
  export function approximateBox(item: CanvasItem): Box | null {
115
148
  switch (item.type) {
116
149
  case "arrow":
117
150
  return null
118
151
  case "text": {
119
- const size = TEXT_SIZES[item.size]
152
+ const size = CANVAS_TEXT_PIXELS[item.size]
120
153
  return {
121
154
  x: item.x,
122
155
  y: item.y,
@@ -125,8 +158,27 @@ export function approximateBox(item: CanvasItem): Box | null {
125
158
  }
126
159
  }
127
160
  case "note":
128
- return { x: item.x, y: item.y, width: item.w, height: item.h ?? item.w }
161
+ return { x: item.x, y: item.y, width: item.w, height: item.h ?? noteHeight(item) }
129
162
  default:
130
163
  return { x: item.x, y: item.y, width: item.w, height: item.h }
131
164
  }
132
165
  }
166
+
167
+ /** Roughly how wide a character of a note's words is, against its type's size. */
168
+ const NOTE_CHARACTER_WIDTH = 0.55
169
+
170
+ /**
171
+ * How tall a note without a height draws: as many lines as its words take at its width, inside
172
+ * its padding, and never shorter than the least a note is. A thumbnail can't measure it.
173
+ */
174
+ function noteHeight(note: CanvasNote): number {
175
+ const size = canvasNoteFontSize(note.w)
176
+
177
+ // The note's own padding: 1em on each side, 0.85em above and below.
178
+ const perLine = Math.max(1, Math.floor((note.w - size * 2) / (size * NOTE_CHARACTER_WIDTH)))
179
+ const lines = note.text
180
+ .split("\n")
181
+ .reduce((count, paragraph) => count + Math.max(1, Math.ceil(paragraph.length / perLine)), 0)
182
+
183
+ return Math.max(Math.min(note.w, 112), lines * size * 1.4 + size * 1.7)
184
+ }
@@ -0,0 +1,184 @@
1
+ import type { ArtifactLiveUser } from "@sixb/core/artifacts/live"
2
+ import { type InternalNode, useStore, ViewportPortal } from "@xyflow/react"
3
+ import { Sparkles } from "lucide-react"
4
+ import { memo, useCallback } from "react"
5
+ import { livePersonName, useLivePresence } from "../../live/presence"
6
+ import type { LiveArtifact } from "../../live/session"
7
+ import { useArtifactMessages } from "../../messages"
8
+ import { NAME_SCALE_VALUE } from "./items"
9
+
10
+ /** An item's box on the canvas, as React Flow measured it. */
11
+ interface Box {
12
+ readonly x: number
13
+ readonly y: number
14
+ readonly w: number
15
+ readonly h: number
16
+ }
17
+
18
+ /**
19
+ * How far down the board view a selection's top must be for its name to show above it: the
20
+ * toolbar, while editing, and a name's height. Higher, the name shows under the selection's top
21
+ * edge, never under the toolbar nor off the view.
22
+ */
23
+ export const NAME_CLEARANCE = 96
24
+
25
+ /** Whether a selection's name goes under its top edge, where the view puts its box now. */
26
+ export function nameBelow(box: { readonly y: number }, transform: readonly number[]): boolean {
27
+ const [, panY = 0, zoom = 1] = transform
28
+ return box.y * zoom + panY < NAME_CLEARANCE
29
+ }
30
+
31
+ /**
32
+ * Over the canvas, where the others are: each person's selection outlined in their color, their
33
+ * name above it, or just under its top edge near the top of the view, and each board an Agent
34
+ * turn is changing, its outline shimmering and a badge saying so, kept within the board. Drawn
35
+ * in the canvas's own coordinates, it takes no pointer.
36
+ */
37
+ export const PresenceLayer = memo(function PresenceLayer({
38
+ live,
39
+ }: {
40
+ readonly live: LiveArtifact
41
+ }) {
42
+ const messages = useArtifactMessages().canvas.live
43
+ const all = useArtifactMessages()
44
+ const guestLabel = all.canvas.comments.guest
45
+ const labels = { guest: guestLabel, teamMember: all.live.teamMember }
46
+ const { peers, agents } = useLivePresence(live)
47
+
48
+ // One outline per item someone selected: the first person who did names it.
49
+ const selected = new Map<string, ArtifactLiveUser>()
50
+ for (const peer of peers) {
51
+ for (const id of peer.selection) if (!selected.has(id)) selected.set(id, peer.user)
52
+ }
53
+ const changing = [...new Set(agents.flatMap((agent) => agent.boards))]
54
+ const boxes = useBoxes([...selected.keys(), ...changing])
55
+ // The selections whose names go under their top edge: read again as the view moves, drawn
56
+ // again only as one of them crosses.
57
+ const below = useStore(
58
+ useCallback(
59
+ (state: { readonly transform: readonly number[] }) =>
60
+ [...boxes]
61
+ .filter(([, box]) => nameBelow(box, state.transform))
62
+ .map(([id]) => id)
63
+ .join("\n"),
64
+ [boxes]
65
+ )
66
+ )
67
+
68
+ if (boxes.size === 0) return null
69
+ return (
70
+ <ViewportPortal>
71
+ {changing.map((id) => {
72
+ const box = boxes.get(id)
73
+ return box ? (
74
+ <div
75
+ key={`agent:${id}`}
76
+ data-agent-board={id}
77
+ className="sixb-agent-board pointer-events-none absolute rounded-[12px]"
78
+ style={place(box, 4)}
79
+ >
80
+ {/*
81
+ * The badge's lane: the board's width less its margins, at the badge's scale, so the
82
+ * badge never reaches past the board. Narrow, its words truncate, then leave the icon.
83
+ */}
84
+ <div
85
+ className="@container absolute top-3 right-3 flex origin-top-right justify-end"
86
+ style={{
87
+ width: `calc(${Math.max(box.w - 16, 0)}px / ${NAME_SCALE_VALUE})`,
88
+ transform: `scale(${NAME_SCALE_VALUE})`,
89
+ }}
90
+ >
91
+ <span
92
+ title={messages.agentChanging}
93
+ className="flex max-w-full min-w-0 items-center gap-1.5 rounded-full bg-background/95 px-2.5 py-1 text-[12px] font-medium whitespace-nowrap text-primary shadow-[0_1px_2px_rgb(0_0_0/0.08),0_6px_16px_-8px_rgb(0_0_0/0.3)] ring-1 ring-[color-mix(in_oklab,var(--primary)_25%,transparent)] @max-[8rem]:px-1.5"
94
+ >
95
+ <Sparkles
96
+ className="size-3.5 shrink-0 motion-safe:animate-pulse"
97
+ aria-hidden="true"
98
+ />
99
+ <span className="min-w-0 truncate @max-[8rem]:sr-only">
100
+ {messages.agentChanging}
101
+ </span>
102
+ </span>
103
+ </div>
104
+ </div>
105
+ ) : null
106
+ })}
107
+ {[...selected].map(([id, user]) => {
108
+ const box = boxes.get(id)
109
+ return box ? (
110
+ <div
111
+ key={`peer:${id}`}
112
+ data-peer-selection={id}
113
+ className="pointer-events-none absolute rounded-[6px]"
114
+ style={{
115
+ ...place(box, 3),
116
+ boxShadow: `0 0 0 calc(2px * ${NAME_SCALE_VALUE}) ${user.color}`,
117
+ }}
118
+ >
119
+ <span
120
+ data-name={below.split("\n").includes(id) ? "below" : "above"}
121
+ className="absolute left-0 rounded-[4px] px-1.5 py-px text-[11px] leading-4 font-medium whitespace-nowrap text-white data-[name=above]:bottom-full data-[name=above]:mb-1 data-[name=above]:origin-bottom-left data-[name=below]:top-1 data-[name=below]:left-1 data-[name=below]:origin-top-left"
122
+ style={{ backgroundColor: user.color, transform: `scale(${NAME_SCALE_VALUE})` }}
123
+ >
124
+ {livePersonName(user, labels)}
125
+ {user.guest && user.name ? <span className="opacity-75"> · {guestLabel}</span> : null}
126
+ </span>
127
+ </div>
128
+ ) : null
129
+ })}
130
+ </ViewportPortal>
131
+ )
132
+ })
133
+
134
+ /** A box drawn `margin` pixels around an item. */
135
+ function place(box: Box, margin: number) {
136
+ return {
137
+ transform: `translate(${box.x - margin}px, ${box.y - margin}px)`,
138
+ width: box.w + margin * 2,
139
+ height: box.h + margin * 2,
140
+ }
141
+ }
142
+
143
+ /** The boxes of these items, read again only as one of them moves or changes size. */
144
+ function useBoxes(ids: readonly string[]): ReadonlyMap<string, Box> {
145
+ const key = ids.join("\n")
146
+ const select = useCallback(
147
+ (state: { readonly nodeLookup: ReadonlyMap<string, InternalNode> }) => {
148
+ const boxes = new Map<string, Box>()
149
+ for (const id of key ? key.split("\n") : []) {
150
+ const node = state.nodeLookup.get(id)
151
+ const box = node ? boxOf(node) : null
152
+ if (box) boxes.set(id, box)
153
+ }
154
+ return boxes
155
+ },
156
+ [key]
157
+ )
158
+ return useStore(select, sameBoxes)
159
+ }
160
+
161
+ function boxOf(node: InternalNode): Box | null {
162
+ const w = node.measured.width ?? node.width
163
+ const h = node.measured.height ?? node.height
164
+ if (w === undefined || h === undefined) return null
165
+ const { x, y } = node.internals.positionAbsolute
166
+ return { x, y, w, h }
167
+ }
168
+
169
+ function sameBoxes(left: ReadonlyMap<string, Box>, right: ReadonlyMap<string, Box>): boolean {
170
+ if (left.size !== right.size) return false
171
+ for (const [id, box] of left) {
172
+ const other = right.get(id)
173
+ if (
174
+ !other ||
175
+ other.x !== box.x ||
176
+ other.y !== box.y ||
177
+ other.w !== box.w ||
178
+ other.h !== box.h
179
+ ) {
180
+ return false
181
+ }
182
+ }
183
+ return true
184
+ }
@@ -0,0 +1,127 @@
1
+ import { client, getArtifactVersion, withSharedAccess } from "@sixb/client"
2
+ import { BOARD_PREVIEW_WAIT_MS, SMALL_BOARD_PREVIEW_WIDTH } from "@sixb/core/artifacts"
3
+ import { type Query, useQuery } from "@tanstack/react-query"
4
+ import type { ArtifactVersion } from "../../queries"
5
+
6
+ /**
7
+ * Whether a board's picture can be shown: `ready`, `pending` while it is rendered, `none` when
8
+ * none will come and the board shows its outline.
9
+ */
10
+ export type BoardPreviewStatus = "ready" | "pending" | "none"
11
+
12
+ export type BoardPreviews = Readonly<Record<string, BoardPreviewStatus>>
13
+
14
+ const NO_PREVIEWS: BoardPreviews = {}
15
+
16
+ /** The first look again for pictures still rendered, and the longest between two. */
17
+ const FIRST_CHECK_MS = 2_000
18
+ const LONGEST_CHECK_MS = 30_000
19
+
20
+ /**
21
+ * How long to wait before asking the version again which pictures are ready: never when none is
22
+ * pending or the version's last write is past the server's wait, else a little longer each time
23
+ * it is asked. An open version waits from its last write, as the server does.
24
+ */
25
+ export function nextPreviewCheck(
26
+ previews: BoardPreviews,
27
+ version: Pick<ArtifactVersion, "updatedAt">,
28
+ checks: number,
29
+ now: number
30
+ ): number | false {
31
+ if (!Object.values(previews).includes("pending")) return false
32
+
33
+ if (now - Date.parse(version.updatedAt) >= BOARD_PREVIEW_WAIT_MS) return false
34
+
35
+ return Math.min(LONGEST_CHECK_MS, FIRST_CHECK_MS * 1.5 ** checks)
36
+ }
37
+
38
+ /**
39
+ * A canvas version's boards and whether each one's picture is ready, asked again while some are
40
+ * rendered, as {@link nextPreviewCheck} says. Its own query, so the viewer's version stays as it
41
+ * was read. Without a version, a canvas drawn on its own, no board has a picture.
42
+ */
43
+ export function useBoardPreviews(version: ArtifactVersion | undefined): BoardPreviews {
44
+ return useQuery(boardPreviewsQuery(version)).data ?? NO_PREVIEWS
45
+ }
46
+
47
+ /**
48
+ * The query {@link useBoardPreviews} runs. The version's own answer starts it when it holds one:
49
+ * one without it, such as a version seeded from elsewhere, is asked rather than read as none.
50
+ */
51
+ export function boardPreviewsQuery(version: ArtifactVersion | undefined) {
52
+ return {
53
+ // A revision's boards are pictured once: an open version that changed asks again.
54
+ queryKey: ["artifact-board-previews", version?.artifactId, version?.version, version?.revision],
55
+ queryFn: async (): Promise<BoardPreviews> => {
56
+ if (!version) return NO_PREVIEWS
57
+
58
+ const { data } = await getArtifactVersion({
59
+ path: { artifactId: version.artifactId, version: String(version.version) },
60
+ throwOnError: true,
61
+ })
62
+ return data.boardPreviews ?? NO_PREVIEWS
63
+ },
64
+ ...(version?.boardPreviews ? { initialData: version.boardPreviews } : {}),
65
+ enabled: version !== undefined,
66
+ staleTime: Number.POSITIVE_INFINITY,
67
+ retry: false,
68
+ refetchInterval: (current: Query<BoardPreviews>) =>
69
+ version
70
+ ? nextPreviewCheck(
71
+ current.state.data ?? NO_PREVIEWS,
72
+ version,
73
+ current.state.dataUpdateCount,
74
+ Date.now()
75
+ )
76
+ : false,
77
+ }
78
+ }
79
+
80
+ /** A board's picture at its own size, or one at most {@link SMALL_BOARD_PREVIEW_WIDTH} wide. */
81
+ export type BoardPreviewSize = "small" | "full"
82
+
83
+ /**
84
+ * The picture a board's tile shows, from how wide it is on screen: the small one while that
85
+ * covers it pixel for pixel, the full one past it, so a canvas fitted to a hundred boards holds a
86
+ * hundred small pictures, not a hundred screens.
87
+ */
88
+ export function boardPreviewSize(screenWidth: number, pixelRatio: number): BoardPreviewSize {
89
+ return screenWidth * pixelRatio <= SMALL_BOARD_PREVIEW_WIDTH ? "small" : "full"
90
+ }
91
+
92
+ /**
93
+ * Where a board's picture is, in the reader's mode, at a size, of what the board shows: the
94
+ * server picks the mode a canvas pins, and the full size is its default. Named by the board's
95
+ * render key, the picture stays the same while the board does, however often an open canvas
96
+ * changes around it, as it does edited live; without one, by the revision shown. Either way it is
97
+ * kept for good, and one the version moved past is not found, never shown.
98
+ */
99
+ export function boardPreviewUrl(
100
+ version: Pick<ArtifactVersion, "artifactId" | "version" | "revision" | "outline">,
101
+ board: string,
102
+ mode: "light" | "dark",
103
+ size: BoardPreviewSize = "full"
104
+ ): string {
105
+ const artifact = `/api/artifacts/${encodeURIComponent(version.artifactId)}`
106
+ const path = `${artifact}/versions/${version.version}/boards/${encodeURIComponent(board)}/preview`
107
+ const url = new URL(path, client.getConfig().baseUrl || window.location.origin)
108
+ url.searchParams.set("theme", mode)
109
+ if (size === "small") url.searchParams.set("size", "small")
110
+ const key = renderKeyOf(version, board)
111
+ if (key) url.searchParams.set("key", key)
112
+ else url.searchParams.set("revision", String(version.revision))
113
+ // An `<img>` sends no header: a shared link's session names its grant in the address.
114
+ return withSharedAccess(url.toString())
115
+ }
116
+
117
+ /** The render key a version's outline gives a board, if it gives one. */
118
+ export function renderKeyOf(
119
+ version: Pick<ArtifactVersion, "outline">,
120
+ board: string
121
+ ): string | undefined {
122
+ if (version.outline.kind !== "canvas") return undefined
123
+ const item = version.outline.items.find(
124
+ (candidate) => candidate.type === "board" && candidate.id === board
125
+ )
126
+ return item?.type === "board" ? item.renderKey : undefined
127
+ }
@@ -1,9 +1,12 @@
1
1
  import { CANVAS_FILE, type Canvas, parseCanvas } from "@sixb/core/artifacts"
2
2
  import { useOptionalTheme } from "@sixb/ui/hooks"
3
- import { cn } from "@sixb/ui/lib/utils"
4
- import { lazy, Suspense, useEffect, useMemo, useState } from "react"
3
+ import { lazy, Suspense, useEffect, useMemo, useState, useSyncExternalStore } from "react"
5
4
  import { useArtifactEditing, useReportDraft } from "../../edit-session"
6
5
  import { type History, recordChange, redoChange, startHistory, undoChange } from "../../history"
6
+ import { type LiveCanvas, liveCanvasOf } from "../../live/canvas"
7
+ import { useLiveArtifactState, useViewerLiveArtifact } from "../../live/hooks"
8
+ import { shareSelection } from "../../live/presence"
9
+ import type { LiveArtifact } from "../../live/session"
7
10
  import { useArtifactMessages } from "../../messages"
8
11
  import { type ArtifactVersion, useFileText, versionFileSource } from "../../queries"
9
12
  import { useArtifactThemeAttributes } from "../../theme"
@@ -17,8 +20,13 @@ const CanvasBoard = lazy(() => import("./canvas"))
17
20
  * A version's `canvas.json`, parsed once it is read: undefined until then, and null when it
18
21
  * cannot be read or does not parse.
19
22
  */
20
- export function useCanvas(version: ArtifactVersion): Canvas | null | undefined {
21
- const file = useFileText(versionFileSource(version, CANVAS_FILE))
23
+ export function useCanvas(
24
+ version: ArtifactVersion,
25
+ options: { readonly enabled?: boolean } = {}
26
+ ): Canvas | null | undefined {
27
+ const file = useFileText(
28
+ options.enabled === false ? null : versionFileSource(version, CANVAS_FILE)
29
+ )
22
30
  return useMemo(() => {
23
31
  if (file.text === undefined) return file.loading ? undefined : null
24
32
  const parsed = parseCanvas(file.text)
@@ -26,7 +34,27 @@ export function useCanvas(version: ArtifactVersion): Canvas | null | undefined {
26
34
  }, [file.text, file.loading])
27
35
  }
28
36
 
29
- /** A canvas artifact: its board, in the app's theme or its own, opened where an address points. */
37
+ /** The mode a canvas's boards draw in: the one its theme.json pins, else the app's. */
38
+ export function useCanvasMode(version: ArtifactVersion): "light" | "dark" {
39
+ const theme = useArtifactThemeAttributes(version)
40
+ const app = useOptionalTheme()?.resolvedTheme
41
+
42
+ if (theme.className === "dark" || theme.className === "light") return theme.className
43
+
44
+ return (
45
+ app ??
46
+ (typeof document !== "undefined" && document.documentElement.classList.contains("dark")
47
+ ? "dark"
48
+ : "light")
49
+ )
50
+ }
51
+
52
+ /**
53
+ * A canvas artifact: its board, in the app's theme or its own, opened where an address points.
54
+ * Held live by the viewer, it is drawn from its live document once that holds it, everyone's
55
+ * changes as they make them, and edited there; else from the version's `canvas.json`, edited as
56
+ * a draft the header saves.
57
+ */
30
58
  export function CanvasRenderer({
31
59
  version,
32
60
  part,
@@ -36,33 +64,33 @@ export function CanvasRenderer({
36
64
  }) {
37
65
  const messages = useArtifactMessages()
38
66
  const theme = useArtifactThemeAttributes(version)
39
- const app = useOptionalTheme()?.resolvedTheme
40
- const canvas = useCanvas(version)
41
- const draft = useCanvasDraft(canvas)
42
- // The board draws in the mode its theme.json pins, else the app's.
43
- const mode =
44
- theme.className === "dark" || theme.className === "light"
45
- ? theme.className
46
- : (app ??
47
- (typeof document !== "undefined" && document.documentElement.classList.contains("dark")
48
- ? "dark"
49
- : "light"))
67
+ const mode = useCanvasMode(version)
68
+ const live = useViewerLiveArtifact()
69
+ const liveState = useLiveArtifactState(live)
70
+ const liveCanvas = live && liveState.synced && !liveState.left ? liveCanvasOf(live) : null
71
+ const fromDocument = useLiveCanvas(liveCanvas)
72
+ const fromVersion = useCanvas(version, { enabled: !fromDocument })
73
+ const canvas = fromDocument ?? fromVersion
74
+ const editing = useArtifactEditing()
75
+ const liveEdit = useLiveEditor(
76
+ live,
77
+ fromDocument && editing && liveState.access === "edit" ? liveCanvas : null
78
+ )
79
+ const draft = useCanvasDraft(fromDocument ? undefined : canvas)
50
80
  const loading = <ViewerLoading label={messages.viewer.loading} />
51
81
  if (canvas === undefined) return loading
52
82
  if (canvas === null) return <ViewerNotice title={messages.canvas.loadFailed} />
53
83
  return (
54
- <div
55
- data-sixb-artifact=""
56
- className={cn("flex min-h-0 flex-1 flex-col", theme.className)}
57
- style={theme.style}
58
- >
84
+ <div data-sixb-artifact="" className="flex min-h-0 flex-1 flex-col">
59
85
  <Suspense fallback={loading}>
60
86
  <CanvasBoard
61
87
  canvas={draft.canvas ?? canvas}
62
- {...(draft.edit ? { edit: draft.edit } : {})}
88
+ {...(liveEdit ? { edit: liveEdit } : draft.edit ? { edit: draft.edit } : {})}
89
+ {...(fromDocument && live ? { live } : {})}
63
90
  version={version}
64
91
  title={version.title}
65
92
  mode={mode}
93
+ theme={theme}
66
94
  {...(part ? { focus: part } : {})}
67
95
  />
68
96
  </Suspense>
@@ -70,6 +98,43 @@ export function CanvasRenderer({
70
98
  )
71
99
  }
72
100
 
101
+ const noSubscription = () => () => {}
102
+ const nothing = () => null
103
+
104
+ /** The canvas a live document holds, as it changes; null while there is none. */
105
+ function useLiveCanvas(canvas: LiveCanvas | null): Canvas | null {
106
+ return useSyncExternalStore(
107
+ canvas?.subscribe ?? noSubscription,
108
+ canvas?.getCanvas ?? nothing,
109
+ nothing
110
+ )
111
+ }
112
+
113
+ /**
114
+ * Editing the live document: each change written for everyone at once, this reader's own taken
115
+ * back by undo, and what they select shown to the others. Null while not editing.
116
+ */
117
+ function useLiveEditor(live: LiveArtifact | null, canvas: LiveCanvas | null): CanvasEditor | null {
118
+ return useMemo<CanvasEditor | null>(
119
+ () =>
120
+ live && canvas
121
+ ? {
122
+ apply: (change) => canvas.apply(change),
123
+ undo: () => canvas.undo(),
124
+ redo: () => canvas.redo(),
125
+ live: {
126
+ startDrag: () => canvas.startDrag(),
127
+ endDrag: () => canvas.endDrag(),
128
+ stopCapturing: () => canvas.stopCapturing(),
129
+ select: (ids) => shareSelection(live, ids),
130
+ editBoard: (path, make, files) => canvas.editBoard(path, make, files),
131
+ },
132
+ }
133
+ : null,
134
+ [live, canvas]
135
+ )
136
+ }
137
+
73
138
  /**
74
139
  * The canvas as the reader arranges it, while the viewer is editing: each change a step for undo,
75
140
  * and the draft reported to the header's Save. Leaving editing drops it.