@sixb/app 0.2.0 → 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 (469) hide show
  1. package/assets/connector-icons/README.md +1 -0
  2. package/assets/connector-icons/fleetio.ico +0 -0
  3. package/dist/agent/activity-label.d.ts.map +1 -1
  4. package/dist/agent/agent-chat.d.ts +9 -2
  5. package/dist/agent/agent-chat.d.ts.map +1 -1
  6. package/dist/agent/agent-panel.d.ts +9 -1
  7. package/dist/agent/agent-panel.d.ts.map +1 -1
  8. package/dist/agent/agent-surface.d.ts.map +1 -1
  9. package/dist/agent/artifact-card.d.ts +3 -1
  10. package/dist/agent/artifact-card.d.ts.map +1 -1
  11. package/dist/agent/artifact-panel.d.ts +7 -1
  12. package/dist/agent/artifact-panel.d.ts.map +1 -1
  13. package/dist/agent/background/background-card.d.ts +10 -0
  14. package/dist/agent/background/background-card.d.ts.map +1 -0
  15. package/dist/agent/background/background-tool-row.d.ts +9 -0
  16. package/dist/agent/background/background-tool-row.d.ts.map +1 -0
  17. package/dist/agent/background/context.d.ts +23 -0
  18. package/dist/agent/background/context.d.ts.map +1 -0
  19. package/dist/agent/background/interpret.d.ts +116 -0
  20. package/dist/agent/background/interpret.d.ts.map +1 -0
  21. package/dist/agent/bash/bash-tool-view.d.ts.map +1 -1
  22. package/dist/agent/bash/interpret.d.ts +4 -0
  23. package/dist/agent/bash/interpret.d.ts.map +1 -1
  24. package/dist/agent/components/composer-menu.d.ts +3 -1
  25. package/dist/agent/components/composer-menu.d.ts.map +1 -1
  26. package/dist/agent/components/composer-place.d.ts +13 -0
  27. package/dist/agent/components/composer-place.d.ts.map +1 -0
  28. package/dist/agent/components/composer.d.ts +23 -1
  29. package/dist/agent/components/composer.d.ts.map +1 -1
  30. package/dist/agent/components/computer-place.d.ts +3 -1
  31. package/dist/agent/components/computer-place.d.ts.map +1 -1
  32. package/dist/agent/components/context-chips.d.ts.map +1 -1
  33. package/dist/agent/components/context-meter.d.ts +1 -1
  34. package/dist/agent/components/conversation-panel.d.ts +3 -1
  35. package/dist/agent/components/conversation-panel.d.ts.map +1 -1
  36. package/dist/agent/components/message-parts.d.ts +3 -1
  37. package/dist/agent/components/message-parts.d.ts.map +1 -1
  38. package/dist/agent/components/thread-artifacts-menu.d.ts.map +1 -1
  39. package/dist/agent/components/transcript.d.ts +6 -0
  40. package/dist/agent/components/transcript.d.ts.map +1 -1
  41. package/dist/agent/components/web-fetch-tool-view.d.ts.map +1 -1
  42. package/dist/agent/composer-insertion.d.ts +24 -0
  43. package/dist/agent/composer-insertion.d.ts.map +1 -0
  44. package/dist/agent/delegation/child-parts.d.ts +2 -0
  45. package/dist/agent/delegation/child-parts.d.ts.map +1 -1
  46. package/dist/agent/delegation/use-children.d.ts +5 -5
  47. package/dist/agent/delegation/use-children.d.ts.map +1 -1
  48. package/dist/agent/hooks/use-agent-conversation.d.ts +24 -4
  49. package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
  50. package/dist/agent/hooks/use-new-thread-place.d.ts +70 -0
  51. package/dist/agent/hooks/use-new-thread-place.d.ts.map +1 -0
  52. package/dist/agent/hooks/use-thread-lists.d.ts +40 -0
  53. package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
  54. package/dist/agent/i18n/en.d.ts +74 -0
  55. package/dist/agent/i18n/en.d.ts.map +1 -1
  56. package/dist/agent/i18n/fr.d.ts.map +1 -1
  57. package/dist/agent/i18n/index.d.ts +126 -0
  58. package/dist/agent/i18n/index.d.ts.map +1 -1
  59. package/dist/agent/observed-conversation.d.ts.map +1 -1
  60. package/dist/agent/publish-artifact/interpret.d.ts +8 -2
  61. package/dist/agent/publish-artifact/interpret.d.ts.map +1 -1
  62. package/dist/agent/publish-artifact/open-artifact-tool-view.d.ts +9 -0
  63. package/dist/agent/publish-artifact/open-artifact-tool-view.d.ts.map +1 -0
  64. package/dist/agent/publish-artifact/publish-artifact-tool-view.d.ts +4 -2
  65. package/dist/agent/publish-artifact/publish-artifact-tool-view.d.ts.map +1 -1
  66. package/dist/agent/publish-artifact/use-live-publishes.d.ts +3 -3
  67. package/dist/agent/publish-artifact/use-live-publishes.d.ts.map +1 -1
  68. package/dist/agent/tool-views/built-in.d.ts.map +1 -1
  69. package/dist/agent/types.d.ts +3 -1
  70. package/dist/agent/types.d.ts.map +1 -1
  71. package/dist/agent/utils/web-fetch.d.ts +33 -1
  72. package/dist/agent/utils/web-fetch.d.ts.map +1 -1
  73. package/dist/agent/utils/web-search.d.ts +14 -2
  74. package/dist/agent/utils/web-search.d.ts.map +1 -1
  75. package/dist/artifacts/artifact-page.d.ts.map +1 -1
  76. package/dist/artifacts/artifact-viewer.d.ts +16 -0
  77. package/dist/artifacts/artifact-viewer.d.ts.map +1 -0
  78. package/dist/artifacts/card-details.d.ts +1 -1
  79. package/dist/artifacts/card-details.d.ts.map +1 -1
  80. package/dist/artifacts/card-preview.d.ts.map +1 -1
  81. package/dist/artifacts/comments-context.d.ts +48 -0
  82. package/dist/artifacts/comments-context.d.ts.map +1 -0
  83. package/dist/artifacts/edit-session.d.ts +6 -6
  84. package/dist/artifacts/edit-session.d.ts.map +1 -1
  85. package/dist/artifacts/file-source.d.ts.map +1 -1
  86. package/dist/artifacts/frame.d.ts +10 -2
  87. package/dist/artifacts/frame.d.ts.map +1 -1
  88. package/dist/artifacts/guest-badge.d.ts +8 -0
  89. package/dist/artifacts/guest-badge.d.ts.map +1 -0
  90. package/dist/artifacts/held-artifact.d.ts +19 -0
  91. package/dist/artifacts/held-artifact.d.ts.map +1 -0
  92. package/dist/artifacts/holders.d.ts +10 -0
  93. package/dist/artifacts/holders.d.ts.map +1 -0
  94. package/dist/artifacts/live/boards.d.ts +15 -0
  95. package/dist/artifacts/live/boards.d.ts.map +1 -0
  96. package/dist/artifacts/live/canvas.d.ts +79 -0
  97. package/dist/artifacts/live/canvas.d.ts.map +1 -0
  98. package/dist/artifacts/live/header.d.ts +29 -0
  99. package/dist/artifacts/live/header.d.ts.map +1 -0
  100. package/dist/artifacts/live/hooks.d.ts +21 -0
  101. package/dist/artifacts/live/hooks.d.ts.map +1 -0
  102. package/dist/artifacts/live/presence.d.ts +32 -0
  103. package/dist/artifacts/live/presence.d.ts.map +1 -0
  104. package/dist/artifacts/live/session.d.ts +130 -0
  105. package/dist/artifacts/live/session.d.ts.map +1 -0
  106. package/dist/artifacts/live/view.d.ts +28 -0
  107. package/dist/artifacts/live/view.d.ts.map +1 -0
  108. package/dist/artifacts/messages.d.ts +424 -14
  109. package/dist/artifacts/messages.d.ts.map +1 -1
  110. package/dist/artifacts/page-queries.d.ts +2 -2
  111. package/dist/artifacts/page-queries.d.ts.map +1 -1
  112. package/dist/artifacts/page-state.d.ts.map +1 -1
  113. package/dist/artifacts/publish-edit.d.ts +24 -14
  114. package/dist/artifacts/publish-edit.d.ts.map +1 -1
  115. package/dist/artifacts/queries.d.ts +490 -9
  116. package/dist/artifacts/queries.d.ts.map +1 -1
  117. package/dist/artifacts/references/references.d.ts.map +1 -1
  118. package/dist/artifacts/renderers/canvas/arrows.d.ts +0 -18
  119. package/dist/artifacts/renderers/canvas/arrows.d.ts.map +1 -1
  120. package/dist/artifacts/renderers/canvas/board-editor.d.ts +43 -0
  121. package/dist/artifacts/renderers/canvas/board-editor.d.ts.map +1 -0
  122. package/dist/artifacts/renderers/canvas/board-properties.d.ts +37 -0
  123. package/dist/artifacts/renderers/canvas/board-properties.d.ts.map +1 -0
  124. package/dist/artifacts/renderers/canvas/board-source.d.ts +18 -0
  125. package/dist/artifacts/renderers/canvas/board-source.d.ts.map +1 -0
  126. package/dist/artifacts/renderers/canvas/board.d.ts +64 -19
  127. package/dist/artifacts/renderers/canvas/board.d.ts.map +1 -1
  128. package/dist/artifacts/renderers/canvas/canvas.d.ts +13 -4
  129. package/dist/artifacts/renderers/canvas/canvas.d.ts.map +1 -1
  130. package/dist/artifacts/renderers/canvas/comment-pins.d.ts +84 -0
  131. package/dist/artifacts/renderers/canvas/comment-pins.d.ts.map +1 -0
  132. package/dist/artifacts/renderers/canvas/commenting.d.ts +58 -0
  133. package/dist/artifacts/renderers/canvas/commenting.d.ts.map +1 -0
  134. package/dist/artifacts/renderers/canvas/comments-panel.d.ts +27 -0
  135. package/dist/artifacts/renderers/canvas/comments-panel.d.ts.map +1 -0
  136. package/dist/artifacts/renderers/canvas/comments.d.ts +56 -0
  137. package/dist/artifacts/renderers/canvas/comments.d.ts.map +1 -0
  138. package/dist/artifacts/renderers/canvas/draft.d.ts +7 -6
  139. package/dist/artifacts/renderers/canvas/draft.d.ts.map +1 -1
  140. package/dist/artifacts/renderers/canvas/edit-mode.d.ts +19 -2
  141. package/dist/artifacts/renderers/canvas/edit-mode.d.ts.map +1 -1
  142. package/dist/artifacts/renderers/canvas/focus.d.ts +40 -5
  143. package/dist/artifacts/renderers/canvas/focus.d.ts.map +1 -1
  144. package/dist/artifacts/renderers/canvas/items.d.ts +47 -4
  145. package/dist/artifacts/renderers/canvas/items.d.ts.map +1 -1
  146. package/dist/artifacts/renderers/canvas/layout.d.ts +5 -8
  147. package/dist/artifacts/renderers/canvas/layout.d.ts.map +1 -1
  148. package/dist/artifacts/renderers/canvas/presence.d.ts +21 -0
  149. package/dist/artifacts/renderers/canvas/presence.d.ts.map +1 -0
  150. package/dist/artifacts/renderers/canvas/previews.d.ts +54 -0
  151. package/dist/artifacts/renderers/canvas/previews.d.ts.map +1 -0
  152. package/dist/artifacts/renderers/canvas/renderer.d.ts +11 -2
  153. package/dist/artifacts/renderers/canvas/renderer.d.ts.map +1 -1
  154. package/dist/artifacts/renderers/canvas/thumbnail.d.ts +5 -2
  155. package/dist/artifacts/renderers/canvas/thumbnail.d.ts.map +1 -1
  156. package/dist/artifacts/version-menu.d.ts +19 -0
  157. package/dist/artifacts/version-menu.d.ts.map +1 -0
  158. package/dist/artifacts/view-context.d.ts +43 -0
  159. package/dist/artifacts/view-context.d.ts.map +1 -0
  160. package/dist/artifacts/viewer.d.ts.map +1 -1
  161. package/dist/build.d.ts +5 -0
  162. package/dist/build.d.ts.map +1 -1
  163. package/dist/{chunk-fw2bm6dq.js → chunk-001c4gnk.js} +8086 -3870
  164. package/dist/chunk-001c4gnk.js.map +204 -0
  165. package/dist/chunk-00wggsst.js +7 -0
  166. package/dist/chunk-00wggsst.js.map +10 -0
  167. package/dist/chunk-5crvhjp2.js +4704 -0
  168. package/dist/chunk-5crvhjp2.js.map +28 -0
  169. package/dist/{chunk-q69001w3.js → chunk-694m74s7.js} +7 -1
  170. package/dist/{chunk-q69001w3.js.map → chunk-694m74s7.js.map} +3 -3
  171. package/dist/{chunk-4mprsd2n.js → chunk-fg6thecb.js} +25 -1
  172. package/dist/chunk-fg6thecb.js.map +10 -0
  173. package/dist/{chunk-j9653e83.js → chunk-fwb9mxwm.js} +1 -1
  174. package/dist/{chunk-km25essq.js → chunk-kes4ygmz.js} +1 -1
  175. package/dist/{chunk-kwbw4dyk.js → chunk-ryed2jq8.js} +1 -1
  176. package/dist/codegen.d.ts.map +1 -1
  177. package/dist/createCustomApp.d.ts.map +1 -1
  178. package/dist/index.d.ts +7 -1
  179. package/dist/index.d.ts.map +1 -1
  180. package/dist/index.js +930 -309
  181. package/dist/index.js.map +15 -10
  182. package/dist/locale-messages.d.ts +12 -0
  183. package/dist/locale-messages.d.ts.map +1 -1
  184. package/dist/locale.d.ts +12 -0
  185. package/dist/locale.d.ts.map +1 -1
  186. package/dist/locale.js +1 -1
  187. package/dist/metadata.d.ts +8 -0
  188. package/dist/metadata.d.ts.map +1 -1
  189. package/dist/pages/console/action-run.d.ts.map +1 -1
  190. package/dist/pages/console/data/connectors.d.ts.map +1 -1
  191. package/dist/pages/console/data/datasets.d.ts.map +1 -1
  192. package/dist/pages/console/data/lake-health.d.ts +3 -0
  193. package/dist/pages/console/data/lake-health.d.ts.map +1 -0
  194. package/dist/pages/console/data/messages.d.ts +98 -2
  195. package/dist/pages/console/data/messages.d.ts.map +1 -1
  196. package/dist/pages/console/data/pipelines.d.ts.map +1 -1
  197. package/dist/pages/console/data/projections.d.ts.map +1 -1
  198. package/dist/pages/console/data/shared.d.ts.map +1 -1
  199. package/dist/pages/console/data/syncs.d.ts.map +1 -1
  200. package/dist/pages/console/ontology/action-runs.d.ts.map +1 -1
  201. package/dist/pages/console/ontology/actions.d.ts.map +1 -1
  202. package/dist/pages/console/ontology/components/action-button.d.ts.map +1 -1
  203. package/dist/pages/console/ontology/components/artifact-picker.d.ts +36 -0
  204. package/dist/pages/console/ontology/components/artifact-picker.d.ts.map +1 -0
  205. package/dist/pages/console/ontology/components/object-query-bar.d.ts.map +1 -1
  206. package/dist/pages/console/ontology/lib/action-params.d.ts +2 -0
  207. package/dist/pages/console/ontology/lib/action-params.d.ts.map +1 -1
  208. package/dist/pages/console/ontology/lineage/properties-panel.d.ts +2 -1
  209. package/dist/pages/console/ontology/lineage/properties-panel.d.ts.map +1 -1
  210. package/dist/pages/console/ontology/object-page.d.ts.map +1 -1
  211. package/dist/pages/console/ontology/object-type.d.ts.map +1 -1
  212. package/dist/pages/console/ontology/object-types.d.ts.map +1 -1
  213. package/dist/pages/console/ontology/objects.d.ts.map +1 -1
  214. package/dist/pages/console/ontology/rules.d.ts.map +1 -1
  215. package/dist/pages/console/ontology/workflow.d.ts.map +1 -1
  216. package/dist/pages/console/ontology/workflows/run-input-form.d.ts.map +1 -1
  217. package/dist/pages/console/ontology/workflows/schema-shape.d.ts.map +1 -1
  218. package/dist/pages/console/ontology/workflows.d.ts.map +1 -1
  219. package/dist/pages/console/skeletons.d.ts +30 -0
  220. package/dist/pages/console/skeletons.d.ts.map +1 -0
  221. package/dist/pages/console/workflow-run.d.ts.map +1 -1
  222. package/dist/pages/section-page.d.ts +11 -1
  223. package/dist/pages/section-page.d.ts.map +1 -1
  224. package/dist/pages/section-ui.d.ts +25 -3
  225. package/dist/pages/section-ui.d.ts.map +1 -1
  226. package/dist/pages/settings/activity/calendar.d.ts.map +1 -1
  227. package/dist/pages/settings/activity/connections.d.ts.map +1 -1
  228. package/dist/pages/settings/activity/page.d.ts.map +1 -1
  229. package/dist/pages/settings/activity/thread.d.ts.map +1 -1
  230. package/dist/pages/settings/activity/timeline.d.ts +2 -0
  231. package/dist/pages/settings/activity/timeline.d.ts.map +1 -1
  232. package/dist/pages/settings/controls.d.ts +4 -0
  233. package/dist/pages/settings/controls.d.ts.map +1 -1
  234. package/dist/pages/settings/members.d.ts.map +1 -1
  235. package/dist/pages/settings/memory-history.d.ts +2 -0
  236. package/dist/pages/settings/memory-history.d.ts.map +1 -1
  237. package/dist/pages/settings/memory.d.ts.map +1 -1
  238. package/dist/pages/settings/service-accounts.d.ts.map +1 -1
  239. package/dist/pages/settings/sessions.d.ts.map +1 -1
  240. package/dist/pages/settings/usage/breakdown.d.ts.map +1 -1
  241. package/dist/pages/settings/usage/limits.d.ts.map +1 -1
  242. package/dist/pages/settings/usage/messages.d.ts +2 -2
  243. package/dist/pages/settings/usage/messages.d.ts.map +1 -1
  244. package/dist/pages/settings/usage/runs.d.ts +8 -2
  245. package/dist/pages/settings/usage/runs.d.ts.map +1 -1
  246. package/dist/pages/settings/usage/spend-chart.d.ts.map +1 -1
  247. package/dist/pages/settings/usage/spend-model.d.ts +5 -0
  248. package/dist/pages/settings/usage/spend-model.d.ts.map +1 -1
  249. package/dist/pages/values.d.ts +6 -0
  250. package/dist/pages/values.d.ts.map +1 -1
  251. package/dist/pages.d.ts +4 -0
  252. package/dist/pages.d.ts.map +1 -1
  253. package/dist/pages.js +8195 -4841
  254. package/dist/pages.js.map +58 -49
  255. package/dist/sections/catalog.d.ts.map +1 -1
  256. package/dist/sections/sections.d.ts.map +1 -1
  257. package/dist/server.js +294 -23
  258. package/dist/server.js.map +8 -7
  259. package/dist/service-worker.d.ts +39 -0
  260. package/dist/service-worker.d.ts.map +1 -0
  261. package/dist/shared-session.d.ts +25 -0
  262. package/dist/shared-session.d.ts.map +1 -0
  263. package/dist/shell/app-return.d.ts +35 -0
  264. package/dist/shell/app-return.d.ts.map +1 -0
  265. package/dist/shell/app-shell.d.ts +1 -1
  266. package/dist/shell/app-shell.d.ts.map +1 -1
  267. package/dist/shell/nav-items.d.ts +2 -0
  268. package/dist/shell/nav-items.d.ts.map +1 -1
  269. package/dist/shell/phone/back.d.ts +6 -0
  270. package/dist/shell/phone/back.d.ts.map +1 -0
  271. package/dist/shell/phone/launch.d.ts +7 -0
  272. package/dist/shell/phone/launch.d.ts.map +1 -0
  273. package/dist/shell/phone/more-sheet.d.ts +36 -0
  274. package/dist/shell/phone/more-sheet.d.ts.map +1 -0
  275. package/dist/shell/phone/phone-foundations.d.ts +9 -0
  276. package/dist/shell/phone/phone-foundations.d.ts.map +1 -0
  277. package/dist/shell/phone/pull-to-refresh.d.ts +9 -0
  278. package/dist/shell/phone/pull-to-refresh.d.ts.map +1 -0
  279. package/dist/shell/phone/routes.d.ts +12 -0
  280. package/dist/shell/phone/routes.d.ts.map +1 -0
  281. package/dist/shell/phone/screen-motion.d.ts +11 -0
  282. package/dist/shell/phone/screen-motion.d.ts.map +1 -0
  283. package/dist/shell/phone/scroll-restoration.d.ts +7 -0
  284. package/dist/shell/phone/scroll-restoration.d.ts.map +1 -0
  285. package/dist/shell/phone/startup-image.d.ts +17 -0
  286. package/dist/shell/phone/startup-image.d.ts.map +1 -0
  287. package/dist/shell/phone/tab-bar.d.ts +14 -0
  288. package/dist/shell/phone/tab-bar.d.ts.map +1 -0
  289. package/dist/shell/phone/top-bar.d.ts +24 -0
  290. package/dist/shell/phone/top-bar.d.ts.map +1 -0
  291. package/dist/shell/search-command.d.ts +3 -1
  292. package/dist/shell/search-command.d.ts.map +1 -1
  293. package/dist/shell/user-menu.d.ts +2 -0
  294. package/dist/shell/user-menu.d.ts.map +1 -1
  295. package/package.json +8 -5
  296. package/src/agent/activity-label.ts +6 -2
  297. package/src/agent/agent-chat.tsx +51 -8
  298. package/src/agent/agent-panel.tsx +12 -0
  299. package/src/agent/agent-surface.tsx +4 -0
  300. package/src/agent/agent.css +18 -0
  301. package/src/agent/artifact-card.tsx +84 -16
  302. package/src/agent/artifact-panel.tsx +63 -43
  303. package/src/agent/background/background-card.tsx +308 -0
  304. package/src/agent/background/background-tool-row.tsx +58 -0
  305. package/src/agent/background/context.ts +26 -0
  306. package/src/agent/background/interpret.ts +356 -0
  307. package/src/agent/bash/bash-tool-view.tsx +9 -4
  308. package/src/agent/bash/interpret.ts +21 -3
  309. package/src/agent/components/agent-message-body.tsx +1 -1
  310. package/src/agent/components/composer-menu.tsx +4 -1
  311. package/src/agent/components/composer-place.tsx +168 -0
  312. package/src/agent/components/composer.tsx +101 -3
  313. package/src/agent/components/computer-place.tsx +18 -1
  314. package/src/agent/components/context-chips.tsx +72 -2
  315. package/src/agent/components/conversation-panel.tsx +3 -2
  316. package/src/agent/components/message-parts.tsx +6 -1
  317. package/src/agent/components/thread-artifacts-menu.tsx +22 -5
  318. package/src/agent/components/transcript.tsx +33 -1
  319. package/src/agent/components/web-fetch-tool-view.tsx +94 -29
  320. package/src/agent/composer-insertion.ts +36 -0
  321. package/src/agent/delegation/child-parts.tsx +1 -1
  322. package/src/agent/hooks/use-agent-conversation.ts +101 -8
  323. package/src/agent/hooks/use-new-thread-place.ts +294 -0
  324. package/src/agent/i18n/en.ts +70 -3
  325. package/src/agent/i18n/fr.ts +70 -3
  326. package/src/agent/observed-conversation.tsx +3 -0
  327. package/src/agent/publish-artifact/interpret.ts +27 -5
  328. package/src/agent/publish-artifact/open-artifact-tool-view.tsx +49 -0
  329. package/src/agent/publish-artifact/publish-artifact-tool-view.tsx +14 -8
  330. package/src/agent/publish-artifact/use-live-publishes.ts +7 -11
  331. package/src/agent/react-router.tsx +2 -2
  332. package/src/agent/tool-views/built-in.tsx +29 -11
  333. package/src/agent/types.ts +4 -0
  334. package/src/agent/utils/web-fetch.ts +89 -10
  335. package/src/agent/utils/web-search.ts +67 -28
  336. package/src/artifacts/artifact-page.tsx +42 -17
  337. package/src/artifacts/artifact-viewer.tsx +56 -0
  338. package/src/artifacts/artifacts.css +80 -0
  339. package/src/artifacts/card-details.ts +2 -2
  340. package/src/artifacts/card-preview.tsx +17 -3
  341. package/src/artifacts/comments-context.ts +125 -0
  342. package/src/artifacts/edit-session.tsx +6 -6
  343. package/src/artifacts/file-source.ts +10 -3
  344. package/src/artifacts/frame.tsx +50 -12
  345. package/src/artifacts/gallery.tsx +9 -11
  346. package/src/artifacts/guest-badge.tsx +21 -0
  347. package/src/artifacts/held-artifact.tsx +241 -0
  348. package/src/artifacts/holders.tsx +170 -0
  349. package/src/artifacts/live/boards.ts +95 -0
  350. package/src/artifacts/live/canvas.ts +402 -0
  351. package/src/artifacts/live/header.tsx +137 -0
  352. package/src/artifacts/live/hooks.ts +94 -0
  353. package/src/artifacts/live/presence.ts +147 -0
  354. package/src/artifacts/live/session.ts +520 -0
  355. package/src/artifacts/live/view.ts +81 -0
  356. package/src/artifacts/messages.ts +415 -24
  357. package/src/artifacts/page-queries.ts +2 -3
  358. package/src/artifacts/page-state.ts +16 -7
  359. package/src/artifacts/publish-edit.ts +50 -22
  360. package/src/artifacts/queries.ts +108 -10
  361. package/src/artifacts/references/references.tsx +6 -9
  362. package/src/artifacts/renderers/canvas/arrows.tsx +12 -39
  363. package/src/artifacts/renderers/canvas/board-editor.tsx +817 -0
  364. package/src/artifacts/renderers/canvas/board-properties.tsx +488 -0
  365. package/src/artifacts/renderers/canvas/board-source.ts +110 -0
  366. package/src/artifacts/renderers/canvas/board.tsx +309 -33
  367. package/src/artifacts/renderers/canvas/canvas.tsx +387 -72
  368. package/src/artifacts/renderers/canvas/comment-pins.tsx +465 -0
  369. package/src/artifacts/renderers/canvas/commenting.tsx +319 -0
  370. package/src/artifacts/renderers/canvas/comments-panel.tsx +574 -0
  371. package/src/artifacts/renderers/canvas/comments.ts +225 -0
  372. package/src/artifacts/renderers/canvas/draft.ts +41 -50
  373. package/src/artifacts/renderers/canvas/edit-mode.tsx +145 -20
  374. package/src/artifacts/renderers/canvas/focus.tsx +175 -24
  375. package/src/artifacts/renderers/canvas/items.tsx +179 -52
  376. package/src/artifacts/renderers/canvas/layout.ts +99 -47
  377. package/src/artifacts/renderers/canvas/presence.tsx +184 -0
  378. package/src/artifacts/renderers/canvas/previews.ts +127 -0
  379. package/src/artifacts/renderers/canvas/renderer.tsx +87 -22
  380. package/src/artifacts/renderers/canvas/thumbnail.tsx +56 -15
  381. package/src/artifacts/renderers/canvas/toolbar.tsx +1 -1
  382. package/src/artifacts/renderers/slides/slides.tsx +1 -1
  383. package/src/artifacts/version-menu.tsx +438 -0
  384. package/src/artifacts/view-context.ts +102 -0
  385. package/src/artifacts/viewer.tsx +205 -147
  386. package/src/build.ts +96 -11
  387. package/src/codegen.ts +83 -5
  388. package/src/createCustomApp.ts +20 -7
  389. package/src/index.ts +12 -0
  390. package/src/locale-messages.ts +24 -0
  391. package/src/metadata.ts +12 -0
  392. package/src/pages/console/action-run.tsx +20 -0
  393. package/src/pages/console/data/connectors.tsx +27 -3
  394. package/src/pages/console/data/datasets.tsx +30 -1
  395. package/src/pages/console/data/lake-health.tsx +299 -0
  396. package/src/pages/console/data/messages.ts +143 -2
  397. package/src/pages/console/data/pipelines.tsx +91 -3
  398. package/src/pages/console/data/projections.tsx +23 -4
  399. package/src/pages/console/data/shared.tsx +1 -0
  400. package/src/pages/console/data/syncs.tsx +39 -2
  401. package/src/pages/console/ontology/action-runs.tsx +8 -2
  402. package/src/pages/console/ontology/actions.tsx +39 -15
  403. package/src/pages/console/ontology/components/action-button.tsx +10 -0
  404. package/src/pages/console/ontology/components/artifact-picker.tsx +522 -0
  405. package/src/pages/console/ontology/components/object-query-bar.tsx +21 -5
  406. package/src/pages/console/ontology/lib/action-params.ts +10 -0
  407. package/src/pages/console/ontology/lineage/properties-panel.tsx +32 -24
  408. package/src/pages/console/ontology/object-page.tsx +2 -0
  409. package/src/pages/console/ontology/object-type.tsx +73 -14
  410. package/src/pages/console/ontology/object-types.tsx +56 -7
  411. package/src/pages/console/ontology/objects.tsx +167 -19
  412. package/src/pages/console/ontology/rules.tsx +186 -30
  413. package/src/pages/console/ontology/workflow.tsx +130 -74
  414. package/src/pages/console/ontology/workflows/run-input-form.tsx +21 -2
  415. package/src/pages/console/ontology/workflows/schema-shape.tsx +3 -0
  416. package/src/pages/console/ontology/workflows.tsx +34 -21
  417. package/src/pages/console/skeletons.tsx +99 -0
  418. package/src/pages/console/workflow-run.tsx +20 -0
  419. package/src/pages/section-page.tsx +37 -7
  420. package/src/pages/section-ui.tsx +96 -13
  421. package/src/pages/settings/activity/calendar.tsx +13 -6
  422. package/src/pages/settings/activity/connections.tsx +26 -9
  423. package/src/pages/settings/activity/page.tsx +31 -4
  424. package/src/pages/settings/activity/thread.tsx +32 -18
  425. package/src/pages/settings/activity/timeline.tsx +39 -0
  426. package/src/pages/settings/controls.tsx +19 -1
  427. package/src/pages/settings/developers.tsx +2 -2
  428. package/src/pages/settings/members.tsx +42 -9
  429. package/src/pages/settings/memory-history.tsx +76 -10
  430. package/src/pages/settings/memory.tsx +47 -5
  431. package/src/pages/settings/service-accounts.tsx +7 -2
  432. package/src/pages/settings/sessions.tsx +6 -2
  433. package/src/pages/settings/usage/breakdown.tsx +62 -2
  434. package/src/pages/settings/usage/limits.tsx +45 -3
  435. package/src/pages/settings/usage/messages.ts +2 -2
  436. package/src/pages/settings/usage/page.tsx +99 -52
  437. package/src/pages/settings/usage/runs.tsx +105 -8
  438. package/src/pages/settings/usage/spend-chart.tsx +79 -45
  439. package/src/pages/settings/usage/spend-model.ts +17 -0
  440. package/src/pages/values.tsx +72 -6
  441. package/src/pages.ts +4 -0
  442. package/src/sections/catalog.ts +6 -0
  443. package/src/sections/sections.tsx +2 -0
  444. package/src/service-worker.ts +176 -0
  445. package/src/shared-session.ts +73 -0
  446. package/src/shell/app-return.ts +115 -0
  447. package/src/shell/app-shell.tsx +125 -27
  448. package/src/shell/nav-items.tsx +2 -0
  449. package/src/shell/phone/back.ts +16 -0
  450. package/src/shell/phone/launch.ts +6 -0
  451. package/src/shell/phone/more-sheet.tsx +249 -0
  452. package/src/shell/phone/phone-foundations.tsx +43 -0
  453. package/src/shell/phone/phone.css +660 -0
  454. package/src/shell/phone/pull-to-refresh.tsx +201 -0
  455. package/src/shell/phone/routes.ts +34 -0
  456. package/src/shell/phone/screen-motion.ts +292 -0
  457. package/src/shell/phone/scroll-restoration.tsx +70 -0
  458. package/src/shell/phone/startup-image.ts +119 -0
  459. package/src/shell/phone/tab-bar.tsx +95 -0
  460. package/src/shell/phone/top-bar.tsx +195 -0
  461. package/src/shell/search-command.tsx +30 -14
  462. package/src/shell/user-menu.tsx +2 -1
  463. package/dist/chunk-4mprsd2n.js.map +0 -10
  464. package/dist/chunk-fw2bm6dq.js.map +0 -182
  465. package/dist/chunk-zxthr2q5.js +0 -1487
  466. package/dist/chunk-zxthr2q5.js.map +0 -18
  467. /package/dist/{chunk-j9653e83.js.map → chunk-fwb9mxwm.js.map} +0 -0
  468. /package/dist/{chunk-km25essq.js.map → chunk-kes4ygmz.js.map} +0 -0
  469. /package/dist/{chunk-kwbw4dyk.js.map → chunk-ryed2jq8.js.map} +0 -0
@@ -0,0 +1,225 @@
1
+ import {
2
+ type AddArtifactCommentData,
3
+ addArtifactComment,
4
+ deleteArtifactComment,
5
+ isSixbApiError,
6
+ type ListArtifactCommentsResponse,
7
+ resolveArtifactComment,
8
+ } from "@sixb/client"
9
+ import { listArtifactCommentsOptions, listArtifactCommentsQueryKey } from "@sixb/client/hooks"
10
+ import { type QueryClient, useQuery } from "@tanstack/react-query"
11
+ import { useMemo } from "react"
12
+ import { useCurrentUser } from "../../../session"
13
+ import { useSharedGuest } from "../../../shared-session"
14
+ import { useArtifactMessages } from "../../messages"
15
+
16
+ // The comments on a canvas: read once, kept in step as anyone adds, resolves or deletes one by the
17
+ // `artifact.commented` events the viewer follows, and changed in place by the reader's own
18
+ // actions, so the panel answers at once.
19
+
20
+ export type ArtifactComment = ListArtifactCommentsResponse["comments"][number]
21
+ export type ArtifactCommentAnchor = ArtifactComment["anchor"]
22
+
23
+ /** A comment and its replies, oldest first. */
24
+ export interface CommentThread {
25
+ readonly comment: ArtifactComment
26
+ readonly replies: readonly ArtifactComment[]
27
+ /** Its place among the canvas's threads, from 1, as its pin shows it. */
28
+ readonly number: number
29
+ }
30
+
31
+ /** Why a comment action failed, in the reader's terms. */
32
+ export type CommentFailure = "full" | "invalid" | "notAllowed" | "gone" | "failed" | "name"
33
+
34
+ export class CommentActionError extends Error {
35
+ readonly name = "CommentActionError"
36
+
37
+ constructor(readonly failure: CommentFailure) {
38
+ super(`[SixbApp] The comment action failed: ${failure}.`)
39
+ }
40
+ }
41
+
42
+ /** The threads of these comments, in the order they were started; replies under each. */
43
+ export function commentThreads(comments: readonly ArtifactComment[]): CommentThread[] {
44
+ const replies = new Map<string, ArtifactComment[]>()
45
+ for (const comment of comments) {
46
+ if (!comment.parentId) continue
47
+ const list = replies.get(comment.parentId) ?? []
48
+ list.push(comment)
49
+ replies.set(comment.parentId, list)
50
+ }
51
+
52
+ return comments
53
+ .filter((comment) => !comment.parentId)
54
+ .map((comment, index) => ({
55
+ comment,
56
+ replies: replies.get(comment.id) ?? [],
57
+ number: index + 1,
58
+ }))
59
+ }
60
+
61
+ const NO_COMMENTS: readonly ArtifactComment[] = []
62
+
63
+ /**
64
+ * The comments on an artifact, as threads. They are read again whenever someone changes one, as
65
+ * `useArtifactUpdates` hears it on the events socket.
66
+ */
67
+ export function useArtifactComments(artifactId: string | null): {
68
+ readonly threads: readonly CommentThread[]
69
+ readonly loading: boolean
70
+ readonly failed: boolean
71
+ } {
72
+ const query = useQuery({
73
+ ...listArtifactCommentsOptions({ path: { artifactId: artifactId ?? "" } }),
74
+ enabled: artifactId !== null,
75
+ retry: false,
76
+ })
77
+
78
+ const comments = query.data?.comments ?? NO_COMMENTS
79
+ const threads = useMemo(() => commentThreads(comments), [comments])
80
+ return { threads, loading: query.isLoading, failed: query.isError }
81
+ }
82
+
83
+ function commentsKey(artifactId: string) {
84
+ return listArtifactCommentsQueryKey({ path: { artifactId } })
85
+ }
86
+
87
+ /** Changes the cached comments of an artifact, as a change the reader made shows at once. */
88
+ function updateCached(
89
+ queries: QueryClient,
90
+ artifactId: string,
91
+ update: (comments: readonly ArtifactComment[]) => readonly ArtifactComment[]
92
+ ): void {
93
+ queries.setQueryData<ListArtifactCommentsResponse>(commentsKey(artifactId), (current) =>
94
+ current ? { ...current, comments: [...update(current.comments)] } : current
95
+ )
96
+ }
97
+
98
+ /** Adds a comment, or a reply, as the reader; it shows in the panel as soon as it is taken. */
99
+ export async function addComment(
100
+ queries: QueryClient,
101
+ artifactId: string,
102
+ body: AddArtifactCommentData["body"]
103
+ ): Promise<ArtifactComment> {
104
+ try {
105
+ const { data } = await addArtifactComment({
106
+ path: { artifactId },
107
+ body,
108
+ throwOnError: true,
109
+ })
110
+ updateCached(queries, artifactId, (comments) =>
111
+ comments.some((comment) => comment.id === data.id) ? comments : [...comments, data]
112
+ )
113
+ return data
114
+ } catch (error) {
115
+ throw commentError(error)
116
+ }
117
+ }
118
+
119
+ /** Marks a comment resolved, or opens it again. */
120
+ export async function resolveComment(
121
+ queries: QueryClient,
122
+ artifactId: string,
123
+ commentId: string,
124
+ resolved: boolean
125
+ ): Promise<void> {
126
+ try {
127
+ const { data } = await resolveArtifactComment({
128
+ path: { artifactId, commentId },
129
+ body: { resolved },
130
+ throwOnError: true,
131
+ })
132
+ updateCached(queries, artifactId, (comments) =>
133
+ comments.map((comment) => (comment.id === data.id ? data : comment))
134
+ )
135
+ } catch (error) {
136
+ throw commentError(error)
137
+ }
138
+ }
139
+
140
+ /** Deletes a comment and its replies. */
141
+ export async function deleteComment(
142
+ queries: QueryClient,
143
+ artifactId: string,
144
+ commentId: string
145
+ ): Promise<void> {
146
+ try {
147
+ await deleteArtifactComment({ path: { artifactId, commentId }, throwOnError: true })
148
+ updateCached(queries, artifactId, (comments) =>
149
+ comments.filter((comment) => comment.id !== commentId && comment.parentId !== commentId)
150
+ )
151
+ } catch (error) {
152
+ throw commentError(error)
153
+ }
154
+ }
155
+
156
+ function commentError(error: unknown): CommentActionError {
157
+ if (!isSixbApiError(error)) return new CommentActionError("failed")
158
+ switch (error.code) {
159
+ case "comments_full":
160
+ return new CommentActionError("full")
161
+ case "invalid_comment":
162
+ return new CommentActionError("invalid")
163
+ case "name_required":
164
+ case "invalid_name":
165
+ return new CommentActionError("name")
166
+ case "not_allowed":
167
+ return new CommentActionError("notAllowed")
168
+ case "comment_not_found":
169
+ case "artifact_not_found":
170
+ return new CommentActionError("gone")
171
+ default:
172
+ return new CommentActionError("failed")
173
+ }
174
+ }
175
+
176
+ /**
177
+ * Whether the reader may resolve or delete a comment: its author, or whoever may change the
178
+ * artifact, as the API decides.
179
+ */
180
+ export function canManageComment(
181
+ comment: Pick<ArtifactComment, "author">,
182
+ access: "owner" | "update" | "read",
183
+ userId: string | null
184
+ ): boolean {
185
+ if (access === "owner" || access === "update") return true
186
+ return comment.author.type === "user" && comment.author.id === userId
187
+ }
188
+
189
+ /** Who wrote a comment, as the panel says it. */
190
+ export interface CommentAuthor {
191
+ readonly name: string
192
+ readonly you: boolean
193
+ /** The Agent wrote it, for its author. */
194
+ readonly agent?: boolean
195
+ /** A shared link's visitor wrote it, under a name nobody vouches for. */
196
+ readonly guest?: boolean
197
+ }
198
+
199
+ /**
200
+ * Who wrote a comment: the reader themselves, else the name the API gives its author, and the
201
+ * Agent for them when its run wrote it. A shared link's guest is marked as one, for everyone, and
202
+ * is "you" to themselves. Null for an author the project cannot name.
203
+ */
204
+ export function useCommentAuthors(): (
205
+ comment: Pick<ArtifactComment, "author" | "authorName" | "origin">
206
+ ) => CommentAuthor | null {
207
+ const user = useCurrentUser()
208
+ const guest = useSharedGuest()
209
+ const messages = useArtifactMessages().canvas.comments
210
+
211
+ return ({ author, authorName, origin }) => {
212
+ if (author.type === "guest") {
213
+ const name = authorName ?? messages.guest
214
+ return { name, you: author.id === guest?.id, guest: true }
215
+ }
216
+
217
+ const own = author.type === "user" && author.id === user?.id
218
+ if (origin) {
219
+ const name = own ? messages.you.toLowerCase() : (authorName ?? messages.someone)
220
+ return { name: messages.agentFor(name), you: false, agent: true }
221
+ }
222
+ if (own) return { name: user.displayName ?? user.email ?? authorName ?? "", you: true }
223
+ return authorName ? { name: authorName, you: false } : null
224
+ }
225
+ }
@@ -7,6 +7,7 @@ import {
7
7
  type CanvasItem,
8
8
  type CanvasShape,
9
9
  type CanvasTextSize,
10
+ formatCanvas,
10
11
  } from "@sixb/core/artifacts"
11
12
 
12
13
  /**
@@ -67,19 +68,20 @@ export function resizeItem(id: string, box: Box): CanvasChange {
67
68
  })
68
69
  }
69
70
 
70
- /** An item added at a point, its top left there; the next free id names it. */
71
+ /** An item added at a point, its top left there, under a new id of its kind. */
71
72
  export function addItem(
72
73
  kind: NewItem,
73
74
  at: { x: number; y: number },
74
75
  text: string
75
76
  ): {
76
77
  readonly change: CanvasChange
77
- readonly id: (canvas: Canvas) => string
78
+ readonly id: string
78
79
  } {
79
- const id = (canvas: Canvas) => freeId(new Set(canvas.items.map((item) => item.id)), kind)
80
+ const id = newItemId(kind)
80
81
  const change: CanvasChange = (canvas) => {
81
82
  if (canvas.items.length >= ARTIFACT_LIMITS.maxCanvasItems) return canvas
82
- const place = { id: id(canvas), x: position(at.x), y: position(at.y) }
83
+ if (canvas.items.some((item) => item.id === id)) return canvas
84
+ const place = { id, x: position(at.x), y: position(at.y) }
83
85
  const item: CanvasItem =
84
86
  kind === "note"
85
87
  ? { ...place, type: "note", w: 240, text }
@@ -119,20 +121,27 @@ export function duplicateItems(ids: ReadonlySet<string>): {
119
121
  readonly change: CanvasChange
120
122
  readonly copies: (canvas: Canvas) => readonly string[]
121
123
  } {
122
- /** Each item copied, by its id, and its copy's: the next free. */
124
+ // Each copy's id, new once and then the same: the change and the copies it names agree.
125
+ const names = new Map<string, string>()
126
+ const copyOf = (id: string) => {
127
+ let name = names.get(id)
128
+ if (!name) {
129
+ name = newItemId(id)
130
+ names.set(id, name)
131
+ }
132
+ return name
133
+ }
134
+ /** Each item copied, by its id, and its copy's. */
123
135
  const plan = (canvas: Canvas) => {
124
- const taken = new Set(canvas.items.map((item) => item.id))
125
136
  const renamed = new Map<string, string>()
126
137
  for (const item of canvas.items) {
127
138
  if (!ids.has(item.id) || item.type === "arrow") continue
128
- const id = freeId(taken, item.id)
129
- taken.add(id)
130
- renamed.set(item.id, id)
139
+ renamed.set(item.id, copyOf(item.id))
131
140
  }
132
- return { taken, renamed }
141
+ return renamed
133
142
  }
134
143
  const change: CanvasChange = (canvas) => {
135
- const { taken, renamed } = plan(canvas)
144
+ const renamed = plan(canvas)
136
145
  if (renamed.size === 0) return canvas
137
146
  const copies: CanvasItem[] = []
138
147
  for (const item of canvas.items) {
@@ -140,9 +149,7 @@ export function duplicateItems(ids: ReadonlySet<string>): {
140
149
  const from = typeof item.from === "string" ? renamed.get(item.from) : undefined
141
150
  const to = typeof item.to === "string" ? renamed.get(item.to) : undefined
142
151
  if (!from || !to) continue
143
- const id = freeId(taken, item.id)
144
- taken.add(id)
145
- copies.push({ ...item, id, from, to })
152
+ copies.push({ ...item, id: copyOf(item.id), from, to })
146
153
  continue
147
154
  }
148
155
  const id = renamed.get(item.id)
@@ -151,7 +158,7 @@ export function duplicateItems(ids: ReadonlySet<string>): {
151
158
  const room = Math.max(0, ARTIFACT_LIMITS.maxCanvasItems - canvas.items.length)
152
159
  return { ...canvas, items: [...canvas.items, ...copies.slice(0, room)] }
153
160
  }
154
- return { change, copies: (canvas) => [...plan(canvas).renamed.values()] }
161
+ return { change, copies: (canvas) => [...plan(canvas).values()] }
155
162
  }
156
163
 
157
164
  /**
@@ -191,8 +198,9 @@ export function setItemText(id: string, typed: string): CanvasChange {
191
198
  }
192
199
  }
193
200
 
194
- /** An arrow from one item to another, its id the next free; none when they are one item. */
201
+ /** An arrow from one item to another, under a new id; none when they are one item. */
195
202
  export function connectItems(from: string, to: string): CanvasChange {
203
+ const id = newItemId("arrow")
196
204
  return (canvas) => {
197
205
  if (from === to || canvas.items.length >= ARTIFACT_LIMITS.maxCanvasItems) return canvas
198
206
  const exists = canvas.items.some(
@@ -200,7 +208,7 @@ export function connectItems(from: string, to: string): CanvasChange {
200
208
  )
201
209
  if (exists) return canvas
202
210
  const arrow: CanvasArrow = {
203
- id: freeId(new Set(canvas.items.map((item) => item.id)), "arrow"),
211
+ id,
204
212
  type: "arrow",
205
213
  from,
206
214
  to,
@@ -248,42 +256,25 @@ export function canvasFiles(original: Canvas, canvas: Canvas): Map<string, strin
248
256
  return files
249
257
  }
250
258
 
251
- /**
252
- * A canvas as `canvas.json` writes it, the inverse of `parseCanvas`: its items in order, each
253
- * without what is a default, positions and sizes in whole pixels.
254
- */
255
- export function formatCanvas(canvas: Canvas): string {
256
- const items = canvas.items.map((item) => {
257
- if (item.type === "arrow") {
258
- const { dashed, ...rest } = item
259
- return dashed ? item : rest
260
- }
261
- const rounded = Object.fromEntries(
262
- Object.entries(item).map(([key, value]) => [
263
- key,
264
- typeof value === "number" && ["x", "y", "w", "h"].includes(key) ? Math.round(value) : value,
265
- ])
266
- )
267
- if (item.type === "text" && item.size === "m") {
268
- const { size: _, ...rest } = rounded
269
- return rest
270
- }
271
- return rounded
272
- })
273
- return `${JSON.stringify({ items }, null, 2)}\n`
274
- }
275
-
276
259
  /** How far a copy sits from what it copies, down and to the right. */
277
260
  const STEP = 32
278
261
 
279
- /** The first id of the form `note`, `note-2`, … not taken; one ending in a number counts on. */
280
- function freeId(taken: ReadonlySet<string>, base: string): string {
281
- const stem = base.replace(/-\d+$/, "").slice(0, 34)
282
- if (!taken.has(stem)) return stem
283
- for (let number = 2; ; number += 1) {
284
- const id = `${stem}-${number}`
285
- if (!taken.has(id)) return id
286
- }
262
+ /** The letters and digits a new id ends in, after a dash, and how many. */
263
+ const ID_ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789"
264
+ const ID_SUFFIX = 6
265
+ /** A suffix a new id was given, letters and digits mixed, or a number. */
266
+ const RANDOM_SUFFIX = /-(?:(?=[a-z]*\d)(?=\d*[a-z])[a-z0-9]{6}|\d+)$/
267
+
268
+ /**
269
+ * A new item's id: what it is or what it copies, then a dash and six random letters and digits,
270
+ * as `note-k3m9q2`, so two people adding at once never name two items alike. A copy of a copy
271
+ * drops the suffix its original was given. Ids stay within what `canvas.json` takes: forty at most.
272
+ */
273
+ export function newItemId(base: string): string {
274
+ const stem = base.replace(RANDOM_SUFFIX, "").slice(0, 40 - ID_SUFFIX - 1)
275
+ const bytes = crypto.getRandomValues(new Uint8Array(ID_SUFFIX))
276
+ const suffix = [...bytes].map((byte) => ID_ALPHABET[byte % ID_ALPHABET.length]).join("")
277
+ return `${stem || "item"}-${suffix}`
287
278
  }
288
279
 
289
280
  function joins(end: CanvasArrow["from"], ids: ReadonlySet<string>): boolean {
@@ -19,6 +19,7 @@ import {
19
19
  useRef,
20
20
  useState,
21
21
  } from "react"
22
+ import type { LiveCanvas } from "../../live/canvas"
22
23
  import { useArtifactMessages } from "../../messages"
23
24
  import {
24
25
  addItem,
@@ -42,8 +43,25 @@ export interface CanvasEditor {
42
43
  readonly apply: (change: CanvasChange) => void
43
44
  readonly undo: () => void
44
45
  readonly redo: () => void
46
+ /**
47
+ * Edits everyone sees as they are made: a drag moves its items for the others while it goes,
48
+ * and is one undo step from its start to its end, however long it pauses.
49
+ */
50
+ readonly live?: {
51
+ readonly startDrag: () => void
52
+ readonly endDrag: () => void
53
+ /** Ends the undo step being made: a board's edit is one step of its own. */
54
+ readonly stopCapturing: () => void
55
+ /** Tells the others what is selected. */
56
+ readonly select: (ids: readonly string[]) => void
57
+ /** Edits what a board's page shows, as one step of the same undo. */
58
+ readonly editBoard: LiveCanvas["editBoard"]
59
+ }
45
60
  }
46
61
 
62
+ /** How often a drag tells the others where its items are, at most. */
63
+ const DRAG_SHARE_MS = 50
64
+
47
65
  /** The grid items snap to as they move and resize. */
48
66
  const GRID = 8
49
67
  /** What an item added from the toolbar first measures, to place it in the middle of the view. */
@@ -68,30 +86,72 @@ export function useBoardEditing(
68
86
  const messages = useArtifactMessages().canvas.toolbar
69
87
  const store = useStoreApi()
70
88
  const graph = useMemo(() => canvasGraph(canvas), [canvas])
89
+ const read = useReadGraph(graph, store)
71
90
  const editing = !!edit
72
91
  const [nodes, setNodes] = useState<Node[]>(graph.nodes)
73
92
  const [edges, setEdges] = useState<Edge[]>(graph.edges)
93
+ // Which of the graph's nodes and edges each one drawn now was made from: one whose item did
94
+ // not change is kept as it is, so React Flow draws again only the items that changed.
95
+ const [madeFrom] = useState(() => new WeakMap<object, object>())
74
96
  const selected = useRef<ReadonlySet<string>>(new Set())
75
97
  const [selection, setSelection] = useState<ReadonlySet<string>>(new Set())
76
98
  const [typing, setTyping] = useState<string | null>(null)
77
99
  const root = useRef<HTMLDivElement | null>(null)
78
100
 
79
- // Drawn from the canvas as it changes, what was selected still selected.
80
- useEffect(() => {
81
- const chosen = selected.current
82
- setNodes(
83
- graph.nodes.map((node) =>
84
- editing && node.type !== "point"
85
- ? { ...node, draggable: true, selectable: true, selected: chosen.has(node.id) }
86
- : node
87
- )
88
- )
89
- setEdges(
90
- graph.edges.map((edge) =>
91
- editing ? { ...edge, selectable: true, selected: chosen.has(edge.id) } : edge
92
- )
93
- )
94
- }, [graph, editing])
101
+ // Editing, drawn from the canvas as it changes, what was selected still selected, what React
102
+ // Flow measured kept, and an item being dragged where the drag has it. Brought up to date as
103
+ // the board draws, not in an effect after it, so a change of the canvas is one commit. Read, the
104
+ // graph is drawn as it is, and nothing is kept.
105
+ const [drawnFrom, setDrawnFrom] = useState<{
106
+ readonly graph: typeof graph | null
107
+ readonly editing: boolean
108
+ }>({ graph: null, editing: false })
109
+ if (drawnFrom.graph !== graph || drawnFrom.editing !== editing) {
110
+ if (editing || drawnFrom.editing) setDrawnFrom({ graph, editing })
111
+ if (editing) {
112
+ const chosen = selected.current
113
+ setNodes((current) => {
114
+ const drawn = new Map(current.map((node) => [node.id, node]))
115
+ const next = graph.nodes.map((node) => {
116
+ const was = drawn.get(node.id)
117
+ const choose = node.type !== "point"
118
+ const isSelected = choose && chosen.has(node.id)
119
+ const same =
120
+ was &&
121
+ madeFrom.get(was) === node &&
122
+ !!was.draggable === choose &&
123
+ !!was.selected === isSelected &&
124
+ !was.dragging
125
+ if (same) return was
126
+
127
+ const next: Node = {
128
+ ...node,
129
+ ...(choose ? { draggable: true, selectable: true, selected: isSelected } : {}),
130
+ ...(was?.measured ? { measured: was.measured } : {}),
131
+ ...(was?.dragging ? { position: was.position, dragging: true } : {}),
132
+ }
133
+ madeFrom.set(next, node)
134
+ return next
135
+ })
136
+ return sameItems(current, next) ? current : next
137
+ })
138
+ setEdges((current) => {
139
+ const drawn = new Map(current.map((edge) => [edge.id, edge]))
140
+ const next = graph.edges.map((edge) => {
141
+ const was = drawn.get(edge.id)
142
+ const isSelected = chosen.has(edge.id)
143
+ const same =
144
+ was && madeFrom.get(was) === edge && !!was.selectable && !!was.selected === isSelected
145
+ if (same) return was
146
+
147
+ const next: Edge = { ...edge, selectable: true, selected: isSelected }
148
+ madeFrom.set(next, edge)
149
+ return next
150
+ })
151
+ return sameItems(current, next) ? current : next
152
+ })
153
+ }
154
+ }
95
155
  useEffect(() => {
96
156
  if (!editing) {
97
157
  selected.current = new Set()
@@ -123,6 +183,16 @@ export function useBoardEditing(
123
183
 
124
184
  const focusBoard = useCallback(() => root.current?.focus({ preventScroll: true }), [])
125
185
 
186
+ // The others see what this reader selects.
187
+ const share = edit?.live?.select
188
+ useEffect(() => {
189
+ share?.([...selection])
190
+ }, [share, selection])
191
+ useEffect(() => () => share?.([]), [share])
192
+
193
+ // A drag tells the others where its items are as it goes, a few times a second at most.
194
+ const dragShared = useRef(0)
195
+
126
196
  const items: CanvasItemEditing | null = useMemo(
127
197
  () =>
128
198
  edit
@@ -141,7 +211,7 @@ export function useBoardEditing(
141
211
  )
142
212
 
143
213
  if (!edit) {
144
- return { nodes: graph.nodes, edges: graph.edges, editing: false as const, root }
214
+ return { nodes: read.nodes, edges: read.edges, editing: false as const, root }
145
215
  }
146
216
 
147
217
  const chosenItems = canvas.items.filter((item) => selection.has(item.id))
@@ -157,7 +227,7 @@ export function useBoardEditing(
157
227
  }
158
228
  const text = kind === "text" ? messages.newText : kind === "section" ? messages.newSection : ""
159
229
  const added = addItem(kind, at, text)
160
- const id = added.id(canvas)
230
+ const id = added.id
161
231
  edit.apply((current) => {
162
232
  const next = added.change(current)
163
233
  return shape && shape !== "rect" ? styleItems(new Set([id]), { shape })(next) : next
@@ -276,8 +346,18 @@ export function useBoardEditing(
276
346
  setEdges((current) => applyEdgeChanges(changes, current))
277
347
  if (changes.some((change) => change.type === "select")) chose(changes)
278
348
  },
279
- onNodeDragStop: (_: unknown, __: Node, dragged: Node[]) =>
280
- edit.apply(moveItems(new Map(dragged.map((node) => [node.id, node.position] as const)))),
349
+ onNodeDragStart: () => edit.live?.startDrag(),
350
+ onNodeDrag: (_: unknown, __: Node, dragged: Node[]) => {
351
+ if (!edit.live) return
352
+ const now = performance.now()
353
+ if (now - dragShared.current < DRAG_SHARE_MS) return
354
+ dragShared.current = now
355
+ edit.apply(moveItems(new Map(dragged.map((node) => [node.id, node.position] as const))))
356
+ },
357
+ onNodeDragStop: (_: unknown, __: Node, dragged: Node[]) => {
358
+ edit.apply(moveItems(new Map(dragged.map((node) => [node.id, node.position] as const))))
359
+ edit.live?.endDrag()
360
+ },
281
361
  onConnect: (connection: Connection) =>
282
362
  edit.apply(connectItems(connection.source, connection.target)),
283
363
  onNodeDoubleClick: (_: unknown, node: Node) => {
@@ -299,3 +379,48 @@ export function useBoardEditing(
299
379
  },
300
380
  }
301
381
  }
382
+
383
+ /** Whether two lists hold the same items, in the same order. */
384
+ function sameItems<T>(left: readonly T[], right: readonly T[]): boolean {
385
+ return left.length === right.length && left.every((item, index) => item === right[index])
386
+ }
387
+
388
+ /**
389
+ * The graph as a read board hands it to React Flow. Its lists stay the ones given before while
390
+ * they hold the same items: React Flow takes a list in again, and works out every arrow's ends,
391
+ * whenever it is a new one. A node made again, as for an item someone moved, keeps the size React
392
+ * Flow measured while its own stays the same: without it, React Flow measures it again, in a
393
+ * commit of its own that redraws every arrow.
394
+ */
395
+ function useReadGraph(
396
+ graph: { readonly nodes: Node[]; readonly edges: Edge[] },
397
+ store: ReturnType<typeof useStoreApi>
398
+ ): { readonly nodes: Node[]; readonly edges: Edge[] } {
399
+ // Caches of what the graph draws as: one kept from a render that was thrown away is as good.
400
+ const [measuredFrom] = useState(() => new WeakMap<Node, Node>())
401
+ const last = useRef<{ readonly nodes: Node[]; readonly edges: Edge[] } | null>(null)
402
+
403
+ const { nodeLookup } = store.getState()
404
+ const measured = graph.nodes.map((node) => {
405
+ const kept = measuredFrom.get(node)
406
+ if (kept) return kept
407
+
408
+ const drawn = nodeLookup.get(node.id)
409
+ const same =
410
+ drawn?.measured.width !== undefined &&
411
+ drawn.measured.height !== undefined &&
412
+ drawn.internals.userNode.width === node.width &&
413
+ drawn.internals.userNode.height === node.height
414
+ const next = same ? { ...node, measured: { ...drawn.measured } } : node
415
+ measuredFrom.set(node, next)
416
+ return next
417
+ })
418
+
419
+ const nodes =
420
+ last.current && sameItems(last.current.nodes, measured) ? last.current.nodes : measured
421
+ const edges =
422
+ last.current && sameItems(last.current.edges, graph.edges) ? last.current.edges : graph.edges
423
+ if (nodes !== last.current?.nodes || edges !== last.current?.edges)
424
+ last.current = { nodes, edges }
425
+ return last.current
426
+ }