@sixb/app 0.2.4 → 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 (247) 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/components/composer-settings.d.ts +1 -1
  10. package/dist/agent/components/composer-settings.d.ts.map +1 -1
  11. package/dist/agent/components/composer.d.ts +22 -5
  12. package/dist/agent/components/composer.d.ts.map +1 -1
  13. package/dist/agent/components/context-meter.d.ts +1 -1
  14. package/dist/agent/components/context-meter.d.ts.map +1 -1
  15. package/dist/agent/components/conversation-panel.d.ts +5 -2
  16. package/dist/agent/components/conversation-panel.d.ts.map +1 -1
  17. package/dist/agent/components/message-parts.d.ts +2 -1
  18. package/dist/agent/components/message-parts.d.ts.map +1 -1
  19. package/dist/agent/components/message-view.d.ts.map +1 -1
  20. package/dist/agent/components/pending-messages.d.ts +20 -0
  21. package/dist/agent/components/pending-messages.d.ts.map +1 -0
  22. package/dist/agent/components/sandbox-recovery.d.ts +11 -2
  23. package/dist/agent/components/sandbox-recovery.d.ts.map +1 -1
  24. package/dist/agent/components/threads-button.d.ts +1 -1
  25. package/dist/agent/components/threads-button.d.ts.map +1 -1
  26. package/dist/agent/components/transcript.d.ts.map +1 -1
  27. package/dist/agent/conversation.d.ts +3 -6
  28. package/dist/agent/conversation.d.ts.map +1 -1
  29. package/dist/agent/delegation/interpret.d.ts +5 -0
  30. package/dist/agent/delegation/interpret.d.ts.map +1 -1
  31. package/dist/agent/delegation/use-children.d.ts.map +1 -1
  32. package/dist/agent/hooks/use-agent-conversation.d.ts +10 -4
  33. package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
  34. package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
  35. package/dist/agent/hooks/use-thread-stream.d.ts.map +1 -1
  36. package/dist/agent/i18n/en.d.ts +68 -0
  37. package/dist/agent/i18n/en.d.ts.map +1 -1
  38. package/dist/agent/i18n/fr.d.ts.map +1 -1
  39. package/dist/agent/i18n/index.d.ts +114 -0
  40. package/dist/agent/i18n/index.d.ts.map +1 -1
  41. package/dist/agent/inbox-handoff.d.ts +10 -0
  42. package/dist/agent/inbox-handoff.d.ts.map +1 -0
  43. package/dist/agent/live-run.d.ts +8 -1
  44. package/dist/agent/live-run.d.ts.map +1 -1
  45. package/dist/agent/search/interpret.d.ts +101 -0
  46. package/dist/agent/search/interpret.d.ts.map +1 -0
  47. package/dist/agent/search/search-tool-view.d.ts +10 -0
  48. package/dist/agent/search/search-tool-view.d.ts.map +1 -0
  49. package/dist/agent/thread-state.d.ts +26 -0
  50. package/dist/agent/thread-state.d.ts.map +1 -0
  51. package/dist/agent/tool-views/built-in.d.ts.map +1 -1
  52. package/dist/agent/tool-views/registry.d.ts +5 -6
  53. package/dist/agent/tool-views/registry.d.ts.map +1 -1
  54. package/dist/agent/types.d.ts +5 -1
  55. package/dist/agent/types.d.ts.map +1 -1
  56. package/dist/agent/view-file/view-file-tool-view.d.ts +2 -1
  57. package/dist/agent/view-file/view-file-tool-view.d.ts.map +1 -1
  58. package/dist/artifacts/card-preview.d.ts.map +1 -1
  59. package/dist/artifacts/editor/block-handle.d.ts +20 -0
  60. package/dist/artifacts/editor/block-handle.d.ts.map +1 -0
  61. package/dist/artifacts/editor/blocks.d.ts +34 -0
  62. package/dist/artifacts/editor/blocks.d.ts.map +1 -0
  63. package/dist/artifacts/editor/callout-view.d.ts +7 -0
  64. package/dist/artifacts/editor/callout-view.d.ts.map +1 -0
  65. package/dist/artifacts/editor/document-editor.d.ts +30 -0
  66. package/dist/artifacts/editor/document-editor.d.ts.map +1 -0
  67. package/dist/artifacts/editor/figure-view.d.ts +12 -0
  68. package/dist/artifacts/editor/figure-view.d.ts.map +1 -0
  69. package/dist/artifacts/editor/find-blocks.d.ts +6 -0
  70. package/dist/artifacts/editor/find-blocks.d.ts.map +1 -0
  71. package/dist/artifacts/editor/markdown-document.d.ts +12 -0
  72. package/dist/artifacts/editor/markdown-document.d.ts.map +1 -0
  73. package/dist/artifacts/editor/messages.d.ts +4 -0
  74. package/dist/artifacts/editor/messages.d.ts.map +1 -0
  75. package/dist/artifacts/editor/schema.d.ts +21 -0
  76. package/dist/artifacts/editor/schema.d.ts.map +1 -0
  77. package/dist/artifacts/editor/selection-toolbar.d.ts +35 -0
  78. package/dist/artifacts/editor/selection-toolbar.d.ts.map +1 -0
  79. package/dist/artifacts/editor/slash-menu.d.ts +43 -0
  80. package/dist/artifacts/editor/slash-menu.d.ts.map +1 -0
  81. package/dist/artifacts/editor/upload.d.ts +12 -0
  82. package/dist/artifacts/editor/upload.d.ts.map +1 -0
  83. package/dist/artifacts/file-source.d.ts +5 -0
  84. package/dist/artifacts/file-source.d.ts.map +1 -1
  85. package/dist/artifacts/frame-editor/bundle.d.ts +7 -0
  86. package/dist/artifacts/frame-editor/bundle.d.ts.map +1 -0
  87. package/dist/artifacts/frame-editor/commands.d.ts +93 -0
  88. package/dist/artifacts/frame-editor/commands.d.ts.map +1 -0
  89. package/dist/artifacts/frame-editor/entry.d.ts +2 -0
  90. package/dist/artifacts/frame-editor/entry.d.ts.map +1 -0
  91. package/dist/artifacts/frame-editor/frame.d.ts +5 -0
  92. package/dist/artifacts/frame-editor/frame.d.ts.map +1 -0
  93. package/dist/artifacts/frame-editor/keys.d.ts +8 -0
  94. package/dist/artifacts/frame-editor/keys.d.ts.map +1 -0
  95. package/dist/artifacts/frame-editor/protocol.d.ts +186 -0
  96. package/dist/artifacts/frame-editor/protocol.d.ts.map +1 -0
  97. package/dist/artifacts/frame-editor/schema.d.ts +34 -0
  98. package/dist/artifacts/frame-editor/schema.d.ts.map +1 -0
  99. package/dist/artifacts/frame-editor/style.d.ts +2 -0
  100. package/dist/artifacts/frame-editor/style.d.ts.map +1 -0
  101. package/dist/artifacts/frame.d.ts +2 -2
  102. package/dist/artifacts/frame.d.ts.map +1 -1
  103. package/dist/artifacts/live/boards.d.ts +2 -0
  104. package/dist/artifacts/live/boards.d.ts.map +1 -1
  105. package/dist/artifacts/live/document.d.ts +32 -0
  106. package/dist/artifacts/live/document.d.ts.map +1 -0
  107. package/dist/artifacts/live/header.d.ts +4 -4
  108. package/dist/artifacts/live/header.d.ts.map +1 -1
  109. package/dist/artifacts/live/presence.d.ts.map +1 -1
  110. package/dist/artifacts/live/session.d.ts +2 -0
  111. package/dist/artifacts/live/session.d.ts.map +1 -1
  112. package/dist/artifacts/live/view.d.ts +4 -3
  113. package/dist/artifacts/live/view.d.ts.map +1 -1
  114. package/dist/artifacts/messages.d.ts +226 -2
  115. package/dist/artifacts/messages.d.ts.map +1 -1
  116. package/dist/artifacts/pdf.d.ts +8 -0
  117. package/dist/artifacts/pdf.d.ts.map +1 -0
  118. package/dist/artifacts/queries.d.ts +80 -0
  119. package/dist/artifacts/queries.d.ts.map +1 -1
  120. package/dist/artifacts/references/references.d.ts +3 -3
  121. package/dist/artifacts/references/references.d.ts.map +1 -1
  122. package/dist/artifacts/renderers/canvas/board-editor.d.ts.map +1 -1
  123. package/dist/artifacts/renderers/canvas/comment-pins.d.ts +4 -2
  124. package/dist/artifacts/renderers/canvas/comment-pins.d.ts.map +1 -1
  125. package/dist/artifacts/renderers/canvas/comments-panel.d.ts.map +1 -1
  126. package/dist/artifacts/renderers/canvas/comments.d.ts +2 -1
  127. package/dist/artifacts/renderers/canvas/comments.d.ts.map +1 -1
  128. package/dist/artifacts/renderers/designed-document.d.ts +28 -0
  129. package/dist/artifacts/renderers/designed-document.d.ts.map +1 -0
  130. package/dist/artifacts/renderers/document-tree.d.ts +2 -0
  131. package/dist/artifacts/renderers/document-tree.d.ts.map +1 -1
  132. package/dist/artifacts/renderers/document.d.ts +9 -1
  133. package/dist/artifacts/renderers/document.d.ts.map +1 -1
  134. package/dist/artifacts/renderers/live-frame.d.ts +145 -0
  135. package/dist/artifacts/renderers/live-frame.d.ts.map +1 -0
  136. package/dist/artifacts/renderers/page-editor.d.ts +16 -0
  137. package/dist/artifacts/renderers/page-editor.d.ts.map +1 -0
  138. package/dist/artifacts/renderers/page.d.ts +10 -1
  139. package/dist/artifacts/renderers/page.d.ts.map +1 -1
  140. package/dist/artifacts/viewer.d.ts.map +1 -1
  141. package/dist/{chunk-kymx9y5e.js → chunk-4fex83k2.js} +10874 -4690
  142. package/dist/chunk-4fex83k2.js.map +239 -0
  143. package/dist/{chunk-yrcm1pbg.js → chunk-4wm09prf.js} +491 -2128
  144. package/dist/chunk-4wm09prf.js.map +27 -0
  145. package/dist/{chunk-pxd07kvx.js → chunk-5sgac68y.js} +1 -1
  146. package/dist/{chunk-970s5nkn.js → chunk-69qgh20f.js} +1 -1
  147. package/dist/chunk-y51c4tsz.js +11 -0
  148. package/dist/chunk-y51c4tsz.js.map +10 -0
  149. package/dist/index.d.ts +2 -1
  150. package/dist/index.d.ts.map +1 -1
  151. package/dist/index.js +11 -6
  152. package/dist/index.js.map +5 -5
  153. package/dist/pages/console/data/messages.d.ts +6 -0
  154. package/dist/pages/console/data/messages.d.ts.map +1 -1
  155. package/dist/pages/console/data/shared.d.ts.map +1 -1
  156. package/dist/pages.js +12 -5
  157. package/dist/pages.js.map +6 -6
  158. package/dist/shell/search-command.d.ts.map +1 -1
  159. package/package.json +22 -5
  160. package/src/agent/activity-label.ts +3 -0
  161. package/src/agent/agent-chat.tsx +56 -37
  162. package/src/agent/agent-execution-trace.tsx +2 -2
  163. package/src/agent/agent-panel.tsx +6 -4
  164. package/src/agent/agent.css +254 -0
  165. package/src/agent/artifact-panel.tsx +77 -22
  166. package/src/agent/components/composer-settings.tsx +20 -10
  167. package/src/agent/components/composer.tsx +342 -104
  168. package/src/agent/components/context-meter.tsx +7 -3
  169. package/src/agent/components/conversation-panel.tsx +69 -29
  170. package/src/agent/components/message-parts.tsx +367 -59
  171. package/src/agent/components/message-view.tsx +12 -2
  172. package/src/agent/components/pending-messages.tsx +338 -0
  173. package/src/agent/components/sandbox-recovery.tsx +36 -17
  174. package/src/agent/components/threads-button.tsx +3 -2
  175. package/src/agent/components/transcript.tsx +63 -34
  176. package/src/agent/conversation.ts +203 -54
  177. package/src/agent/delegation/interpret.ts +31 -7
  178. package/src/agent/hooks/use-agent-conversation.ts +348 -100
  179. package/src/agent/hooks/use-thread-stream.ts +10 -0
  180. package/src/agent/i18n/en.ts +87 -11
  181. package/src/agent/i18n/fr.ts +83 -12
  182. package/src/agent/inbox-handoff.ts +47 -0
  183. package/src/agent/live-run.ts +23 -2
  184. package/src/agent/react-router.tsx +2 -2
  185. package/src/agent/search/interpret.ts +367 -0
  186. package/src/agent/search/search-tool-view.tsx +235 -0
  187. package/src/agent/thread-state.ts +114 -0
  188. package/src/agent/tool-views/built-in.tsx +16 -0
  189. package/src/agent/tool-views/registry.tsx +28 -2
  190. package/src/agent/types.ts +7 -0
  191. package/src/agent/view-file/view-file-tool-view.tsx +33 -19
  192. package/src/artifacts/artifacts.css +398 -0
  193. package/src/artifacts/card-preview.tsx +6 -1
  194. package/src/artifacts/editor/block-handle.tsx +278 -0
  195. package/src/artifacts/editor/blocks.ts +216 -0
  196. package/src/artifacts/editor/callout-view.tsx +31 -0
  197. package/src/artifacts/editor/document-editor.tsx +484 -0
  198. package/src/artifacts/editor/figure-view.tsx +66 -0
  199. package/src/artifacts/editor/find-blocks.ts +19 -0
  200. package/src/artifacts/editor/markdown-document.tsx +72 -0
  201. package/src/artifacts/editor/messages.ts +4 -0
  202. package/src/artifacts/editor/schema.ts +159 -0
  203. package/src/artifacts/editor/selection-toolbar.tsx +364 -0
  204. package/src/artifacts/editor/slash-menu.tsx +251 -0
  205. package/src/artifacts/editor/upload.ts +40 -0
  206. package/src/artifacts/file-source.ts +11 -0
  207. package/src/artifacts/frame-editor/bundle.ts +8 -0
  208. package/src/artifacts/frame-editor/commands.ts +565 -0
  209. package/src/artifacts/frame-editor/entry.ts +6 -0
  210. package/src/artifacts/frame-editor/frame.ts +847 -0
  211. package/src/artifacts/frame-editor/generated/editor.txt +149 -0
  212. package/src/artifacts/frame-editor/generated.d.ts +5 -0
  213. package/src/artifacts/frame-editor/keys.ts +323 -0
  214. package/src/artifacts/frame-editor/protocol.ts +151 -0
  215. package/src/artifacts/frame-editor/schema.ts +293 -0
  216. package/src/artifacts/frame-editor/style.ts +58 -0
  217. package/src/artifacts/frame.tsx +11 -3
  218. package/src/artifacts/live/boards.ts +46 -3
  219. package/src/artifacts/live/document.ts +89 -0
  220. package/src/artifacts/live/header.tsx +9 -14
  221. package/src/artifacts/live/presence.ts +5 -1
  222. package/src/artifacts/live/session.ts +4 -2
  223. package/src/artifacts/live/view.ts +14 -8
  224. package/src/artifacts/messages.ts +138 -2
  225. package/src/artifacts/pdf.ts +50 -0
  226. package/src/artifacts/references/references.tsx +46 -11
  227. package/src/artifacts/renderers/canvas/board-editor.tsx +11 -144
  228. package/src/artifacts/renderers/canvas/comment-pins.tsx +5 -0
  229. package/src/artifacts/renderers/canvas/comments-panel.tsx +58 -1
  230. package/src/artifacts/renderers/canvas/comments.ts +8 -4
  231. package/src/artifacts/renderers/designed-document.tsx +277 -0
  232. package/src/artifacts/renderers/document-tree.ts +9 -0
  233. package/src/artifacts/renderers/document.tsx +13 -102
  234. package/src/artifacts/renderers/live-frame.ts +163 -0
  235. package/src/artifacts/renderers/page-editor.tsx +613 -0
  236. package/src/artifacts/renderers/page.tsx +21 -4
  237. package/src/artifacts/viewer.tsx +87 -41
  238. package/src/index.ts +6 -0
  239. package/src/pages/console/data/messages.ts +6 -0
  240. package/src/pages/console/data/projections.tsx +4 -0
  241. package/src/pages/console/data/shared.tsx +1 -0
  242. package/src/pages/console/ontology/lineage/trail.tsx +3 -0
  243. package/src/shell/search-command.tsx +2 -0
  244. package/dist/chunk-kymx9y5e.js.map +0 -211
  245. package/dist/chunk-yrcm1pbg.js.map +0 -34
  246. /package/dist/{chunk-pxd07kvx.js.map → chunk-5sgac68y.js.map} +0 -0
  247. /package/dist/{chunk-970s5nkn.js.map → chunk-69qgh20f.js.map} +0 -0
@@ -1,5 +1,6 @@
1
1
  import { useEffect, useRef, useState, useSyncExternalStore } from "react"
2
2
  import { liveCanvasOf } from "./canvas"
3
+ import { liveDocumentOf } from "./document"
3
4
  import type { LiveNoticeReason } from "./header"
4
5
  import { useLiveArtifact, useLiveArtifactState } from "./hooks"
5
6
  import type { LiveArtifact, LiveArtifactState } from "./session"
@@ -29,10 +30,14 @@ const noSubscription = () => () => {}
29
30
 
30
31
  /**
31
32
  * Holds the artifact live while its latest version is shown: null for an older version, and for
32
- * a kind that is not edited live. The document draws the canvas once it holds it; until then, and
33
- * if the server never holds it live, the version does, and editing it is a draft.
33
+ * an artifact that is not edited live. A canvas is drawn from the document once it holds it;
34
+ * until then, and if the server never holds it live, the version does, and editing it is a draft.
35
+ * A designed document is typed into through its frame, and its undo is the document's.
34
36
  */
35
- export function useLiveView(artifactId: string | null): LiveView | null {
37
+ export function useLiveView(
38
+ artifactId: string | null,
39
+ kind: "canvas" | "document" = "canvas"
40
+ ): LiveView | null {
36
41
  const live = useLiveArtifact(artifactId)
37
42
  const state = useLiveArtifactState(live)
38
43
  const [editing, setEditing] = useState(false)
@@ -58,10 +63,11 @@ export function useLiveView(artifactId: string | null): LiveView | null {
58
63
  return () => window.clearTimeout(timer)
59
64
  }, [notice])
60
65
 
61
- const canvas = live && state.synced ? liveCanvasOf(live) : null
66
+ const editor =
67
+ live && state.synced ? (kind === "canvas" ? liveCanvasOf(live) : liveDocumentOf(live)) : null
62
68
  const history = useSyncExternalStore(
63
- canvas?.subscribe ?? noSubscription,
64
- canvas?.getHistory ?? (() => NO_HISTORY),
69
+ editor?.subscribe ?? noSubscription,
70
+ editor?.getHistory ?? (() => NO_HISTORY),
65
71
  () => NO_HISTORY
66
72
  )
67
73
 
@@ -74,8 +80,8 @@ export function useLiveView(artifactId: string | null): LiveView | null {
74
80
  start: () => setEditing(true),
75
81
  stop: () => setEditing(false),
76
82
  history: editing ? history : NO_HISTORY,
77
- undo: () => canvas?.undo(),
78
- redo: () => canvas?.redo(),
83
+ undo: () => editor?.undo(),
84
+ redo: () => editor?.redo(),
79
85
  notice,
80
86
  }
81
87
  }
@@ -100,6 +100,8 @@ export const en = {
100
100
  saved: "Saved",
101
101
  saving: "Saving…",
102
102
  failed: "Couldn't save — retrying",
103
+ /** Publishing refused the latest change: nothing tries it again until someone changes it. */
104
+ refused: "Couldn't save this change — undo it",
103
105
  offline: "Offline — your changes are kept here",
104
106
  reconnecting: "Offline — reconnecting",
105
107
  connecting: "Connecting…",
@@ -147,8 +149,11 @@ export const en = {
147
149
  cancel: "Cancel",
148
150
  },
149
151
  document: {
150
- outline: "On this page",
151
152
  copySection: (heading: string) => `Copy a link to “${heading}”`,
153
+ frame: (title: string) => `Document ${title}`,
154
+ loadFailed: "This document could not be opened.",
155
+ pdf: "PDF",
156
+ pdfDetail: "Ready to print or share",
152
157
  callouts: {
153
158
  note: "Note",
154
159
  tip: "Tip",
@@ -157,6 +162,65 @@ export const en = {
157
162
  caution: "Caution",
158
163
  },
159
164
  },
165
+ editor: {
166
+ placeholder: "Write, or press / for blocks",
167
+ titlePlaceholder: "Untitled",
168
+ heading: (level: number) => `Heading ${level}`,
169
+ listItem: "List",
170
+ taskItem: "To-do",
171
+ blocksTitle: "Blocks",
172
+ noBlocks: "No blocks match",
173
+ verbatim: "Kept as written",
174
+ caption: "Add a caption",
175
+ blocks: {
176
+ paragraph: { label: "Text", description: "Just words" },
177
+ heading1: { label: "Heading 1", description: "A section's title" },
178
+ heading2: { label: "Heading 2", description: "A subsection" },
179
+ heading3: { label: "Heading 3", description: "A smaller heading" },
180
+ bulletList: { label: "Bulleted list", description: "A simple list" },
181
+ orderedList: { label: "Numbered list", description: "Steps in order" },
182
+ taskList: { label: "To-do list", description: "Things to check off" },
183
+ quote: { label: "Quote", description: "Someone's words" },
184
+ callout: { label: "Callout", description: "A note that stands out" },
185
+ warning: { label: "Warning", description: "Something to watch for" },
186
+ codeBlock: { label: "Code", description: "A block of code" },
187
+ table: { label: "Table", description: "Rows and columns" },
188
+ image: { label: "Image", description: "Upload a picture" },
189
+ divider: { label: "Divider", description: "A line between sections" },
190
+ pageBreak: { label: "Page break", description: "Start a new page after this" },
191
+ },
192
+ pageBreak: "Page break",
193
+ handle: {
194
+ add: "Add a block below",
195
+ drag: "Drag to move",
196
+ menu: "Click for options",
197
+ },
198
+ blockMenu: {
199
+ turnInto: "Turn into",
200
+ duplicate: "Duplicate",
201
+ moveUp: "Move up",
202
+ moveDown: "Move down",
203
+ delete: "Delete",
204
+ },
205
+ toolbar: {
206
+ turnInto: "Turn into",
207
+ bold: "Bold",
208
+ italic: "Italic",
209
+ strike: "Strikethrough",
210
+ code: "Code",
211
+ link: "Link",
212
+ },
213
+ link: {
214
+ placeholder: "Paste a link",
215
+ apply: "Apply",
216
+ open: "Open link",
217
+ remove: "Remove link",
218
+ },
219
+ imageFailed: "The image could not be added.",
220
+ imageTooLarge: (limit: string) => `Images can be up to ${limit}.`,
221
+ collaborators: (count: number) =>
222
+ count === 1 ? "1 other person is editing" : `${number(count)} other people are editing`,
223
+ },
160
224
  references: {
161
225
  open: "Open",
162
226
  latest: "Latest",
@@ -362,6 +426,10 @@ export const en = {
362
426
  guestHint: "Opened a shared link, without an account",
363
427
  guestName: "Your name",
364
428
  guestNameHint: "Shown with your comments",
429
+ guestSees: (name: string) => `${name} (guest) will see your reply`,
430
+ guestSeesHint: "So will anyone who opens the same shared link",
431
+ internal: "Internal",
432
+ internalHint: "Only your team sees this thread. Guests see only the threads they start.",
365
433
  agentFor: (name: string) => `Agent, for ${name}`,
366
434
  replies: (count: number) => (count === 1 ? "1 reply" : `${number(count)} replies`),
367
435
  wholeBoard: "Whole board",
@@ -760,6 +828,7 @@ export const fr: Translation<ArtifactMessages> = {
760
828
  saved: "Enregistré",
761
829
  saving: "Enregistrement…",
762
830
  failed: "Échec de l’enregistrement — nouvel essai",
831
+ refused: "Impossible d’enregistrer cette modification — annulez-la",
763
832
  offline: "Hors ligne — vos modifications sont gardées ici",
764
833
  reconnecting: "Hors ligne — reconnexion",
765
834
  connecting: "Connexion…",
@@ -802,8 +871,11 @@ export const fr: Translation<ArtifactMessages> = {
802
871
  cancel: "Annuler",
803
872
  },
804
873
  document: {
805
- outline: "Sur cette page",
806
874
  copySection: (heading) => `Copier un lien vers « ${heading} »`,
875
+ frame: (title) => `Document ${title}`,
876
+ loadFailed: "Ce document n’a pas pu être ouvert.",
877
+ pdf: "PDF",
878
+ pdfDetail: "Prêt à imprimer ou à partager",
807
879
  callouts: {
808
880
  note: "Remarque",
809
881
  tip: "Conseil",
@@ -812,6 +884,65 @@ export const fr: Translation<ArtifactMessages> = {
812
884
  caution: "Prudence",
813
885
  },
814
886
  },
887
+ editor: {
888
+ placeholder: "Écrivez, ou tapez / pour les blocs",
889
+ titlePlaceholder: "Sans titre",
890
+ heading: (level) => `Titre ${level}`,
891
+ listItem: "Liste",
892
+ taskItem: "À faire",
893
+ blocksTitle: "Blocs",
894
+ noBlocks: "Aucun bloc ne correspond",
895
+ verbatim: "Gardé tel quel",
896
+ caption: "Ajouter une légende",
897
+ blocks: {
898
+ paragraph: { label: "Texte", description: "Du texte, simplement" },
899
+ heading1: { label: "Titre 1", description: "Le titre d’une section" },
900
+ heading2: { label: "Titre 2", description: "Une sous-section" },
901
+ heading3: { label: "Titre 3", description: "Un titre plus petit" },
902
+ bulletList: { label: "Liste à puces", description: "Une liste simple" },
903
+ orderedList: { label: "Liste numérotée", description: "Des étapes dans l’ordre" },
904
+ taskList: { label: "Liste de tâches", description: "Des choses à cocher" },
905
+ quote: { label: "Citation", description: "Les mots de quelqu’un" },
906
+ callout: { label: "Encadré", description: "Une note qui ressort" },
907
+ warning: { label: "Avertissement", description: "Un point d’attention" },
908
+ codeBlock: { label: "Code", description: "Un bloc de code" },
909
+ table: { label: "Tableau", description: "Des lignes et des colonnes" },
910
+ image: { label: "Image", description: "Importer une image" },
911
+ divider: { label: "Séparateur", description: "Une ligne entre deux sections" },
912
+ pageBreak: { label: "Saut de page", description: "Commencer une nouvelle page ensuite" },
913
+ },
914
+ pageBreak: "Saut de page",
915
+ handle: {
916
+ add: "Ajouter un bloc dessous",
917
+ drag: "Glisser pour déplacer",
918
+ menu: "Cliquer pour les options",
919
+ },
920
+ blockMenu: {
921
+ turnInto: "Transformer en",
922
+ duplicate: "Dupliquer",
923
+ moveUp: "Monter",
924
+ moveDown: "Descendre",
925
+ delete: "Supprimer",
926
+ },
927
+ toolbar: {
928
+ turnInto: "Transformer en",
929
+ bold: "Gras",
930
+ italic: "Italique",
931
+ strike: "Barré",
932
+ code: "Code",
933
+ link: "Lien",
934
+ },
935
+ link: {
936
+ placeholder: "Collez un lien",
937
+ apply: "Appliquer",
938
+ open: "Ouvrir le lien",
939
+ remove: "Retirer le lien",
940
+ },
941
+ imageFailed: "L’image n’a pas pu être ajoutée.",
942
+ imageTooLarge: (limit) => `Les images font au plus ${limit}.`,
943
+ collaborators: (count) =>
944
+ count === 1 ? "1 autre personne modifie" : `${numberFr(count)} autres personnes modifient`,
945
+ },
815
946
  references: {
816
947
  open: "Ouvrir",
817
948
  latest: "Dernière version",
@@ -1020,6 +1151,11 @@ export const fr: Translation<ArtifactMessages> = {
1020
1151
  guestHint: "A ouvert un lien de partage, sans compte",
1021
1152
  guestName: "Votre nom",
1022
1153
  guestNameHint: "Affiché avec vos commentaires",
1154
+ guestSees: (name) => `${name} (invité) verra votre réponse`,
1155
+ guestSeesHint: "Comme toute personne qui ouvre le même lien de partage",
1156
+ internal: "Interne",
1157
+ internalHint:
1158
+ "Seule votre équipe voit ce fil. Les invités ne voient que les fils qu’ils ouvrent.",
1023
1159
  agentFor: (name) => `Agent, pour ${name}`,
1024
1160
  replies: (count) => (count === 1 ? "1 réponse" : `${numberFr(count)} réponses`),
1025
1161
  wholeBoard: "Toute la planche",
@@ -0,0 +1,50 @@
1
+ import { printArtifactPdf } from "@sixb/client"
2
+ import { DOCUMENT_PDF_WAIT_MS } from "@sixb/core/artifacts"
3
+ import { documentPdfUrl } from "./file-source"
4
+ import type { ArtifactVersion } from "./queries"
5
+
6
+ // A designed document's PDF, which the server prints when it is first asked for, with the values
7
+ // its fields read as the reader reads them: the download asks until it is ready, a few seconds,
8
+ // then saves it. Asking again while it prints asks nothing more. When it could not be printed,
9
+ // the download stops there.
10
+
11
+ const FIRST_CHECK_MS = 1_000
12
+ const LONGEST_CHECK_MS = 5_000
13
+
14
+ /**
15
+ * Asks for the version's PDF, printing it again when it failed before, waits until it is printed,
16
+ * then saves it as the browser downloads a file. Throws when it could not be printed, or is not
17
+ * printed within every attempt the render worker makes.
18
+ */
19
+ export async function downloadDocumentPdf(
20
+ version: Pick<ArtifactVersion, "artifactId" | "version">
21
+ ): Promise<void> {
22
+ const path = { artifactId: version.artifactId, version: String(version.version) }
23
+ const ask = async (query: { retry?: "true"; key?: string }) =>
24
+ (await printArtifactPdf({ path, query, throwOnError: true })).data
25
+
26
+ // The first ask prints again a PDF that failed before. A document that shows live data answers
27
+ // with the key of the values it prints, which the rest ask for, though the values change.
28
+ let answer = await ask({ retry: "true" })
29
+ const key = answer.key
30
+ const deadline = Date.now() + DOCUMENT_PDF_WAIT_MS
31
+ let wait = FIRST_CHECK_MS
32
+ while (answer.status !== "ready") {
33
+ if (answer.status === "failed") {
34
+ throw new Error(`[SixbApp] The PDF could not be printed: ${answer.reason}`)
35
+ }
36
+ if (Date.now() + wait > deadline) {
37
+ throw new Error("[SixbApp] The PDF was not printed in time.")
38
+ }
39
+ await new Promise((resolve) => setTimeout(resolve, wait))
40
+ wait = Math.min(wait * 1.5, LONGEST_CHECK_MS)
41
+ answer = await ask(key ? { key } : {})
42
+ }
43
+
44
+ const link = document.createElement("a")
45
+ link.href = documentPdfUrl(version, key)
46
+ link.download = ""
47
+ document.body.append(link)
48
+ link.click()
49
+ link.remove()
50
+ }
@@ -19,6 +19,7 @@ import {
19
19
  createContext,
20
20
  lazy,
21
21
  type MouseEvent,
22
+ memo,
22
23
  type ReactNode,
23
24
  Suspense,
24
25
  useCallback,
@@ -39,8 +40,9 @@ import {
39
40
  useFileText,
40
41
  versionFileSource,
41
42
  } from "../queries"
42
- import { documentComponents } from "../renderers/document"
43
- import { rehypeArtifactDocument } from "../renderers/document-tree"
43
+ import { isDesignedDocument } from "../renderers/designed-document"
44
+ import { Callout, documentComponents, isCalloutKind } from "../renderers/document"
45
+ import { rehypeArtifactDocument, rehypeCallouts } from "../renderers/document-tree"
44
46
  import { usePageEvents } from "../renderers/page"
45
47
  import { cellFormatter } from "../renderers/sheet/format"
46
48
  import { lockedCellLabel } from "../renderers/sheet/locked"
@@ -58,7 +60,7 @@ import {
58
60
  const SheetChart = lazy(() => import("../renderers/sheet/chart"))
59
61
 
60
62
  // Embeds come first, so a lone `artifact:` image is an embed rather than a captioned figure.
61
- const REPLY_PLUGINS = [rehypeArtifactEmbeds]
63
+ const REPLY_PLUGINS = [rehypeArtifactEmbeds, rehypeCallouts]
62
64
 
63
65
  /** A whole sheet shows its first rows; a range shows as written, up to a page of rows. */
64
66
  const EMBED_ROWS = 12
@@ -116,8 +118,15 @@ export function withArtifactReferences(components: Components = {}): Components
116
118
  return <ArtifactLink address={props.href}>{props.children}</ArtifactLink>
117
119
  }
118
120
  if (Anchor) return <Anchor {...props} />
119
- const { node: _node, ...rest } = props
120
- return <a {...rest} target="_blank" rel="noreferrer noopener" />
121
+ const { node: _node, href, ...rest } = props
122
+ const external = typeof href === "string" && !href.startsWith("#")
123
+ return (
124
+ <a
125
+ href={href}
126
+ {...(external ? { target: "_blank", rel: "noreferrer noopener" } : {})}
127
+ {...rest}
128
+ />
129
+ )
121
130
  },
122
131
  img(props) {
123
132
  if (typeof props.src === "string" && isArtifactAddress(props.src)) {
@@ -154,26 +163,47 @@ export function useOpenArtifactAddress(): (address: string) => void {
154
163
  )
155
164
  }
156
165
 
157
- /** Markdown with `artifact:` addresses resolved, as a chat reply renders it. */
158
- export function ReferencingMarkdown({
166
+ function ReplyCallout({
167
+ node: _node,
168
+ children,
169
+ ...props
170
+ }: ComponentProps<"aside"> & { readonly node?: unknown }) {
171
+ const callouts = useArtifactMessages().document.callouts
172
+ const kind = (props as Record<string, unknown>)["data-callout"]
173
+ if (!isCalloutKind(kind)) return <aside {...props}>{children}</aside>
174
+ return (
175
+ <Callout kind={kind} label={callouts[kind]}>
176
+ {children}
177
+ </Callout>
178
+ )
179
+ }
180
+
181
+ let defaultReferencingComponents: Components | null = null
182
+
183
+ function getReferencingComponents(): Components {
184
+ defaultReferencingComponents ??= withArtifactReferences({ aside: ReplyCallout })
185
+ return defaultReferencingComponents
186
+ }
187
+
188
+ /** Markdown with `artifact:` addresses and callouts resolved, as a chat reply renders it. */
189
+ export const ReferencingMarkdown = memo(function ReferencingMarkdown({
159
190
  children,
160
191
  className,
161
192
  }: {
162
193
  readonly children: string
163
194
  readonly className?: string
164
195
  }) {
165
- const components = useMemo(() => withArtifactReferences(), [])
166
196
  return (
167
197
  <Markdown
168
198
  className={className}
169
- components={components}
199
+ components={getReferencingComponents()}
170
200
  rehypePlugins={REPLY_PLUGINS}
171
201
  urlTransform={artifactUrlTransform}
172
202
  >
173
203
  {children}
174
204
  </Markdown>
175
205
  )
176
- }
206
+ })
177
207
 
178
208
  /** A link to an artifact, or a part of one, that opens where the reader is. */
179
209
  export function ArtifactLink({
@@ -356,7 +386,12 @@ function EmbedBody({
356
386
  case "chart":
357
387
  return <ChartEmbed version={version} chart={part.chart} fill={fill} />
358
388
  case "section":
359
- return <SectionEmbed version={version} slug={part.slug} />
389
+ // A designed document's section is laid out by its whole design: it opens from a card.
390
+ return isDesignedDocument(version) ? (
391
+ <CardEmbed version={version} address={address} />
392
+ ) : (
393
+ <SectionEmbed version={version} slug={part.slug} />
394
+ )
360
395
  case "file":
361
396
  return (
362
397
  <FileEmbed
@@ -5,11 +5,9 @@ import {
5
5
  type FrameEditTarget,
6
6
  type FrameEvent,
7
7
  type FrameZoom,
8
- parseFrameEvent,
9
8
  } from "@sixb/core/artifacts"
10
9
  import {
11
10
  boardFilePath,
12
- boardFramePatches,
13
11
  mergeBoardText,
14
12
  setBoardImage,
15
13
  setBoardStyle,
@@ -31,19 +29,15 @@ import {
31
29
  useState,
32
30
  } from "react"
33
31
  import { formatFileSize } from "../../file-size"
34
- import { ArtifactFrame, type ArtifactFrameHandle } from "../../frame"
35
- import { useLiveBoardSource, useLiveStoredFiles } from "../../live/boards"
32
+ import { ArtifactFrame } from "../../frame"
33
+ import { useLiveStoredFiles } from "../../live/boards"
36
34
  import type { LiveCanvas } from "../../live/canvas"
37
35
  import type { LiveArtifact } from "../../live/session"
38
36
  import { useArtifactMessages } from "../../messages"
39
- import { type ArtifactVersion, useFileText, versionFileSource } from "../../queries"
37
+ import { type ArtifactVersion, versionFileSource } from "../../queries"
38
+ import { useFrameEditing, useLiveFrame } from "../live-frame"
40
39
  import { type CanvasImage, ImagePanel, type StyleChange, StylePanel } from "./board-properties"
41
- import {
42
- boardAttribute,
43
- boardInlineStyle,
44
- boardReferencePath,
45
- showablePatches,
46
- } from "./board-source"
40
+ import { boardAttribute, boardInlineStyle, boardReferencePath } from "./board-source"
47
41
  import {
48
42
  CommentPin,
49
43
  cardPlace,
@@ -55,13 +49,8 @@ import {
55
49
  import type { PageSize } from "./page-size"
56
50
 
57
51
  // A board opened over the canvas, as its page runs in its frame, and what the reader does on it:
58
- // read it, edit what it shows, or pick what to comment on.
59
- //
60
- // The frame serves the board as a stored version holds it, marked for editing; the live document
61
- // holds it as everyone is changing it now. The frame is kept at the version it loaded and told,
62
- // element by element, what changed since (`edit.patch`), so typing goes on under the caret while
63
- // others change other elements. It loads a newer version only when the elements themselves
64
- // 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.
65
54
  //
66
55
  // frame ── edit.select ──▶ the element picked, its toolbar (the reader's own click)
67
56
  // ── edit.text ───▶ mergeBoardText → the board's Y.Text (only for the element picked)
@@ -80,95 +69,6 @@ export type CommentPick = Omit<DraftPlace, "board">
80
69
  /** The image file types a board shows, by extension. */
81
70
  const IMAGE_EXTENSIONS = /\.(png|jpe?g|gif|webp|avif|svg)$/i
82
71
 
83
- /**
84
- * Follows a board's frame and the live document together: the version it shows, kept until it
85
- * must move, what it showed last, and the patches that bring it to what the document holds.
86
- */
87
- function useBoardFrame({
88
- version,
89
- board,
90
- live,
91
- }: {
92
- readonly version: ArtifactVersion
93
- readonly board: CanvasBoard
94
- readonly live: LiveArtifact | null
95
- }) {
96
- const source = useLiveBoardSource(live, board.file)
97
- const patching = source !== null
98
- const [pinned, setPinned] = useState(version)
99
- const shows = patching ? pinned : version
100
- const stored = useFileText(patching ? versionFileSource(pinned, board.file) : null).text
101
-
102
- const handle = useRef<ArtifactFrameHandle | null>(null)
103
- /** Each load the frame said it is ready, for what follows to start over. */
104
- const [loads, setLoads] = useState(0)
105
- /** What the frame shows now, once patched past its version's page. */
106
- const shown = useRef<string | null>(null)
107
- /** Pictures the reader just uploaded, shown from their bytes until a version holds them. */
108
- const previews = useRef(new Map<string, string>())
109
- /** The frame must load a newer version: the elements changed, or a picture is missing. */
110
- const [stale, setStale] = useState(false)
111
- /**
112
- * The elements themselves changed: the frame's addresses name other elements than the
113
- * document's, so nothing is edited through it until it loads a version that has them.
114
- */
115
- const [moved, setMoved] = useState(false)
116
- const [holding, setHolding] = useState(false)
117
-
118
- const ready = useCallback(() => {
119
- shown.current = null
120
- setLoads((count) => count + 1)
121
- }, [])
122
-
123
- // What the document holds now, as patches to what the frame shows.
124
- useEffect(() => {
125
- if (loads === 0 || stored === undefined || source === null) return
126
-
127
- const patches = boardFramePatches(shown.current ?? stored, source)
128
- if (patches === null) {
129
- setStale(true)
130
- setMoved(true)
131
- return
132
- }
133
- setMoved(false)
134
-
135
- const holds = (path: string) => shows.files.some((file) => file.path === path)
136
- const showable = showablePatches(patches, board.file, holds, previews.current)
137
- if (showable.waiting) setStale(true)
138
- shown.current = source
139
- if (showable.patches.length === 0) return
140
-
141
- handle.current?.send("edit.patch", { patches: showable.patches }).catch(() => {})
142
- }, [loads, stored, source, shows, board.file])
143
-
144
- // A stale frame loads the version the viewer has now once it is past the one it shows, and
145
- // while the reader is not typing in it, unless what they type in is no longer where it was.
146
- useEffect(() => {
147
- if (!stale || (holding && !moved) || version.revision <= pinned.revision) return
148
- setStale(false)
149
- setPinned(version)
150
- }, [stale, holding, moved, version, pinned.revision])
151
-
152
- /** Loads the frame's page again, as what it shows can no longer be patched. */
153
- const resync = useCallback(() => {
154
- shown.current = null
155
- handle.current?.send("reload", {}).catch(() => {})
156
- }, [])
157
-
158
- return {
159
- shows,
160
- source,
161
- handle,
162
- loads,
163
- ready,
164
- resync,
165
- stale,
166
- moved,
167
- previews: previews.current,
168
- hold: setHolding,
169
- }
170
- }
171
-
172
72
  /**
173
73
  * An opened board at its size on screen: its page in its frame, laid out at `size`, the picture
174
74
  * under it until it is ready, comments' pins over it, and, editing, the picked element's tools.
@@ -222,7 +122,7 @@ export function BoardStage({
222
122
  readonly onZoom?: (zoom: FrameZoom) => void
223
123
  }) {
224
124
  const messages = useArtifactMessages().canvas
225
- const frame = useBoardFrame({ version, board, live })
125
+ const frame = useLiveFrame({ version, file: board.file, live })
226
126
  const editing = mode === "edit" && canvas !== null
227
127
  const [selected, setSelected] = useState<FrameEditTarget | null>(null)
228
128
  /** What the pointer is over while the reader picks what to comment on. */
@@ -259,41 +159,6 @@ export function BoardStage({
259
159
  if (!draft) setHovered(null)
260
160
  }, [draft])
261
161
 
262
- // Each load of the frame, a port of its own, handed over with its first `edit` request: what
263
- // editing reports comes through it alone, never through the window, where the board's scripts
264
- // post too.
265
- const port = useRef<{ readonly mine: MessagePort; handed: MessagePort | null } | null>(null)
266
- const onEditRef = useRef<(event: FrameEvent) => void>(() => {})
267
- const onZoomRef = useRef(onZoom)
268
- onZoomRef.current = onZoom
269
- useEffect(() => {
270
- if (frame.loads === 0) return
271
- const channel = new MessageChannel()
272
- channel.port1.onmessage = (message: MessageEvent) => {
273
- const event = parseFrameEvent(message.data)
274
- if (event?.event === "zoom") onZoomRef.current?.(event.params)
275
- else if (event?.event.startsWith("edit.")) onEditRef.current(event)
276
- }
277
- port.current = { mine: channel.port1, handed: channel.port2 }
278
- return () => channel.port1.close()
279
- }, [frame.loads])
280
-
281
- // The frame picks and types as the mode says, each time it loads; while its elements are not
282
- // the document's, it does neither.
283
- const send = frame.handle
284
- useEffect(() => {
285
- if (frame.loads === 0) return
286
- const handed = port.current?.handed
287
- if (port.current) port.current.handed = null
288
- send.current
289
- ?.send(
290
- "edit",
291
- { on: mode !== "read" && !frame.moved, typing: editing },
292
- handed ? [handed] : []
293
- )
294
- .catch(() => {})
295
- }, [frame.loads, frame.moved, mode, editing, send])
296
-
297
162
  const point = useCallback(
298
163
  (at: { readonly x: number; readonly y: number } | undefined, rect: FrameEditTarget["rect"]) => {
299
164
  const x = at?.x ?? rect.x + rect.width
@@ -323,7 +188,7 @@ export function BoardStage({
323
188
  [frame, onPress, onContentHeight]
324
189
  )
325
190
 
326
- onEditRef.current = (event: FrameEvent) => {
191
+ const onEdit = (event: FrameEvent) => {
327
192
  if (moved.current) return
328
193
 
329
194
  switch (event.event) {
@@ -372,6 +237,8 @@ export function BoardStage({
372
237
  return
373
238
  }
374
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 })
375
242
 
376
243
  return (
377
244
  <div className="relative size-full">
@@ -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
  )