@sixb/app 0.2.3 → 0.2.5

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 (329) hide show
  1. package/assets/connector-icons/README.md +1 -0
  2. package/assets/connector-icons/ctm.png +0 -0
  3. package/dist/agent/activity-label.d.ts.map +1 -1
  4. package/dist/agent/agent-chat.d.ts +3 -1
  5. package/dist/agent/agent-chat.d.ts.map +1 -1
  6. package/dist/agent/agent-panel.d.ts.map +1 -1
  7. package/dist/agent/artifact-panel.d.ts +3 -1
  8. package/dist/agent/artifact-panel.d.ts.map +1 -1
  9. package/dist/agent/background/background-tool-row.d.ts.map +1 -1
  10. package/dist/agent/background/interpret.d.ts +1 -1
  11. package/dist/agent/background/interpret.d.ts.map +1 -1
  12. package/dist/agent/components/composer-settings.d.ts +1 -1
  13. package/dist/agent/components/composer-settings.d.ts.map +1 -1
  14. package/dist/agent/components/composer.d.ts +22 -5
  15. package/dist/agent/components/composer.d.ts.map +1 -1
  16. package/dist/agent/components/context-meter.d.ts +1 -1
  17. package/dist/agent/components/context-meter.d.ts.map +1 -1
  18. package/dist/agent/components/conversation-panel.d.ts +8 -2
  19. package/dist/agent/components/conversation-panel.d.ts.map +1 -1
  20. package/dist/agent/components/message-parts.d.ts +2 -1
  21. package/dist/agent/components/message-parts.d.ts.map +1 -1
  22. package/dist/agent/components/message-view.d.ts.map +1 -1
  23. package/dist/agent/components/pending-messages.d.ts +20 -0
  24. package/dist/agent/components/pending-messages.d.ts.map +1 -0
  25. package/dist/agent/components/sandbox-recovery.d.ts +11 -2
  26. package/dist/agent/components/sandbox-recovery.d.ts.map +1 -1
  27. package/dist/agent/components/threads-button.d.ts +1 -1
  28. package/dist/agent/components/threads-button.d.ts.map +1 -1
  29. package/dist/agent/components/transcript.d.ts +5 -0
  30. package/dist/agent/components/transcript.d.ts.map +1 -1
  31. package/dist/agent/conversation.d.ts +3 -6
  32. package/dist/agent/conversation.d.ts.map +1 -1
  33. package/dist/agent/delegation/agent-exchange.d.ts +16 -0
  34. package/dist/agent/delegation/agent-exchange.d.ts.map +1 -0
  35. package/dist/agent/delegation/child-card.d.ts +3 -3
  36. package/dist/agent/delegation/child-card.d.ts.map +1 -1
  37. package/dist/agent/delegation/child-parts.d.ts +1 -10
  38. package/dist/agent/delegation/child-parts.d.ts.map +1 -1
  39. package/dist/agent/delegation/child-work.d.ts.map +1 -1
  40. package/dist/agent/delegation/interpret.d.ts +9 -10
  41. package/dist/agent/delegation/interpret.d.ts.map +1 -1
  42. package/dist/agent/delegation/use-children.d.ts.map +1 -1
  43. package/dist/agent/file-edits/file-edit-tool-view.d.ts +10 -0
  44. package/dist/agent/file-edits/file-edit-tool-view.d.ts.map +1 -0
  45. package/dist/agent/file-edits/interpret.d.ts +25 -0
  46. package/dist/agent/file-edits/interpret.d.ts.map +1 -0
  47. package/dist/agent/hooks/use-agent-conversation.d.ts +16 -4
  48. package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
  49. package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
  50. package/dist/agent/hooks/use-thread-stream.d.ts.map +1 -1
  51. package/dist/agent/i18n/en.d.ts +114 -5
  52. package/dist/agent/i18n/en.d.ts.map +1 -1
  53. package/dist/agent/i18n/fr.d.ts.map +1 -1
  54. package/dist/agent/i18n/index.d.ts +190 -8
  55. package/dist/agent/i18n/index.d.ts.map +1 -1
  56. package/dist/agent/inbox-handoff.d.ts +10 -0
  57. package/dist/agent/inbox-handoff.d.ts.map +1 -0
  58. package/dist/agent/live-run.d.ts +8 -1
  59. package/dist/agent/live-run.d.ts.map +1 -1
  60. package/dist/agent/message-agent/interpret.d.ts +2 -2
  61. package/dist/agent/message-agent/interpret.d.ts.map +1 -1
  62. package/dist/agent/publish-artifact/interpret.d.ts +1 -1
  63. package/dist/agent/publish-artifact/interpret.d.ts.map +1 -1
  64. package/dist/agent/questions/interpret.d.ts +31 -0
  65. package/dist/agent/questions/interpret.d.ts.map +1 -0
  66. package/dist/agent/questions/question-card.d.ts +16 -0
  67. package/dist/agent/questions/question-card.d.ts.map +1 -0
  68. package/dist/agent/questions/question-composer.d.ts +15 -0
  69. package/dist/agent/questions/question-composer.d.ts.map +1 -0
  70. package/dist/agent/read/interpret.d.ts +8 -1
  71. package/dist/agent/read/interpret.d.ts.map +1 -1
  72. package/dist/agent/read/read-tool-view.d.ts.map +1 -1
  73. package/dist/agent/search/interpret.d.ts +101 -0
  74. package/dist/agent/search/interpret.d.ts.map +1 -0
  75. package/dist/agent/search/search-tool-view.d.ts +10 -0
  76. package/dist/agent/search/search-tool-view.d.ts.map +1 -0
  77. package/dist/agent/thread-state.d.ts +26 -0
  78. package/dist/agent/thread-state.d.ts.map +1 -0
  79. package/dist/agent/tool-views/built-in.d.ts.map +1 -1
  80. package/dist/agent/tool-views/registry.d.ts +5 -6
  81. package/dist/agent/tool-views/registry.d.ts.map +1 -1
  82. package/dist/agent/types.d.ts +5 -1
  83. package/dist/agent/types.d.ts.map +1 -1
  84. package/dist/agent/view-file/view-file-tool-view.d.ts +2 -1
  85. package/dist/agent/view-file/view-file-tool-view.d.ts.map +1 -1
  86. package/dist/agent/waits.d.ts +14 -0
  87. package/dist/agent/waits.d.ts.map +1 -0
  88. package/dist/artifacts/card-preview.d.ts.map +1 -1
  89. package/dist/artifacts/edit-session.d.ts +11 -1
  90. package/dist/artifacts/edit-session.d.ts.map +1 -1
  91. package/dist/artifacts/editor/block-handle.d.ts +20 -0
  92. package/dist/artifacts/editor/block-handle.d.ts.map +1 -0
  93. package/dist/artifacts/editor/blocks.d.ts +34 -0
  94. package/dist/artifacts/editor/blocks.d.ts.map +1 -0
  95. package/dist/artifacts/editor/callout-view.d.ts +7 -0
  96. package/dist/artifacts/editor/callout-view.d.ts.map +1 -0
  97. package/dist/artifacts/editor/document-editor.d.ts +30 -0
  98. package/dist/artifacts/editor/document-editor.d.ts.map +1 -0
  99. package/dist/artifacts/editor/figure-view.d.ts +12 -0
  100. package/dist/artifacts/editor/figure-view.d.ts.map +1 -0
  101. package/dist/artifacts/editor/find-blocks.d.ts +6 -0
  102. package/dist/artifacts/editor/find-blocks.d.ts.map +1 -0
  103. package/dist/artifacts/editor/markdown-document.d.ts +12 -0
  104. package/dist/artifacts/editor/markdown-document.d.ts.map +1 -0
  105. package/dist/artifacts/editor/messages.d.ts +4 -0
  106. package/dist/artifacts/editor/messages.d.ts.map +1 -0
  107. package/dist/artifacts/editor/schema.d.ts +21 -0
  108. package/dist/artifacts/editor/schema.d.ts.map +1 -0
  109. package/dist/artifacts/editor/selection-toolbar.d.ts +35 -0
  110. package/dist/artifacts/editor/selection-toolbar.d.ts.map +1 -0
  111. package/dist/artifacts/editor/slash-menu.d.ts +43 -0
  112. package/dist/artifacts/editor/slash-menu.d.ts.map +1 -0
  113. package/dist/artifacts/editor/upload.d.ts +12 -0
  114. package/dist/artifacts/editor/upload.d.ts.map +1 -0
  115. package/dist/artifacts/file-source.d.ts +5 -0
  116. package/dist/artifacts/file-source.d.ts.map +1 -1
  117. package/dist/artifacts/frame-editor/bundle.d.ts +7 -0
  118. package/dist/artifacts/frame-editor/bundle.d.ts.map +1 -0
  119. package/dist/artifacts/frame-editor/commands.d.ts +93 -0
  120. package/dist/artifacts/frame-editor/commands.d.ts.map +1 -0
  121. package/dist/artifacts/frame-editor/entry.d.ts +2 -0
  122. package/dist/artifacts/frame-editor/entry.d.ts.map +1 -0
  123. package/dist/artifacts/frame-editor/frame.d.ts +5 -0
  124. package/dist/artifacts/frame-editor/frame.d.ts.map +1 -0
  125. package/dist/artifacts/frame-editor/keys.d.ts +8 -0
  126. package/dist/artifacts/frame-editor/keys.d.ts.map +1 -0
  127. package/dist/artifacts/frame-editor/protocol.d.ts +186 -0
  128. package/dist/artifacts/frame-editor/protocol.d.ts.map +1 -0
  129. package/dist/artifacts/frame-editor/schema.d.ts +34 -0
  130. package/dist/artifacts/frame-editor/schema.d.ts.map +1 -0
  131. package/dist/artifacts/frame-editor/style.d.ts +2 -0
  132. package/dist/artifacts/frame-editor/style.d.ts.map +1 -0
  133. package/dist/artifacts/frame.d.ts +2 -2
  134. package/dist/artifacts/frame.d.ts.map +1 -1
  135. package/dist/artifacts/live/boards.d.ts +2 -0
  136. package/dist/artifacts/live/boards.d.ts.map +1 -1
  137. package/dist/artifacts/live/document.d.ts +32 -0
  138. package/dist/artifacts/live/document.d.ts.map +1 -0
  139. package/dist/artifacts/live/header.d.ts +4 -4
  140. package/dist/artifacts/live/header.d.ts.map +1 -1
  141. package/dist/artifacts/live/presence.d.ts.map +1 -1
  142. package/dist/artifacts/live/session.d.ts +2 -0
  143. package/dist/artifacts/live/session.d.ts.map +1 -1
  144. package/dist/artifacts/live/view.d.ts +4 -3
  145. package/dist/artifacts/live/view.d.ts.map +1 -1
  146. package/dist/artifacts/messages.d.ts +278 -2
  147. package/dist/artifacts/messages.d.ts.map +1 -1
  148. package/dist/artifacts/pdf.d.ts +8 -0
  149. package/dist/artifacts/pdf.d.ts.map +1 -0
  150. package/dist/artifacts/queries.d.ts +80 -0
  151. package/dist/artifacts/queries.d.ts.map +1 -1
  152. package/dist/artifacts/references/references.d.ts +3 -3
  153. package/dist/artifacts/references/references.d.ts.map +1 -1
  154. package/dist/artifacts/renderers/canvas/board-editor.d.ts +11 -4
  155. package/dist/artifacts/renderers/canvas/board-editor.d.ts.map +1 -1
  156. package/dist/artifacts/renderers/canvas/board.d.ts +14 -2
  157. package/dist/artifacts/renderers/canvas/board.d.ts.map +1 -1
  158. package/dist/artifacts/renderers/canvas/canvas.d.ts +4 -3
  159. package/dist/artifacts/renderers/canvas/canvas.d.ts.map +1 -1
  160. package/dist/artifacts/renderers/canvas/comment-pins.d.ts +4 -2
  161. package/dist/artifacts/renderers/canvas/comment-pins.d.ts.map +1 -1
  162. package/dist/artifacts/renderers/canvas/comments-panel.d.ts.map +1 -1
  163. package/dist/artifacts/renderers/canvas/comments.d.ts +2 -1
  164. package/dist/artifacts/renderers/canvas/comments.d.ts.map +1 -1
  165. package/dist/artifacts/renderers/canvas/controls.d.ts +15 -4
  166. package/dist/artifacts/renderers/canvas/controls.d.ts.map +1 -1
  167. package/dist/artifacts/renderers/canvas/focus.d.ts +19 -5
  168. package/dist/artifacts/renderers/canvas/focus.d.ts.map +1 -1
  169. package/dist/artifacts/renderers/canvas/gestures.d.ts +46 -0
  170. package/dist/artifacts/renderers/canvas/gestures.d.ts.map +1 -0
  171. package/dist/artifacts/renderers/canvas/page-resize.d.ts +21 -0
  172. package/dist/artifacts/renderers/canvas/page-resize.d.ts.map +1 -0
  173. package/dist/artifacts/renderers/canvas/page-size-controls.d.ts +21 -0
  174. package/dist/artifacts/renderers/canvas/page-size-controls.d.ts.map +1 -0
  175. package/dist/artifacts/renderers/canvas/page-size.d.ts +93 -0
  176. package/dist/artifacts/renderers/canvas/page-size.d.ts.map +1 -0
  177. package/dist/artifacts/renderers/canvas/page-zoom.d.ts +64 -0
  178. package/dist/artifacts/renderers/canvas/page-zoom.d.ts.map +1 -0
  179. package/dist/artifacts/renderers/canvas/shown-size.d.ts +26 -0
  180. package/dist/artifacts/renderers/canvas/shown-size.d.ts.map +1 -0
  181. package/dist/artifacts/renderers/designed-document.d.ts +28 -0
  182. package/dist/artifacts/renderers/designed-document.d.ts.map +1 -0
  183. package/dist/artifacts/renderers/document-tree.d.ts +2 -0
  184. package/dist/artifacts/renderers/document-tree.d.ts.map +1 -1
  185. package/dist/artifacts/renderers/document.d.ts +9 -1
  186. package/dist/artifacts/renderers/document.d.ts.map +1 -1
  187. package/dist/artifacts/renderers/live-frame.d.ts +145 -0
  188. package/dist/artifacts/renderers/live-frame.d.ts.map +1 -0
  189. package/dist/artifacts/renderers/page-editor.d.ts +16 -0
  190. package/dist/artifacts/renderers/page-editor.d.ts.map +1 -0
  191. package/dist/artifacts/renderers/page.d.ts +10 -1
  192. package/dist/artifacts/renderers/page.d.ts.map +1 -1
  193. package/dist/artifacts/viewer.d.ts.map +1 -1
  194. package/dist/{chunk-001c4gnk.js → chunk-4fex83k2.js} +19965 -13027
  195. package/dist/chunk-4fex83k2.js.map +239 -0
  196. package/dist/{chunk-5crvhjp2.js → chunk-4wm09prf.js} +1633 -1999
  197. package/dist/chunk-4wm09prf.js.map +27 -0
  198. package/dist/{chunk-fwb9mxwm.js → chunk-5sgac68y.js} +1 -1
  199. package/dist/{chunk-kes4ygmz.js → chunk-69qgh20f.js} +1 -1
  200. package/dist/chunk-y51c4tsz.js +11 -0
  201. package/dist/chunk-y51c4tsz.js.map +10 -0
  202. package/dist/index.d.ts +4 -1
  203. package/dist/index.d.ts.map +1 -1
  204. package/dist/index.js +13 -6
  205. package/dist/index.js.map +5 -5
  206. package/dist/pages/console/data/messages.d.ts +6 -0
  207. package/dist/pages/console/data/messages.d.ts.map +1 -1
  208. package/dist/pages/console/data/shared.d.ts.map +1 -1
  209. package/dist/pages.js +12 -5
  210. package/dist/pages.js.map +6 -6
  211. package/dist/shell/search-command.d.ts.map +1 -1
  212. package/package.json +22 -5
  213. package/src/agent/activity-label.ts +9 -1
  214. package/src/agent/agent-chat.tsx +57 -37
  215. package/src/agent/agent-execution-trace.tsx +2 -2
  216. package/src/agent/agent-panel.tsx +6 -4
  217. package/src/agent/agent.css +254 -0
  218. package/src/agent/artifact-panel.tsx +77 -22
  219. package/src/agent/background/background-tool-row.tsx +24 -10
  220. package/src/agent/background/interpret.ts +60 -51
  221. package/src/agent/components/composer-settings.tsx +20 -10
  222. package/src/agent/components/composer.tsx +342 -104
  223. package/src/agent/components/context-meter.tsx +7 -3
  224. package/src/agent/components/conversation-panel.tsx +96 -37
  225. package/src/agent/components/message-parts.tsx +390 -64
  226. package/src/agent/components/message-view.tsx +12 -2
  227. package/src/agent/components/pending-messages.tsx +338 -0
  228. package/src/agent/components/sandbox-recovery.tsx +36 -17
  229. package/src/agent/components/threads-button.tsx +3 -2
  230. package/src/agent/components/transcript.tsx +92 -45
  231. package/src/agent/conversation.ts +203 -54
  232. package/src/agent/delegation/agent-exchange.tsx +53 -0
  233. package/src/agent/delegation/child-card.tsx +6 -40
  234. package/src/agent/delegation/child-parts.tsx +1 -84
  235. package/src/agent/delegation/child-work.tsx +19 -5
  236. package/src/agent/delegation/interpret.ts +64 -61
  237. package/src/agent/delegation/model.ts +1 -1
  238. package/src/agent/file-edits/file-edit-tool-view.tsx +126 -0
  239. package/src/agent/file-edits/interpret.ts +120 -0
  240. package/src/agent/hooks/use-agent-conversation.ts +360 -92
  241. package/src/agent/hooks/use-thread-stream.ts +10 -0
  242. package/src/agent/i18n/en.ts +134 -16
  243. package/src/agent/i18n/fr.ts +122 -16
  244. package/src/agent/inbox-handoff.ts +47 -0
  245. package/src/agent/live-run.ts +23 -2
  246. package/src/agent/message-agent/interpret.ts +4 -3
  247. package/src/agent/publish-artifact/interpret.ts +14 -5
  248. package/src/agent/publish-artifact/publish-artifact-tool-view.tsx +2 -2
  249. package/src/agent/questions/interpret.ts +90 -0
  250. package/src/agent/questions/question-card.tsx +57 -0
  251. package/src/agent/questions/question-composer.tsx +257 -0
  252. package/src/agent/react-router.tsx +2 -2
  253. package/src/agent/read/interpret.ts +34 -1
  254. package/src/agent/read/read-tool-view.tsx +20 -4
  255. package/src/agent/search/interpret.ts +367 -0
  256. package/src/agent/search/search-tool-view.tsx +235 -0
  257. package/src/agent/thread-state.ts +114 -0
  258. package/src/agent/tool-views/built-in.tsx +33 -6
  259. package/src/agent/tool-views/registry.tsx +28 -2
  260. package/src/agent/types.ts +7 -0
  261. package/src/agent/view-file/view-file-tool-view.tsx +33 -19
  262. package/src/agent/waits.ts +50 -0
  263. package/src/artifacts/artifacts.css +434 -0
  264. package/src/artifacts/card-preview.tsx +6 -1
  265. package/src/artifacts/edit-session.tsx +15 -1
  266. package/src/artifacts/editor/block-handle.tsx +278 -0
  267. package/src/artifacts/editor/blocks.ts +216 -0
  268. package/src/artifacts/editor/callout-view.tsx +31 -0
  269. package/src/artifacts/editor/document-editor.tsx +484 -0
  270. package/src/artifacts/editor/figure-view.tsx +66 -0
  271. package/src/artifacts/editor/find-blocks.ts +19 -0
  272. package/src/artifacts/editor/markdown-document.tsx +72 -0
  273. package/src/artifacts/editor/messages.ts +4 -0
  274. package/src/artifacts/editor/schema.ts +159 -0
  275. package/src/artifacts/editor/selection-toolbar.tsx +364 -0
  276. package/src/artifacts/editor/slash-menu.tsx +251 -0
  277. package/src/artifacts/editor/upload.ts +40 -0
  278. package/src/artifacts/file-source.ts +11 -0
  279. package/src/artifacts/frame-editor/bundle.ts +8 -0
  280. package/src/artifacts/frame-editor/commands.ts +565 -0
  281. package/src/artifacts/frame-editor/entry.ts +6 -0
  282. package/src/artifacts/frame-editor/frame.ts +847 -0
  283. package/src/artifacts/frame-editor/generated/editor.txt +149 -0
  284. package/src/artifacts/frame-editor/generated.d.ts +5 -0
  285. package/src/artifacts/frame-editor/keys.ts +323 -0
  286. package/src/artifacts/frame-editor/protocol.ts +151 -0
  287. package/src/artifacts/frame-editor/schema.ts +293 -0
  288. package/src/artifacts/frame-editor/style.ts +58 -0
  289. package/src/artifacts/frame.tsx +14 -5
  290. package/src/artifacts/live/boards.ts +46 -3
  291. package/src/artifacts/live/document.ts +89 -0
  292. package/src/artifacts/live/header.tsx +9 -14
  293. package/src/artifacts/live/presence.ts +5 -1
  294. package/src/artifacts/live/session.ts +4 -2
  295. package/src/artifacts/live/view.ts +14 -8
  296. package/src/artifacts/messages.ts +192 -2
  297. package/src/artifacts/pdf.ts +50 -0
  298. package/src/artifacts/references/references.tsx +46 -11
  299. package/src/artifacts/renderers/canvas/board-editor.tsx +44 -155
  300. package/src/artifacts/renderers/canvas/board.tsx +70 -8
  301. package/src/artifacts/renderers/canvas/canvas.tsx +66 -15
  302. package/src/artifacts/renderers/canvas/comment-pins.tsx +5 -0
  303. package/src/artifacts/renderers/canvas/comments-panel.tsx +58 -1
  304. package/src/artifacts/renderers/canvas/comments.ts +8 -4
  305. package/src/artifacts/renderers/canvas/controls.tsx +64 -30
  306. package/src/artifacts/renderers/canvas/focus.tsx +200 -56
  307. package/src/artifacts/renderers/canvas/gestures.ts +265 -0
  308. package/src/artifacts/renderers/canvas/page-resize.tsx +542 -0
  309. package/src/artifacts/renderers/canvas/page-size-controls.tsx +193 -0
  310. package/src/artifacts/renderers/canvas/page-size.ts +218 -0
  311. package/src/artifacts/renderers/canvas/page-zoom.ts +280 -0
  312. package/src/artifacts/renderers/canvas/shown-size.ts +105 -0
  313. package/src/artifacts/renderers/designed-document.tsx +277 -0
  314. package/src/artifacts/renderers/document-tree.ts +9 -0
  315. package/src/artifacts/renderers/document.tsx +13 -102
  316. package/src/artifacts/renderers/live-frame.ts +163 -0
  317. package/src/artifacts/renderers/page-editor.tsx +613 -0
  318. package/src/artifacts/renderers/page.tsx +21 -4
  319. package/src/artifacts/viewer.tsx +101 -41
  320. package/src/index.ts +8 -0
  321. package/src/pages/console/data/messages.ts +6 -0
  322. package/src/pages/console/data/projections.tsx +4 -0
  323. package/src/pages/console/data/shared.tsx +1 -0
  324. package/src/pages/console/ontology/lineage/trail.tsx +3 -0
  325. package/src/shell/search-command.tsx +2 -0
  326. package/dist/chunk-001c4gnk.js.map +0 -204
  327. package/dist/chunk-5crvhjp2.js.map +0 -28
  328. /package/dist/{chunk-fwb9mxwm.js.map → chunk-5sgac68y.js.map} +0 -0
  329. /package/dist/{chunk-kes4ygmz.js.map → chunk-69qgh20f.js.map} +0 -0
@@ -4,11 +4,10 @@ import {
4
4
  type CanvasBoard,
5
5
  type FrameEditTarget,
6
6
  type FrameEvent,
7
- parseFrameEvent,
7
+ type FrameZoom,
8
8
  } from "@sixb/core/artifacts"
9
9
  import {
10
10
  boardFilePath,
11
- boardFramePatches,
12
11
  mergeBoardText,
13
12
  setBoardImage,
14
13
  setBoardStyle,
@@ -30,19 +29,15 @@ import {
30
29
  useState,
31
30
  } from "react"
32
31
  import { formatFileSize } from "../../file-size"
33
- import { ArtifactFrame, type ArtifactFrameHandle } from "../../frame"
34
- import { useLiveBoardSource, useLiveStoredFiles } from "../../live/boards"
32
+ import { ArtifactFrame } from "../../frame"
33
+ import { useLiveStoredFiles } from "../../live/boards"
35
34
  import type { LiveCanvas } from "../../live/canvas"
36
35
  import type { LiveArtifact } from "../../live/session"
37
36
  import { useArtifactMessages } from "../../messages"
38
- import { type ArtifactVersion, useFileText, versionFileSource } from "../../queries"
37
+ import { type ArtifactVersion, versionFileSource } from "../../queries"
38
+ import { useFrameEditing, useLiveFrame } from "../live-frame"
39
39
  import { type CanvasImage, ImagePanel, type StyleChange, StylePanel } from "./board-properties"
40
- import {
41
- boardAttribute,
42
- boardInlineStyle,
43
- boardReferencePath,
44
- showablePatches,
45
- } from "./board-source"
40
+ import { boardAttribute, boardInlineStyle, boardReferencePath } from "./board-source"
46
41
  import {
47
42
  CommentPin,
48
43
  cardPlace,
@@ -51,18 +46,15 @@ import {
51
46
  type PinPlace,
52
47
  pinPoint,
53
48
  } from "./comment-pins"
49
+ import type { PageSize } from "./page-size"
54
50
 
55
51
  // A board opened over the canvas, as its page runs in its frame, and what the reader does on it:
56
- // read it, edit what it shows, or pick what to comment on.
57
- //
58
- // The frame serves the board as a stored version holds it, marked for editing; the live document
59
- // holds it as everyone is changing it now. The frame is kept at the version it loaded and told,
60
- // element by element, what changed since (`edit.patch`), so typing goes on under the caret while
61
- // others change other elements. It loads a newer version only when the elements themselves
62
- // changed, or a picture it does not hold yet is shown, and then once the stored version holds it.
52
+ // read it, edit what it shows, or pick what to comment on. The frame follows the live document as
53
+ // ../live-frame.ts describes.
63
54
  //
64
55
  // frame ── edit.select ──▶ the element picked, its toolbar (the reader's own click)
65
56
  // ── edit.text ───▶ mergeBoardText → the board's Y.Text (only for the element picked)
57
+ // ── zoom ────────▶ the opened board zoomed, not the browser (the reader's own gesture)
66
58
  // ◀─ edit.patch ── what the document changed since the frame's version
67
59
 
68
60
  /** What edits a board's elements: the live canvas, under the reader's own undo. */
@@ -78,101 +70,13 @@ export type CommentPick = Omit<DraftPlace, "board">
78
70
  const IMAGE_EXTENSIONS = /\.(png|jpe?g|gif|webp|avif|svg)$/i
79
71
 
80
72
  /**
81
- * Follows a board's frame and the live document together: the version it shows, kept until it
82
- * must move, what it showed last, and the patches that bring it to what the document holds.
83
- */
84
- function useBoardFrame({
85
- version,
86
- board,
87
- live,
88
- }: {
89
- readonly version: ArtifactVersion
90
- readonly board: CanvasBoard
91
- readonly live: LiveArtifact | null
92
- }) {
93
- const source = useLiveBoardSource(live, board.file)
94
- const patching = source !== null
95
- const [pinned, setPinned] = useState(version)
96
- const shows = patching ? pinned : version
97
- const stored = useFileText(patching ? versionFileSource(pinned, board.file) : null).text
98
-
99
- const handle = useRef<ArtifactFrameHandle | null>(null)
100
- /** Each load the frame said it is ready, for what follows to start over. */
101
- const [loads, setLoads] = useState(0)
102
- /** What the frame shows now, once patched past its version's page. */
103
- const shown = useRef<string | null>(null)
104
- /** Pictures the reader just uploaded, shown from their bytes until a version holds them. */
105
- const previews = useRef(new Map<string, string>())
106
- /** The frame must load a newer version: the elements changed, or a picture is missing. */
107
- const [stale, setStale] = useState(false)
108
- /**
109
- * The elements themselves changed: the frame's addresses name other elements than the
110
- * document's, so nothing is edited through it until it loads a version that has them.
111
- */
112
- const [moved, setMoved] = useState(false)
113
- const [holding, setHolding] = useState(false)
114
-
115
- const ready = useCallback(() => {
116
- shown.current = null
117
- setLoads((count) => count + 1)
118
- }, [])
119
-
120
- // What the document holds now, as patches to what the frame shows.
121
- useEffect(() => {
122
- if (loads === 0 || stored === undefined || source === null) return
123
-
124
- const patches = boardFramePatches(shown.current ?? stored, source)
125
- if (patches === null) {
126
- setStale(true)
127
- setMoved(true)
128
- return
129
- }
130
- setMoved(false)
131
-
132
- const holds = (path: string) => shows.files.some((file) => file.path === path)
133
- const showable = showablePatches(patches, board.file, holds, previews.current)
134
- if (showable.waiting) setStale(true)
135
- shown.current = source
136
- if (showable.patches.length === 0) return
137
-
138
- handle.current?.send("edit.patch", { patches: showable.patches }).catch(() => {})
139
- }, [loads, stored, source, shows, board.file])
140
-
141
- // A stale frame loads the version the viewer has now once it is past the one it shows, and
142
- // while the reader is not typing in it, unless what they type in is no longer where it was.
143
- useEffect(() => {
144
- if (!stale || (holding && !moved) || version.revision <= pinned.revision) return
145
- setStale(false)
146
- setPinned(version)
147
- }, [stale, holding, moved, version, pinned.revision])
148
-
149
- /** Loads the frame's page again, as what it shows can no longer be patched. */
150
- const resync = useCallback(() => {
151
- shown.current = null
152
- handle.current?.send("reload", {}).catch(() => {})
153
- }, [])
154
-
155
- return {
156
- shows,
157
- source,
158
- handle,
159
- loads,
160
- ready,
161
- resync,
162
- stale,
163
- moved,
164
- previews: previews.current,
165
- hold: setHolding,
166
- }
167
- }
168
-
169
- /**
170
- * An opened board at its size on screen: its page in its frame, the picture under it until it is
171
- * ready, comments' pins over it, and, editing, the picked element's tools.
73
+ * An opened board at its size on screen: its page in its frame, laid out at `size`, the picture
74
+ * under it until it is ready, comments' pins over it, and, editing, the picked element's tools.
172
75
  */
173
76
  export function BoardStage({
174
77
  version,
175
78
  board,
79
+ size,
176
80
  title,
177
81
  scale,
178
82
  live,
@@ -188,9 +92,13 @@ export function BoardStage({
188
92
  onOpenPin,
189
93
  onSubmitDraft,
190
94
  onCancelDraft,
95
+ onContentHeight,
96
+ onZoom,
191
97
  }: {
192
98
  readonly version: ArtifactVersion
193
99
  readonly board: CanvasBoard
100
+ /** The size the page is laid out at: the board's, or the one the reader chose to see it at. */
101
+ readonly size: PageSize
194
102
  readonly title: string
195
103
  readonly scale: number
196
104
  /** The canvas held live, whose document the board is patched from. */
@@ -208,9 +116,13 @@ export function BoardStage({
208
116
  readonly onOpenPin: (id: string) => void
209
117
  readonly onSubmitDraft: (body: string) => Promise<void>
210
118
  readonly onCancelDraft: () => void
119
+ /** The page's height as laid out at its width, as the frame reports it. */
120
+ readonly onContentHeight?: (height: number) => void
121
+ /** The reader zoomed over the page: the frame passes it on instead of the browser zooming. */
122
+ readonly onZoom?: (zoom: FrameZoom) => void
211
123
  }) {
212
124
  const messages = useArtifactMessages().canvas
213
- const frame = useBoardFrame({ version, board, live })
125
+ const frame = useLiveFrame({ version, file: board.file, live })
214
126
  const editing = mode === "edit" && canvas !== null
215
127
  const [selected, setSelected] = useState<FrameEditTarget | null>(null)
216
128
  /** What the pointer is over while the reader picks what to comment on. */
@@ -247,48 +159,16 @@ export function BoardStage({
247
159
  if (!draft) setHovered(null)
248
160
  }, [draft])
249
161
 
250
- // Each load of the frame, a port of its own, handed over with its first `edit` request: what
251
- // editing reports comes through it alone, never through the window, where the board's scripts
252
- // post too.
253
- const port = useRef<{ readonly mine: MessagePort; handed: MessagePort | null } | null>(null)
254
- const onEditRef = useRef<(event: FrameEvent) => void>(() => {})
255
- useEffect(() => {
256
- if (frame.loads === 0) return
257
- const channel = new MessageChannel()
258
- channel.port1.onmessage = (message: MessageEvent) => {
259
- const event = parseFrameEvent(message.data)
260
- if (event?.event.startsWith("edit.")) onEditRef.current(event)
261
- }
262
- port.current = { mine: channel.port1, handed: channel.port2 }
263
- return () => channel.port1.close()
264
- }, [frame.loads])
265
-
266
- // The frame picks and types as the mode says, each time it loads; while its elements are not
267
- // the document's, it does neither.
268
- const send = frame.handle
269
- useEffect(() => {
270
- if (frame.loads === 0) return
271
- const handed = port.current?.handed
272
- if (port.current) port.current.handed = null
273
- send.current
274
- ?.send(
275
- "edit",
276
- { on: mode !== "read" && !frame.moved, typing: editing },
277
- handed ? [handed] : []
278
- )
279
- .catch(() => {})
280
- }, [frame.loads, frame.moved, mode, editing, send])
281
-
282
162
  const point = useCallback(
283
163
  (at: { readonly x: number; readonly y: number } | undefined, rect: FrameEditTarget["rect"]) => {
284
164
  const x = at?.x ?? rect.x + rect.width
285
165
  const y = at?.y ?? rect.y
286
166
  return {
287
- x: Math.min(1, Math.max(0, x / board.w)),
288
- y: Math.min(1, Math.max(0, y / board.h)),
167
+ x: Math.min(1, Math.max(0, x / size.w)),
168
+ y: Math.min(1, Math.max(0, y / size.h)),
289
169
  }
290
170
  },
291
- [board.w, board.h]
171
+ [size.w, size.h]
292
172
  )
293
173
 
294
174
  const onEvent = useCallback(
@@ -301,12 +181,14 @@ export function BoardStage({
301
181
  frame.ready()
302
182
  } else if (event.event === "press") {
303
183
  onPress(event.params.text)
184
+ } else if (event.event === "size") {
185
+ onContentHeight?.(event.params.height)
304
186
  }
305
187
  },
306
- [frame, onPress]
188
+ [frame, onPress, onContentHeight]
307
189
  )
308
190
 
309
- onEditRef.current = (event: FrameEvent) => {
191
+ const onEdit = (event: FrameEvent) => {
310
192
  if (moved.current) return
311
193
 
312
194
  switch (event.event) {
@@ -326,7 +208,7 @@ export function BoardStage({
326
208
  // The page's body is the whole board, named by its title.
327
209
  ...(target.address === "body" ? { anchor: title } : {}),
328
210
  point: point(at, target.rect),
329
- under: Math.min(1, (target.rect.y + target.rect.height) / board.h),
211
+ under: Math.min(1, (target.rect.y + target.rect.height) / size.h),
330
212
  })
331
213
  return
332
214
  }
@@ -355,13 +237,15 @@ export function BoardStage({
355
237
  return
356
238
  }
357
239
  }
240
+ // The frame picks and types as the mode says, each time it loads.
241
+ useFrameEditing({ frame, on: mode !== "read", typing: editing, onEdit, onZoom })
358
242
 
359
243
  return (
360
244
  <div className="relative size-full">
361
245
  <div className="absolute inset-0 overflow-hidden rounded-[inherit]">
362
246
  <div
363
247
  className="absolute top-0 left-0 origin-top-left"
364
- style={{ width: board.w, height: board.h, transform: `scale(${scale})` }}
248
+ style={{ width: size.w, height: size.h, transform: `scale(${scale})` }}
365
249
  >
366
250
  <ArtifactFrame
367
251
  key={board.id}
@@ -378,14 +262,15 @@ export function BoardStage({
378
262
  </div>
379
263
  </div>
380
264
 
381
- <div className="pointer-events-none absolute inset-0" data-board-overlay="">
265
+ {/* Over the page's resize handles: a pin at the page's edge stays pressable. */}
266
+ <div className="pointer-events-none absolute inset-0 z-10" data-board-overlay="">
382
267
  {pins.map((pin, index) => {
383
268
  const at = pinPoint(pin, pin.point ? 0 : index)
384
269
  return (
385
270
  <div
386
271
  key={pin.id}
387
272
  className="absolute"
388
- style={{ left: at.x * board.w * scale, top: at.y * board.h * scale }}
273
+ style={{ left: at.x * size.w * scale, top: at.y * size.h * scale }}
389
274
  >
390
275
  <CommentPin
391
276
  number={pin.number}
@@ -403,13 +288,13 @@ export function BoardStage({
403
288
  {draft ? (
404
289
  <div
405
290
  className="absolute"
406
- style={{ left: draft.point.x * board.w * scale, top: draft.point.y * board.h * scale }}
291
+ style={{ left: draft.point.x * size.w * scale, top: draft.point.y * size.h * scale }}
407
292
  >
408
293
  <CommentPin label={messages.comments.newPin} active resolved={false} draft />
409
294
  <div
410
295
  className={cn("absolute", draftAbove(draft) ? "bottom-9" : null)}
411
296
  style={{
412
- ...cardPlace(draft.point.x * board.w * scale, board.w * scale),
297
+ ...cardPlace(draft.point.x * size.w * scale, size.w * scale),
413
298
  // Under what it is about, so the words it points at stay in view.
414
299
  ...(draftAbove(draft)
415
300
  ? {}
@@ -417,7 +302,7 @@ export function BoardStage({
417
302
  top:
418
303
  Math.max(
419
304
  0,
420
- ((draft.under ?? draft.point.y) - draft.point.y) * board.h * scale
305
+ ((draft.under ?? draft.point.y) - draft.point.y) * size.h * scale
421
306
  ) + 10,
422
307
  }),
423
308
  }}
@@ -436,6 +321,7 @@ export function BoardStage({
436
321
  key={selected.address ?? "scripted"}
437
322
  target={selected}
438
323
  scale={scale}
324
+ width={size.w}
439
325
  board={board}
440
326
  version={version}
441
327
  live={live}
@@ -514,6 +400,7 @@ function HoverTag({ target, scale }: { readonly target: FrameEditTarget; readonl
514
400
  function ElementTools({
515
401
  target,
516
402
  scale,
403
+ width: pageWidth,
517
404
  board,
518
405
  version,
519
406
  live,
@@ -524,6 +411,8 @@ function ElementTools({
524
411
  }: {
525
412
  readonly target: FrameEditTarget
526
413
  readonly scale: number
414
+ /** The page's width as laid out. */
415
+ readonly width: number
527
416
  readonly board: CanvasBoard
528
417
  readonly version: ArtifactVersion
529
418
  readonly live: LiveArtifact | null
@@ -542,7 +431,7 @@ function ElementTools({
542
431
  useLayoutEffect(() => {
543
432
  setWidth(toolbar.current?.offsetWidth ?? 0)
544
433
  })
545
- const left = Math.max(4, Math.min(rect.x * scale, board.w * scale - width - 4))
434
+ const left = Math.max(4, Math.min(rect.x * scale, pageWidth * scale - width - 4))
546
435
  const above = rect.y * scale >= 44
547
436
  const top = above ? rect.y * scale - 40 : (rect.y + rect.height) * scale + 8
548
437
 
@@ -1,18 +1,20 @@
1
- import { CANVAS_FILE } from "@sixb/core/artifacts"
1
+ import { CANVAS_FILE, parseFrameEvent } from "@sixb/core/artifacts"
2
2
  import { cn } from "@sixb/ui/lib/utils"
3
3
  import { useStoreApi } from "@xyflow/react"
4
4
  import type { LucideIcon } from "lucide-react"
5
5
  import {
6
6
  createContext,
7
7
  type ReactNode,
8
+ type RefObject,
8
9
  useContext,
9
10
  useEffect,
10
11
  useRef,
11
12
  useState,
12
13
  useSyncExternalStore,
13
14
  } from "react"
14
- import { ArtifactFrame } from "../../frame"
15
+ import { ArtifactFrame, type ArtifactFrameHandle } from "../../frame"
15
16
  import type { ArtifactVersion } from "../../queries"
17
+ import type { BoardGestures } from "./gestures"
16
18
  import type { BoardPreviews } from "./previews"
17
19
 
18
20
  /** The most boards and embeds live at once: each board is a page running in its own frame. */
@@ -157,6 +159,13 @@ interface LiveBoards {
157
159
  readonly mode: "light" | "dark"
158
160
  /** Opens a board over the canvas. */
159
161
  readonly open?: (id: string) => void
162
+ /**
163
+ * Whether the reader uses the running boards' pages in place: while they read the canvas, not
164
+ * while they edit it or place a comment.
165
+ */
166
+ readonly interactive?: boolean
167
+ /** What the canvas does with what a running board's page hands it. */
168
+ readonly gestures?: BoardGestures | null
160
169
  }
161
170
 
162
171
  const LiveBoardsContext = createContext<LiveBoards>({
@@ -340,8 +349,12 @@ function usePagesVersion(version: ArtifactVersion | null): ArtifactVersion | nul
340
349
  * A board's page, running, when the view shows it large enough, over its tile: the tile stays
341
350
  * under the frame while it fades in, once its page is ready, so a board never flashes blank as it
342
351
  * starts or stops; then the tile goes, so nothing of it shows through a page drawn on the board's
343
- * own surface. On the board a frame takes no clicks, so dragging across it pans; it is a picture
344
- * until the reader opens it.
352
+ * own surface.
353
+ *
354
+ * While the reader reads the canvas, a running page is theirs to use in place: its clicks, keys,
355
+ * text and cursor are its own, and its frame hands the canvas what moves it, as `gestures.ts`
356
+ * says. Editing the canvas or placing a comment, or until it runs, it takes no clicks: a drag
357
+ * across it pans, as across its picture.
345
358
  */
346
359
  export function LiveBoard({
347
360
  id,
@@ -354,15 +367,28 @@ export function LiveBoard({
354
367
  readonly title: string
355
368
  readonly tile: ReactNode
356
369
  }) {
357
- const { version } = useContext(LiveBoardsContext)
370
+ const { version, interactive = false, gestures = null } = useContext(LiveBoardsContext)
358
371
  const live = useLive(id)
359
372
  const pages = usePagesVersion(version)
360
373
  // The pages whose frame said it is ready: a frame that runs other pages, or stops, shows the
361
374
  // tile again until it is.
362
375
  const [ready, setReady] = useState<ArtifactVersion | null>(null)
363
376
  const running = live && pages !== null && ready === pages
377
+ const usable = running && interactive
378
+
379
+ const page = useRef<HTMLDivElement | null>(null)
380
+ const handle = useRef<ArtifactFrameHandle | null>(null)
381
+ /** Each load the frame said it is ready, for its port to be handed over again. */
382
+ const [loads, setLoads] = useState(0)
383
+ useCanvasPort(id, gestures, handle, loads, page)
384
+
364
385
  return (
365
- <div className="group/board relative size-full" data-running={running ? "" : undefined}>
386
+ <div
387
+ ref={page}
388
+ className="group/board relative size-full"
389
+ data-running={running ? "" : undefined}
390
+ data-interactive={usable ? "" : undefined}
391
+ >
366
392
  {/* Gone once the frame has faded in over it: as long as the fade, then not drawn at all. */}
367
393
  <div className="size-full transition-[visibility] delay-300 group-data-[running]/board:invisible">
368
394
  {tile}
@@ -372,13 +398,49 @@ export function LiveBoard({
372
398
  version={pages}
373
399
  entry={file}
374
400
  title={title}
375
- decorative
401
+ decorative={!usable}
402
+ handle={handle}
376
403
  className="absolute inset-0 overflow-hidden rounded-[10px]"
377
404
  onEvent={(event) => {
378
- if (event.event === "ready") setReady(pages)
405
+ if (event.event !== "ready") return
406
+ setReady(pages)
407
+ setLoads((count) => count + 1)
379
408
  }}
380
409
  />
381
410
  ) : null}
382
411
  </div>
383
412
  )
384
413
  }
414
+
415
+ /**
416
+ * Each load of a running board's frame, a port of its own, handed over with its first `canvas`
417
+ * request: what moves the canvas comes through it alone, never through the window, where the
418
+ * page's scripts post too. The frame hears from then on whether the canvas pans by the wheel.
419
+ */
420
+ function useCanvasPort(
421
+ id: string,
422
+ gestures: BoardGestures | null,
423
+ handle: RefObject<ArtifactFrameHandle | null>,
424
+ loads: number,
425
+ page: RefObject<HTMLElement | null>
426
+ ): void {
427
+ useEffect(() => {
428
+ if (loads === 0 || !gestures) return
429
+
430
+ const channel = new MessageChannel()
431
+ channel.port1.onmessage = (message: MessageEvent) => {
432
+ const event = parseFrameEvent(message.data)
433
+ if (event) gestures.receive(id, event, page.current)
434
+ }
435
+ const tell = (moving: boolean, transfer: Transferable[] = []) => {
436
+ handle.current?.send("canvas", { moving }, transfer).catch(() => {})
437
+ }
438
+
439
+ tell(gestures.moving(), [channel.port2])
440
+ const stop = gestures.onMoving((moving) => tell(moving))
441
+ return () => {
442
+ stop()
443
+ channel.port1.close()
444
+ }
445
+ }, [id, gestures, handle, loads, page])
446
+ }
@@ -26,6 +26,7 @@ import {
26
26
  useRef,
27
27
  useState,
28
28
  } from "react"
29
+ import { useStartEditing } from "../../edit-session"
29
30
  import type { LiveArtifact } from "../../live/session"
30
31
  import { useArtifactMessages } from "../../messages"
31
32
  import type { ArtifactVersion } from "../../queries"
@@ -38,18 +39,21 @@ import { CanvasCommentPins } from "./comment-pins"
38
39
  import { CommentModeHint, CommentTools, useCanvasCommenting } from "./commenting"
39
40
  import { CommentsPanel } from "./comments-panel"
40
41
  import { CanvasControls } from "./controls"
42
+ import type { Box } from "./draft"
41
43
  import { type CanvasEditor, useBoardEditing } from "./edit-mode"
42
- import { CanvasEditingProvider } from "./editing"
43
- import { BoardFocus } from "./focus"
44
+ import { CanvasEditingProvider, type CanvasItemEditing } from "./editing"
45
+ import { BoardFocus, followedArrow } from "./focus"
46
+ import { useBoardGestures } from "./gestures"
44
47
  import { CANVAS_NODE_TYPES, NAME_SCALE, zoomMarks } from "./items"
45
48
  import { PresenceLayer } from "./presence"
46
49
  import { boardPreviewUrl, useBoardPreviews } from "./previews"
47
50
 
48
51
  /**
49
52
  * A canvas on an endless board: drag or scroll to pan, pinch or ⌘-scroll to zoom, the zoom
50
- * controls in a corner. Boards and embeds run live once the view shows them large enough;
51
- * double-click a board, press Enter on it, or press its Open to open it over the canvas. It opens
52
- * on the item an address named, else fitted to everything. Given an editor, its items are
53
+ * controls in a corner. Boards and embeds run live once the view shows them large enough, and a
54
+ * running board's page is the reader's to use in place while they read; double-click a board,
55
+ * press Enter on it, or press its Open to open it over the canvas. It opens on the item an
56
+ * address named, else fitted to everything. Given an editor, its items are
53
57
  * selected, moved, resized, connected, and typed into, with a toolbar to add more.
54
58
  */
55
59
  export default memo(function CanvasBoard({
@@ -157,16 +161,6 @@ function Board({
157
161
 
158
162
  void fitView({ nodes: [{ id }], padding: CANVAS_FIT_PADDING, maxZoom: 1, duration: 220 })
159
163
  }, [opened, fitView])
160
- const live = useMemo(
161
- () => ({
162
- version: version ?? null,
163
- live: running,
164
- previews,
165
- mode,
166
- ...(version ? { open: setOpened } : {}),
167
- }),
168
- [version, running, previews, mode]
169
- )
170
164
  // An opened board's picture, at its own size, under its page until the page is ready.
171
165
  const pictureOf = useCallback(
172
166
  (id: string) =>
@@ -175,6 +169,7 @@ function Board({
175
169
  )
176
170
 
177
171
  const board = useBoardEditing(canvas, edit, version ? setOpened : undefined)
172
+ const resizeBoard = useResizeBoard(board.editing ? board.items : null)
178
173
  // What edits a board's elements in place: the live canvas, while the reader edits it.
179
174
  const editBoard = edit?.live?.editBoard
180
175
  const stopCapturing = edit?.live?.stopCapturing
@@ -275,6 +270,36 @@ function Board({
275
270
  [commenting, boards, opened, fitView]
276
271
  )
277
272
 
273
+ // Read, the running boards' pages are the reader's to use in place, and a button or a link in one
274
+ // that reads as the label of an arrow leaving it glides the canvas to the board it points to.
275
+ const reads = !board.editing && !commenting.commenting && opened === null
276
+ const follow = useRef<(from: string, text: string) => void>(() => {})
277
+ const gestures = useBoardGestures({
278
+ root: board.root,
279
+ pointed,
280
+ reading: reads,
281
+ opened: opened !== null,
282
+ padding: CANVAS_FIT_PADDING,
283
+ onPress: (from, text) => follow.current(from, text),
284
+ })
285
+ follow.current = (from, text) => {
286
+ const to = followedArrow(arrows, boards, from, text)
287
+ const target = boards.find((each) => each.id === to)
288
+ if (target) gestures.glide(target)
289
+ }
290
+ const live = useMemo(
291
+ () => ({
292
+ version: version ?? null,
293
+ live: running,
294
+ previews,
295
+ mode,
296
+ interactive: reads && version !== undefined,
297
+ gestures,
298
+ ...(version ? { open: setOpened } : {}),
299
+ }),
300
+ [version, running, previews, mode, reads, gestures]
301
+ )
302
+
278
303
  // Read, the board's handlers stay the same from one draw to the next, so React Flow doesn't
279
304
  // draw every item again when the board does.
280
305
  const open = live.open
@@ -416,6 +441,8 @@ function Board({
416
441
  live={liveArtifact ?? null}
417
442
  canvas={boardEditor}
418
443
  mode={commenting.commenting ? "comment" : boardEditor ? "edit" : "read"}
444
+ // Keep this size resizes the board as its handles on the canvas do.
445
+ {...(resizeBoard ? { onResizeBoard: resizeBoard } : {})}
419
446
  {...(commenting.enabled
420
447
  ? {
421
448
  pins: commenting.pins,
@@ -468,6 +495,30 @@ function Board({
468
495
  )
469
496
  }
470
497
 
498
+ /**
499
+ * Keep this size: a board resized as its handles on the canvas resize it, while the canvas is
500
+ * edited. Outside editing, for whoever may change the canvas, it starts editing and resizes the
501
+ * board once editing is on, as if they had resized it there: the header's Undo takes it back.
502
+ * Null for whoever may not change the canvas.
503
+ */
504
+ function useResizeBoard(items: CanvasItemEditing | null): ((id: string, box: Box) => void) | null {
505
+ const start = useStartEditing()
506
+ const [waiting, setWaiting] = useState<{ readonly id: string; readonly box: Box } | null>(null)
507
+
508
+ useEffect(() => {
509
+ if (!waiting || !items) return
510
+ items.resize(waiting.id, waiting.box)
511
+ setWaiting(null)
512
+ }, [waiting, items])
513
+
514
+ if (items) return items.resize
515
+ if (!start) return null
516
+ return (id, box) => {
517
+ setWaiting({ id, box })
518
+ start()
519
+ }
520
+ }
521
+
471
522
  /** What belongs to the comments: their panel, their pins, and a board's element tools. */
472
523
  const COMMENTS = "[data-comments-panel], [data-comment-pin], [data-board-tools]"
473
524
 
@@ -119,6 +119,7 @@ export function CommentComposer({
119
119
  onCancel,
120
120
  autoFocus = true,
121
121
  compact = false,
122
+ notice,
122
123
  className,
123
124
  }: {
124
125
  readonly placeholder: string
@@ -127,6 +128,8 @@ export function CommentComposer({
127
128
  readonly autoFocus?: boolean
128
129
  /** A reply's: one line until it grows. */
129
130
  readonly compact?: boolean
131
+ /** Under the words, before they are posted: who else will read them. */
132
+ readonly notice?: ReactNode
130
133
  readonly className?: string
131
134
  }) {
132
135
  const messages = useArtifactMessages().canvas.comments
@@ -218,6 +221,8 @@ export function CommentComposer({
218
221
  <p role="alert" className="m-0 px-1 text-xs text-destructive">
219
222
  {messages.failures[failure]}
220
223
  </p>
224
+ ) : notice ? (
225
+ <div className="px-1">{notice}</div>
221
226
  ) : null}
222
227
  </div>
223
228
  )