@sixb/app 0.2.4 → 0.2.6

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 (306) 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/agent-threads.d.ts.map +1 -1
  10. package/dist/agent/components/composer-place.d.ts.map +1 -1
  11. package/dist/agent/components/composer-settings.d.ts +1 -1
  12. package/dist/agent/components/composer-settings.d.ts.map +1 -1
  13. package/dist/agent/components/composer.d.ts +22 -5
  14. package/dist/agent/components/composer.d.ts.map +1 -1
  15. package/dist/agent/components/computer-place.d.ts +24 -6
  16. package/dist/agent/components/computer-place.d.ts.map +1 -1
  17. package/dist/agent/components/context-meter.d.ts +1 -1
  18. package/dist/agent/components/context-meter.d.ts.map +1 -1
  19. package/dist/agent/components/conversation-panel.d.ts +5 -2
  20. package/dist/agent/components/conversation-panel.d.ts.map +1 -1
  21. package/dist/agent/components/message-parts.d.ts +2 -1
  22. package/dist/agent/components/message-parts.d.ts.map +1 -1
  23. package/dist/agent/components/message-view.d.ts +13 -3
  24. package/dist/agent/components/message-view.d.ts.map +1 -1
  25. package/dist/agent/components/pending-messages.d.ts +20 -0
  26. package/dist/agent/components/pending-messages.d.ts.map +1 -0
  27. package/dist/agent/components/sandbox-recovery.d.ts +11 -2
  28. package/dist/agent/components/sandbox-recovery.d.ts.map +1 -1
  29. package/dist/agent/components/threads-button.d.ts +1 -1
  30. package/dist/agent/components/threads-button.d.ts.map +1 -1
  31. package/dist/agent/components/transcript.d.ts +13 -0
  32. package/dist/agent/components/transcript.d.ts.map +1 -1
  33. package/dist/agent/conversation.d.ts +7 -6
  34. package/dist/agent/conversation.d.ts.map +1 -1
  35. package/dist/agent/delegation/interpret.d.ts +5 -0
  36. package/dist/agent/delegation/interpret.d.ts.map +1 -1
  37. package/dist/agent/delegation/use-children.d.ts.map +1 -1
  38. package/dist/agent/format.d.ts +7 -0
  39. package/dist/agent/format.d.ts.map +1 -1
  40. package/dist/agent/hooks/thread-queries.d.ts +1548 -0
  41. package/dist/agent/hooks/thread-queries.d.ts.map +1 -0
  42. package/dist/agent/hooks/use-agent-conversation.d.ts +51 -6
  43. package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
  44. package/dist/agent/hooks/use-thread-lists.d.ts +80 -3
  45. package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
  46. package/dist/agent/hooks/use-thread-place.d.ts +49 -0
  47. package/dist/agent/hooks/use-thread-place.d.ts.map +1 -0
  48. package/dist/agent/hooks/use-thread-stream.d.ts.map +1 -1
  49. package/dist/agent/i18n/en.d.ts +107 -6
  50. package/dist/agent/i18n/en.d.ts.map +1 -1
  51. package/dist/agent/i18n/fr.d.ts.map +1 -1
  52. package/dist/agent/i18n/index.d.ts +180 -12
  53. package/dist/agent/i18n/index.d.ts.map +1 -1
  54. package/dist/agent/inbox-handoff.d.ts +10 -0
  55. package/dist/agent/inbox-handoff.d.ts.map +1 -0
  56. package/dist/agent/live-run.d.ts +8 -1
  57. package/dist/agent/live-run.d.ts.map +1 -1
  58. package/dist/agent/model-selection.d.ts +3 -2
  59. package/dist/agent/model-selection.d.ts.map +1 -1
  60. package/dist/agent/moves.d.ts +40 -0
  61. package/dist/agent/moves.d.ts.map +1 -0
  62. package/dist/agent/search/interpret.d.ts +101 -0
  63. package/dist/agent/search/interpret.d.ts.map +1 -0
  64. package/dist/agent/search/search-tool-view.d.ts +10 -0
  65. package/dist/agent/search/search-tool-view.d.ts.map +1 -0
  66. package/dist/agent/thread-reader-state.d.ts +30 -0
  67. package/dist/agent/thread-reader-state.d.ts.map +1 -0
  68. package/dist/agent/thread-state.d.ts +26 -0
  69. package/dist/agent/thread-state.d.ts.map +1 -0
  70. package/dist/agent/tool-views/built-in.d.ts.map +1 -1
  71. package/dist/agent/tool-views/registry.d.ts +5 -6
  72. package/dist/agent/tool-views/registry.d.ts.map +1 -1
  73. package/dist/agent/types.d.ts +9 -1
  74. package/dist/agent/types.d.ts.map +1 -1
  75. package/dist/agent/view-file/view-file-tool-view.d.ts +2 -1
  76. package/dist/agent/view-file/view-file-tool-view.d.ts.map +1 -1
  77. package/dist/artifacts/card-preview.d.ts.map +1 -1
  78. package/dist/artifacts/editor/block-handle.d.ts +20 -0
  79. package/dist/artifacts/editor/block-handle.d.ts.map +1 -0
  80. package/dist/artifacts/editor/blocks.d.ts +34 -0
  81. package/dist/artifacts/editor/blocks.d.ts.map +1 -0
  82. package/dist/artifacts/editor/callout-view.d.ts +7 -0
  83. package/dist/artifacts/editor/callout-view.d.ts.map +1 -0
  84. package/dist/artifacts/editor/document-editor.d.ts +30 -0
  85. package/dist/artifacts/editor/document-editor.d.ts.map +1 -0
  86. package/dist/artifacts/editor/figure-view.d.ts +12 -0
  87. package/dist/artifacts/editor/figure-view.d.ts.map +1 -0
  88. package/dist/artifacts/editor/find-blocks.d.ts +6 -0
  89. package/dist/artifacts/editor/find-blocks.d.ts.map +1 -0
  90. package/dist/artifacts/editor/markdown-document.d.ts +12 -0
  91. package/dist/artifacts/editor/markdown-document.d.ts.map +1 -0
  92. package/dist/artifacts/editor/messages.d.ts +4 -0
  93. package/dist/artifacts/editor/messages.d.ts.map +1 -0
  94. package/dist/artifacts/editor/schema.d.ts +21 -0
  95. package/dist/artifacts/editor/schema.d.ts.map +1 -0
  96. package/dist/artifacts/editor/selection-toolbar.d.ts +35 -0
  97. package/dist/artifacts/editor/selection-toolbar.d.ts.map +1 -0
  98. package/dist/artifacts/editor/slash-menu.d.ts +43 -0
  99. package/dist/artifacts/editor/slash-menu.d.ts.map +1 -0
  100. package/dist/artifacts/editor/upload.d.ts +12 -0
  101. package/dist/artifacts/editor/upload.d.ts.map +1 -0
  102. package/dist/artifacts/file-source.d.ts +5 -0
  103. package/dist/artifacts/file-source.d.ts.map +1 -1
  104. package/dist/artifacts/frame-editor/bundle.d.ts +7 -0
  105. package/dist/artifacts/frame-editor/bundle.d.ts.map +1 -0
  106. package/dist/artifacts/frame-editor/commands.d.ts +93 -0
  107. package/dist/artifacts/frame-editor/commands.d.ts.map +1 -0
  108. package/dist/artifacts/frame-editor/entry.d.ts +2 -0
  109. package/dist/artifacts/frame-editor/entry.d.ts.map +1 -0
  110. package/dist/artifacts/frame-editor/frame.d.ts +5 -0
  111. package/dist/artifacts/frame-editor/frame.d.ts.map +1 -0
  112. package/dist/artifacts/frame-editor/keys.d.ts +8 -0
  113. package/dist/artifacts/frame-editor/keys.d.ts.map +1 -0
  114. package/dist/artifacts/frame-editor/protocol.d.ts +186 -0
  115. package/dist/artifacts/frame-editor/protocol.d.ts.map +1 -0
  116. package/dist/artifacts/frame-editor/schema.d.ts +34 -0
  117. package/dist/artifacts/frame-editor/schema.d.ts.map +1 -0
  118. package/dist/artifacts/frame-editor/style.d.ts +2 -0
  119. package/dist/artifacts/frame-editor/style.d.ts.map +1 -0
  120. package/dist/artifacts/frame.d.ts +2 -2
  121. package/dist/artifacts/frame.d.ts.map +1 -1
  122. package/dist/artifacts/live/boards.d.ts +2 -0
  123. package/dist/artifacts/live/boards.d.ts.map +1 -1
  124. package/dist/artifacts/live/document.d.ts +32 -0
  125. package/dist/artifacts/live/document.d.ts.map +1 -0
  126. package/dist/artifacts/live/header.d.ts +4 -4
  127. package/dist/artifacts/live/header.d.ts.map +1 -1
  128. package/dist/artifacts/live/presence.d.ts.map +1 -1
  129. package/dist/artifacts/live/session.d.ts +2 -0
  130. package/dist/artifacts/live/session.d.ts.map +1 -1
  131. package/dist/artifacts/live/view.d.ts +4 -3
  132. package/dist/artifacts/live/view.d.ts.map +1 -1
  133. package/dist/artifacts/messages.d.ts +226 -2
  134. package/dist/artifacts/messages.d.ts.map +1 -1
  135. package/dist/artifacts/pdf.d.ts +8 -0
  136. package/dist/artifacts/pdf.d.ts.map +1 -0
  137. package/dist/artifacts/queries.d.ts +80 -0
  138. package/dist/artifacts/queries.d.ts.map +1 -1
  139. package/dist/artifacts/references/references.d.ts +3 -3
  140. package/dist/artifacts/references/references.d.ts.map +1 -1
  141. package/dist/artifacts/renderers/canvas/board-editor.d.ts.map +1 -1
  142. package/dist/artifacts/renderers/canvas/comment-pins.d.ts +4 -2
  143. package/dist/artifacts/renderers/canvas/comment-pins.d.ts.map +1 -1
  144. package/dist/artifacts/renderers/canvas/comments-panel.d.ts.map +1 -1
  145. package/dist/artifacts/renderers/canvas/comments.d.ts +2 -1
  146. package/dist/artifacts/renderers/canvas/comments.d.ts.map +1 -1
  147. package/dist/artifacts/renderers/designed-document.d.ts +28 -0
  148. package/dist/artifacts/renderers/designed-document.d.ts.map +1 -0
  149. package/dist/artifacts/renderers/document-tree.d.ts +2 -0
  150. package/dist/artifacts/renderers/document-tree.d.ts.map +1 -1
  151. package/dist/artifacts/renderers/document.d.ts +9 -1
  152. package/dist/artifacts/renderers/document.d.ts.map +1 -1
  153. package/dist/artifacts/renderers/live-frame.d.ts +145 -0
  154. package/dist/artifacts/renderers/live-frame.d.ts.map +1 -0
  155. package/dist/artifacts/renderers/page-editor.d.ts +16 -0
  156. package/dist/artifacts/renderers/page-editor.d.ts.map +1 -0
  157. package/dist/artifacts/renderers/page.d.ts +10 -1
  158. package/dist/artifacts/renderers/page.d.ts.map +1 -1
  159. package/dist/artifacts/viewer.d.ts.map +1 -1
  160. package/dist/{chunk-pxd07kvx.js → chunk-096d52h2.js} +1 -1
  161. package/dist/{chunk-yrcm1pbg.js → chunk-94d7enwc.js} +491 -2128
  162. package/dist/chunk-94d7enwc.js.map +27 -0
  163. package/dist/{chunk-970s5nkn.js → chunk-ezntd3yy.js} +1 -1
  164. package/dist/{chunk-kymx9y5e.js → chunk-qjw5r2vk.js} +12729 -5044
  165. package/dist/chunk-qjw5r2vk.js.map +242 -0
  166. package/dist/chunk-y51c4tsz.js +11 -0
  167. package/dist/chunk-y51c4tsz.js.map +10 -0
  168. package/dist/createCustomApp.d.ts +8 -1
  169. package/dist/createCustomApp.d.ts.map +1 -1
  170. package/dist/index.d.ts +4 -2
  171. package/dist/index.d.ts.map +1 -1
  172. package/dist/index.js +13 -6
  173. package/dist/index.js.map +5 -5
  174. package/dist/pages/console/data/accounts.d.ts +94 -0
  175. package/dist/pages/console/data/accounts.d.ts.map +1 -0
  176. package/dist/pages/console/data/connectors.d.ts.map +1 -1
  177. package/dist/pages/console/data/live-updates.d.ts.map +1 -1
  178. package/dist/pages/console/data/messages.d.ts +52 -0
  179. package/dist/pages/console/data/messages.d.ts.map +1 -1
  180. package/dist/pages/console/data/shared.d.ts.map +1 -1
  181. package/dist/pages/console/data/sync-button.d.ts.map +1 -1
  182. package/dist/pages/console/data/syncs.d.ts.map +1 -1
  183. package/dist/pages/settings/usage/breakdown.d.ts.map +1 -1
  184. package/dist/pages/settings/usage/page.d.ts +4 -1
  185. package/dist/pages/settings/usage/page.d.ts.map +1 -1
  186. package/dist/pages/settings/usage/spend-model.d.ts +43 -19
  187. package/dist/pages/settings/usage/spend-model.d.ts.map +1 -1
  188. package/dist/pages.js +23044 -22570
  189. package/dist/pages.js.map +17 -16
  190. package/dist/server.d.ts +1 -1
  191. package/dist/server.d.ts.map +1 -1
  192. package/dist/server.js +40 -3
  193. package/dist/server.js.map +3 -3
  194. package/dist/shell/search-command.d.ts.map +1 -1
  195. package/package.json +22 -5
  196. package/src/agent/activity-label.ts +3 -0
  197. package/src/agent/agent-chat.tsx +58 -39
  198. package/src/agent/agent-execution-trace.tsx +2 -2
  199. package/src/agent/agent-panel.tsx +6 -4
  200. package/src/agent/agent.css +254 -0
  201. package/src/agent/artifact-panel.tsx +77 -22
  202. package/src/agent/components/agent-threads.tsx +42 -2
  203. package/src/agent/components/composer-place.tsx +2 -7
  204. package/src/agent/components/composer-settings.tsx +20 -10
  205. package/src/agent/components/composer.tsx +342 -104
  206. package/src/agent/components/computer-place.tsx +415 -70
  207. package/src/agent/components/context-meter.tsx +7 -3
  208. package/src/agent/components/conversation-panel.tsx +99 -54
  209. package/src/agent/components/message-parts.tsx +367 -59
  210. package/src/agent/components/message-view.tsx +428 -9
  211. package/src/agent/components/pending-messages.tsx +342 -0
  212. package/src/agent/components/sandbox-recovery.tsx +36 -17
  213. package/src/agent/components/threads-button.tsx +3 -2
  214. package/src/agent/components/transcript.tsx +198 -38
  215. package/src/agent/conversation.ts +219 -55
  216. package/src/agent/delegation/interpret.ts +31 -7
  217. package/src/agent/format.ts +52 -0
  218. package/src/agent/hooks/thread-queries.ts +75 -0
  219. package/src/agent/hooks/use-agent-conversation.ts +801 -211
  220. package/src/agent/hooks/use-thread-lists.ts +72 -7
  221. package/src/agent/hooks/use-thread-place.ts +239 -0
  222. package/src/agent/hooks/use-thread-stream.ts +10 -0
  223. package/src/agent/i18n/en.ts +150 -27
  224. package/src/agent/i18n/fr.ts +148 -31
  225. package/src/agent/inbox-handoff.ts +47 -0
  226. package/src/agent/live-run.ts +61 -2
  227. package/src/agent/model-selection.ts +3 -2
  228. package/src/agent/moves.ts +174 -0
  229. package/src/agent/react-router.tsx +2 -2
  230. package/src/agent/search/interpret.ts +367 -0
  231. package/src/agent/search/search-tool-view.tsx +235 -0
  232. package/src/agent/thread-reader-state.ts +75 -0
  233. package/src/agent/thread-state.ts +114 -0
  234. package/src/agent/tool-views/built-in.tsx +16 -0
  235. package/src/agent/tool-views/registry.tsx +28 -2
  236. package/src/agent/types.ts +13 -0
  237. package/src/agent/view-file/view-file-tool-view.tsx +33 -19
  238. package/src/artifacts/artifacts.css +398 -0
  239. package/src/artifacts/card-preview.tsx +6 -1
  240. package/src/artifacts/editor/block-handle.tsx +278 -0
  241. package/src/artifacts/editor/blocks.ts +216 -0
  242. package/src/artifacts/editor/callout-view.tsx +31 -0
  243. package/src/artifacts/editor/document-editor.tsx +484 -0
  244. package/src/artifacts/editor/figure-view.tsx +66 -0
  245. package/src/artifacts/editor/find-blocks.ts +19 -0
  246. package/src/artifacts/editor/markdown-document.tsx +72 -0
  247. package/src/artifacts/editor/messages.ts +4 -0
  248. package/src/artifacts/editor/schema.ts +159 -0
  249. package/src/artifacts/editor/selection-toolbar.tsx +364 -0
  250. package/src/artifacts/editor/slash-menu.tsx +251 -0
  251. package/src/artifacts/editor/upload.ts +40 -0
  252. package/src/artifacts/file-source.ts +11 -0
  253. package/src/artifacts/frame-editor/bundle.ts +8 -0
  254. package/src/artifacts/frame-editor/commands.ts +565 -0
  255. package/src/artifacts/frame-editor/entry.ts +6 -0
  256. package/src/artifacts/frame-editor/frame.ts +847 -0
  257. package/src/artifacts/frame-editor/generated/editor.txt +149 -0
  258. package/src/artifacts/frame-editor/generated.d.ts +5 -0
  259. package/src/artifacts/frame-editor/keys.ts +323 -0
  260. package/src/artifacts/frame-editor/protocol.ts +151 -0
  261. package/src/artifacts/frame-editor/schema.ts +293 -0
  262. package/src/artifacts/frame-editor/style.ts +58 -0
  263. package/src/artifacts/frame.tsx +11 -3
  264. package/src/artifacts/live/boards.ts +46 -3
  265. package/src/artifacts/live/document.ts +89 -0
  266. package/src/artifacts/live/header.tsx +9 -14
  267. package/src/artifacts/live/presence.ts +5 -1
  268. package/src/artifacts/live/session.ts +9 -2
  269. package/src/artifacts/live/view.ts +14 -8
  270. package/src/artifacts/messages.ts +138 -2
  271. package/src/artifacts/pdf.ts +50 -0
  272. package/src/artifacts/references/references.tsx +46 -11
  273. package/src/artifacts/renderers/canvas/board-editor.tsx +11 -144
  274. package/src/artifacts/renderers/canvas/comment-pins.tsx +5 -0
  275. package/src/artifacts/renderers/canvas/comments-panel.tsx +58 -1
  276. package/src/artifacts/renderers/canvas/comments.ts +8 -4
  277. package/src/artifacts/renderers/designed-document.tsx +277 -0
  278. package/src/artifacts/renderers/document-tree.ts +9 -0
  279. package/src/artifacts/renderers/document.tsx +13 -102
  280. package/src/artifacts/renderers/live-frame.ts +163 -0
  281. package/src/artifacts/renderers/page-editor.tsx +613 -0
  282. package/src/artifacts/renderers/page.tsx +21 -4
  283. package/src/artifacts/viewer.tsx +87 -41
  284. package/src/createCustomApp.ts +57 -3
  285. package/src/index.ts +10 -0
  286. package/src/pages/console/data/accounts.tsx +509 -0
  287. package/src/pages/console/data/connectors.tsx +7 -15
  288. package/src/pages/console/data/live-updates.ts +2 -0
  289. package/src/pages/console/data/messages.ts +79 -0
  290. package/src/pages/console/data/projections.tsx +4 -0
  291. package/src/pages/console/data/shared.tsx +1 -0
  292. package/src/pages/console/data/sync-button.tsx +56 -16
  293. package/src/pages/console/data/syncs.tsx +66 -41
  294. package/src/pages/console/ontology/lineage/trail.tsx +3 -0
  295. package/src/pages/section-ui.tsx +1 -1
  296. package/src/pages/settings/usage/breakdown.tsx +5 -2
  297. package/src/pages/settings/usage/filter-menu.tsx +1 -1
  298. package/src/pages/settings/usage/page.tsx +32 -13
  299. package/src/pages/settings/usage/spend-chart.tsx +2 -2
  300. package/src/pages/settings/usage/spend-model.ts +118 -50
  301. package/src/server.ts +1 -0
  302. package/src/shell/search-command.tsx +2 -0
  303. package/dist/chunk-kymx9y5e.js.map +0 -211
  304. package/dist/chunk-yrcm1pbg.js.map +0 -34
  305. /package/dist/{chunk-pxd07kvx.js.map → chunk-096d52h2.js.map} +0 -0
  306. /package/dist/{chunk-970s5nkn.js.map → chunk-ezntd3yy.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"search-command.d.ts","sourceRoot":"","sources":["../../src/shell/search-command.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAAc,KAAK,QAAQ,EAAgB,MAAM,aAAa,CAAA;AAErE,MAAM,WAAW,kBAAkB;IACjC,4FAA4F;IAC5F,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAA;IACpC,4FAA4F;IAC5F,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;CAC3C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAAE,KAAU,EAAE,SAAqB,EAAE,EAAE,kBAAkB,sCAwHtF"}
1
+ {"version":3,"file":"search-command.d.ts","sourceRoot":"","sources":["../../src/shell/search-command.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAAc,KAAK,QAAQ,EAAgB,MAAM,aAAa,CAAA;AAErE,MAAM,WAAW,kBAAkB;IACjC,4FAA4F;IAC5F,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAA;IACpC,4FAA4F;IAC5F,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;CAC3C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAAE,KAAU,EAAE,SAAqB,EAAE,EAAE,kBAAkB,sCA0HtF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sixb/app",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "Custom app toolkit for Sixb projects — route scanning, dev serving, and production builds",
5
5
  "keywords": [
6
6
  "sixb",
@@ -51,13 +51,30 @@
51
51
  "build": "bun ../../scripts/build-package.ts",
52
52
  "test:e2e": "bun ../../scripts/ci-guard.ts --stall 60 --max 180 bun test ./tests/app-entry.e2e.ts ./tests/build-browser.e2e.ts ./tests/shared-shell.e2e.ts",
53
53
  "typecheck": "tsc --noEmit",
54
- "prepack": "bun run build"
54
+ "prepack": "bun run build",
55
+ "generate:frame-editor": "bun ./scripts/generate-frame-editor.ts"
55
56
  },
56
57
  "dependencies": {
57
- "@sixb/client": "^0.2.3",
58
- "@sixb/core": "^0.2.4",
59
- "@sixb/ui": "^0.2.3",
58
+ "@sixb/client": "^0.2.6",
59
+ "@sixb/core": "^0.2.6",
60
+ "@sixb/ui": "^0.2.5",
60
61
  "@tailwindcss/cli": "^4.2.2",
62
+ "@tiptap/core": "^3.33.1",
63
+ "@tiptap/extension-code-block": "^3.33.1",
64
+ "@tiptap/extension-collaboration": "^3.33.1",
65
+ "@tiptap/extension-collaboration-caret": "^3.33.1",
66
+ "@tiptap/extension-drag-handle": "^3.33.1",
67
+ "@tiptap/extension-drag-handle-react": "^3.33.1",
68
+ "@tiptap/extension-image": "^3.33.1",
69
+ "@tiptap/extension-list": "^3.33.1",
70
+ "@tiptap/extension-node-range": "^3.33.1",
71
+ "@tiptap/extension-table": "^3.33.1",
72
+ "@tiptap/extensions": "^3.33.1",
73
+ "@tiptap/pm": "^3.33.1",
74
+ "@tiptap/react": "^3.33.1",
75
+ "@tiptap/starter-kit": "^3.33.1",
76
+ "@tiptap/suggestion": "^3.33.1",
77
+ "@tiptap/y-tiptap": "^3.3.0",
61
78
  "@xyflow/react": "^12.10.2",
62
79
  "lib0": "0.2.119",
63
80
  "lucide-react": "^0.562.0",
@@ -14,6 +14,7 @@ import { childQuestions, describeMessageAgent } from "./message-agent/interpret"
14
14
  import type { NormalizedPart, NormalizedTool } from "./parts"
15
15
  import { isPublishTool, publishTitle } from "./publish-artifact/interpret"
16
16
  import { coerceReadInput, coerceReadOutput, describeRead } from "./read/interpret"
17
+ import { describeGlob, describeGrep } from "./search/interpret"
17
18
  import { webFetchQuestion, webFetchUrl } from "./utils/web-fetch"
18
19
  import { describeViewFile } from "./view-file/interpret"
19
20
  import { waitsForCommandsOnly } from "./waits"
@@ -75,6 +76,8 @@ function toolProgressLabel(
75
76
 
76
77
  if (tool.toolName === "edit") return describeEdit(tool, messages).runningTitle
77
78
  if (tool.toolName === "write") return describeWrite(tool, messages).runningTitle
79
+ if (tool.toolName === "glob") return describeGlob(tool, messages).runningTitle
80
+ if (tool.toolName === "grep") return describeGrep(tool, messages).runningTitle
78
81
 
79
82
  if (tool.toolName === "view_file") return messages.viewFile.running(describeViewFile(tool).target)
80
83
  if (tool.toolName === "message_agent") return describeMessageAgent(tool, messages).running
@@ -3,12 +3,12 @@ import { Button, EmptyState, Toaster } from "@sixb/ui/components"
3
3
  import { cn } from "@sixb/ui/lib/utils"
4
4
  import { useQueryClient } from "@tanstack/react-query"
5
5
  import { MessagesSquare } from "lucide-react"
6
- import { type ReactNode, useEffect, useId } from "react"
6
+ import { type ReactNode, useCallback, useEffect, useId, useMemo } from "react"
7
7
  import { ArtifactPeopleContext } from "../artifacts/people"
8
8
  import type { ArtifactTarget } from "../artifacts/target"
9
9
  import { takeAgentDraft } from "../artifacts/view-context"
10
10
  import { ArtifactPanelRoot } from "./artifact-panel"
11
- import { ComputerBadge, ComputerOfflineNotice } from "./components/computer-place"
11
+ import { ComputerOfflineNotice, ThreadPlaceControl } from "./components/computer-place"
12
12
  import { ConversationPanel } from "./components/conversation-panel"
13
13
  import { SandboxRecovery } from "./components/sandbox-recovery"
14
14
  import { SharedThreadNotice } from "./components/shared-thread-notice"
@@ -23,8 +23,11 @@ import { useThreadSharing } from "./hooks/use-thread-sharing"
23
23
  import { useAgentMessages } from "./i18n"
24
24
  import { knownName, MessageAuthorsContext, useConversationAuthors } from "./message-authors"
25
25
  import { personName, threadOwner } from "./sharing"
26
+ import { ThreadStateContext, threadStateStoreFor } from "./thread-state"
26
27
  import type { AgentContextInput, AgentThreadSandboxParams } from "./types"
27
28
 
29
+ const EMPTY_AMBIENT_CONTEXT: readonly AgentContextInput[] = []
30
+
28
31
  export interface AgentChatProps {
29
32
  readonly threadId?: string | null
30
33
  readonly onNavigateHome: () => void
@@ -42,7 +45,10 @@ export interface AgentChatProps {
42
45
  readonly splitArtifacts?: boolean
43
46
  /** The open artifact when the host keeps it in its route; files stay local. */
44
47
  readonly artifactTarget?: ArtifactTarget | null
45
- readonly onArtifactTargetChange?: (target: ArtifactTarget | null) => void
48
+ readonly onArtifactTargetChange?: (
49
+ target: ArtifactTarget | null,
50
+ options?: { readonly replace?: boolean }
51
+ ) => void
46
52
  readonly conversationHeaderActions?: ReactNode
47
53
  readonly composerPlaceholder?: string
48
54
  /**
@@ -66,7 +72,7 @@ export function AgentChat({
66
72
  onNavigateThread,
67
73
  onOpenThreads,
68
74
  className,
69
- ambientContext = [],
75
+ ambientContext = EMPTY_AMBIENT_CONTEXT,
70
76
  compact = false,
71
77
  welcomeContent,
72
78
  artifactHost,
@@ -92,6 +98,7 @@ export function AgentChat({
92
98
  // What an artifact on its own page asked the Agent before coming here starts the input, when
93
99
  // it was this person, in this project, a moment ago.
94
100
  const queries = useQueryClient()
101
+ const threadState = useMemo(() => threadStateStoreFor(queries), [queries])
95
102
  useEffect(() => {
96
103
  let current = true
97
104
  Promise.all([
@@ -135,7 +142,7 @@ export function AgentChat({
135
142
  const conversationHeaderActions =
136
143
  threadId || hostHeaderActions ? (
137
144
  <>
138
- {conversation.computer ? <ComputerBadge computer={conversation.computer} /> : null}
145
+ {conversation.place ? <ThreadPlaceControl place={conversation.place} /> : null}
139
146
  {threadId ? <ThreadArtifactsMenu threadId={threadId} /> : null}
140
147
  {sharingThread ? (
141
148
  <ThreadPeople
@@ -149,6 +156,18 @@ export function AgentChat({
149
156
  </>
150
157
  ) : null
151
158
 
159
+ const showNewThreadControls = threadId === null ? newThreadControls : undefined
160
+ const mergedComposerProps = useMemo(
161
+ () => ({
162
+ ...conversation.composerProps,
163
+ ...(dictation ? {} : { dictation: undefined }),
164
+ ...(showNewThreadControls ? { newThreadControls: showNewThreadControls } : {}),
165
+ ...(insertion ? { insertion } : {}),
166
+ onInserted: inserted,
167
+ }),
168
+ [conversation.composerProps, dictation, showNewThreadControls, insertion, inserted]
169
+ )
170
+
152
171
  let content: ReactNode
153
172
  let controlsInConversationHeader = false
154
173
  if (conversation.agentLoading) {
@@ -189,14 +208,9 @@ export function AgentChat({
189
208
  <ConversationPanel
190
209
  agent={conversation.currentAgent}
191
210
  transcript={conversation.transcriptProps}
192
- composer={{
193
- ...conversation.composerProps,
194
- ...(dictation ? {} : { dictation: undefined }),
195
- ...(threadId === null && newThreadControls ? { newThreadControls } : {}),
196
- ...(insertion ? { insertion } : {}),
197
- onInserted: inserted,
198
- }}
211
+ composer={mergedComposerProps}
199
212
  question={conversation.questionProps}
213
+ pending={conversation.pendingProps}
200
214
  messagesLoading={conversation.messagesLoading}
201
215
  messagesError={conversation.messagesError ? messages.chat.messagesLoadFailed : null}
202
216
  currentThread={conversation.currentThread}
@@ -227,36 +241,41 @@ export function AgentChat({
227
241
  }
228
242
 
229
243
  // An artifact opened from here names who published each version, from this conversation's people.
230
- const artifactPeople = (author: { readonly type: string; readonly id: string }) =>
231
- knownName(author, currentThread, conversation.authors)
244
+ const artifactPeople = useCallback(
245
+ (author: { readonly type: string; readonly id: string }) =>
246
+ knownName(author, currentThread, conversation.authors),
247
+ [currentThread, conversation.authors]
248
+ )
232
249
 
233
250
  return (
234
- <ArtifactPeopleContext.Provider value={artifactPeople}>
235
- <ArtifactPanelRoot
236
- compact={compact}
237
- split={splitArtifacts}
238
- overlayHost={artifactHost}
239
- scopeKey={threadId ?? "draft"}
240
- routeTarget={artifactTarget}
241
- onRouteTargetChange={onArtifactTargetChange}
242
- {...(readOnly ? {} : { onAgentDraft: insert })}
243
- >
244
- <div
245
- data-agent-panel={compact ? "" : undefined}
246
- className={cn("relative flex h-full min-h-0 flex-col", className)}
251
+ <ThreadStateContext.Provider value={threadState}>
252
+ <ArtifactPeopleContext.Provider value={artifactPeople}>
253
+ <ArtifactPanelRoot
254
+ compact={compact}
255
+ split={splitArtifacts}
256
+ overlayHost={artifactHost}
257
+ scopeKey={threadId ?? "draft"}
258
+ routeTarget={artifactTarget}
259
+ onRouteTargetChange={onArtifactTargetChange}
260
+ {...(readOnly ? {} : { onAgentDraft: insert })}
247
261
  >
248
- {!controlsInConversationHeader && conversationHeaderActions ? (
249
- <div className="absolute top-1.5 right-2 z-20 flex items-center gap-1">
250
- {conversationHeaderActions}
251
- </div>
252
- ) : null}
253
- <MessageAuthorsContext.Provider value={authors}>
254
- <main className="min-h-0 min-w-0 flex-1">{content}</main>
255
- </MessageAuthorsContext.Provider>
256
- <Toaster id={toasterId} position="top-center" />
257
- </div>
258
- </ArtifactPanelRoot>
259
- </ArtifactPeopleContext.Provider>
262
+ <div
263
+ data-agent-panel={compact ? "" : undefined}
264
+ className={cn("relative flex h-full min-h-0 flex-col", className)}
265
+ >
266
+ {!controlsInConversationHeader && conversationHeaderActions ? (
267
+ <div className="absolute top-1.5 right-2 z-20 flex items-center gap-1">
268
+ {conversationHeaderActions}
269
+ </div>
270
+ ) : null}
271
+ <MessageAuthorsContext.Provider value={authors}>
272
+ <main className="min-h-0 min-w-0 flex-1">{content}</main>
273
+ </MessageAuthorsContext.Provider>
274
+ <Toaster id={toasterId} position="top-center" />
275
+ </div>
276
+ </ArtifactPanelRoot>
277
+ </ArtifactPeopleContext.Provider>
278
+ </ThreadStateContext.Provider>
260
279
  )
261
280
  }
262
281
 
@@ -135,7 +135,7 @@ function DebugStepCard({
135
135
  ) : (
136
136
  <div className="space-y-1.5">
137
137
  <DebugLabel icon={<MessageSquareText />} label="Agent message" />
138
- <Markdown className="prose-chat text-sm">{text}</Markdown>
138
+ <Markdown className="prose-chat text-sm!">{text}</Markdown>
139
139
  </div>
140
140
  )
141
141
  ) : null}
@@ -185,7 +185,7 @@ function FinalAnswerDisclosure({ text }: { text: string }) {
185
185
  </p>
186
186
  )}
187
187
  <CollapsibleContent>
188
- <Markdown className="prose-chat mt-2 text-sm">{text}</Markdown>
188
+ <Markdown className="prose-chat mt-2 text-sm!">{text}</Markdown>
189
189
  </CollapsibleContent>
190
190
  </Collapsible>
191
191
  )
@@ -72,6 +72,11 @@ export function AgentPanel({
72
72
  [controlled, onThreadChange]
73
73
  )
74
74
 
75
+ const navigateHome = useCallback(() => {
76
+ changeThread(null)
77
+ onNewThread?.()
78
+ }, [changeThread, onNewThread])
79
+
75
80
  return (
76
81
  <AgentChat
77
82
  threadId={threadId}
@@ -85,10 +90,7 @@ export function AgentPanel({
85
90
  welcomeContent={welcomeContent}
86
91
  newThreadSandbox={newThreadSandbox}
87
92
  newThreadControls={newThreadControls}
88
- onNavigateHome={() => {
89
- changeThread(null)
90
- onNewThread?.()
91
- }}
93
+ onNavigateHome={navigateHome}
92
94
  onNavigateThread={changeThread}
93
95
  onOpenThreads={onOpenThreads}
94
96
  className={cn("min-h-0 overflow-hidden bg-background", className)}
@@ -35,6 +35,260 @@
35
35
  }
36
36
  }
37
37
 
38
+ /* Agent replies and execution traces: proportioned for conversation rather than docs pages. */
39
+ .prose.prose-chat {
40
+ font-size: 15px;
41
+ line-height: 1.65;
42
+ }
43
+
44
+ .prose.prose-chat h1 {
45
+ margin: 22px 0 10px;
46
+ font-size: 20px;
47
+ font-weight: 650;
48
+ letter-spacing: -0.018em;
49
+ line-height: 1.3;
50
+ }
51
+
52
+ .prose.prose-chat h2 {
53
+ margin: 20px 0 8px;
54
+ font-size: 17px;
55
+ font-weight: 650;
56
+ letter-spacing: -0.014em;
57
+ line-height: 1.34;
58
+ }
59
+
60
+ .prose.prose-chat h3 {
61
+ margin: 16px 0 6px;
62
+ font-size: 15.5px;
63
+ font-weight: 620;
64
+ letter-spacing: -0.01em;
65
+ line-height: 1.38;
66
+ }
67
+
68
+ .prose.prose-chat h4 {
69
+ margin: 14px 0 4px;
70
+ font-size: 14.5px;
71
+ font-weight: 600;
72
+ line-height: 1.42;
73
+ }
74
+
75
+ .prose.prose-chat h5 {
76
+ margin: 12px 0 4px;
77
+ font-size: 13.5px;
78
+ font-weight: 600;
79
+ line-height: 1.45;
80
+ }
81
+
82
+ .prose.prose-chat h6 {
83
+ margin: 12px 0 4px;
84
+ font-size: 12px;
85
+ line-height: 1.45;
86
+ }
87
+
88
+ .prose.prose-chat :is(h1, h2, h3, h4) + :is(h2, h3, h4, h5, h6) {
89
+ margin-top: 10px;
90
+ }
91
+
92
+ .prose.prose-chat :is(p, ul, ol, table, blockquote, pre) {
93
+ margin: 0 0 12px;
94
+ }
95
+
96
+ .prose.prose-chat :is(.code-block, .prose-table) {
97
+ margin: 0 0 14px;
98
+ }
99
+
100
+ .prose.prose-chat li {
101
+ margin: 4px 0;
102
+ }
103
+
104
+ .prose.prose-chat li > :is(ul, ol) {
105
+ margin-top: 4px;
106
+ margin-bottom: 4px;
107
+ }
108
+
109
+ .prose.prose-chat li:has(> .code-block, > .prose-table, > pre) {
110
+ margin-bottom: 10px;
111
+ }
112
+
113
+ .prose.prose-chat hr {
114
+ margin: 20px 0;
115
+ }
116
+
117
+ .prose.prose-chat :is(.code-block pre.shiki, pre) {
118
+ padding: 12px 14px;
119
+ font-size: 13px;
120
+ line-height: 1.55;
121
+ }
122
+
123
+ .prose.prose-chat table {
124
+ font-size: 13.5px;
125
+ font-variant-numeric: tabular-nums;
126
+ }
127
+
128
+ .prose.prose-chat :is(th, td) {
129
+ padding: 8px 12px;
130
+ }
131
+
132
+ .prose.prose-chat :is(th, td):first-child {
133
+ padding-left: 0;
134
+ }
135
+
136
+ .prose.prose-chat :is(th, td):last-child {
137
+ padding-right: 0;
138
+ }
139
+
140
+ .prose.prose-chat .sixb-callout {
141
+ margin: 14px 0;
142
+ padding: 11px 14px;
143
+ font-size: 14px;
144
+ }
145
+
146
+ .prose.prose-chat section[data-footnotes] {
147
+ margin-top: 18px;
148
+ padding-top: 10px;
149
+ font-size: 12.5px;
150
+ }
151
+
152
+ .prose.prose-chat > :first-child {
153
+ margin-top: 0;
154
+ }
155
+
156
+ .prose.prose-chat > :last-child,
157
+ .prose.prose-chat :is(li, blockquote, .sixb-callout-body) > :last-child {
158
+ margin-bottom: 0;
159
+ }
160
+
161
+ /* Work disclosure scroll container: soft edge fades only in directions with hidden steps. */
162
+ .sixb-work-scroll[data-fade-top]:not([data-fade-bottom]) {
163
+ -webkit-mask-image: linear-gradient(to bottom, transparent, #000 22px);
164
+ mask-image: linear-gradient(to bottom, transparent, #000 22px);
165
+ }
166
+
167
+ .sixb-work-scroll[data-fade-bottom]:not([data-fade-top]) {
168
+ -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent);
169
+ mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent);
170
+ }
171
+
172
+ .sixb-work-scroll[data-fade-top][data-fade-bottom] {
173
+ -webkit-mask-image: linear-gradient(
174
+ to bottom,
175
+ transparent,
176
+ #000 22px,
177
+ #000 calc(100% - 22px),
178
+ transparent
179
+ );
180
+ mask-image: linear-gradient(
181
+ to bottom,
182
+ transparent,
183
+ #000 22px,
184
+ #000 calc(100% - 22px),
185
+ transparent
186
+ );
187
+ }
188
+
189
+ .sixb-work-latest {
190
+ background: color-mix(in oklab, var(--card) 86%, transparent);
191
+ -webkit-backdrop-filter: blur(16px) saturate(1.3);
192
+ backdrop-filter: blur(16px) saturate(1.3);
193
+ box-shadow:
194
+ inset 0 1px 0 rgb(255 255 255 / 0.8),
195
+ 0 0 0 0.5px rgb(0 0 0 / 0.12),
196
+ 0 6px 16px -6px rgb(0 0 0 / 0.18);
197
+ animation: sixb-composer-pop 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
198
+ }
199
+
200
+ :is(.dark *).sixb-work-latest {
201
+ background: color-mix(in oklab, var(--popover) 86%, transparent);
202
+ box-shadow:
203
+ inset 0 1px 0 rgb(255 255 255 / 0.1),
204
+ 0 0 0 0.5px rgb(255 255 255 / 0.14),
205
+ 0 6px 16px -6px rgb(0 0 0 / 0.45);
206
+ }
207
+
208
+ @media (prefers-reduced-motion: reduce) {
209
+ .sixb-work-latest {
210
+ animation: none;
211
+ }
212
+ }
213
+
214
+ /* Reasoning inside the work trace: quiet structured notes subordinate to the main reply. */
215
+ .prose.sixb-reasoning-prose {
216
+ color: color-mix(in oklab, var(--muted-foreground) 88%, transparent);
217
+ font-size: 12.5px;
218
+ line-height: 1.58;
219
+ }
220
+
221
+ .prose.sixb-reasoning-prose :is(h1, h2, h3, h4, h5, h6) {
222
+ margin: 10px 0 3px;
223
+ font-size: 12.5px;
224
+ font-weight: 600;
225
+ line-height: 1.45;
226
+ letter-spacing: -0.005em;
227
+ text-transform: none;
228
+ color: color-mix(in oklab, var(--foreground) 76%, var(--muted-foreground));
229
+ }
230
+
231
+ .prose.sixb-reasoning-prose :is(p, ul, ol, blockquote, pre) {
232
+ margin: 0 0 7px;
233
+ }
234
+
235
+ .prose.sixb-reasoning-prose p:has(> strong:only-child) {
236
+ margin: 10px 0 2px;
237
+ }
238
+
239
+ .prose.sixb-reasoning-prose p > strong:only-child {
240
+ font-weight: 600;
241
+ color: color-mix(in oklab, var(--foreground) 76%, var(--muted-foreground));
242
+ }
243
+
244
+ .prose.sixb-reasoning-prose strong {
245
+ font-weight: 600;
246
+ color: color-mix(in oklab, var(--foreground) 72%, var(--muted-foreground));
247
+ }
248
+
249
+ .prose.sixb-reasoning-prose :is(ul, ol) {
250
+ padding-left: 18px;
251
+ }
252
+
253
+ .prose.sixb-reasoning-prose li {
254
+ margin: 2px 0;
255
+ }
256
+
257
+ .prose.sixb-reasoning-prose :not(pre) > code {
258
+ padding: 0.1em 0.35em;
259
+ border-radius: 4px;
260
+ font-size: 11.5px;
261
+ background: color-mix(in oklab, var(--foreground) 6%, transparent);
262
+ color: color-mix(in oklab, var(--foreground) 78%, var(--muted-foreground));
263
+ }
264
+
265
+ .dark .prose.sixb-reasoning-prose :not(pre) > code {
266
+ background: color-mix(in oklab, var(--foreground) 10%, transparent);
267
+ }
268
+
269
+ .prose.sixb-reasoning-prose :is(.code-block, .prose-table) {
270
+ margin: 4px 0 8px;
271
+ }
272
+
273
+ .prose.sixb-reasoning-prose :is(.code-block pre.shiki, pre) {
274
+ padding: 8px 10px;
275
+ font-size: 11.5px;
276
+ line-height: 1.5;
277
+ }
278
+
279
+ .prose.sixb-reasoning-prose > :first-child {
280
+ margin-top: 0;
281
+ }
282
+
283
+ .prose.sixb-reasoning-prose > :last-child {
284
+ margin-bottom: 0;
285
+ }
286
+
287
+ .prose.sixb-reasoning-prose[data-streaming="true"] > :last-child::after {
288
+ content: " ▍";
289
+ opacity: 0.55;
290
+ }
291
+
38
292
  /* What a fetched page said, inside its row: one reading size, headings marked by weight alone. */
39
293
  .prose.sixb-web-fetch {
40
294
  font-size: 13px;
@@ -41,6 +41,7 @@ import {
41
41
  writeArtifactPanelWidth,
42
42
  } from "./artifact-panel-state"
43
43
  import { useAgentMessages } from "./i18n"
44
+ import { useThreadStateStore } from "./thread-state"
44
45
 
45
46
  /**
46
47
  * A place in the panel a part of the conversation fills itself, such as a sub-agent's thread: the
@@ -100,7 +101,10 @@ export interface ArtifactPanelRootProps {
100
101
  /** The conversation; a different one starts with nothing open. */
101
102
  readonly scopeKey: string
102
103
  readonly routeTarget?: ArtifactTarget | null
103
- readonly onRouteTargetChange?: (target: ArtifactTarget | null) => void
104
+ readonly onRouteTargetChange?: (
105
+ target: ArtifactTarget | null,
106
+ options?: { readonly replace?: boolean }
107
+ ) => void
104
108
  /** Offer each artifact's own page, to open or to copy a link to. Off for an observer. */
105
109
  readonly pageLinks?: boolean
106
110
  /**
@@ -128,41 +132,89 @@ export function ArtifactPanelRoot({
128
132
  }: ArtifactPanelRootProps) {
129
133
  const messages = useAgentMessages().artifacts
130
134
  const idPrefix = useId()
131
- const [localTarget, setLocalTarget] = useState<PanelTarget | null>(null)
132
- const target: PanelTarget | null = routeTarget ?? localTarget
133
- // What the reader followed a reference from, so the panel can take them back.
134
- const [trail, setTrail] = useState<readonly PanelTarget[]>([])
135
- const [slotHost, setSlotHost] = useState<HTMLElement | null>(null)
135
+ const store = useThreadStateStore()
136
+ const storeRef = useRef(store)
137
+ storeRef.current = store
136
138
  const presentation = artifactPanelPresentation({
137
139
  compact,
138
140
  isMobile: useIsMobile(),
139
141
  hasCanvas: Boolean(overlayHost),
140
142
  split,
141
143
  })
144
+ // Restore side-by-side panels and dock canvases automatically; never auto-pop a blocking modal.
145
+ const canAutoRestore = presentation !== "dialog"
146
+ const [localTarget, setLocalTarget] = useState<PanelTarget | null>(() =>
147
+ routeTarget || !canAutoRestore ? null : store.readPanelTarget(scopeKey)
148
+ )
149
+ const target: PanelTarget | null = routeTarget ?? localTarget
150
+ // What the reader followed a reference from, so the panel can take them back.
151
+ const [trail, setTrail] = useState<readonly PanelTarget[]>([])
152
+ const [slotHost, setSlotHost] = useState<HTMLElement | null>(null)
142
153
  const [revealCount, reveal] = useReducer((count: number) => count + 1, 0)
143
154
  const openerRef = useRef<HTMLElement | null>(null)
144
155
  const scopeRef = useRef(scopeKey)
156
+ const prevRouteKeyRef = useRef<string | null>(routeTarget ? viewerTargetKey(routeTarget) : null)
157
+ const localTargetRef = useRef(localTarget)
158
+ localTargetRef.current = localTarget
159
+
160
+ const routeRef = useRef({ routeTarget, onRouteTargetChange })
161
+ routeRef.current = { routeTarget, onRouteTargetChange }
145
162
 
146
163
  useLayoutEffect(() => {
147
- if (scopeRef.current === scopeKey) return
164
+ const scopeChanged = scopeRef.current !== scopeKey
165
+ const nextRouteKey = routeTarget ? viewerTargetKey(routeTarget) : null
166
+ const prevRouteKey = prevRouteKeyRef.current
148
167
  scopeRef.current = scopeKey
149
- setLocalTarget(null)
150
- setTrail([])
151
- openerRef.current = null
152
- }, [scopeKey])
168
+ prevRouteKeyRef.current = nextRouteKey
153
169
 
154
- const show = useCallback(
155
- (next: PanelTarget) => {
156
- if (onRouteTargetChange && next.type === "artifact") {
170
+ if (scopeChanged) {
171
+ setTrail([])
172
+ openerRef.current = null
173
+ if (routeTarget) {
157
174
  setLocalTarget(null)
158
- onRouteTargetChange(next)
175
+ storeRef.current.writePanelTarget(scopeKey, routeTarget)
176
+ } else if (canAutoRestore) {
177
+ const restored = storeRef.current.readPanelTarget(scopeKey)
178
+ setLocalTarget(restored)
179
+ if (restored?.type === "artifact" && routeRef.current.onRouteTargetChange) {
180
+ routeRef.current.onRouteTargetChange(restored, { replace: true })
181
+ }
159
182
  } else {
160
- setLocalTarget(next)
161
- if (onRouteTargetChange && routeTarget) onRouteTargetChange(null)
183
+ setLocalTarget(null)
162
184
  }
163
- },
164
- [onRouteTargetChange, routeTarget]
165
- )
185
+ return
186
+ }
187
+
188
+ if (routeTarget) {
189
+ setLocalTarget(null)
190
+ storeRef.current.writePanelTarget(scopeKey, routeTarget)
191
+ } else if (prevRouteKey !== null && localTargetRef.current === null) {
192
+ storeRef.current.writePanelTarget(scopeKey, null)
193
+ }
194
+ }, [scopeKey, routeTarget, canAutoRestore])
195
+
196
+ // biome-ignore lint/correctness/useExhaustiveDependencies: sync restored artifact once on mount
197
+ useEffect(() => {
198
+ const changeRoute = routeRef.current.onRouteTargetChange
199
+ if (!routeTarget && localTarget?.type === "artifact" && changeRoute) {
200
+ changeRoute(localTarget, { replace: true })
201
+ }
202
+ }, [])
203
+
204
+ const show = useCallback((next: PanelTarget) => {
205
+ // A slot does not come back with its conversation, and neither does what it replaced.
206
+ storeRef.current.writePanelTarget(scopeRef.current, next.type === "slot" ? null : next)
207
+ const { routeTarget: currentRoute, onRouteTargetChange: changeRoute } = routeRef.current
208
+ if (changeRoute && next.type === "artifact") {
209
+ localTargetRef.current = null
210
+ setLocalTarget(null)
211
+ changeRoute(next)
212
+ } else {
213
+ localTargetRef.current = next
214
+ setLocalTarget(next)
215
+ if (changeRoute && currentRoute) changeRoute(null)
216
+ }
217
+ }, [])
166
218
  const open = useCallback(
167
219
  (next: PanelTarget) => {
168
220
  const active = typeof document === "undefined" ? null : document.activeElement
@@ -177,13 +229,16 @@ export function ArtifactPanelRoot({
177
229
  [show]
178
230
  )
179
231
  const close = useCallback(() => {
232
+ storeRef.current.writePanelTarget(scopeRef.current, null)
233
+ const { routeTarget: currentRoute, onRouteTargetChange: changeRoute } = routeRef.current
234
+ localTargetRef.current = null
180
235
  setLocalTarget(null)
181
236
  setTrail([])
182
- if (onRouteTargetChange && routeTarget) onRouteTargetChange(null)
237
+ if (changeRoute && currentRoute) changeRoute(null)
183
238
  const opener = openerRef.current
184
239
  openerRef.current = null
185
240
  if (opener?.isConnected) queueMicrotask(() => opener.focus())
186
- }, [onRouteTargetChange, routeTarget])
241
+ }, [])
187
242
 
188
243
  const value = useMemo<ArtifactPanelValue>(
189
244
  () => ({