@buoy-gg/ask-buoy 7.0.41 → 7.0.43

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 (313) hide show
  1. package/README.md +13 -98
  2. package/lib/commonjs/blocks/AskBlocks.js +1 -338
  3. package/lib/commonjs/blocks/BlockRenderer.js +1 -262
  4. package/lib/commonjs/blocks/ChromePrototypes.js +1 -514
  5. package/lib/commonjs/blocks/DataBlocks.js +1 -783
  6. package/lib/commonjs/blocks/ExtraBlocks.js +1 -1862
  7. package/lib/commonjs/blocks/MediaBlocks.js +1 -158
  8. package/lib/commonjs/blocks/ReceiptBlocks.js +2 -592
  9. package/lib/commonjs/blocks/blockText.js +1 -60
  10. package/lib/commonjs/blocks/blockText.test.js +1 -53
  11. package/lib/commonjs/blocks/context.js +1 -42
  12. package/lib/commonjs/blocks/icons.js +1 -96
  13. package/lib/commonjs/blocks/index.js +1 -95
  14. package/lib/commonjs/blocks/listRow.test.js +1 -55
  15. package/lib/commonjs/blocks/pageState.js +1 -34
  16. package/lib/commonjs/blocks/pageState.test.js +1 -57
  17. package/lib/commonjs/blocks/primitives.js +1 -457
  18. package/lib/commonjs/blocks/primitivesIndex.js +1 -62
  19. package/lib/commonjs/blocks/ruleStates.js +1 -39
  20. package/lib/commonjs/components/ApprovalCard.js +1 -297
  21. package/lib/commonjs/components/AskBuoyHeader.js +1 -196
  22. package/lib/commonjs/components/AskBuoyIcon.js +1 -19
  23. package/lib/commonjs/components/AskBuoyModal.js +2 -482
  24. package/lib/commonjs/components/AskBuoySettings.js +1 -181
  25. package/lib/commonjs/components/ChangesBar.js +1 -212
  26. package/lib/commonjs/components/Composer.js +1 -255
  27. package/lib/commonjs/components/EmptyState.js +1 -161
  28. package/lib/commonjs/components/KeyboardPad.js +1 -80
  29. package/lib/commonjs/components/Markdown.js +1 -310
  30. package/lib/commonjs/components/MessageList.js +1 -970
  31. package/lib/commonjs/components/QueuedMessages.js +1 -145
  32. package/lib/commonjs/components/ThinkingStrip.js +1 -223
  33. package/lib/commonjs/components/TypingDots.js +1 -63
  34. package/lib/commonjs/components/markdownParse.js +1 -131
  35. package/lib/commonjs/components/markdownParse.test.js +1 -99
  36. package/lib/commonjs/components/useCopyAction.js +1 -50
  37. package/lib/commonjs/index.js +1 -252
  38. package/lib/commonjs/preset.js +1 -91
  39. package/lib/commonjs/store/activityGroups.js +1 -110
  40. package/lib/commonjs/store/activityGroups.test.js +1 -78
  41. package/lib/commonjs/store/askBuoySettings.js +1 -72
  42. package/lib/commonjs/store/askBuoyStore.js +2 -588
  43. package/lib/commonjs/store/blockPlacement.js +1 -64
  44. package/lib/commonjs/store/blockPlacement.test.js +1 -123
  45. package/lib/commonjs/store/queue.test.js +1 -150
  46. package/lib/commonjs/store/resetConversation.js +1 -77
  47. package/lib/commonjs/store/restorePending.test.js +1 -63
  48. package/lib/commonjs/store/restoredIds.test.js +1 -47
  49. package/lib/commonjs/store/suggestions.js +1 -54
  50. package/lib/commonjs/store/suggestions.test.js +1 -58
  51. package/lib/commonjs/store/systemLine.test.js +1 -77
  52. package/lib/commonjs/store/ticketPrompt.js +1 -17
  53. package/lib/commonjs/store/traceText.js +1 -81
  54. package/lib/commonjs/store/traceText.test.js +1 -112
  55. package/lib/commonjs/store/transcriptPersistence.js +1 -297
  56. package/lib/commonjs/store/transcriptPersistence.test.js +1 -333
  57. package/lib/commonjs/store/turnRendering.test.js +1 -151
  58. package/lib/commonjs/store/useAskBuoy.js +1 -651
  59. package/lib/commonjs/store/useAskBuoySettings.js +1 -14
  60. package/lib/commonjs/sync/askBuoySyncAdapter.js +1 -153
  61. package/lib/commonjs/sync/askBuoySyncAdapter.test.js +1 -141
  62. package/lib/commonjs/sync/wire.js +1 -58
  63. package/lib/commonjs/types.js +1 -6
  64. package/lib/module/blocks/AskBlocks.js +1 -331
  65. package/lib/module/blocks/BlockRenderer.js +1 -257
  66. package/lib/module/blocks/ChromePrototypes.js +1 -503
  67. package/lib/module/blocks/DataBlocks.js +1 -769
  68. package/lib/module/blocks/ExtraBlocks.js +1 -1835
  69. package/lib/module/blocks/MediaBlocks.js +1 -153
  70. package/lib/module/blocks/ReceiptBlocks.js +2 -580
  71. package/lib/module/blocks/blockText.js +1 -55
  72. package/lib/module/blocks/blockText.test.js +1 -53
  73. package/lib/module/blocks/context.js +1 -35
  74. package/lib/module/blocks/icons.js +1 -91
  75. package/lib/module/blocks/index.js +1 -8
  76. package/lib/module/blocks/listRow.test.js +1 -56
  77. package/lib/module/blocks/pageState.js +1 -30
  78. package/lib/module/blocks/pageState.test.js +1 -56
  79. package/lib/module/blocks/primitives.js +1 -445
  80. package/lib/module/blocks/primitivesIndex.js +1 -5
  81. package/lib/module/blocks/ruleStates.js +1 -35
  82. package/lib/module/components/ApprovalCard.js +1 -292
  83. package/lib/module/components/AskBuoyHeader.js +1 -193
  84. package/lib/module/components/AskBuoyIcon.js +1 -8
  85. package/lib/module/components/AskBuoyModal.js +2 -477
  86. package/lib/module/components/AskBuoySettings.js +1 -176
  87. package/lib/module/components/ChangesBar.js +1 -206
  88. package/lib/module/components/Composer.js +1 -250
  89. package/lib/module/components/EmptyState.js +1 -156
  90. package/lib/module/components/KeyboardPad.js +1 -75
  91. package/lib/module/components/Markdown.js +1 -305
  92. package/lib/module/components/MessageList.js +1 -964
  93. package/lib/module/components/QueuedMessages.js +1 -140
  94. package/lib/module/components/ThinkingStrip.js +1 -218
  95. package/lib/module/components/TypingDots.js +1 -58
  96. package/lib/module/components/markdownParse.js +1 -125
  97. package/lib/module/components/markdownParse.test.js +1 -98
  98. package/lib/module/components/useCopyAction.js +1 -46
  99. package/lib/module/index.js +1 -34
  100. package/lib/module/preset.js +1 -74
  101. package/lib/module/store/activityGroups.js +1 -103
  102. package/lib/module/store/activityGroups.test.js +1 -77
  103. package/lib/module/store/askBuoySettings.js +1 -67
  104. package/lib/module/store/askBuoyStore.js +2 -582
  105. package/lib/module/store/blockPlacement.js +1 -59
  106. package/lib/module/store/blockPlacement.test.js +1 -122
  107. package/lib/module/store/queue.test.js +1 -149
  108. package/lib/module/store/resetConversation.js +1 -72
  109. package/lib/module/store/restorePending.test.js +1 -62
  110. package/lib/module/store/restoredIds.test.js +1 -46
  111. package/lib/module/store/suggestions.js +1 -49
  112. package/lib/module/store/suggestions.test.js +1 -57
  113. package/lib/module/store/systemLine.test.js +1 -76
  114. package/lib/module/store/ticketPrompt.js +1 -13
  115. package/lib/module/store/traceText.js +1 -75
  116. package/lib/module/store/traceText.test.js +1 -111
  117. package/lib/module/store/transcriptPersistence.js +1 -287
  118. package/lib/module/store/transcriptPersistence.test.js +1 -332
  119. package/lib/module/store/turnRendering.test.js +1 -150
  120. package/lib/module/store/useAskBuoy.js +1 -646
  121. package/lib/module/store/useAskBuoySettings.js +1 -9
  122. package/lib/module/sync/askBuoySyncAdapter.js +1 -148
  123. package/lib/module/sync/askBuoySyncAdapter.test.js +1 -140
  124. package/lib/module/sync/wire.js +1 -47
  125. package/lib/module/types.js +1 -4
  126. package/lib/web/index.mjs +11 -12
  127. package/package.json +8 -12
  128. package/lib/commonjs/blocks/AskBlocks.js.map +0 -1
  129. package/lib/commonjs/blocks/BlockRenderer.js.map +0 -1
  130. package/lib/commonjs/blocks/ChromePrototypes.js.map +0 -1
  131. package/lib/commonjs/blocks/DataBlocks.js.map +0 -1
  132. package/lib/commonjs/blocks/ExtraBlocks.js.map +0 -1
  133. package/lib/commonjs/blocks/MediaBlocks.js.map +0 -1
  134. package/lib/commonjs/blocks/ReceiptBlocks.js.map +0 -1
  135. package/lib/commonjs/blocks/blockText.js.map +0 -1
  136. package/lib/commonjs/blocks/blockText.test.js.map +0 -1
  137. package/lib/commonjs/blocks/context.js.map +0 -1
  138. package/lib/commonjs/blocks/icons.js.map +0 -1
  139. package/lib/commonjs/blocks/index.js.map +0 -1
  140. package/lib/commonjs/blocks/listRow.test.js.map +0 -1
  141. package/lib/commonjs/blocks/pageState.js.map +0 -1
  142. package/lib/commonjs/blocks/pageState.test.js.map +0 -1
  143. package/lib/commonjs/blocks/primitives.js.map +0 -1
  144. package/lib/commonjs/blocks/primitivesIndex.js.map +0 -1
  145. package/lib/commonjs/blocks/ruleStates.js.map +0 -1
  146. package/lib/commonjs/components/ApprovalCard.js.map +0 -1
  147. package/lib/commonjs/components/AskBuoyHeader.js.map +0 -1
  148. package/lib/commonjs/components/AskBuoyIcon.js.map +0 -1
  149. package/lib/commonjs/components/AskBuoyModal.js.map +0 -1
  150. package/lib/commonjs/components/AskBuoySettings.js.map +0 -1
  151. package/lib/commonjs/components/ChangesBar.js.map +0 -1
  152. package/lib/commonjs/components/Composer.js.map +0 -1
  153. package/lib/commonjs/components/EmptyState.js.map +0 -1
  154. package/lib/commonjs/components/KeyboardPad.js.map +0 -1
  155. package/lib/commonjs/components/Markdown.js.map +0 -1
  156. package/lib/commonjs/components/MessageList.js.map +0 -1
  157. package/lib/commonjs/components/QueuedMessages.js.map +0 -1
  158. package/lib/commonjs/components/ThinkingStrip.js.map +0 -1
  159. package/lib/commonjs/components/TypingDots.js.map +0 -1
  160. package/lib/commonjs/components/markdownParse.js.map +0 -1
  161. package/lib/commonjs/components/markdownParse.test.js.map +0 -1
  162. package/lib/commonjs/components/useCopyAction.js.map +0 -1
  163. package/lib/commonjs/index.js.map +0 -1
  164. package/lib/commonjs/preset.js.map +0 -1
  165. package/lib/commonjs/store/activityGroups.js.map +0 -1
  166. package/lib/commonjs/store/activityGroups.test.js.map +0 -1
  167. package/lib/commonjs/store/askBuoySettings.js.map +0 -1
  168. package/lib/commonjs/store/askBuoyStore.js.map +0 -1
  169. package/lib/commonjs/store/blockPlacement.js.map +0 -1
  170. package/lib/commonjs/store/blockPlacement.test.js.map +0 -1
  171. package/lib/commonjs/store/queue.test.js.map +0 -1
  172. package/lib/commonjs/store/resetConversation.js.map +0 -1
  173. package/lib/commonjs/store/restorePending.test.js.map +0 -1
  174. package/lib/commonjs/store/restoredIds.test.js.map +0 -1
  175. package/lib/commonjs/store/suggestions.js.map +0 -1
  176. package/lib/commonjs/store/suggestions.test.js.map +0 -1
  177. package/lib/commonjs/store/systemLine.test.js.map +0 -1
  178. package/lib/commonjs/store/ticketPrompt.js.map +0 -1
  179. package/lib/commonjs/store/traceText.js.map +0 -1
  180. package/lib/commonjs/store/traceText.test.js.map +0 -1
  181. package/lib/commonjs/store/transcriptPersistence.js.map +0 -1
  182. package/lib/commonjs/store/transcriptPersistence.test.js.map +0 -1
  183. package/lib/commonjs/store/turnRendering.test.js.map +0 -1
  184. package/lib/commonjs/store/useAskBuoy.js.map +0 -1
  185. package/lib/commonjs/store/useAskBuoySettings.js.map +0 -1
  186. package/lib/commonjs/sync/askBuoySyncAdapter.js.map +0 -1
  187. package/lib/commonjs/sync/askBuoySyncAdapter.test.js.map +0 -1
  188. package/lib/commonjs/sync/wire.js.map +0 -1
  189. package/lib/commonjs/types.js.map +0 -1
  190. package/lib/module/blocks/AskBlocks.js.map +0 -1
  191. package/lib/module/blocks/BlockRenderer.js.map +0 -1
  192. package/lib/module/blocks/ChromePrototypes.js.map +0 -1
  193. package/lib/module/blocks/DataBlocks.js.map +0 -1
  194. package/lib/module/blocks/ExtraBlocks.js.map +0 -1
  195. package/lib/module/blocks/MediaBlocks.js.map +0 -1
  196. package/lib/module/blocks/ReceiptBlocks.js.map +0 -1
  197. package/lib/module/blocks/blockText.js.map +0 -1
  198. package/lib/module/blocks/blockText.test.js.map +0 -1
  199. package/lib/module/blocks/context.js.map +0 -1
  200. package/lib/module/blocks/icons.js.map +0 -1
  201. package/lib/module/blocks/index.js.map +0 -1
  202. package/lib/module/blocks/listRow.test.js.map +0 -1
  203. package/lib/module/blocks/pageState.js.map +0 -1
  204. package/lib/module/blocks/pageState.test.js.map +0 -1
  205. package/lib/module/blocks/primitives.js.map +0 -1
  206. package/lib/module/blocks/primitivesIndex.js.map +0 -1
  207. package/lib/module/blocks/ruleStates.js.map +0 -1
  208. package/lib/module/components/ApprovalCard.js.map +0 -1
  209. package/lib/module/components/AskBuoyHeader.js.map +0 -1
  210. package/lib/module/components/AskBuoyIcon.js.map +0 -1
  211. package/lib/module/components/AskBuoyModal.js.map +0 -1
  212. package/lib/module/components/AskBuoySettings.js.map +0 -1
  213. package/lib/module/components/ChangesBar.js.map +0 -1
  214. package/lib/module/components/Composer.js.map +0 -1
  215. package/lib/module/components/EmptyState.js.map +0 -1
  216. package/lib/module/components/KeyboardPad.js.map +0 -1
  217. package/lib/module/components/Markdown.js.map +0 -1
  218. package/lib/module/components/MessageList.js.map +0 -1
  219. package/lib/module/components/QueuedMessages.js.map +0 -1
  220. package/lib/module/components/ThinkingStrip.js.map +0 -1
  221. package/lib/module/components/TypingDots.js.map +0 -1
  222. package/lib/module/components/markdownParse.js.map +0 -1
  223. package/lib/module/components/markdownParse.test.js.map +0 -1
  224. package/lib/module/components/useCopyAction.js.map +0 -1
  225. package/lib/module/index.js.map +0 -1
  226. package/lib/module/preset.js.map +0 -1
  227. package/lib/module/store/activityGroups.js.map +0 -1
  228. package/lib/module/store/activityGroups.test.js.map +0 -1
  229. package/lib/module/store/askBuoySettings.js.map +0 -1
  230. package/lib/module/store/askBuoyStore.js.map +0 -1
  231. package/lib/module/store/blockPlacement.js.map +0 -1
  232. package/lib/module/store/blockPlacement.test.js.map +0 -1
  233. package/lib/module/store/queue.test.js.map +0 -1
  234. package/lib/module/store/resetConversation.js.map +0 -1
  235. package/lib/module/store/restorePending.test.js.map +0 -1
  236. package/lib/module/store/restoredIds.test.js.map +0 -1
  237. package/lib/module/store/suggestions.js.map +0 -1
  238. package/lib/module/store/suggestions.test.js.map +0 -1
  239. package/lib/module/store/systemLine.test.js.map +0 -1
  240. package/lib/module/store/ticketPrompt.js.map +0 -1
  241. package/lib/module/store/traceText.js.map +0 -1
  242. package/lib/module/store/traceText.test.js.map +0 -1
  243. package/lib/module/store/transcriptPersistence.js.map +0 -1
  244. package/lib/module/store/transcriptPersistence.test.js.map +0 -1
  245. package/lib/module/store/turnRendering.test.js.map +0 -1
  246. package/lib/module/store/useAskBuoy.js.map +0 -1
  247. package/lib/module/store/useAskBuoySettings.js.map +0 -1
  248. package/lib/module/sync/askBuoySyncAdapter.js.map +0 -1
  249. package/lib/module/sync/askBuoySyncAdapter.test.js.map +0 -1
  250. package/lib/module/sync/wire.js.map +0 -1
  251. package/lib/module/types.js.map +0 -1
  252. package/lib/typescript/blocks/AskBlocks.d.ts.map +0 -1
  253. package/lib/typescript/blocks/BlockRenderer.d.ts.map +0 -1
  254. package/lib/typescript/blocks/ChromePrototypes.d.ts.map +0 -1
  255. package/lib/typescript/blocks/DataBlocks.d.ts.map +0 -1
  256. package/lib/typescript/blocks/ExtraBlocks.d.ts.map +0 -1
  257. package/lib/typescript/blocks/MediaBlocks.d.ts.map +0 -1
  258. package/lib/typescript/blocks/ReceiptBlocks.d.ts.map +0 -1
  259. package/lib/typescript/blocks/blockText.d.ts.map +0 -1
  260. package/lib/typescript/blocks/blockText.test.d.ts.map +0 -1
  261. package/lib/typescript/blocks/context.d.ts.map +0 -1
  262. package/lib/typescript/blocks/icons.d.ts.map +0 -1
  263. package/lib/typescript/blocks/index.d.ts.map +0 -1
  264. package/lib/typescript/blocks/listRow.test.d.ts.map +0 -1
  265. package/lib/typescript/blocks/pageState.d.ts.map +0 -1
  266. package/lib/typescript/blocks/pageState.test.d.ts.map +0 -1
  267. package/lib/typescript/blocks/primitives.d.ts.map +0 -1
  268. package/lib/typescript/blocks/primitivesIndex.d.ts.map +0 -1
  269. package/lib/typescript/blocks/ruleStates.d.ts.map +0 -1
  270. package/lib/typescript/components/ApprovalCard.d.ts.map +0 -1
  271. package/lib/typescript/components/AskBuoyHeader.d.ts.map +0 -1
  272. package/lib/typescript/components/AskBuoyIcon.d.ts.map +0 -1
  273. package/lib/typescript/components/AskBuoyModal.d.ts.map +0 -1
  274. package/lib/typescript/components/AskBuoySettings.d.ts.map +0 -1
  275. package/lib/typescript/components/ChangesBar.d.ts.map +0 -1
  276. package/lib/typescript/components/Composer.d.ts.map +0 -1
  277. package/lib/typescript/components/EmptyState.d.ts.map +0 -1
  278. package/lib/typescript/components/KeyboardPad.d.ts.map +0 -1
  279. package/lib/typescript/components/Markdown.d.ts.map +0 -1
  280. package/lib/typescript/components/MessageList.d.ts.map +0 -1
  281. package/lib/typescript/components/QueuedMessages.d.ts.map +0 -1
  282. package/lib/typescript/components/ThinkingStrip.d.ts.map +0 -1
  283. package/lib/typescript/components/TypingDots.d.ts.map +0 -1
  284. package/lib/typescript/components/markdownParse.d.ts.map +0 -1
  285. package/lib/typescript/components/markdownParse.test.d.ts.map +0 -1
  286. package/lib/typescript/components/useCopyAction.d.ts.map +0 -1
  287. package/lib/typescript/index.d.ts.map +0 -1
  288. package/lib/typescript/preset.d.ts.map +0 -1
  289. package/lib/typescript/store/activityGroups.d.ts.map +0 -1
  290. package/lib/typescript/store/activityGroups.test.d.ts.map +0 -1
  291. package/lib/typescript/store/askBuoySettings.d.ts.map +0 -1
  292. package/lib/typescript/store/askBuoyStore.d.ts.map +0 -1
  293. package/lib/typescript/store/blockPlacement.d.ts.map +0 -1
  294. package/lib/typescript/store/blockPlacement.test.d.ts.map +0 -1
  295. package/lib/typescript/store/queue.test.d.ts.map +0 -1
  296. package/lib/typescript/store/resetConversation.d.ts.map +0 -1
  297. package/lib/typescript/store/restorePending.test.d.ts.map +0 -1
  298. package/lib/typescript/store/restoredIds.test.d.ts.map +0 -1
  299. package/lib/typescript/store/suggestions.d.ts.map +0 -1
  300. package/lib/typescript/store/suggestions.test.d.ts.map +0 -1
  301. package/lib/typescript/store/systemLine.test.d.ts.map +0 -1
  302. package/lib/typescript/store/ticketPrompt.d.ts.map +0 -1
  303. package/lib/typescript/store/traceText.d.ts.map +0 -1
  304. package/lib/typescript/store/traceText.test.d.ts.map +0 -1
  305. package/lib/typescript/store/transcriptPersistence.d.ts.map +0 -1
  306. package/lib/typescript/store/transcriptPersistence.test.d.ts.map +0 -1
  307. package/lib/typescript/store/turnRendering.test.d.ts.map +0 -1
  308. package/lib/typescript/store/useAskBuoy.d.ts.map +0 -1
  309. package/lib/typescript/store/useAskBuoySettings.d.ts.map +0 -1
  310. package/lib/typescript/sync/askBuoySyncAdapter.d.ts.map +0 -1
  311. package/lib/typescript/sync/askBuoySyncAdapter.test.d.ts.map +0 -1
  312. package/lib/typescript/sync/wire.d.ts.map +0 -1
  313. package/lib/typescript/types.d.ts.map +0 -1
@@ -1,140 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * Messages typed while the agent was working, waiting their turn.
5
- *
6
- * Visible because the alternative was a placeholder. The queue used to be one
7
- * string behind the composer's "Queued — sends when this turn finishes" hint:
8
- * a second message typed mid-turn silently replaced the first, and nothing on
9
- * screen could have told you. A list you can see is a list you can trust.
10
- *
11
- * Each row: the text (capped at three lines), tap to pull it back into the
12
- * composer to edit, ✕ to drop it. The hint underneath says whether the queue
13
- * is delivering or why it is holding — see `queuePauseReason` in the store.
14
- *
15
- * Height is bounded, so a long queue can never push the approval card or the
16
- * Stop button off the bottom of the sheet.
17
- */
18
- import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native";
19
- import { night, X } from "@buoy-gg/shared-ui";
20
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
21
- /** Three rows, then it scrolls. */
22
- const MAX_LIST_HEIGHT = 132;
23
- export function QueuedMessages({
24
- items,
25
- paused,
26
- onEdit,
27
- onRemove
28
- }) {
29
- if (items.length === 0) return null;
30
- return /*#__PURE__*/_jsxs(View, {
31
- style: styles.wrap,
32
- testID: "buoy-ask-buoy-queued",
33
- children: [/*#__PURE__*/_jsx(ScrollView, {
34
- style: styles.list,
35
- contentContainerStyle: styles.listContent,
36
- keyboardShouldPersistTaps: "handled",
37
- children: items.map((item, i) => /*#__PURE__*/_jsxs(View, {
38
- style: [styles.row, paused !== null && styles.rowPaused],
39
- children: [/*#__PURE__*/_jsxs(Pressable, {
40
- testID: `buoy-ask-buoy-queue-item-${i}`,
41
- accessibilityRole: "button",
42
- accessibilityLabel: `Edit queued message: ${item.text}`,
43
- onPress: () => onEdit(item.id),
44
- style: ({
45
- pressed
46
- }) => [styles.rowBody, pressed && styles.pressed],
47
- children: [/*#__PURE__*/_jsx(Text, {
48
- style: styles.ordinal,
49
- children: i === 0 ? "NEXT" : "THEN"
50
- }), /*#__PURE__*/_jsx(Text, {
51
- style: styles.text,
52
- numberOfLines: 3,
53
- children: item.text
54
- })]
55
- }), /*#__PURE__*/_jsx(Pressable, {
56
- testID: `buoy-ask-buoy-queue-remove-${i}`,
57
- accessibilityRole: "button",
58
- accessibilityLabel: "Remove queued message",
59
- onPress: () => onRemove(item.id),
60
- hitSlop: 8,
61
- style: ({
62
- pressed
63
- }) => [styles.remove, pressed && styles.pressed],
64
- children: /*#__PURE__*/_jsx(X, {
65
- size: 11,
66
- color: night.color.textTertiary
67
- })
68
- })]
69
- }, item.id))
70
- }), /*#__PURE__*/_jsx(Text, {
71
- style: [styles.hint, paused !== null && styles.hintPaused],
72
- testID: "buoy-ask-buoy-queue-hint",
73
- children: paused ?? "Sends one at a time when this turn finishes · tap to edit"
74
- })]
75
- });
76
- }
77
- const styles = StyleSheet.create({
78
- wrap: {
79
- paddingHorizontal: night.gutter,
80
- paddingTop: 8,
81
- gap: 6,
82
- // Opaque, like the composer: the transcript scrolls under it.
83
- backgroundColor: night.color.bg
84
- },
85
- list: {
86
- maxHeight: MAX_LIST_HEIGHT
87
- },
88
- listContent: {
89
- gap: 6
90
- },
91
- row: {
92
- flexDirection: "row",
93
- alignItems: "center",
94
- borderRadius: night.radius.row,
95
- borderWidth: StyleSheet.hairlineWidth,
96
- borderColor: night.color.border,
97
- backgroundColor: night.color.surface
98
- },
99
- rowPaused: {
100
- borderColor: night.color.warning
101
- },
102
- rowBody: {
103
- flex: 1,
104
- flexDirection: "row",
105
- alignItems: "center",
106
- gap: 8,
107
- paddingVertical: 7,
108
- paddingLeft: 10
109
- },
110
- ordinal: {
111
- color: night.color.textTertiary,
112
- fontSize: 9,
113
- fontWeight: "700",
114
- letterSpacing: 0.6,
115
- width: 30
116
- },
117
- text: {
118
- flex: 1,
119
- color: night.color.textSecondary,
120
- fontSize: night.font.caption,
121
- lineHeight: 17
122
- },
123
- remove: {
124
- width: 32,
125
- height: 32,
126
- alignItems: "center",
127
- justifyContent: "center"
128
- },
129
- pressed: {
130
- opacity: 0.7
131
- },
132
- hint: {
133
- color: night.color.textTertiary,
134
- fontSize: night.font.micro
135
- },
136
- hintPaused: {
137
- color: night.color.warning
138
- }
139
- });
140
- //# sourceMappingURL=QueuedMessages.js.map
1
+ "use strict";import{Pressable as c,ScrollView as g,StyleSheet as u,Text as l,View as h}from"react-native";import{night as e,X as p}from"@buoy-gg/shared-ui";import{jsx as o,jsxs as a}from"react/jsx-runtime";const f=132;export function QueuedMessages({items:d,paused:i,onEdit:y,onRemove:b}){if(d.length===0)return null;return a(h,{style:t.wrap,testID:"buoy-ask-buoy-queued",children:[o(g,{style:t.list,contentContainerStyle:t.listContent,keyboardShouldPersistTaps:"handled",children:d.map((r,n)=>a(h,{style:[t.row,i!==null&&t.rowPaused],children:[a(c,{testID:`buoy-ask-buoy-queue-item-${n}`,accessibilityRole:"button",accessibilityLabel:`Edit queued message: ${r.text}`,onPress:()=>y(r.id),style:({pressed:s})=>[t.rowBody,s&&t.pressed],children:[o(l,{style:t.ordinal,children:n===0?"NEXT":"THEN"}),o(l,{style:t.text,numberOfLines:3,children:r.text})]}),o(c,{testID:`buoy-ask-buoy-queue-remove-${n}`,accessibilityRole:"button",accessibilityLabel:"Remove queued message",onPress:()=>b(r.id),hitSlop:8,style:({pressed:s})=>[t.remove,s&&t.pressed],children:o(p,{size:11,color:e.color.textTertiary})})]},r.id))}),o(l,{style:[t.hint,i!==null&&t.hintPaused],testID:"buoy-ask-buoy-queue-hint",children:i??"Sends one at a time when this turn finishes \xB7 tap to edit"})]})}const t=u.create({wrap:{paddingHorizontal:e.gutter,paddingTop:8,gap:6,backgroundColor:e.color.bg},list:{maxHeight:f},listContent:{gap:6},row:{flexDirection:"row",alignItems:"center",borderRadius:e.radius.row,borderWidth:u.hairlineWidth,borderColor:e.color.border,backgroundColor:e.color.surface},rowPaused:{borderColor:e.color.warning},rowBody:{flex:1,flexDirection:"row",alignItems:"center",gap:8,paddingVertical:7,paddingLeft:10},ordinal:{color:e.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.6,width:30},text:{flex:1,color:e.color.textSecondary,fontSize:e.font.caption,lineHeight:17},remove:{width:32,height:32,alignItems:"center",justifyContent:"center"},pressed:{opacity:.7},hint:{color:e.color.textTertiary,fontSize:e.font.micro},hintPaused:{color:e.color.warning}});
@@ -1,218 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * The agent's own working, under an answer, collapsed by default.
5
- *
6
- * Collapsed is the whole design constraint. A multi-step turn's reasoning is
7
- * longer than the answer it produced, and rendered open it pushes the answer —
8
- * the thing the user came for — off the screen. So the strip is one line until
9
- * someone wants it, and the summary on that line ("3 steps · 2 thoughts") is
10
- * enough to tell whether opening it is worth it.
11
- *
12
- * Every step is expandable on its own too, because the parameters are the
13
- * useful part when hunting a bug and the tool name alone is not.
14
- */
15
- import { useState } from "react";
16
- import { Pressable, StyleSheet, Text, View } from "react-native";
17
- import { Activity, ChevronDown, ChevronRight, night } from "@buoy-gg/shared-ui";
18
- import { hasTrace, traceEntries } from "../store/traceText";
19
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
20
- function StepRow({
21
- n,
22
- call
23
- }) {
24
- const [open, setOpen] = useState(false);
25
- const failed = call.status === "failed" || call.status === "refused";
26
- return /*#__PURE__*/_jsxs(Pressable, {
27
- onPress: () => setOpen(v => !v),
28
- accessibilityRole: "button",
29
- accessibilityState: {
30
- expanded: open
31
- },
32
- style: styles.step,
33
- children: [/*#__PURE__*/_jsxs(View, {
34
- style: styles.stepLine,
35
- children: [/*#__PURE__*/_jsx(Text, {
36
- style: styles.stepN,
37
- children: n
38
- }), /*#__PURE__*/_jsxs(Text, {
39
- style: [styles.stepName, failed && styles.stepFailed],
40
- numberOfLines: 1,
41
- children: [call.toolId, ".", call.action]
42
- }), call.durationMs !== undefined ? /*#__PURE__*/_jsxs(Text, {
43
- style: styles.stepMs,
44
- children: [call.durationMs, "ms"]
45
- }) : null, /*#__PURE__*/_jsx(Text, {
46
- style: [styles.stepStatus, failed && styles.stepFailed],
47
- numberOfLines: 1,
48
- children: call.status === "ok" ? call.summary || "done" : call.status
49
- })]
50
- }), open ? /*#__PURE__*/_jsxs(View, {
51
- style: styles.detail,
52
- children: [/*#__PURE__*/_jsx(Text, {
53
- style: styles.detailLabel,
54
- children: "SENT"
55
- }), /*#__PURE__*/_jsx(Text, {
56
- style: styles.code,
57
- selectable: true,
58
- children: call.params ?? "no parameters"
59
- }), call.result ? /*#__PURE__*/_jsxs(_Fragment, {
60
- children: [/*#__PURE__*/_jsx(Text, {
61
- style: styles.detailLabel,
62
- children: "RETURNED"
63
- }), /*#__PURE__*/_jsx(Text, {
64
- style: styles.code,
65
- selectable: true,
66
- children: call.result
67
- })]
68
- }) : null]
69
- }) : null]
70
- });
71
- }
72
- export function ThinkingStrip({
73
- message
74
- }) {
75
- const [open, setOpen] = useState(false);
76
- if (!hasTrace(message)) return null;
77
- const entries = traceEntries(message);
78
- const steps = entries.filter(e => e.kind === "step").length;
79
- const thoughts = entries.length - steps;
80
- const wall = message.startedAt !== undefined && message.endedAt !== undefined ? `${((message.endedAt - message.startedAt) / 1000).toFixed(1)}s` : null;
81
- const summary = [steps ? `${steps} step${steps === 1 ? "" : "s"}` : null, thoughts ? `${thoughts} thought${thoughts === 1 ? "" : "s"}` : null, wall, message.usage ? `${message.usage.input + message.usage.output} tokens` : null].filter(Boolean).join(" · ");
82
- return /*#__PURE__*/_jsxs(View, {
83
- style: styles.wrap,
84
- testID: "buoy-ask-buoy-thinking",
85
- children: [/*#__PURE__*/_jsxs(Pressable, {
86
- testID: "buoy-ask-buoy-thinking-toggle",
87
- onPress: () => setOpen(v => !v),
88
- accessibilityRole: "button",
89
- accessibilityLabel: open ? "Hide agent thinking" : "Show agent thinking",
90
- accessibilityState: {
91
- expanded: open
92
- },
93
- style: styles.head,
94
- children: [/*#__PURE__*/_jsx(Activity, {
95
- size: 12,
96
- color: night.color.textTertiary
97
- }), /*#__PURE__*/_jsx(Text, {
98
- style: styles.headText,
99
- children: summary
100
- }), open ? /*#__PURE__*/_jsx(ChevronDown, {
101
- size: 12,
102
- color: night.color.textTertiary
103
- }) : /*#__PURE__*/_jsx(ChevronRight, {
104
- size: 12,
105
- color: night.color.textTertiary
106
- })]
107
- }), open ? /*#__PURE__*/_jsxs(View, {
108
- style: styles.body,
109
- children: [entries.map((entry, i) => entry.kind === "thought" ? /*#__PURE__*/_jsx(Text, {
110
- style: styles.thought,
111
- selectable: true,
112
- children: entry.text.trim()
113
- }, `t${i}`) : /*#__PURE__*/_jsx(StepRow, {
114
- n: entry.n,
115
- call: entry.call
116
- }, entry.call.id)), thoughts === 0 ?
117
- /*#__PURE__*/
118
- // Said plainly, because an empty reasoning section reads as broken.
119
- // Most models report none: Claude thinks by default, gpt-4.1 never.
120
- _jsx(Text, {
121
- style: styles.none,
122
- children: "This model reports no reasoning \u2014 the steps above are the whole trace."
123
- }) : null]
124
- }) : null]
125
- });
126
- }
127
- const styles = StyleSheet.create({
128
- wrap: {
129
- marginTop: 8,
130
- borderRadius: night.radius.badge,
131
- borderWidth: StyleSheet.hairlineWidth,
132
- borderColor: night.color.separator,
133
- backgroundColor: night.color.fill,
134
- overflow: "hidden"
135
- },
136
- head: {
137
- flexDirection: "row",
138
- alignItems: "center",
139
- gap: 6,
140
- paddingHorizontal: 10,
141
- paddingVertical: 7
142
- },
143
- headText: {
144
- flex: 1,
145
- color: night.color.textTertiary,
146
- fontSize: night.font.micro,
147
- fontWeight: "600"
148
- },
149
- body: {
150
- borderTopWidth: StyleSheet.hairlineWidth,
151
- borderTopColor: night.color.separator
152
- },
153
- thought: {
154
- color: night.color.textSecondary,
155
- fontSize: night.font.micro,
156
- lineHeight: 17,
157
- fontStyle: "italic",
158
- paddingHorizontal: 10,
159
- paddingVertical: 8
160
- },
161
- step: {
162
- paddingHorizontal: 10,
163
- paddingVertical: 7
164
- },
165
- stepLine: {
166
- flexDirection: "row",
167
- alignItems: "center",
168
- gap: 8
169
- },
170
- stepN: {
171
- color: night.color.textTertiary,
172
- fontSize: night.font.micro,
173
- width: 14
174
- },
175
- stepName: {
176
- flex: 1,
177
- color: night.color.textSecondary,
178
- fontSize: night.font.micro,
179
- fontWeight: "600"
180
- },
181
- stepMs: {
182
- color: night.color.textTertiary,
183
- fontSize: night.font.micro
184
- },
185
- stepStatus: {
186
- color: night.color.textTertiary,
187
- fontSize: night.font.micro,
188
- maxWidth: 110
189
- },
190
- stepFailed: {
191
- color: night.color.danger
192
- },
193
- detail: {
194
- marginTop: 6,
195
- marginLeft: 22,
196
- gap: 3
197
- },
198
- detailLabel: {
199
- color: night.color.textTertiary,
200
- fontSize: 9,
201
- fontWeight: "700",
202
- letterSpacing: 0.5
203
- },
204
- code: {
205
- color: night.color.textSecondary,
206
- fontSize: night.font.micro,
207
- lineHeight: 16,
208
- marginBottom: 3
209
- },
210
- none: {
211
- color: night.color.textTertiary,
212
- fontSize: night.font.micro,
213
- fontStyle: "italic",
214
- paddingHorizontal: 10,
215
- paddingVertical: 8
216
- }
217
- });
218
- //# sourceMappingURL=ThinkingStrip.js.map
1
+ "use strict";import{useState as f}from"react";import{Pressable as y,StyleSheet as u,Text as n,View as p}from"react-native";import{Activity as x,ChevronDown as S,ChevronRight as T,night as t}from"@buoy-gg/shared-ui";import{hasTrace as z,traceEntries as k}from"../store/traceText";import{jsx as i,jsxs as s,Fragment as w}from"react/jsx-runtime";function L({n:r,call:o}){const[h,c]=f(false);const a=o.status==="failed"||o.status==="refused";return s(y,{onPress:()=>c(d=>!d),accessibilityRole:"button",accessibilityState:{expanded:h},style:e.step,children:[s(p,{style:e.stepLine,children:[i(n,{style:e.stepN,children:r}),s(n,{style:[e.stepName,a&&e.stepFailed],numberOfLines:1,children:[o.toolId,".",o.action]}),o.durationMs!==void 0?s(n,{style:e.stepMs,children:[o.durationMs,"ms"]}):null,i(n,{style:[e.stepStatus,a&&e.stepFailed],numberOfLines:1,children:o.status==="ok"?o.summary||"done":o.status})]}),h?s(p,{style:e.detail,children:[i(n,{style:e.detailLabel,children:"SENT"}),i(n,{style:e.code,selectable:true,children:o.params??"no parameters"}),o.result?s(w,{children:[i(n,{style:e.detailLabel,children:"RETURNED"}),i(n,{style:e.code,selectable:true,children:o.result})]}):null]}):null]})}export function ThinkingStrip({message:r}){const[o,h]=f(false);if(!z(r))return null;const c=k(r);const a=c.filter(l=>l.kind==="step").length;const d=c.length-a;const g=r.startedAt!==void 0&&r.endedAt!==void 0?`${((r.endedAt-r.startedAt)/1e3).toFixed(1)}s`:null;const m=[a?`${a} step${a===1?"":"s"}`:null,d?`${d} thought${d===1?"":"s"}`:null,g,r.usage?`${r.usage.input+r.usage.output} tokens`:null].filter(Boolean).join(" \xB7 ");return s(p,{style:e.wrap,testID:"buoy-ask-buoy-thinking",children:[s(y,{testID:"buoy-ask-buoy-thinking-toggle",onPress:()=>h(l=>!l),accessibilityRole:"button",accessibilityLabel:o?"Hide agent thinking":"Show agent thinking",accessibilityState:{expanded:o},style:e.head,children:[i(x,{size:12,color:t.color.textTertiary}),i(n,{style:e.headText,children:m}),o?i(S,{size:12,color:t.color.textTertiary}):i(T,{size:12,color:t.color.textTertiary})]}),o?s(p,{style:e.body,children:[c.map((l,b)=>l.kind==="thought"?i(n,{style:e.thought,selectable:true,children:l.text.trim()},`t${b}`):i(L,{n:l.n,call:l.call},l.call.id)),d===0?i(n,{style:e.none,children:"This model reports no reasoning \u2014 the steps above are the whole trace."}):null]}):null]})}const e=u.create({wrap:{marginTop:8,borderRadius:t.radius.badge,borderWidth:u.hairlineWidth,borderColor:t.color.separator,backgroundColor:t.color.fill,overflow:"hidden"},head:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:7},headText:{flex:1,color:t.color.textTertiary,fontSize:t.font.micro,fontWeight:"600"},body:{borderTopWidth:u.hairlineWidth,borderTopColor:t.color.separator},thought:{color:t.color.textSecondary,fontSize:t.font.micro,lineHeight:17,fontStyle:"italic",paddingHorizontal:10,paddingVertical:8},step:{paddingHorizontal:10,paddingVertical:7},stepLine:{flexDirection:"row",alignItems:"center",gap:8},stepN:{color:t.color.textTertiary,fontSize:t.font.micro,width:14},stepName:{flex:1,color:t.color.textSecondary,fontSize:t.font.micro,fontWeight:"600"},stepMs:{color:t.color.textTertiary,fontSize:t.font.micro},stepStatus:{color:t.color.textTertiary,fontSize:t.font.micro,maxWidth:110},stepFailed:{color:t.color.danger},detail:{marginTop:6,marginLeft:22,gap:3},detailLabel:{color:t.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5},code:{color:t.color.textSecondary,fontSize:t.font.micro,lineHeight:16,marginBottom:3},none:{color:t.color.textTertiary,fontSize:t.font.micro,fontStyle:"italic",paddingHorizontal:10,paddingVertical:8}});
@@ -1,58 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * Three pulsing dots — the "it heard you" signal between sending a message
5
- * and the first streamed token. A static "…" glyph read as a finished (and
6
- * confusing) answer.
7
- *
8
- * Native-driver opacity only, so it costs the JS thread nothing while the
9
- * stream that replaces it is being parsed.
10
- */
11
- import { useEffect, useRef } from "react";
12
- import { Animated, Easing, StyleSheet, View } from "react-native";
13
- import { night } from "@buoy-gg/shared-ui";
14
- import { jsx as _jsx } from "react/jsx-runtime";
15
- export function TypingDots() {
16
- const dots = useRef([0, 1, 2].map(() => new Animated.Value(0.25))).current;
17
- useEffect(() => {
18
- const loops = dots.map((v, i) => Animated.loop(Animated.sequence([Animated.delay(i * 140), Animated.timing(v, {
19
- toValue: 1,
20
- duration: 320,
21
- easing: Easing.inOut(Easing.ease),
22
- useNativeDriver: true
23
- }), Animated.timing(v, {
24
- toValue: 0.25,
25
- duration: 320,
26
- easing: Easing.inOut(Easing.ease),
27
- useNativeDriver: true
28
- }), Animated.delay((2 - i) * 140)])));
29
- loops.forEach(l => l.start());
30
- return () => loops.forEach(l => l.stop());
31
- }, [dots]);
32
- return /*#__PURE__*/_jsx(View, {
33
- style: styles.wrap,
34
- testID: "buoy-ask-buoy-typing",
35
- accessibilityLabel: "Thinking",
36
- children: dots.map((v, i) => /*#__PURE__*/_jsx(Animated.View, {
37
- style: [styles.dot, {
38
- opacity: v
39
- }]
40
- }, i))
41
- });
42
- }
43
- const styles = StyleSheet.create({
44
- wrap: {
45
- flexDirection: "row",
46
- alignItems: "center",
47
- gap: 5,
48
- paddingVertical: 8,
49
- paddingHorizontal: 2
50
- },
51
- dot: {
52
- width: 7,
53
- height: 7,
54
- borderRadius: 4,
55
- backgroundColor: night.color.textSecondary
56
- }
57
- });
58
- //# sourceMappingURL=TypingDots.js.map
1
+ "use strict";import{useEffect as u,useRef as c}from"react";import{Animated as t,Easing as o,StyleSheet as l,View as p}from"react-native";import{night as d}from"@buoy-gg/shared-ui";import{jsx as n}from"react/jsx-runtime";export function TypingDots(){const r=c([0,1,2].map(()=>new t.Value(.25))).current;u(()=>{const i=r.map((e,a)=>t.loop(t.sequence([t.delay(a*140),t.timing(e,{toValue:1,duration:320,easing:o.inOut(o.ease),useNativeDriver:true}),t.timing(e,{toValue:.25,duration:320,easing:o.inOut(o.ease),useNativeDriver:true}),t.delay((2-a)*140)])));i.forEach(e=>e.start());return()=>i.forEach(e=>e.stop())},[r]);return n(p,{style:s.wrap,testID:"buoy-ask-buoy-typing",accessibilityLabel:"Thinking",children:r.map((i,e)=>n(t.View,{style:[s.dot,{opacity:i}]},e))})}const s=l.create({wrap:{flexDirection:"row",alignItems:"center",gap:5,paddingVertical:8,paddingHorizontal:2},dot:{width:7,height:7,borderRadius:4,backgroundColor:d.color.textSecondary}});
@@ -1,125 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * The Markdown parser, kept apart from the renderer so it can be unit-tested
5
- * without React Native.
6
- *
7
- * Just enough for a chat answer: paragraphs, `-`/`*`/`1.` lists, `#` headings,
8
- * pipe tables, and fenced code. Anything it does not understand falls through
9
- * as plain text, never as a blank.
10
- */
11
-
12
- const isTableRow = l => /^\s*\|.*\|\s*$/.test(l);
13
- const isTableRule = l => /^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(l);
14
- const splitRow = l => l.trim().replace(/^\|/, "").replace(/\|$/, "").split("|").map(c => c.trim());
15
- const FENCE = /^\s*```\s*([\w+-]*)\s*$/;
16
- export function parseBlocks(source) {
17
- const blocks = [];
18
- let para = [];
19
- const flush = () => {
20
- if (para.length) blocks.push({
21
- kind: "p",
22
- text: para.join(" ")
23
- });
24
- para = [];
25
- };
26
- const lines = source.split("\n");
27
- for (let li = 0; li < lines.length; li++) {
28
- const raw = lines[li];
29
- const line = raw.replace(/\s+$/, "");
30
-
31
- // A fence opens a block that keeps its newlines and indentation — the
32
- // one place in a chat answer where whitespace IS the content (JSON, a
33
- // stack trace, a repro). Fences used to be unknown to this parser, so the
34
- // lines were joined into a paragraph with the backticks shown literally.
35
- const fence = FENCE.exec(line);
36
- if (fence) {
37
- flush();
38
- const body = [];
39
- let j = li + 1;
40
- let closed = false;
41
- while (j < lines.length) {
42
- if (/^\s*```\s*$/.test(lines[j])) {
43
- closed = true;
44
- break;
45
- }
46
- body.push(lines[j]);
47
- j++;
48
- }
49
- blocks.push({
50
- kind: "code",
51
- lang: fence[1] ?? "",
52
- text: body.join("\n"),
53
- closed
54
- });
55
- li = closed ? j : lines.length;
56
- continue;
57
- }
58
- if (!line.trim()) {
59
- flush();
60
- continue;
61
- }
62
- // A pipe table: header row, a rule row, then body rows.
63
- if (isTableRow(line) && lines[li + 1] && isTableRule(lines[li + 1])) {
64
- flush();
65
- const header = splitRow(line);
66
- const rows = [];
67
- let j = li + 2;
68
- while (j < lines.length && isTableRow(lines[j])) {
69
- rows.push(splitRow(lines[j]));
70
- j++;
71
- }
72
- blocks.push({
73
- kind: "table",
74
- header,
75
- rows
76
- });
77
- li = j - 1;
78
- continue;
79
- }
80
- const heading = /^#{1,6}\s+(.*)$/.exec(line);
81
- if (heading) {
82
- flush();
83
- blocks.push({
84
- kind: "h",
85
- text: heading[1]
86
- });
87
- continue;
88
- }
89
- const bullet = /^(\s*)([-*•]|\d+[.)])\s+(.*)$/.exec(line);
90
- if (bullet) {
91
- flush();
92
- const depth = Math.min(2, Math.floor(bullet[1].length / 2));
93
- const marker = /^\d/.test(bullet[2]) ? bullet[2].replace(")", ".") : "•";
94
- blocks.push({
95
- kind: "li",
96
- text: bullet[3],
97
- marker,
98
- depth
99
- });
100
- continue;
101
- }
102
- para.push(line.trim());
103
- }
104
- flush();
105
- return blocks;
106
- }
107
-
108
- /** The preview a table is cut to. Past this it says so and offers the rest. */
109
- export const TABLE_PREVIEW_ROWS = 12;
110
- export const TABLE_PREVIEW_COLS = 4;
111
-
112
- /**
113
- * What a table preview leaves out, in the user's words — or null when nothing.
114
- *
115
- * The renderer used to slice to 4 columns and 12 rows and say nothing, so a
116
- * 30-line bag read as a 12-line bag and the bug report that followed was
117
- * "the bag only has 12 items". Evidence that is cut must say it is cut.
118
- */
119
- export function tableTruncation(header, rows) {
120
- const parts = [];
121
- if (rows.length > TABLE_PREVIEW_ROWS) parts.push(`${TABLE_PREVIEW_ROWS} of ${rows.length} rows`);
122
- if (header.length > TABLE_PREVIEW_COLS) parts.push(`${TABLE_PREVIEW_COLS} of ${header.length} columns`);
123
- return parts.length ? `Showing ${parts.join(" · ")}` : null;
124
- }
125
- //# sourceMappingURL=markdownParse.js.map
1
+ "use strict";const f=n=>/^\s*\|.*\|\s*$/.test(n);const d=n=>/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(n);const g=n=>n.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>t.trim());const x=/^\s*```\s*([\w+-]*)\s*$/;export function parseBlocks(n){const t=[];let o=[];const h=()=>{if(o.length)t.push({kind:"p",text:o.join(" ")});o=[]};const e=n.split("\n");for(let l=0;l<e.length;l++){const $=e[l];const c=$.replace(/\s+$/,"");const u=x.exec(c);if(u){h();const r=[];let s=l+1;let i=false;while(s<e.length){if(/^\s*```\s*$/.test(e[s])){i=true;break}r.push(e[s]);s++}t.push({kind:"code",lang:u[1]??"",text:r.join("\n"),closed:i});l=i?s:e.length;continue}if(!c.trim()){h();continue}if(f(c)&&e[l+1]&&d(e[l+1])){h();const r=g(c);const s=[];let i=l+2;while(i<e.length&&f(e[i])){s.push(g(e[i]));i++}t.push({kind:"table",header:r,rows:s});l=i-1;continue}const a=/^#{1,6}\s+(.*)$/.exec(c);if(a){h();t.push({kind:"h",text:a[1]});continue}const p=/^(\s*)([-*•]|\d+[.)])\s+(.*)$/.exec(c);if(p){h();const r=Math.min(2,Math.floor(p[1].length/2));const s=/^\d/.test(p[2])?p[2].replace(")","."):"\u2022";t.push({kind:"li",text:p[3],marker:s,depth:r});continue}o.push(c.trim())}h();return t}export const TABLE_PREVIEW_ROWS=12;export const TABLE_PREVIEW_COLS=4;export function tableTruncation(n,t){const o=[];if(t.length>TABLE_PREVIEW_ROWS)o.push(`${TABLE_PREVIEW_ROWS} of ${t.length} rows`);if(n.length>TABLE_PREVIEW_COLS)o.push(`${TABLE_PREVIEW_COLS} of ${n.length} columns`);return o.length?`Showing ${o.join(" \xB7 ")}`:null}
@@ -1,98 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * The two things the old parser got wrong, written down so they stay fixed:
5
- * fenced code flattened into a paragraph with the backticks shown, and a table
6
- * cut to 12 × 4 with nothing to say it had been.
7
- */
8
- import { describe, expect, it } from "vitest";
9
- import { parseBlocks, tableTruncation } from "./markdownParse";
10
- describe("fenced code", () => {
11
- it("keeps newlines and indentation", () => {
12
- const src = 'Here:\n```json\n{\n "qty": 14\n}\n```\n— the qty changed.';
13
- const blocks = parseBlocks(src);
14
- expect(blocks.map(b => b.kind)).toEqual(["p", "code", "p"]);
15
- const code = blocks[1];
16
- expect(code.kind === "code" && code.text).toBe('{\n "qty": 14\n}');
17
- expect(code.kind === "code" && code.lang).toBe("json");
18
- expect(code.kind === "code" && code.closed).toBe(true);
19
- });
20
- it("renders an unclosed fence as code while the stream is still inside it", () => {
21
- const blocks = parseBlocks("```\nline one\nline two");
22
- expect(blocks).toHaveLength(1);
23
- const code = blocks[0];
24
- expect(code.kind).toBe("code");
25
- expect(code.kind === "code" && code.closed).toBe(false);
26
- expect(code.kind === "code" && code.text).toBe("line one\nline two");
27
- });
28
- it("does not treat fence contents as lists or tables", () => {
29
- const blocks = parseBlocks("```\n- not a bullet\n| a | b |\n|---|---|\n```");
30
- expect(blocks).toHaveLength(1);
31
- expect(blocks[0].kind).toBe("code");
32
- });
33
- });
34
- describe("tables", () => {
35
- const table = (rows, cols) => {
36
- const header = Array.from({
37
- length: cols
38
- }, (_, i) => `c${i}`);
39
- const body = Array.from({
40
- length: rows
41
- }, (_, r) => header.map((_, c) => `r${r}c${c}`));
42
- return {
43
- header,
44
- rows: body
45
- };
46
- };
47
- it("says nothing about a table that fits", () => {
48
- const t = table(12, 4);
49
- expect(tableTruncation(t.header, t.rows)).toBeNull();
50
- });
51
- it("names the rows it cut", () => {
52
- const t = table(30, 4);
53
- expect(tableTruncation(t.header, t.rows)).toBe("Showing 12 of 30 rows");
54
- });
55
- it("names the columns it cut", () => {
56
- const t = table(3, 6);
57
- expect(tableTruncation(t.header, t.rows)).toBe("Showing 4 of 6 columns");
58
- });
59
- it("names both when both are cut", () => {
60
- const t = table(30, 6);
61
- expect(tableTruncation(t.header, t.rows)).toBe("Showing 12 of 30 rows · 4 of 6 columns");
62
- });
63
- it("still parses a pipe table from text", () => {
64
- const blocks = parseBlocks("| Item | Qty |\n|---|---|\n| Charizard | 14 |\n| Blastoise | 2 |");
65
- expect(blocks).toHaveLength(1);
66
- const t = blocks[0];
67
- expect(t.kind === "table" && t.header).toEqual(["Item", "Qty"]);
68
- expect(t.kind === "table" && t.rows).toEqual([["Charizard", "14"], ["Blastoise", "2"]]);
69
- });
70
- });
71
- describe("everything else still works", () => {
72
- it("paragraphs, headings and lists", () => {
73
- const blocks = parseBlocks("# Title\n\nSome prose\ncontinues.\n\n- one\n - nested\n1. first");
74
- expect(blocks).toEqual([{
75
- kind: "h",
76
- text: "Title"
77
- }, {
78
- kind: "p",
79
- text: "Some prose continues."
80
- }, {
81
- kind: "li",
82
- text: "one",
83
- marker: "•",
84
- depth: 0
85
- }, {
86
- kind: "li",
87
- text: "nested",
88
- marker: "•",
89
- depth: 1
90
- }, {
91
- kind: "li",
92
- text: "first",
93
- marker: "1.",
94
- depth: 0
95
- }]);
96
- });
97
- });
98
- //# sourceMappingURL=markdownParse.test.js.map
1
+ "use strict";import{describe as d,expect as t,it as s}from"vitest";import{parseBlocks as a,tableTruncation as r}from"./markdownParse";d("fenced code",()=>{s("keeps newlines and indentation",()=>{const n='Here:\n```json\n{\n "qty": 14\n}\n```\n\u2014 the qty changed.';const e=a(n);t(e.map(i=>i.kind)).toEqual(["p","code","p"]);const o=e[1];t(o.kind==="code"&&o.text).toBe('{\n "qty": 14\n}');t(o.kind==="code"&&o.lang).toBe("json");t(o.kind==="code"&&o.closed).toBe(true)});s("renders an unclosed fence as code while the stream is still inside it",()=>{const n=a("```\nline one\nline two");t(n).toHaveLength(1);const e=n[0];t(e.kind).toBe("code");t(e.kind==="code"&&e.closed).toBe(false);t(e.kind==="code"&&e.text).toBe("line one\nline two")});s("does not treat fence contents as lists or tables",()=>{const n=a("```\n- not a bullet\n| a | b |\n|---|---|\n```");t(n).toHaveLength(1);t(n[0].kind).toBe("code")})});d("tables",()=>{const n=(e,o)=>{const i=Array.from({length:o},(h,c)=>`c${c}`);const l=Array.from({length:e},(h,c)=>i.map((m,k)=>`r${c}c${k}`));return{header:i,rows:l}};s("says nothing about a table that fits",()=>{const e=n(12,4);t(r(e.header,e.rows)).toBeNull()});s("names the rows it cut",()=>{const e=n(30,4);t(r(e.header,e.rows)).toBe("Showing 12 of 30 rows")});s("names the columns it cut",()=>{const e=n(3,6);t(r(e.header,e.rows)).toBe("Showing 4 of 6 columns")});s("names both when both are cut",()=>{const e=n(30,6);t(r(e.header,e.rows)).toBe("Showing 12 of 30 rows \xB7 4 of 6 columns")});s("still parses a pipe table from text",()=>{const e=a("| Item | Qty |\n|---|---|\n| Charizard | 14 |\n| Blastoise | 2 |");t(e).toHaveLength(1);const o=e[0];t(o.kind==="table"&&o.header).toEqual(["Item","Qty"]);t(o.kind==="table"&&o.rows).toEqual([["Charizard","14"],["Blastoise","2"]])})});d("everything else still works",()=>{s("paragraphs, headings and lists",()=>{const n=a("# Title\n\nSome prose\ncontinues.\n\n- one\n - nested\n1. first");t(n).toEqual([{kind:"h",text:"Title"},{kind:"p",text:"Some prose continues."},{kind:"li",text:"one",marker:"\u2022",depth:0},{kind:"li",text:"nested",marker:"\u2022",depth:1},{kind:"li",text:"first",marker:"1.",depth:0}])})});