@buoy-gg/ask-buoy 7.0.38 → 7.0.39

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/lib/commonjs/blocks/AskBlocks.js +338 -1
  2. package/lib/commonjs/blocks/AskBlocks.js.map +1 -0
  3. package/lib/commonjs/blocks/BlockRenderer.js +262 -1
  4. package/lib/commonjs/blocks/BlockRenderer.js.map +1 -0
  5. package/lib/commonjs/blocks/ChromePrototypes.js +514 -1
  6. package/lib/commonjs/blocks/ChromePrototypes.js.map +1 -0
  7. package/lib/commonjs/blocks/DataBlocks.js +781 -1
  8. package/lib/commonjs/blocks/DataBlocks.js.map +1 -0
  9. package/lib/commonjs/blocks/ExtraBlocks.js +1860 -1
  10. package/lib/commonjs/blocks/ExtraBlocks.js.map +1 -0
  11. package/lib/commonjs/blocks/MediaBlocks.js +156 -1
  12. package/lib/commonjs/blocks/MediaBlocks.js.map +1 -0
  13. package/lib/commonjs/blocks/ReceiptBlocks.js +586 -1
  14. package/lib/commonjs/blocks/ReceiptBlocks.js.map +1 -0
  15. package/lib/commonjs/blocks/blockText.js +60 -1
  16. package/lib/commonjs/blocks/blockText.js.map +1 -0
  17. package/lib/commonjs/blocks/blockText.test.js +53 -1
  18. package/lib/commonjs/blocks/blockText.test.js.map +1 -0
  19. package/lib/commonjs/blocks/context.js +42 -1
  20. package/lib/commonjs/blocks/context.js.map +1 -0
  21. package/lib/commonjs/blocks/icons.js +96 -1
  22. package/lib/commonjs/blocks/icons.js.map +1 -0
  23. package/lib/commonjs/blocks/index.js +95 -1
  24. package/lib/commonjs/blocks/index.js.map +1 -0
  25. package/lib/commonjs/blocks/listRow.test.js +55 -1
  26. package/lib/commonjs/blocks/listRow.test.js.map +1 -0
  27. package/lib/commonjs/blocks/pageState.js +34 -1
  28. package/lib/commonjs/blocks/pageState.js.map +1 -0
  29. package/lib/commonjs/blocks/pageState.test.js +57 -1
  30. package/lib/commonjs/blocks/pageState.test.js.map +1 -0
  31. package/lib/commonjs/blocks/primitives.js +457 -1
  32. package/lib/commonjs/blocks/primitives.js.map +1 -0
  33. package/lib/commonjs/blocks/primitivesIndex.js +62 -1
  34. package/lib/commonjs/blocks/primitivesIndex.js.map +1 -0
  35. package/lib/commonjs/components/ApprovalCard.js +297 -1
  36. package/lib/commonjs/components/ApprovalCard.js.map +1 -0
  37. package/lib/commonjs/components/AskBuoyHeader.js +196 -1
  38. package/lib/commonjs/components/AskBuoyHeader.js.map +1 -0
  39. package/lib/commonjs/components/AskBuoyIcon.js +19 -1
  40. package/lib/commonjs/components/AskBuoyIcon.js.map +1 -0
  41. package/lib/commonjs/components/AskBuoyModal.js +479 -1
  42. package/lib/commonjs/components/AskBuoyModal.js.map +1 -0
  43. package/lib/commonjs/components/AskBuoySettings.js +181 -1
  44. package/lib/commonjs/components/AskBuoySettings.js.map +1 -0
  45. package/lib/commonjs/components/ChangesBar.js +211 -1
  46. package/lib/commonjs/components/ChangesBar.js.map +1 -0
  47. package/lib/commonjs/components/Composer.js +255 -1
  48. package/lib/commonjs/components/Composer.js.map +1 -0
  49. package/lib/commonjs/components/EmptyState.js +161 -1
  50. package/lib/commonjs/components/EmptyState.js.map +1 -0
  51. package/lib/commonjs/components/KeyboardPad.js +80 -1
  52. package/lib/commonjs/components/KeyboardPad.js.map +1 -0
  53. package/lib/commonjs/components/Markdown.js +310 -1
  54. package/lib/commonjs/components/Markdown.js.map +1 -0
  55. package/lib/commonjs/components/MessageList.js +970 -1
  56. package/lib/commonjs/components/MessageList.js.map +1 -0
  57. package/lib/commonjs/components/QueuedMessages.js +145 -1
  58. package/lib/commonjs/components/QueuedMessages.js.map +1 -0
  59. package/lib/commonjs/components/ThinkingStrip.js +223 -1
  60. package/lib/commonjs/components/ThinkingStrip.js.map +1 -0
  61. package/lib/commonjs/components/TypingDots.js +63 -1
  62. package/lib/commonjs/components/TypingDots.js.map +1 -0
  63. package/lib/commonjs/components/markdownParse.js +131 -1
  64. package/lib/commonjs/components/markdownParse.js.map +1 -0
  65. package/lib/commonjs/components/markdownParse.test.js +99 -1
  66. package/lib/commonjs/components/markdownParse.test.js.map +1 -0
  67. package/lib/commonjs/components/useCopyAction.js +50 -1
  68. package/lib/commonjs/components/useCopyAction.js.map +1 -0
  69. package/lib/commonjs/index.js +252 -1
  70. package/lib/commonjs/index.js.map +1 -0
  71. package/lib/commonjs/preset.js +91 -1
  72. package/lib/commonjs/preset.js.map +1 -0
  73. package/lib/commonjs/store/activityGroups.js +110 -1
  74. package/lib/commonjs/store/activityGroups.js.map +1 -0
  75. package/lib/commonjs/store/activityGroups.test.js +78 -1
  76. package/lib/commonjs/store/activityGroups.test.js.map +1 -0
  77. package/lib/commonjs/store/askBuoySettings.js +72 -1
  78. package/lib/commonjs/store/askBuoySettings.js.map +1 -0
  79. package/lib/commonjs/store/askBuoyStore.js +589 -1
  80. package/lib/commonjs/store/askBuoyStore.js.map +1 -0
  81. package/lib/commonjs/store/blockPlacement.js +64 -1
  82. package/lib/commonjs/store/blockPlacement.js.map +1 -0
  83. package/lib/commonjs/store/blockPlacement.test.js +123 -1
  84. package/lib/commonjs/store/blockPlacement.test.js.map +1 -0
  85. package/lib/commonjs/store/queue.test.js +150 -1
  86. package/lib/commonjs/store/queue.test.js.map +1 -0
  87. package/lib/commonjs/store/resetConversation.js +77 -1
  88. package/lib/commonjs/store/resetConversation.js.map +1 -0
  89. package/lib/commonjs/store/restorePending.test.js +63 -1
  90. package/lib/commonjs/store/restorePending.test.js.map +1 -0
  91. package/lib/commonjs/store/restoredIds.test.js +47 -1
  92. package/lib/commonjs/store/restoredIds.test.js.map +1 -0
  93. package/lib/commonjs/store/suggestions.js +54 -1
  94. package/lib/commonjs/store/suggestions.js.map +1 -0
  95. package/lib/commonjs/store/suggestions.test.js +58 -1
  96. package/lib/commonjs/store/suggestions.test.js.map +1 -0
  97. package/lib/commonjs/store/systemLine.test.js +77 -1
  98. package/lib/commonjs/store/systemLine.test.js.map +1 -0
  99. package/lib/commonjs/store/ticketPrompt.js +17 -1
  100. package/lib/commonjs/store/ticketPrompt.js.map +1 -0
  101. package/lib/commonjs/store/traceText.js +81 -1
  102. package/lib/commonjs/store/traceText.js.map +1 -0
  103. package/lib/commonjs/store/traceText.test.js +112 -1
  104. package/lib/commonjs/store/traceText.test.js.map +1 -0
  105. package/lib/commonjs/store/transcriptPersistence.js +297 -1
  106. package/lib/commonjs/store/transcriptPersistence.js.map +1 -0
  107. package/lib/commonjs/store/transcriptPersistence.test.js +333 -1
  108. package/lib/commonjs/store/transcriptPersistence.test.js.map +1 -0
  109. package/lib/commonjs/store/turnRendering.test.js +151 -1
  110. package/lib/commonjs/store/turnRendering.test.js.map +1 -0
  111. package/lib/commonjs/store/useAskBuoy.js +651 -1
  112. package/lib/commonjs/store/useAskBuoy.js.map +1 -0
  113. package/lib/commonjs/store/useAskBuoySettings.js +14 -1
  114. package/lib/commonjs/store/useAskBuoySettings.js.map +1 -0
  115. package/lib/commonjs/sync/askBuoySyncAdapter.js +153 -1
  116. package/lib/commonjs/sync/askBuoySyncAdapter.js.map +1 -0
  117. package/lib/commonjs/sync/askBuoySyncAdapter.test.js +141 -1
  118. package/lib/commonjs/sync/askBuoySyncAdapter.test.js.map +1 -0
  119. package/lib/commonjs/sync/wire.js +58 -1
  120. package/lib/commonjs/sync/wire.js.map +1 -0
  121. package/lib/commonjs/types.js +6 -1
  122. package/lib/commonjs/types.js.map +1 -0
  123. package/lib/module/blocks/AskBlocks.js +331 -1
  124. package/lib/module/blocks/AskBlocks.js.map +1 -0
  125. package/lib/module/blocks/BlockRenderer.js +257 -1
  126. package/lib/module/blocks/BlockRenderer.js.map +1 -0
  127. package/lib/module/blocks/ChromePrototypes.js +503 -1
  128. package/lib/module/blocks/ChromePrototypes.js.map +1 -0
  129. package/lib/module/blocks/DataBlocks.js +767 -1
  130. package/lib/module/blocks/DataBlocks.js.map +1 -0
  131. package/lib/module/blocks/ExtraBlocks.js +1833 -1
  132. package/lib/module/blocks/ExtraBlocks.js.map +1 -0
  133. package/lib/module/blocks/MediaBlocks.js +151 -1
  134. package/lib/module/blocks/MediaBlocks.js.map +1 -0
  135. package/lib/module/blocks/ReceiptBlocks.js +574 -1
  136. package/lib/module/blocks/ReceiptBlocks.js.map +1 -0
  137. package/lib/module/blocks/blockText.js +55 -1
  138. package/lib/module/blocks/blockText.js.map +1 -0
  139. package/lib/module/blocks/blockText.test.js +53 -1
  140. package/lib/module/blocks/blockText.test.js.map +1 -0
  141. package/lib/module/blocks/context.js +35 -1
  142. package/lib/module/blocks/context.js.map +1 -0
  143. package/lib/module/blocks/icons.js +91 -1
  144. package/lib/module/blocks/icons.js.map +1 -0
  145. package/lib/module/blocks/index.js +8 -1
  146. package/lib/module/blocks/index.js.map +1 -0
  147. package/lib/module/blocks/listRow.test.js +56 -1
  148. package/lib/module/blocks/listRow.test.js.map +1 -0
  149. package/lib/module/blocks/pageState.js +30 -1
  150. package/lib/module/blocks/pageState.js.map +1 -0
  151. package/lib/module/blocks/pageState.test.js +56 -1
  152. package/lib/module/blocks/pageState.test.js.map +1 -0
  153. package/lib/module/blocks/primitives.js +445 -1
  154. package/lib/module/blocks/primitives.js.map +1 -0
  155. package/lib/module/blocks/primitivesIndex.js +5 -1
  156. package/lib/module/blocks/primitivesIndex.js.map +1 -0
  157. package/lib/module/components/ApprovalCard.js +292 -1
  158. package/lib/module/components/ApprovalCard.js.map +1 -0
  159. package/lib/module/components/AskBuoyHeader.js +193 -1
  160. package/lib/module/components/AskBuoyHeader.js.map +1 -0
  161. package/lib/module/components/AskBuoyIcon.js +8 -1
  162. package/lib/module/components/AskBuoyIcon.js.map +1 -0
  163. package/lib/module/components/AskBuoyModal.js +474 -1
  164. package/lib/module/components/AskBuoyModal.js.map +1 -0
  165. package/lib/module/components/AskBuoySettings.js +176 -1
  166. package/lib/module/components/AskBuoySettings.js.map +1 -0
  167. package/lib/module/components/ChangesBar.js +206 -1
  168. package/lib/module/components/ChangesBar.js.map +1 -0
  169. package/lib/module/components/Composer.js +250 -1
  170. package/lib/module/components/Composer.js.map +1 -0
  171. package/lib/module/components/EmptyState.js +156 -1
  172. package/lib/module/components/EmptyState.js.map +1 -0
  173. package/lib/module/components/KeyboardPad.js +75 -1
  174. package/lib/module/components/KeyboardPad.js.map +1 -0
  175. package/lib/module/components/Markdown.js +305 -1
  176. package/lib/module/components/Markdown.js.map +1 -0
  177. package/lib/module/components/MessageList.js +964 -1
  178. package/lib/module/components/MessageList.js.map +1 -0
  179. package/lib/module/components/QueuedMessages.js +140 -1
  180. package/lib/module/components/QueuedMessages.js.map +1 -0
  181. package/lib/module/components/ThinkingStrip.js +218 -1
  182. package/lib/module/components/ThinkingStrip.js.map +1 -0
  183. package/lib/module/components/TypingDots.js +58 -1
  184. package/lib/module/components/TypingDots.js.map +1 -0
  185. package/lib/module/components/markdownParse.js +125 -1
  186. package/lib/module/components/markdownParse.js.map +1 -0
  187. package/lib/module/components/markdownParse.test.js +98 -1
  188. package/lib/module/components/markdownParse.test.js.map +1 -0
  189. package/lib/module/components/useCopyAction.js +46 -1
  190. package/lib/module/components/useCopyAction.js.map +1 -0
  191. package/lib/module/index.js +34 -1
  192. package/lib/module/index.js.map +1 -0
  193. package/lib/module/preset.js +74 -1
  194. package/lib/module/preset.js.map +1 -0
  195. package/lib/module/store/activityGroups.js +103 -1
  196. package/lib/module/store/activityGroups.js.map +1 -0
  197. package/lib/module/store/activityGroups.test.js +77 -1
  198. package/lib/module/store/activityGroups.test.js.map +1 -0
  199. package/lib/module/store/askBuoySettings.js +67 -1
  200. package/lib/module/store/askBuoySettings.js.map +1 -0
  201. package/lib/module/store/askBuoyStore.js +583 -1
  202. package/lib/module/store/askBuoyStore.js.map +1 -0
  203. package/lib/module/store/blockPlacement.js +59 -1
  204. package/lib/module/store/blockPlacement.js.map +1 -0
  205. package/lib/module/store/blockPlacement.test.js +122 -1
  206. package/lib/module/store/blockPlacement.test.js.map +1 -0
  207. package/lib/module/store/queue.test.js +149 -1
  208. package/lib/module/store/queue.test.js.map +1 -0
  209. package/lib/module/store/resetConversation.js +72 -1
  210. package/lib/module/store/resetConversation.js.map +1 -0
  211. package/lib/module/store/restorePending.test.js +62 -1
  212. package/lib/module/store/restorePending.test.js.map +1 -0
  213. package/lib/module/store/restoredIds.test.js +46 -1
  214. package/lib/module/store/restoredIds.test.js.map +1 -0
  215. package/lib/module/store/suggestions.js +49 -1
  216. package/lib/module/store/suggestions.js.map +1 -0
  217. package/lib/module/store/suggestions.test.js +57 -1
  218. package/lib/module/store/suggestions.test.js.map +1 -0
  219. package/lib/module/store/systemLine.test.js +76 -1
  220. package/lib/module/store/systemLine.test.js.map +1 -0
  221. package/lib/module/store/ticketPrompt.js +13 -1
  222. package/lib/module/store/ticketPrompt.js.map +1 -0
  223. package/lib/module/store/traceText.js +75 -1
  224. package/lib/module/store/traceText.js.map +1 -0
  225. package/lib/module/store/traceText.test.js +111 -1
  226. package/lib/module/store/traceText.test.js.map +1 -0
  227. package/lib/module/store/transcriptPersistence.js +287 -1
  228. package/lib/module/store/transcriptPersistence.js.map +1 -0
  229. package/lib/module/store/transcriptPersistence.test.js +332 -1
  230. package/lib/module/store/transcriptPersistence.test.js.map +1 -0
  231. package/lib/module/store/turnRendering.test.js +150 -1
  232. package/lib/module/store/turnRendering.test.js.map +1 -0
  233. package/lib/module/store/useAskBuoy.js +646 -1
  234. package/lib/module/store/useAskBuoy.js.map +1 -0
  235. package/lib/module/store/useAskBuoySettings.js +9 -1
  236. package/lib/module/store/useAskBuoySettings.js.map +1 -0
  237. package/lib/module/sync/askBuoySyncAdapter.js +148 -1
  238. package/lib/module/sync/askBuoySyncAdapter.js.map +1 -0
  239. package/lib/module/sync/askBuoySyncAdapter.test.js +140 -1
  240. package/lib/module/sync/askBuoySyncAdapter.test.js.map +1 -0
  241. package/lib/module/sync/wire.js +47 -1
  242. package/lib/module/sync/wire.js.map +1 -0
  243. package/lib/module/types.js +4 -1
  244. package/lib/module/types.js.map +1 -0
  245. package/lib/typescript/blocks/AskBlocks.d.ts.map +1 -0
  246. package/lib/typescript/blocks/BlockRenderer.d.ts.map +1 -0
  247. package/lib/typescript/blocks/ChromePrototypes.d.ts.map +1 -0
  248. package/lib/typescript/blocks/DataBlocks.d.ts.map +1 -0
  249. package/lib/typescript/blocks/ExtraBlocks.d.ts.map +1 -0
  250. package/lib/typescript/blocks/MediaBlocks.d.ts.map +1 -0
  251. package/lib/typescript/blocks/ReceiptBlocks.d.ts.map +1 -0
  252. package/lib/typescript/blocks/blockText.d.ts.map +1 -0
  253. package/lib/typescript/blocks/blockText.test.d.ts.map +1 -0
  254. package/lib/typescript/blocks/context.d.ts.map +1 -0
  255. package/lib/typescript/blocks/icons.d.ts.map +1 -0
  256. package/lib/typescript/blocks/index.d.ts.map +1 -0
  257. package/lib/typescript/blocks/listRow.test.d.ts.map +1 -0
  258. package/lib/typescript/blocks/pageState.d.ts.map +1 -0
  259. package/lib/typescript/blocks/pageState.test.d.ts.map +1 -0
  260. package/lib/typescript/blocks/primitives.d.ts.map +1 -0
  261. package/lib/typescript/blocks/primitivesIndex.d.ts.map +1 -0
  262. package/lib/typescript/components/ApprovalCard.d.ts.map +1 -0
  263. package/lib/typescript/components/AskBuoyHeader.d.ts.map +1 -0
  264. package/lib/typescript/components/AskBuoyIcon.d.ts.map +1 -0
  265. package/lib/typescript/components/AskBuoyModal.d.ts.map +1 -0
  266. package/lib/typescript/components/AskBuoySettings.d.ts.map +1 -0
  267. package/lib/typescript/components/ChangesBar.d.ts.map +1 -0
  268. package/lib/typescript/components/Composer.d.ts.map +1 -0
  269. package/lib/typescript/components/EmptyState.d.ts.map +1 -0
  270. package/lib/typescript/components/KeyboardPad.d.ts.map +1 -0
  271. package/lib/typescript/components/Markdown.d.ts.map +1 -0
  272. package/lib/typescript/components/MessageList.d.ts.map +1 -0
  273. package/lib/typescript/components/QueuedMessages.d.ts.map +1 -0
  274. package/lib/typescript/components/ThinkingStrip.d.ts.map +1 -0
  275. package/lib/typescript/components/TypingDots.d.ts.map +1 -0
  276. package/lib/typescript/components/markdownParse.d.ts.map +1 -0
  277. package/lib/typescript/components/markdownParse.test.d.ts.map +1 -0
  278. package/lib/typescript/components/useCopyAction.d.ts.map +1 -0
  279. package/lib/typescript/index.d.ts.map +1 -0
  280. package/lib/typescript/preset.d.ts.map +1 -0
  281. package/lib/typescript/store/activityGroups.d.ts.map +1 -0
  282. package/lib/typescript/store/activityGroups.test.d.ts.map +1 -0
  283. package/lib/typescript/store/askBuoySettings.d.ts.map +1 -0
  284. package/lib/typescript/store/askBuoyStore.d.ts.map +1 -0
  285. package/lib/typescript/store/blockPlacement.d.ts.map +1 -0
  286. package/lib/typescript/store/blockPlacement.test.d.ts.map +1 -0
  287. package/lib/typescript/store/queue.test.d.ts.map +1 -0
  288. package/lib/typescript/store/resetConversation.d.ts.map +1 -0
  289. package/lib/typescript/store/restorePending.test.d.ts.map +1 -0
  290. package/lib/typescript/store/restoredIds.test.d.ts.map +1 -0
  291. package/lib/typescript/store/suggestions.d.ts.map +1 -0
  292. package/lib/typescript/store/suggestions.test.d.ts.map +1 -0
  293. package/lib/typescript/store/systemLine.test.d.ts.map +1 -0
  294. package/lib/typescript/store/ticketPrompt.d.ts.map +1 -0
  295. package/lib/typescript/store/traceText.d.ts.map +1 -0
  296. package/lib/typescript/store/traceText.test.d.ts.map +1 -0
  297. package/lib/typescript/store/transcriptPersistence.d.ts.map +1 -0
  298. package/lib/typescript/store/transcriptPersistence.test.d.ts.map +1 -0
  299. package/lib/typescript/store/turnRendering.test.d.ts.map +1 -0
  300. package/lib/typescript/store/useAskBuoy.d.ts.map +1 -0
  301. package/lib/typescript/store/useAskBuoySettings.d.ts.map +1 -0
  302. package/lib/typescript/sync/askBuoySyncAdapter.d.ts.map +1 -0
  303. package/lib/typescript/sync/askBuoySyncAdapter.test.d.ts.map +1 -0
  304. package/lib/typescript/sync/wire.d.ts.map +1 -0
  305. package/lib/typescript/types.d.ts.map +1 -0
  306. package/package.json +8 -8
@@ -1 +1,150 @@
1
- "use strict";import{beforeEach,describe,expect,it}from"vitest";import{askBuoyStore,queuePauseReason}from"./askBuoyStore";beforeEach(()=>askBuoyStore.reset());const lastText=()=>askBuoyStore.getState().messages.at(-1)?.text??"";describe("round boundaries",()=>{it("opens a paragraph when the engine says a new round began",()=>{const e=askBuoyStore.startAssistant();askBuoyStore.applyEvent(e,{type:"text",delta:"Wiping storage now."}),askBuoyStore.applyEvent(e,{type:"text",delta:"No problem — I left it alone.",breakBefore:!0}),expect(lastText()).toBe("Wiping storage now.\n\nNo problem — I left it alone.")}),it("still streams deltas within one round straight together",()=>{const e=askBuoyStore.startAssistant();askBuoyStore.applyEvent(e,{type:"text",delta:"Hello"}),askBuoyStore.applyEvent(e,{type:"text",delta:" there."}),expect(lastText()).toBe("Hello there.")}),it("never opens with a blank line",()=>{const e=askBuoyStore.startAssistant();askBuoyStore.applyEvent(e,{type:"text",delta:"First words.",breakBefore:!0}),expect(lastText()).toBe("First words.")})}),describe("a declined call",()=>{it("keeps its row and reads as declined, not failed",()=>{const e=askBuoyStore.startAssistant();askBuoyStore.applyEvent(e,{type:"tool-start",id:"c1",toolId:"storage",action:"clearAll",label:"Clear all saved app data",description:"Wipe every stored key",params:{},effect:"destructive"}),askBuoyStore.applyEvent(e,{type:"tool-end",id:"c1",ok:!1,summary:"declined",durationMs:0}),expect(askBuoyStore.getState().messages.at(-1)?.toolCalls[0]).toMatchObject({label:"Clear all saved app data",status:"declined"})})}),describe("stop",()=>{it("marks the turn stopped and leaves no error on it",()=>{const e=askBuoyStore.startAssistant();askBuoyStore.applyEvent(e,{type:"text",delta:"Looking…"}),askBuoyStore.markStopped(e);const t=askBuoyStore.getState().messages.at(-1);expect(t?.stopped).toBe(!0),expect(t?.error).toBeUndefined()})}),describe("stop and the queue",()=>{it("keeps parked messages parked, and says why",()=>{askBuoyStore.addUser("first");const e=askBuoyStore.startAssistant();askBuoyStore.enqueue("do this next"),askBuoyStore.requestStop(),askBuoyStore.markStopped(e),askBuoyStore.finishAssistant(e);const t=askBuoyStore.getState();expect(t.queued.map(e=>e.text)).toEqual(["do this next"]),expect(queuePauseReason(t)).toMatch(/stopped/)}),it("hands one parked message back to the composer to edit",()=>{const e=askBuoyStore.enqueue("words");askBuoyStore.takeQueuedToDraft(e.id),expect(askBuoyStore.getState().queued).toEqual([]),expect(askBuoyStore.getState().draft).toBe("words"),askBuoyStore.clearDraft(),expect(askBuoyStore.getState().draft).toBeNull()})}),describe("hydrate",()=>{it("marks what it puts back",()=>{askBuoyStore.hydrate({messages:[{id:"m1",role:"assistant",text:"hi",toolCalls:[],blocks:[]}],answers:{},usage:{input:0,output:0,requests:0}}),expect(askBuoyStore.getState().messages[0]?.restored).toBe(!0)}),it("leaves a live message unmarked",()=>{askBuoyStore.addUser("live one"),expect(askBuoyStore.getState().messages[0]?.restored).toBeUndefined()})});
1
+ "use strict";
2
+
3
+ /**
4
+ * How the store folds a turn into one bubble.
5
+ *
6
+ * Both rules here were written from a real transcript: rounds of an answer
7
+ * arriving as separate text events were concatenated into
8
+ * "…resets every launch.Here's the full picture…", and a turn the user
9
+ * stopped was reported as "Couldn't reach your AI endpoint."
10
+ */
11
+ import { beforeEach, describe, expect, it } from "vitest";
12
+ import { askBuoyStore, queuePauseReason } from "./askBuoyStore";
13
+ beforeEach(() => askBuoyStore.reset());
14
+ const lastText = () => askBuoyStore.getState().messages.at(-1)?.text ?? "";
15
+ describe("round boundaries", () => {
16
+ it("opens a paragraph when the engine says a new round began", () => {
17
+ const id = askBuoyStore.startAssistant();
18
+ askBuoyStore.applyEvent(id, {
19
+ type: "text",
20
+ delta: "Wiping storage now."
21
+ });
22
+ askBuoyStore.applyEvent(id, {
23
+ type: "text",
24
+ delta: "No problem — I left it alone.",
25
+ breakBefore: true
26
+ });
27
+ expect(lastText()).toBe("Wiping storage now.\n\nNo problem — I left it alone.");
28
+ });
29
+ it("still streams deltas within one round straight together", () => {
30
+ const id = askBuoyStore.startAssistant();
31
+ askBuoyStore.applyEvent(id, {
32
+ type: "text",
33
+ delta: "Hello"
34
+ });
35
+ askBuoyStore.applyEvent(id, {
36
+ type: "text",
37
+ delta: " there."
38
+ });
39
+ expect(lastText()).toBe("Hello there.");
40
+ });
41
+ it("never opens with a blank line", () => {
42
+ const id = askBuoyStore.startAssistant();
43
+ askBuoyStore.applyEvent(id, {
44
+ type: "text",
45
+ delta: "First words.",
46
+ breakBefore: true
47
+ });
48
+ expect(lastText()).toBe("First words.");
49
+ });
50
+ });
51
+ describe("a declined call", () => {
52
+ it("keeps its row and reads as declined, not failed", () => {
53
+ const id = askBuoyStore.startAssistant();
54
+ askBuoyStore.applyEvent(id, {
55
+ type: "tool-start",
56
+ id: "c1",
57
+ toolId: "storage",
58
+ action: "clearAll",
59
+ label: "Clear all saved app data",
60
+ description: "Wipe every stored key",
61
+ params: {},
62
+ effect: "destructive"
63
+ });
64
+ askBuoyStore.applyEvent(id, {
65
+ type: "tool-end",
66
+ id: "c1",
67
+ ok: false,
68
+ summary: "declined",
69
+ durationMs: 0
70
+ });
71
+ expect(askBuoyStore.getState().messages.at(-1)?.toolCalls[0]).toMatchObject({
72
+ label: "Clear all saved app data",
73
+ status: "declined"
74
+ });
75
+ });
76
+ });
77
+ describe("stop", () => {
78
+ it("marks the turn stopped and leaves no error on it", () => {
79
+ const id = askBuoyStore.startAssistant();
80
+ askBuoyStore.applyEvent(id, {
81
+ type: "text",
82
+ delta: "Looking…"
83
+ });
84
+ askBuoyStore.markStopped(id);
85
+ const m = askBuoyStore.getState().messages.at(-1);
86
+ expect(m?.stopped).toBe(true);
87
+ expect(m?.error).toBeUndefined();
88
+ });
89
+ });
90
+
91
+ /**
92
+ * Stop must not launch the messages parked behind it.
93
+ *
94
+ * Ending a turn is exactly what flushes the queue, so Stop used to send the
95
+ * parked message and start a NEW turn — pressing Stop made the agent start
96
+ * talking again. The queue now HOLDS after a stop (see `queuePauseReason`),
97
+ * and the words stay visible as rows rather than being dumped into the
98
+ * composer.
99
+ */
100
+ describe("stop and the queue", () => {
101
+ it("keeps parked messages parked, and says why", () => {
102
+ askBuoyStore.addUser("first");
103
+ const id = askBuoyStore.startAssistant();
104
+ askBuoyStore.enqueue("do this next");
105
+ askBuoyStore.requestStop();
106
+ askBuoyStore.markStopped(id);
107
+ askBuoyStore.finishAssistant(id);
108
+ const s = askBuoyStore.getState();
109
+ expect(s.queued.map(q => q.text)).toEqual(["do this next"]);
110
+ expect(queuePauseReason(s)).toMatch(/stopped/);
111
+ });
112
+ it("hands one parked message back to the composer to edit", () => {
113
+ const item = askBuoyStore.enqueue("words");
114
+ askBuoyStore.takeQueuedToDraft(item.id);
115
+ expect(askBuoyStore.getState().queued).toEqual([]);
116
+ expect(askBuoyStore.getState().draft).toBe("words");
117
+ askBuoyStore.clearDraft();
118
+ expect(askBuoyStore.getState().draft).toBeNull();
119
+ });
120
+ });
121
+
122
+ /**
123
+ * A restored bubble is marked, because the MODEL does not remember it the way
124
+ * the screen does — see `ChatMessage.restored`.
125
+ */
126
+ describe("hydrate", () => {
127
+ it("marks what it puts back", () => {
128
+ askBuoyStore.hydrate({
129
+ messages: [{
130
+ id: "m1",
131
+ role: "assistant",
132
+ text: "hi",
133
+ toolCalls: [],
134
+ blocks: []
135
+ }],
136
+ answers: {},
137
+ usage: {
138
+ input: 0,
139
+ output: 0,
140
+ requests: 0
141
+ }
142
+ });
143
+ expect(askBuoyStore.getState().messages[0]?.restored).toBe(true);
144
+ });
145
+ it("leaves a live message unmarked", () => {
146
+ askBuoyStore.addUser("live one");
147
+ expect(askBuoyStore.getState().messages[0]?.restored).toBeUndefined();
148
+ });
149
+ });
150
+ //# sourceMappingURL=turnRendering.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["beforeEach","describe","expect","it","askBuoyStore","queuePauseReason","reset","lastText","getState","messages","at","text","id","startAssistant","applyEvent","type","delta","breakBefore","toBe","toolId","action","label","description","params","effect","ok","summary","durationMs","toolCalls","toMatchObject","status","markStopped","m","stopped","error","toBeUndefined","addUser","enqueue","requestStop","finishAssistant","s","queued","map","q","toEqual","toMatch","item","takeQueuedToDraft","draft","clearDraft","toBeNull","hydrate","role","blocks","answers","usage","input","output","requests","restored"],"sourceRoot":"../../../src","sources":["store/turnRendering.test.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAEzD,SAASC,YAAY,EAAEC,gBAAgB,QAAQ,gBAAgB;AAE/DL,UAAU,CAAC,MAAMI,YAAY,CAACE,KAAK,CAAC,CAAC,CAAC;AAEtC,MAAMC,QAAQ,GAAGA,CAAA,KAAMH,YAAY,CAACI,QAAQ,CAAC,CAAC,CAACC,QAAQ,CAACC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAEC,IAAI,IAAI,EAAE;AAE1EV,QAAQ,CAAC,kBAAkB,EAAE,MAAM;EACjCE,EAAE,CAAC,0DAA0D,EAAE,MAAM;IACnE,MAAMS,EAAE,GAAGR,YAAY,CAACS,cAAc,CAAC,CAAC;IACxCT,YAAY,CAACU,UAAU,CAACF,EAAE,EAAE;MAAEG,IAAI,EAAE,MAAM;MAAEC,KAAK,EAAE;IAAsB,CAAC,CAAC;IAC3EZ,YAAY,CAACU,UAAU,CAACF,EAAE,EAAE;MAC1BG,IAAI,EAAE,MAAM;MACZC,KAAK,EAAE,+BAA+B;MACtCC,WAAW,EAAE;IACf,CAAC,CAAC;IACFf,MAAM,CAACK,QAAQ,CAAC,CAAC,CAAC,CAACW,IAAI,CAAC,sDAAsD,CAAC;EACjF,CAAC,CAAC;EAEFf,EAAE,CAAC,yDAAyD,EAAE,MAAM;IAClE,MAAMS,EAAE,GAAGR,YAAY,CAACS,cAAc,CAAC,CAAC;IACxCT,YAAY,CAACU,UAAU,CAACF,EAAE,EAAE;MAAEG,IAAI,EAAE,MAAM;MAAEC,KAAK,EAAE;IAAQ,CAAC,CAAC;IAC7DZ,YAAY,CAACU,UAAU,CAAC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