@sixb/app 0.1.12 → 0.1.13

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 (292) hide show
  1. package/README.md +3 -8
  2. package/dist/agent/activity-label.d.ts.map +1 -1
  3. package/dist/agent/agent-chat.d.ts +9 -8
  4. package/dist/agent/agent-chat.d.ts.map +1 -1
  5. package/dist/agent/agent-panel.d.ts +5 -8
  6. package/dist/agent/agent-panel.d.ts.map +1 -1
  7. package/dist/agent/agents-page.d.ts +4 -0
  8. package/dist/agent/agents-page.d.ts.map +1 -0
  9. package/dist/agent/artifact-card.d.ts +9 -0
  10. package/dist/agent/artifact-card.d.ts.map +1 -0
  11. package/dist/agent/artifact-panel-state.d.ts +16 -0
  12. package/dist/agent/artifact-panel-state.d.ts.map +1 -0
  13. package/dist/agent/artifact-panel.d.ts +38 -0
  14. package/dist/agent/artifact-panel.d.ts.map +1 -0
  15. package/dist/agent/components/file-attachment-card.d.ts +3 -3
  16. package/dist/agent/components/file-attachment-card.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 +3 -3
  20. package/dist/agent/components/message-view.d.ts.map +1 -1
  21. package/dist/agent/components/thread-artifacts-menu.d.ts +8 -0
  22. package/dist/agent/components/thread-artifacts-menu.d.ts.map +1 -0
  23. package/dist/agent/hooks/use-agent-conversation.d.ts +3 -4
  24. package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
  25. package/dist/agent/i18n/en.d.ts +10 -49
  26. package/dist/agent/i18n/en.d.ts.map +1 -1
  27. package/dist/agent/i18n/fr.d.ts.map +1 -1
  28. package/dist/agent/i18n/index.d.ts +16 -98
  29. package/dist/agent/i18n/index.d.ts.map +1 -1
  30. package/dist/agent/parts.d.ts +4 -4
  31. package/dist/agent/parts.d.ts.map +1 -1
  32. package/dist/agent/publish-artifact/interpret.d.ts +32 -0
  33. package/dist/agent/publish-artifact/interpret.d.ts.map +1 -0
  34. package/dist/agent/publish-artifact/publish-artifact-tool-view.d.ts +9 -0
  35. package/dist/agent/publish-artifact/publish-artifact-tool-view.d.ts.map +1 -0
  36. package/dist/agent/publish-artifact/use-live-publishes.d.ts +10 -0
  37. package/dist/agent/publish-artifact/use-live-publishes.d.ts.map +1 -0
  38. package/dist/agent/react-router.d.ts +1 -2
  39. package/dist/agent/react-router.d.ts.map +1 -1
  40. package/dist/agent/view-file/view-file-tool-view.d.ts +1 -1
  41. package/dist/agent/view-file/view-file-tool-view.d.ts.map +1 -1
  42. package/dist/artifacts/artifact-page.d.ts +7 -0
  43. package/dist/artifacts/artifact-page.d.ts.map +1 -0
  44. package/dist/artifacts/card-details.d.ts +15 -0
  45. package/dist/artifacts/card-details.d.ts.map +1 -0
  46. package/dist/artifacts/card-preview.d.ts +59 -0
  47. package/dist/artifacts/card-preview.d.ts.map +1 -0
  48. package/dist/artifacts/copy-feedback.d.ts +6 -0
  49. package/dist/artifacts/copy-feedback.d.ts.map +1 -0
  50. package/dist/artifacts/file-size.d.ts +11 -0
  51. package/dist/artifacts/file-size.d.ts.map +1 -0
  52. package/dist/artifacts/file-source.d.ts +45 -0
  53. package/dist/artifacts/file-source.d.ts.map +1 -0
  54. package/dist/artifacts/file-view.d.ts +9 -0
  55. package/dist/artifacts/file-view.d.ts.map +1 -0
  56. package/dist/artifacts/frame.d.ts +45 -0
  57. package/dist/artifacts/frame.d.ts.map +1 -0
  58. package/dist/artifacts/gallery.d.ts +6 -0
  59. package/dist/artifacts/gallery.d.ts.map +1 -0
  60. package/dist/artifacts/kind-icon.d.ts +8 -0
  61. package/dist/artifacts/kind-icon.d.ts.map +1 -0
  62. package/dist/artifacts/markdown-tree.d.ts +22 -0
  63. package/dist/artifacts/markdown-tree.d.ts.map +1 -0
  64. package/dist/artifacts/messages.d.ts +301 -0
  65. package/dist/artifacts/messages.d.ts.map +1 -0
  66. package/dist/artifacts/queries.d.ts +21 -0
  67. package/dist/artifacts/queries.d.ts.map +1 -0
  68. package/dist/artifacts/references/embed-tree.d.ts +17 -0
  69. package/dist/artifacts/references/embed-tree.d.ts.map +1 -0
  70. package/dist/artifacts/references/references.d.ts +50 -0
  71. package/dist/artifacts/references/references.d.ts.map +1 -0
  72. package/dist/artifacts/renderers/document-tree.d.ts +11 -0
  73. package/dist/artifacts/renderers/document-tree.d.ts.map +1 -0
  74. package/dist/artifacts/renderers/document.d.ts +17 -0
  75. package/dist/artifacts/renderers/document.d.ts.map +1 -0
  76. package/dist/artifacts/renderers/file.d.ts +10 -0
  77. package/dist/artifacts/renderers/file.d.ts.map +1 -0
  78. package/dist/artifacts/renderers/notice.d.ts +12 -0
  79. package/dist/artifacts/renderers/notice.d.ts.map +1 -0
  80. package/dist/artifacts/renderers/sheet/chart-data.d.ts +33 -0
  81. package/dist/artifacts/renderers/sheet/chart-data.d.ts.map +1 -0
  82. package/dist/artifacts/renderers/sheet/chart.d.ts +15 -0
  83. package/dist/artifacts/renderers/sheet/chart.d.ts.map +1 -0
  84. package/dist/artifacts/renderers/sheet/format.d.ts +35 -0
  85. package/dist/artifacts/renderers/sheet/format.d.ts.map +1 -0
  86. package/dist/artifacts/renderers/sheet/grid.d.ts +25 -0
  87. package/dist/artifacts/renderers/sheet/grid.d.ts.map +1 -0
  88. package/dist/artifacts/renderers/sheet/mini-chart.d.ts +7 -0
  89. package/dist/artifacts/renderers/sheet/mini-chart.d.ts.map +1 -0
  90. package/dist/artifacts/renderers/sheet/model.d.ts +29 -0
  91. package/dist/artifacts/renderers/sheet/model.d.ts.map +1 -0
  92. package/dist/artifacts/renderers/sheet/selection.d.ts +42 -0
  93. package/dist/artifacts/renderers/sheet/selection.d.ts.map +1 -0
  94. package/dist/artifacts/renderers/sheet/sheet.d.ts +17 -0
  95. package/dist/artifacts/renderers/sheet/sheet.d.ts.map +1 -0
  96. package/dist/artifacts/renderers/sheet/virtual.d.ts +13 -0
  97. package/dist/artifacts/renderers/sheet/virtual.d.ts.map +1 -0
  98. package/dist/artifacts/renderers/sheet/workbook.d.ts +24 -0
  99. package/dist/artifacts/renderers/sheet/workbook.d.ts.map +1 -0
  100. package/dist/artifacts/renderers/slides/navigation.d.ts +17 -0
  101. package/dist/artifacts/renderers/slides/navigation.d.ts.map +1 -0
  102. package/dist/artifacts/renderers/slides/slides.d.ts +14 -0
  103. package/dist/artifacts/renderers/slides/slides.d.ts.map +1 -0
  104. package/dist/artifacts/target.d.ts +29 -0
  105. package/dist/artifacts/target.d.ts.map +1 -0
  106. package/dist/artifacts/theme.d.ts +18 -0
  107. package/dist/artifacts/theme.d.ts.map +1 -0
  108. package/dist/artifacts/viewer.d.ts +19 -0
  109. package/dist/artifacts/viewer.d.ts.map +1 -0
  110. package/dist/{chunk-shmw3f8t.js → chunk-3schcf10.js} +1 -1
  111. package/dist/chunk-c7gy61rx.js +276 -0
  112. package/dist/chunk-c7gy61rx.js.map +10 -0
  113. package/dist/{chunk-48pkffj6.js → chunk-g3f4cm8x.js} +1 -1
  114. package/dist/{chunk-zcxrt24m.js → chunk-gn3k23q5.js} +3 -2
  115. package/dist/{chunk-zcxrt24m.js.map → chunk-gn3k23q5.js.map} +3 -3
  116. package/dist/{chunk-3a99tmwg.js → chunk-ng0hdnrq.js} +10 -3
  117. package/dist/chunk-ng0hdnrq.js.map +10 -0
  118. package/dist/{chunk-j97e06rg.js → chunk-xxpdn63v.js} +7224 -2874
  119. package/dist/chunk-xxpdn63v.js.map +105 -0
  120. package/dist/codegen.d.ts +2 -0
  121. package/dist/codegen.d.ts.map +1 -1
  122. package/dist/createCustomApp.d.ts.map +1 -1
  123. package/dist/index.d.ts +0 -2
  124. package/dist/index.d.ts.map +1 -1
  125. package/dist/index.js +34 -31
  126. package/dist/index.js.map +7 -7
  127. package/dist/locale-messages.d.ts +2 -0
  128. package/dist/locale-messages.d.ts.map +1 -1
  129. package/dist/locale.d.ts +2 -0
  130. package/dist/locale.d.ts.map +1 -1
  131. package/dist/locale.js +1 -1
  132. package/dist/pages/observability/activity/calendar.d.ts +9 -0
  133. package/dist/pages/observability/activity/calendar.d.ts.map +1 -0
  134. package/dist/pages/observability/activity/connections.d.ts +7 -0
  135. package/dist/pages/observability/activity/connections.d.ts.map +1 -0
  136. package/dist/pages/observability/activity/format.d.ts +11 -0
  137. package/dist/pages/observability/activity/format.d.ts.map +1 -0
  138. package/dist/pages/observability/activity/messages.d.ts +231 -0
  139. package/dist/pages/observability/activity/messages.d.ts.map +1 -0
  140. package/dist/pages/observability/activity/meta-items.d.ts +10 -0
  141. package/dist/pages/observability/activity/meta-items.d.ts.map +1 -0
  142. package/dist/pages/observability/activity/page.d.ts +6 -0
  143. package/dist/pages/observability/activity/page.d.ts.map +1 -0
  144. package/dist/pages/observability/activity/period.d.ts +31 -0
  145. package/dist/pages/observability/activity/period.d.ts.map +1 -0
  146. package/dist/pages/observability/activity/steps.d.ts +44 -0
  147. package/dist/pages/observability/activity/steps.d.ts.map +1 -0
  148. package/dist/pages/observability/activity/timeline.d.ts +36 -0
  149. package/dist/pages/observability/activity/timeline.d.ts.map +1 -0
  150. package/dist/pages/observability/activity/users.d.ts +18 -0
  151. package/dist/pages/observability/activity/users.d.ts.map +1 -0
  152. package/dist/pages/routes.d.ts +7 -0
  153. package/dist/pages/routes.d.ts.map +1 -1
  154. package/dist/pages/section-ui.d.ts +2 -1
  155. package/dist/pages/section-ui.d.ts.map +1 -1
  156. package/dist/pages.d.ts +4 -1
  157. package/dist/pages.d.ts.map +1 -1
  158. package/dist/pages.js +5852 -3754
  159. package/dist/pages.js.map +20 -7
  160. package/dist/sections/catalog.d.ts.map +1 -1
  161. package/dist/sections/sections.d.ts.map +1 -1
  162. package/dist/server.js +63 -10
  163. package/dist/server.js.map +5 -5
  164. package/dist/shell/search-command.d.ts.map +1 -1
  165. package/dist/shell/user-menu.d.ts +3 -3
  166. package/dist/shell/user-menu.d.ts.map +1 -1
  167. package/package.json +4 -6
  168. package/src/agent/activity-label.ts +7 -0
  169. package/src/agent/agent-chat.tsx +29 -18
  170. package/src/agent/agent-execution-trace.tsx +1 -1
  171. package/src/agent/agent-panel.tsx +8 -13
  172. package/src/agent/agent-surface.tsx +4 -4
  173. package/src/agent/agents-page.ts +7 -0
  174. package/src/agent/artifact-card.tsx +190 -0
  175. package/src/agent/artifact-panel-state.ts +38 -0
  176. package/src/agent/artifact-panel.tsx +320 -0
  177. package/src/agent/components/file-attachment-card.tsx +13 -14
  178. package/src/agent/components/message-parts.tsx +30 -5
  179. package/src/agent/components/message-view.tsx +13 -19
  180. package/src/agent/components/thread-artifacts-menu.tsx +77 -0
  181. package/src/agent/i18n/en.ts +16 -58
  182. package/src/agent/i18n/fr.ts +15 -59
  183. package/src/agent/parts.ts +6 -6
  184. package/src/agent/publish-artifact/interpret.ts +110 -0
  185. package/src/agent/publish-artifact/publish-artifact-tool-view.tsx +62 -0
  186. package/src/agent/publish-artifact/use-live-publishes.ts +45 -0
  187. package/src/agent/react-router.tsx +26 -7
  188. package/src/agent/view-file/view-file-tool-view.tsx +21 -18
  189. package/src/artifacts/artifact-page.tsx +61 -0
  190. package/src/artifacts/artifacts.css +172 -0
  191. package/src/artifacts/card-details.ts +92 -0
  192. package/src/artifacts/card-preview.tsx +612 -0
  193. package/src/artifacts/copy-feedback.ts +25 -0
  194. package/src/artifacts/file-size.ts +24 -0
  195. package/src/artifacts/file-source.ts +109 -0
  196. package/src/artifacts/file-view.ts +57 -0
  197. package/src/artifacts/frame.tsx +288 -0
  198. package/src/artifacts/gallery.tsx +405 -0
  199. package/src/artifacts/kind-icon.tsx +23 -0
  200. package/src/artifacts/markdown-tree.ts +32 -0
  201. package/src/artifacts/messages.ts +317 -0
  202. package/src/artifacts/queries.ts +85 -0
  203. package/src/artifacts/references/embed-tree.ts +86 -0
  204. package/src/artifacts/references/references.tsx +739 -0
  205. package/src/artifacts/renderers/document-tree.ts +157 -0
  206. package/src/artifacts/renderers/document.tsx +334 -0
  207. package/src/artifacts/renderers/file.tsx +160 -0
  208. package/src/artifacts/renderers/notice.tsx +38 -0
  209. package/src/artifacts/renderers/sheet/chart-data.ts +73 -0
  210. package/src/artifacts/renderers/sheet/chart.tsx +288 -0
  211. package/src/artifacts/renderers/sheet/format.ts +142 -0
  212. package/src/artifacts/renderers/sheet/grid.tsx +709 -0
  213. package/src/artifacts/renderers/sheet/mini-chart.tsx +241 -0
  214. package/src/artifacts/renderers/sheet/model.ts +136 -0
  215. package/src/artifacts/renderers/sheet/selection.ts +152 -0
  216. package/src/artifacts/renderers/sheet/sheet.tsx +471 -0
  217. package/src/artifacts/renderers/sheet/virtual.ts +49 -0
  218. package/src/artifacts/renderers/sheet/workbook.ts +57 -0
  219. package/src/artifacts/renderers/slides/navigation.ts +38 -0
  220. package/src/artifacts/renderers/slides/slides.tsx +441 -0
  221. package/src/artifacts/target.ts +76 -0
  222. package/src/artifacts/theme.ts +29 -0
  223. package/src/artifacts/viewer.tsx +476 -0
  224. package/src/build.ts +13 -2
  225. package/src/codegen.ts +38 -2
  226. package/src/createCustomApp.ts +21 -1
  227. package/src/index.ts +0 -5
  228. package/src/locale-messages.ts +9 -2
  229. package/src/pages/observability/activity/calendar.tsx +239 -0
  230. package/src/pages/observability/activity/connections.tsx +144 -0
  231. package/src/pages/observability/activity/format.ts +49 -0
  232. package/src/pages/observability/activity/messages.ts +255 -0
  233. package/src/pages/observability/activity/meta-items.tsx +23 -0
  234. package/src/pages/observability/activity/page.tsx +605 -0
  235. package/src/pages/observability/activity/period.ts +63 -0
  236. package/src/pages/observability/activity/steps.ts +102 -0
  237. package/src/pages/observability/activity/timeline.tsx +411 -0
  238. package/src/pages/observability/activity/users.tsx +133 -0
  239. package/src/pages/observability/messages.ts +2 -2
  240. package/src/pages/routes.ts +15 -0
  241. package/src/pages/section-ui.tsx +3 -1
  242. package/src/pages.ts +4 -1
  243. package/src/sections/catalog.ts +1 -0
  244. package/src/sections/sections.tsx +2 -0
  245. package/src/shell/search-command.tsx +8 -6
  246. package/src/shell/user-menu.tsx +22 -22
  247. package/dist/agent/document-preview/classify.d.ts +0 -4
  248. package/dist/agent/document-preview/classify.d.ts.map +0 -1
  249. package/dist/agent/document-preview/content-policy.d.ts +0 -10
  250. package/dist/agent/document-preview/content-policy.d.ts.map +0 -1
  251. package/dist/agent/document-preview/content.d.ts +0 -26
  252. package/dist/agent/document-preview/content.d.ts.map +0 -1
  253. package/dist/agent/document-preview/delimited.d.ts +0 -19
  254. package/dist/agent/document-preview/delimited.d.ts.map +0 -1
  255. package/dist/agent/document-preview/document-preview-root.d.ts +0 -24
  256. package/dist/agent/document-preview/document-preview-root.d.ts.map +0 -1
  257. package/dist/agent/document-preview/file-size.d.ts +0 -3
  258. package/dist/agent/document-preview/file-size.d.ts.map +0 -1
  259. package/dist/agent/document-preview/html.d.ts +0 -9
  260. package/dist/agent/document-preview/html.d.ts.map +0 -1
  261. package/dist/agent/document-preview/persistence.d.ts +0 -6
  262. package/dist/agent/document-preview/persistence.d.ts.map +0 -1
  263. package/dist/agent/document-preview/presentation.d.ts +0 -3
  264. package/dist/agent/document-preview/presentation.d.ts.map +0 -1
  265. package/dist/agent/document-preview/rendering.d.ts +0 -14
  266. package/dist/agent/document-preview/rendering.d.ts.map +0 -1
  267. package/dist/agent/document-preview/source.d.ts +0 -13
  268. package/dist/agent/document-preview/source.d.ts.map +0 -1
  269. package/dist/agent/document-preview/state.d.ts +0 -27
  270. package/dist/agent/document-preview/state.d.ts.map +0 -1
  271. package/dist/agent/document-preview/types.d.ts +0 -33
  272. package/dist/agent/document-preview/types.d.ts.map +0 -1
  273. package/dist/agent/workspace.d.ts +0 -11
  274. package/dist/agent/workspace.d.ts.map +0 -1
  275. package/dist/chunk-3a99tmwg.js.map +0 -10
  276. package/dist/chunk-j97e06rg.js.map +0 -80
  277. package/src/agent/document-preview/classify.ts +0 -55
  278. package/src/agent/document-preview/content-policy.ts +0 -37
  279. package/src/agent/document-preview/content.ts +0 -82
  280. package/src/agent/document-preview/delimited.ts +0 -118
  281. package/src/agent/document-preview/document-preview-root.tsx +0 -1017
  282. package/src/agent/document-preview/file-size.ts +0 -26
  283. package/src/agent/document-preview/html.ts +0 -67
  284. package/src/agent/document-preview/persistence.ts +0 -115
  285. package/src/agent/document-preview/presentation.ts +0 -13
  286. package/src/agent/document-preview/rendering.ts +0 -48
  287. package/src/agent/document-preview/source.ts +0 -48
  288. package/src/agent/document-preview/state.ts +0 -77
  289. package/src/agent/document-preview/types.ts +0 -36
  290. package/src/agent/workspace.ts +0 -33
  291. /package/dist/{chunk-shmw3f8t.js.map → chunk-3schcf10.js.map} +0 -0
  292. /package/dist/{chunk-48pkffj6.js.map → chunk-g3f4cm8x.js.map} +0 -0
@@ -203,14 +203,6 @@ export const en = {
203
203
  },
204
204
  /** Platform diagnostics, by their stable `code`; `unknown` covers codes added later. */
205
205
  diagnostics: {
206
- output_file_limit_exceeded:
207
- "Some generated files were not attached because the file limit was reached.",
208
- output_file_too_large: "A generated file exceeds the attachment size limit and was skipped.",
209
- output_budget_exhausted:
210
- "A generated file exceeds the remaining attachment budget and was skipped.",
211
- output_collection_failed: "Generated files could not be collected.",
212
- output_file_changed: "A generated file changed while it was being attached and was skipped.",
213
- output_storage_failed: "A generated file could not be stored as an attachment.",
214
206
  step_limit_reached:
215
207
  "I reached the step limit before producing a final answer. Ask me to continue and I can use the work above as context.",
216
208
  unknown: "Something went wrong during this response.",
@@ -473,56 +465,22 @@ export const en = {
473
465
  hideRaw: "Hide raw",
474
466
  commandFailed: "The command failed.",
475
467
  },
476
- documents: {
477
- preview: (name: string) => `Preview ${name}`,
478
- dialogTitle: "Document preview",
479
- dialogDescription: "Preview, switch between, and download documents from this conversation.",
480
- canvasDescription:
481
- "Preview and switch between documents while continuing to use the assistant.",
482
- tabs: "Open documents",
483
- close: (name: string) => `Close ${name}`,
484
- openInNewTab: (name: string) => `Open ${name} in a new tab`,
485
- open: "Open",
486
- download: (name: string) => `Download ${name}`,
487
- downloadLabel: "Download",
488
- closeViewer: "Close document viewer",
489
- document: "Document",
490
- unavailable: "Preview unavailable",
491
- unsupported: "This file type is not available in the document viewer yet.",
492
- tooLarge: "Document is too large to preview",
493
- tooLargeFor: (size: string) =>
494
- `This viewer accepts files up to ${size}. Download the file to view it elsewhere.`,
495
- downloadToView: "Download the file to view the complete document.",
496
- failed: "Could not preview document",
497
- contentUnavailable: "The document content was unavailable.",
498
- rendererFailed: "The configured document viewer could not render this file.",
499
- noHtml: "The document did not contain readable HTML.",
500
- noText: "The document did not contain readable text.",
501
- tableFailed: "Could not preview table",
502
- notParsed: "The file could not be parsed.",
503
- noRows: "The file did not contain readable rows.",
504
- notDelimited: "The file is not CSV or TSV data.",
505
- malformed: "The file contains malformed delimited text.",
506
- malformedNear: (row: number) => `The file contains malformed delimited text near row ${row}.`,
507
- emptyFile: "The file is empty.",
508
- noHeader: "The file does not contain a header row.",
509
- column: (index: number) => `Column ${index}`,
510
- firstRows: (shown: number, total: number) =>
511
- `the first ${number(shown)} of ${number(total)} rows`,
512
- firstColumns: (shown: number, total: number) =>
513
- `the first ${number(shown)} of ${number(total)} columns`,
514
- showing: (limits: string) => `Showing ${limits}.`,
515
- and: "and",
516
- downloadAll: "Download the file to view all data.",
517
- dataPreview: (name: string) => `${name} data preview`,
518
- noDataRows: "No data rows.",
519
- pdfUnavailable: "PDF preview unavailable",
520
- pdfDescription: "Open the PDF in your browser or download it to view the document.",
521
- openPdf: "Open PDF",
522
- loading: "Loading document…",
523
- gone: "This document is no longer available.",
524
- storageUnavailable: "Document storage is not available.",
525
- loadFailed: "Could not load this document.",
468
+ artifacts: {
469
+ dialogTitle: "Artifact",
470
+ dialogDescription: "View an artifact or file from this conversation.",
471
+ canvasDescription: "View an artifact or file while you keep using the assistant.",
472
+ list: (total: number) =>
473
+ total === 1
474
+ ? "1 artifact in this conversation"
475
+ : `${number(total)} artifacts in this conversation`,
476
+ all: "All artifacts",
477
+ /** A `publish_artifact` call, by the title it names (`title` may be empty). */
478
+ publishing: (title: string) => `Publishing ${title || "an artifact"}`,
479
+ published: (title: string) => `Published ${title || "an artifact"}`,
480
+ publishFailed: (title: string) => `Couldn't publish ${title || "an artifact"}`,
481
+ open: (title: string) => `Open ${title}`,
482
+ /** Labels the cards of what one response published. */
483
+ cards: "Published in this response",
526
484
  },
527
485
  sandbox: {
528
486
  title: "Sandbox recovery required",
@@ -193,16 +193,6 @@ export const fr: Translation<AgentMessages> = {
193
193
  reconnectingLabel: "Reconnexion au flux de l’agent",
194
194
  },
195
195
  diagnostics: {
196
- output_file_limit_exceeded:
197
- "Certains fichiers générés n’ont pas été joints : le nombre maximal de fichiers a été atteint.",
198
- output_file_too_large:
199
- "Un fichier généré dépasse la taille maximale d’une pièce jointe et a été ignoré.",
200
- output_budget_exhausted:
201
- "Un fichier généré dépasse l’espace restant pour les pièces jointes et a été ignoré.",
202
- output_collection_failed: "Les fichiers générés n’ont pas pu être récupérés.",
203
- output_file_changed:
204
- "Un fichier généré a été modifié pendant son ajout en pièce jointe et a été ignoré.",
205
- output_storage_failed: "Un fichier généré n’a pas pu être enregistré en pièce jointe.",
206
196
  step_limit_reached:
207
197
  "J’ai atteint la limite d’étapes avant de produire une réponse finale. Il suffit de me demander de continuer pour reprendre ce travail.",
208
198
  unknown: "Un problème est survenu pendant cette réponse.",
@@ -507,56 +497,22 @@ export const fr: Translation<AgentMessages> = {
507
497
  hideRaw: "Masquer la sortie brute",
508
498
  commandFailed: "La commande a échoué.",
509
499
  },
510
- documents: {
511
- preview: (name) => `Aperçu de ${name}`,
512
- dialogTitle: "Aperçu du document",
513
- dialogDescription:
514
- "Prévisualiser, parcourir et télécharger les documents de cette conversation.",
500
+ artifacts: {
501
+ dialogTitle: "Artefact",
502
+ dialogDescription: "Afficher un artefact ou un fichier de cette conversation.",
515
503
  canvasDescription:
516
- "Prévisualiser et parcourir les documents tout en continuant d’utiliser l’assistant.",
517
- tabs: "Documents ouverts",
518
- close: (name) => `Fermer ${name}`,
519
- openInNewTab: (name) => `Ouvrir ${name} dans un nouvel onglet`,
520
- open: "Ouvrir",
521
- download: (name) => `Télécharger ${name}`,
522
- downloadLabel: "Télécharger",
523
- closeViewer: "Fermer la visionneuse",
524
- document: "Document",
525
- unavailable: "Aperçu indisponible",
526
- unsupported: "Ce type de fichier n’est pas encore pris en charge par la visionneuse.",
527
- tooLarge: "Document trop volumineux pour l’aperçu",
528
- tooLargeFor: (size) =>
529
- `Cette visionneuse accepte les fichiers jusqu’à ${size}. Téléchargez le fichier pour le consulter.`,
530
- downloadToView: "Téléchargez le fichier pour consulter le document complet.",
531
- failed: "Impossible d’afficher le document",
532
- contentUnavailable: "Le contenu du document est indisponible.",
533
- rendererFailed: "La visionneuse configurée n’a pas pu afficher ce fichier.",
534
- noHtml: "Le document ne contient pas de HTML lisible.",
535
- noText: "Le document ne contient pas de texte lisible.",
536
- tableFailed: "Impossible d’afficher le tableau",
537
- notParsed: "Le fichier n’a pas pu être analysé.",
538
- noRows: "Le fichier ne contient aucune ligne lisible.",
539
- notDelimited: "Le fichier n’est pas au format CSV ou TSV.",
540
- malformed: "Le fichier contient du texte délimité mal formé.",
541
- malformedNear: (row) =>
542
- `Le fichier contient du texte délimité mal formé vers la ligne ${number(row)}.`,
543
- emptyFile: "Le fichier est vide.",
544
- noHeader: "Le fichier ne contient pas de ligne d’en-tête.",
545
- column: (index) => `Colonne ${index}`,
546
- firstRows: (shown, total) => `les ${number(shown)} premières lignes sur ${number(total)}`,
547
- firstColumns: (shown, total) => `les ${number(shown)} premières colonnes sur ${number(total)}`,
548
- showing: (limits) => `Seules ${limits} sont affichées.`,
549
- and: "et",
550
- downloadAll: "Téléchargez le fichier pour consulter toutes les données.",
551
- dataPreview: (name) => `Aperçu des données de ${name}`,
552
- noDataRows: "Aucune ligne de données.",
553
- pdfUnavailable: "Aperçu du PDF indisponible",
554
- pdfDescription: "Ouvrez le PDF dans le navigateur ou téléchargez-le pour le consulter.",
555
- openPdf: "Ouvrir le PDF",
556
- loading: "Chargement du document…",
557
- gone: "Ce document n’est plus disponible.",
558
- storageUnavailable: "Le stockage des documents n’est pas disponible.",
559
- loadFailed: "Impossible de charger ce document.",
504
+ "Afficher un artefact ou un fichier tout en continuant d’utiliser l’assistant.",
505
+ list: (total) =>
506
+ total === 1
507
+ ? "1 artefact dans cette conversation"
508
+ : `${number(total)} artefacts dans cette conversation`,
509
+ all: "Tous les artefacts",
510
+ publishing: (title) => (title ? `Publication de ${title}` : "Publication d’un artefact"),
511
+ published: (title) => (title ? `${title} publié` : "Artefact publié"),
512
+ publishFailed: (title) =>
513
+ title ? `Impossible de publier ${title}` : "Impossible de publier l’artefact",
514
+ open: (title) => `Ouvrir ${title}`,
515
+ cards: "Publié dans cette réponse",
560
516
  },
561
517
  sandbox: {
562
518
  title: "Récupération de l’environnement requise",
@@ -1,4 +1,4 @@
1
- import type { AgentDocumentSource } from "./document-preview/types"
1
+ import type { FileSource } from "../artifacts/file-source"
2
2
  import type { AgentFileRef, AgentMessagePart } from "./types"
3
3
 
4
4
  // The render-ready vocabulary shared by the durable transcript and the live streaming row.
@@ -15,10 +15,10 @@ export type NormalizedTool = {
15
15
  readonly files?: readonly NormalizedFile[]
16
16
  }
17
17
 
18
- /** A file shown in a message. The document source exists once the message is saved. */
18
+ /** A file shown in a message. Its source, which reads the bytes, exists once the message is saved. */
19
19
  export type NormalizedFile = {
20
20
  readonly fileRef: AgentFileRef
21
- readonly document?: AgentDocumentSource
21
+ readonly source?: FileSource
22
22
  }
23
23
 
24
24
  export type NormalizedPart =
@@ -32,12 +32,12 @@ export function normalizeDurableParts(
32
32
  parts: readonly AgentMessagePart[],
33
33
  options: {
34
34
  /** Resolve a file of the message from its JSON pointer, such as `/parts/2/fileRef`. */
35
- readonly fileSource?: (fileRef: AgentFileRef, path: string) => AgentDocumentSource | undefined
35
+ readonly fileSource?: (fileRef: AgentFileRef, path: string) => FileSource | undefined
36
36
  } = {}
37
37
  ): NormalizedPart[] {
38
38
  const file = (fileRef: AgentFileRef, path: string): NormalizedFile => {
39
- const document = options.fileSource?.(fileRef, path)
40
- return document === undefined ? { fileRef } : { fileRef, document }
39
+ const source = options.fileSource?.(fileRef, path)
40
+ return source === undefined ? { fileRef } : { fileRef, source }
41
41
  }
42
42
  const toolFiles = (output: unknown, partIndex: number): { files?: NormalizedFile[] } => {
43
43
  const files = toolResultFiles(output).map(({ fileRef, contentIndex }) =>
@@ -0,0 +1,110 @@
1
+ import { ARTIFACT_KINDS } from "@sixb/core/artifacts"
2
+ import type { ArtifactKindName } from "../../artifacts/kind-icon"
3
+ import type { NormalizedPart, NormalizedTool } from "../parts"
4
+
5
+ /** Creating an artifact, and publishing the next version of one. */
6
+ const PUBLISH_TOOLS = new Set(["publish_artifact", "publish_artifact_version"])
7
+
8
+ export function isPublishTool(toolName: string): boolean {
9
+ return PUBLISH_TOOLS.has(toolName)
10
+ }
11
+
12
+ /** What one publish call published, read from its result. */
13
+ export interface PublishedArtifact {
14
+ readonly artifactId: string
15
+ readonly version: number
16
+ readonly kind: ArtifactKindName
17
+ readonly title: string
18
+ readonly warnings: readonly { readonly message: string; readonly part?: string }[]
19
+ }
20
+
21
+ export function publishedArtifact(tool: NormalizedTool): PublishedArtifact | null {
22
+ if (!isPublishTool(tool.toolName) || tool.state !== "output-available") return null
23
+ const output = tool.output
24
+ if (
25
+ !isRecord(output) ||
26
+ typeof output.artifactId !== "string" ||
27
+ typeof output.version !== "number" ||
28
+ typeof output.title !== "string" ||
29
+ !(ARTIFACT_KINDS as readonly string[]).includes(String(output.kind))
30
+ ) {
31
+ return null
32
+ }
33
+ const warnings = Array.isArray(output.warnings) ? output.warnings : []
34
+ return {
35
+ artifactId: output.artifactId,
36
+ version: output.version,
37
+ kind: output.kind as ArtifactKindName,
38
+ title: output.title,
39
+ warnings: warnings.flatMap((warning) =>
40
+ isRecord(warning) && typeof warning.message === "string"
41
+ ? [
42
+ {
43
+ message: warning.message,
44
+ ...(typeof warning.part === "string" ? { part: warning.part } : {}),
45
+ },
46
+ ]
47
+ : []
48
+ ),
49
+ }
50
+ }
51
+
52
+ /** The title a publish call names, from its result or, until then, its input. */
53
+ export function publishTitle(tool: NormalizedTool): string {
54
+ const published = publishedArtifact(tool)
55
+ if (published) return published.title
56
+ return isRecord(tool.input) && typeof tool.input.title === "string" ? tool.input.title : ""
57
+ }
58
+
59
+ /** An artifact as a turn left it, and whether the turn created it or revised an earlier one. */
60
+ export interface TurnArtifact extends PublishedArtifact {
61
+ readonly created: boolean
62
+ }
63
+
64
+ /**
65
+ * Each artifact a turn published, once, at the last version the turn published, in the order the
66
+ * turn first published them.
67
+ */
68
+ export function turnArtifacts(parts: readonly NormalizedPart[]): TurnArtifact[] {
69
+ const byId = new Map<string, TurnArtifact>()
70
+ for (const part of parts) {
71
+ if (part.kind !== "tool") continue
72
+ const published = publishedArtifact(part.tool)
73
+ if (!published) continue
74
+ const earlier = byId.get(published.artifactId)
75
+ const created = earlier?.created === true || part.tool.toolName === "publish_artifact"
76
+ if (!earlier || published.version > earlier.version) {
77
+ byId.set(published.artifactId, { ...published, created })
78
+ } else if (created !== earlier.created) {
79
+ byId.set(published.artifactId, { ...earlier, created })
80
+ }
81
+ }
82
+ return [...byId.values()]
83
+ }
84
+
85
+ /**
86
+ * The titles of what a finished turn last tried to publish and could not: a refused attempt that no
87
+ * later publish of the same artifact (a version, by its id) or the same title (a new one) replaced.
88
+ */
89
+ export function unpublishedTitles(parts: readonly NormalizedPart[]): string[] {
90
+ const refused = new Map<string, string>()
91
+ for (const part of parts) {
92
+ if (part.kind !== "tool" || !isPublishTool(part.tool.toolName)) continue
93
+ const result = publishedArtifact(part.tool)
94
+ if (result) {
95
+ refused.delete(`id:${result.artifactId}`)
96
+ refused.delete(`title:${result.title}`)
97
+ continue
98
+ }
99
+ if (part.tool.state !== "output-error") continue
100
+ const input = isRecord(part.tool.input) ? part.tool.input : {}
101
+ const key =
102
+ typeof input.id === "string" ? `id:${input.id.trim()}` : `title:${publishTitle(part.tool)}`
103
+ refused.set(key, publishTitle(part.tool))
104
+ }
105
+ return [...new Set(refused.values())]
106
+ }
107
+
108
+ function isRecord(value: unknown): value is Record<string, unknown> {
109
+ return typeof value === "object" && value !== null && !Array.isArray(value)
110
+ }
@@ -0,0 +1,62 @@
1
+ import { FileUp } from "lucide-react"
2
+ import { useArtifactMessages } from "../../artifacts/messages"
3
+ import { ActivityStatusText } from "../components/activity-status"
4
+ import { useAgentMessages } from "../i18n"
5
+ import type { NormalizedTool } from "../parts"
6
+ import { publishedArtifact, publishTitle } from "./interpret"
7
+
8
+ /**
9
+ * A publish in the work trace: what it published and at which version, with any warnings, or why
10
+ * it was refused. The answer's cards show the result; this row keeps each attempt.
11
+ */
12
+ export function PublishArtifactToolView({ tool }: { tool: NormalizedTool }) {
13
+ const messages = useAgentMessages().artifacts
14
+ const versionLabel = useArtifactMessages().viewer.version
15
+ const title = publishTitle(tool)
16
+ const published = publishedArtifact(tool)
17
+ const running = tool.state === "input-streaming" || tool.state === "input-available"
18
+ const failed = tool.state === "output-error"
19
+ const label = failed
20
+ ? messages.publishFailed(title)
21
+ : running
22
+ ? messages.publishing(title)
23
+ : messages.published(title)
24
+
25
+ return (
26
+ <div className="min-w-0 space-y-1">
27
+ <div className="flex w-fit max-w-full items-center gap-1.5 text-[13px] leading-normal text-muted-foreground">
28
+ <FileUp className="size-3.5 shrink-0" />
29
+ {running ? (
30
+ <ActivityStatusText label={label} className="font-medium shimmer" />
31
+ ) : (
32
+ <span className="min-w-0 truncate font-medium">{label}</span>
33
+ )}
34
+ {published ? (
35
+ <span className="shrink-0 text-muted-foreground/60 tabular-nums">
36
+ · {versionLabel(published.version)}
37
+ </span>
38
+ ) : null}
39
+ </div>
40
+ {failed && tool.errorText ? (
41
+ <p className="pl-5 text-xs leading-relaxed whitespace-pre-wrap text-muted-foreground/80">
42
+ {refusal(tool.errorText)}
43
+ </p>
44
+ ) : null}
45
+ {published && published.warnings.length > 0 ? (
46
+ <ul className="space-y-0.5 pl-5 text-xs leading-relaxed text-muted-foreground/80">
47
+ {published.warnings.map((warning, index) => (
48
+ <li key={index}>
49
+ {warning.part ? `${warning.part}: ` : ""}
50
+ {warning.message}
51
+ </li>
52
+ ))}
53
+ </ul>
54
+ ) : null}
55
+ </div>
56
+ )
57
+ }
58
+
59
+ /** The refusal the Agent received, without the worker's prefix. */
60
+ function refusal(errorText: string): string {
61
+ return errorText.replace(/^\[SixbAgentWorker\] publish_artifact(_version)? refused: /, "")
62
+ }
@@ -0,0 +1,45 @@
1
+ import { getArtifactQueryKey } from "@sixb/client/hooks"
2
+ import { isMobileViewport } from "@sixb/ui/hooks"
3
+ import { useQueryClient } from "@tanstack/react-query"
4
+ import { useEffect, useRef } from "react"
5
+ import { useArtifactPanel } from "../artifact-panel"
6
+ import type { LiveRunState } from "../live-run"
7
+ import { turnArtifacts } from "./interpret"
8
+
9
+ /** Runs that already opened an artifact in this tab, so a remount does not open it again. */
10
+ const openedRuns = new Set<string>()
11
+
12
+ /**
13
+ * Follows what a live turn publishes: each new version refreshes the artifact and every list of
14
+ * artifacts, and the turn's first publish opens the panel on it, at its latest version so later
15
+ * versions of the turn replace it in place. It opens only beside the conversation or over the app:
16
+ * a dialog would take the reader's focus, and the composer's, while the Agent is still working,
17
+ * so there the card waits to be opened.
18
+ */
19
+ export function useLivePublishes(live: LiveRunState): void {
20
+ const panel = useArtifactPanel()
21
+ const queryClient = useQueryClient()
22
+ const seen = useRef(new Set<string>())
23
+
24
+ useEffect(() => {
25
+ const published = turnArtifacts(live.parts)
26
+ let changed = false
27
+ for (const artifact of published) {
28
+ const key = `${artifact.artifactId}@${artifact.version}`
29
+ if (seen.current.has(key)) continue
30
+ seen.current.add(key)
31
+ changed = true
32
+ void queryClient.invalidateQueries({
33
+ queryKey: getArtifactQueryKey({ path: { artifactId: artifact.artifactId } }),
34
+ })
35
+ }
36
+ if (changed) void queryClient.invalidateQueries({ queryKey: [{ _id: "listArtifacts" }] })
37
+
38
+ const first = published[0]
39
+ if (!first || !panel || !live.runId || openedRuns.has(live.runId)) return
40
+ openedRuns.add(live.runId)
41
+ // On a phone's first render the panel has not learned the width yet, so the width is asked.
42
+ if (panel.presentation === "dialog" || isMobileViewport()) return
43
+ panel.open({ type: "artifact", artifactId: first.artifactId })
44
+ }, [live.parts, live.runId, panel, queryClient])
45
+ }
@@ -1,20 +1,24 @@
1
1
  import { Button } from "@sixb/ui/components"
2
2
  import { cn } from "@sixb/ui/lib/utils"
3
3
  import { ArrowLeft } from "lucide-react"
4
- import { useCallback } from "react"
5
- import { useNavigate, useParams } from "react-router-dom"
4
+ import { useCallback, useMemo } from "react"
5
+ import { useNavigate, useParams, useSearchParams } from "react-router-dom"
6
+ import {
7
+ type ArtifactTarget,
8
+ artifactTargetFromSearch,
9
+ withArtifactTarget,
10
+ } from "../artifacts/target"
6
11
  import { AgentChat, type AgentChatProps } from "./agent-chat"
7
12
  import { useRegisteredAgentContext } from "./agent-context-provider"
8
13
  import { useAgentMessages } from "./i18n"
9
14
 
10
- export type {
11
- AgentDocumentPreviewRenderer,
12
- AgentDocumentPreviewRendererProps,
13
- } from "./document-preview/types"
14
15
  export type { AgentFileRef } from "./types"
15
16
 
16
17
  export interface AgentChatPageProps
17
- extends Omit<AgentChatProps, "threadId" | "onNavigateHome" | "onNavigateThread"> {
18
+ extends Omit<
19
+ AgentChatProps,
20
+ "threadId" | "onNavigateHome" | "onNavigateThread" | "artifactTarget" | "onArtifactTargetChange"
21
+ > {
18
22
  readonly routeBase?: string
19
23
  }
20
24
 
@@ -29,7 +33,20 @@ export function AgentChatPage({
29
33
  const navigate = useNavigate()
30
34
  const registeredContext = useRegisteredAgentContext()
31
35
  const { threadId: routeThreadId } = useParams()
36
+ const [searchParams, setSearchParams] = useSearchParams()
32
37
  const normalizedRouteBase = normalizeRouteBase(routeBase)
38
+ // The open artifact lives in `?artifact=&v=&part=`, so a reload or a shared link lands on it.
39
+ const searchKey = searchParams.toString()
40
+ // biome-ignore lint/correctness/useExhaustiveDependencies: the key stands for the parameters.
41
+ const artifactTarget = useMemo(() => artifactTargetFromSearch(searchParams), [searchKey])
42
+ const onArtifactTargetChange = useCallback(
43
+ (target: ArtifactTarget | null) => {
44
+ setSearchParams((current) => withArtifactTarget(current, target), {
45
+ replace: target === null,
46
+ })
47
+ },
48
+ [setSearchParams]
49
+ )
33
50
 
34
51
  const onNavigateHome = useCallback(() => {
35
52
  navigate(normalizedRouteBase)
@@ -50,6 +67,8 @@ export function AgentChatPage({
50
67
  threadId={routeThreadId ?? null}
51
68
  onNavigateHome={onNavigateHome}
52
69
  onNavigateThread={onNavigateThread}
70
+ artifactTarget={artifactTarget}
71
+ onArtifactTargetChange={onArtifactTargetChange}
53
72
  conversationHeaderActions={
54
73
  <>
55
74
  <Button
@@ -1,16 +1,18 @@
1
+ import { useLocale } from "@sixb/ui/lib/i18n"
1
2
  import { cn } from "@sixb/ui/lib/utils"
2
3
  import { Eye, File as FileIcon } from "lucide-react"
3
4
  import type { ReactNode } from "react"
5
+ import { formatFileSize } from "../../artifacts/file-size"
6
+ import { fileView } from "../../artifacts/file-view"
7
+ import { useArtifactPanel } from "../artifact-panel"
4
8
  import { ActivityStatusText } from "../components/activity-status"
5
- import { useDocumentPreview } from "../document-preview/document-preview-root"
6
- import { formatFileSize } from "../document-preview/file-size"
7
9
  import { useAgentMessages } from "../i18n"
8
10
  import type { NormalizedFile, NormalizedTool } from "../parts"
9
11
  import { describeViewFile } from "./interpret"
10
12
 
11
13
  /**
12
14
  * A file the agent viewed. It belongs to the work, not to the answer, so it stays in the trace: an
13
- * image as a small preview, any other file as a compact chip, each opening the document preview.
15
+ * image as a small preview, any other file as a compact chip, each opening in the artifact panel.
14
16
  */
15
17
  export function ViewFileToolView({ tool }: { tool: NormalizedTool }) {
16
18
  const messages = useAgentMessages().viewFile
@@ -43,15 +45,16 @@ export function ViewFileToolView({ tool }: { tool: NormalizedTool }) {
43
45
  }
44
46
 
45
47
  function ViewedFile({ file }: { file: NormalizedFile }) {
46
- const unnamed = useAgentMessages().files.file
47
- const { fileRef, document } = file
48
- const name = fileRef.fileName?.trim() || unnamed
48
+ const messages = useAgentMessages().files
49
+ const locale = useLocale()
50
+ const { fileRef, source } = file
51
+ const name = fileRef.fileName?.trim() || messages.file
49
52
 
50
- if (document?.kind === "image") {
53
+ if (source && fileView(fileRef) === "image") {
51
54
  return (
52
55
  <OpenFile file={file} name={name}>
53
56
  <img
54
- src={document.inlineUrl}
57
+ src={source.inlineUrl}
55
58
  alt={name}
56
59
  loading="lazy"
57
60
  className="block h-auto max-h-28 w-auto max-w-[min(10rem,100%)] rounded-md border border-border/70 bg-muted/40 object-contain"
@@ -66,14 +69,14 @@ function ViewedFile({ file }: { file: NormalizedFile }) {
66
69
  <FileIcon className="size-3.5 shrink-0" />
67
70
  <span className="min-w-0 truncate font-medium text-foreground/80">{name}</span>
68
71
  <span className="shrink-0 text-muted-foreground/60">
69
- {formatFileSize(fileRef.sizeBytes)}
72
+ {formatFileSize(fileRef.sizeBytes, locale, messages)}
70
73
  </span>
71
74
  </span>
72
75
  </OpenFile>
73
76
  )
74
77
  }
75
78
 
76
- /** Open a saved file in the document preview, or in a new tab when no viewer handles it. */
79
+ /** Open a saved file in the artifact panel, or in a new tab outside a conversation. */
77
80
  function OpenFile({
78
81
  file,
79
82
  name,
@@ -83,30 +86,30 @@ function OpenFile({
83
86
  name: string
84
87
  children: ReactNode
85
88
  }) {
86
- const preview = useDocumentPreview()
89
+ const panel = useArtifactPanel()
87
90
  const messages = useAgentMessages()
88
- const { document } = file
91
+ const { source } = file
89
92
  const className = cn(
90
93
  "block w-fit max-w-full rounded-md outline-none transition-opacity focus-visible:ring-2 focus-visible:ring-ring",
91
- document && "hover:opacity-80"
94
+ source && "hover:opacity-80"
92
95
  )
93
96
 
94
- if (document && preview?.canPreview(document)) {
97
+ if (source && panel) {
95
98
  return (
96
99
  <button
97
100
  type="button"
98
101
  className={className}
99
- onClick={() => preview.openDocument(document)}
100
- aria-label={messages.documents.preview(name)}
102
+ onClick={() => panel.open({ type: "file", source })}
103
+ aria-label={messages.files.preview(name)}
101
104
  >
102
105
  {children}
103
106
  </button>
104
107
  )
105
108
  }
106
- if (document) {
109
+ if (source) {
107
110
  return (
108
111
  <a
109
- href={document.inlineUrl}
112
+ href={source.inlineUrl}
110
113
  target="_blank"
111
114
  rel="noreferrer"
112
115
  className={className}
@@ -0,0 +1,61 @@
1
+ import { useNavigate, useParams, useSearchParams } from "react-router-dom"
2
+ import {
3
+ type ArtifactTarget,
4
+ artifactTargetFromSearch,
5
+ artifactTargetHref,
6
+ withArtifactTarget,
7
+ } from "./target"
8
+ import { Viewer } from "./viewer"
9
+
10
+ /**
11
+ * An artifact on its own page, at `/artifacts/:artifactId` with `?v=` and `?part=`: the whole
12
+ * window, over whatever shell the app draws, so a shared link opens just the artifact. It belongs
13
+ * to no section: whoever may read the artifact can open it, and a link to it works anywhere.
14
+ */
15
+ export function ArtifactPage() {
16
+ const { artifactId } = useParams()
17
+ const [searchParams, setSearchParams] = useSearchParams()
18
+ const navigate = useNavigate()
19
+ if (!artifactId) return null
20
+
21
+ // The artifact is the path; the version and part are parameters.
22
+ const params = new URLSearchParams(searchParams)
23
+ params.set("artifact", artifactId)
24
+ const target: ArtifactTarget = artifactTargetFromSearch(params) ?? {
25
+ type: "artifact",
26
+ artifactId,
27
+ }
28
+
29
+ return (
30
+ <div className="fixed inset-0 z-50 flex flex-col bg-background text-foreground">
31
+ <Viewer
32
+ target={target}
33
+ chrome={{
34
+ // Back to where the link was followed from, or into the app for a link opened cold.
35
+ onBack: () => (canGoBack() ? navigate(-1) : navigate("/")),
36
+ }}
37
+ // A version or part of this artifact replaces the address; it is the same page.
38
+ onTargetChange={(next) => {
39
+ if (next.type !== "artifact") return
40
+ const nextParams = withArtifactTarget(searchParams, next)
41
+ nextParams.delete("artifact")
42
+ setSearchParams(nextParams, { replace: true })
43
+ }}
44
+ // Another artifact is another page, so back returns to this one.
45
+ onOpenReference={(next) => navigate(artifactTargetHref(next))}
46
+ />
47
+ </div>
48
+ )
49
+ }
50
+
51
+ /** React Router numbers the entries it pushed; the first one has nowhere in the app to go back to. */
52
+ function canGoBack(): boolean {
53
+ const state: unknown = window.history.state
54
+ return (
55
+ typeof state === "object" &&
56
+ state !== null &&
57
+ "idx" in state &&
58
+ typeof state.idx === "number" &&
59
+ state.idx > 0
60
+ )
61
+ }