@buoy-gg/ask-buoy 7.0.36 → 7.0.38

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 (312) hide show
  1. package/README.md +58 -27
  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 -781
  6. package/lib/commonjs/blocks/ExtraBlocks.js +1 -1860
  7. package/lib/commonjs/blocks/MediaBlocks.js +1 -156
  8. package/lib/commonjs/blocks/ReceiptBlocks.js +1 -586
  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/components/ApprovalCard.js +1 -244
  20. package/lib/commonjs/components/AskBuoyHeader.js +1 -196
  21. package/lib/commonjs/components/AskBuoyIcon.js +1 -19
  22. package/lib/commonjs/components/AskBuoyModal.js +1 -479
  23. package/lib/commonjs/components/AskBuoySettings.js +1 -119
  24. package/lib/commonjs/components/ChangesBar.js +1 -211
  25. package/lib/commonjs/components/Composer.js +1 -255
  26. package/lib/commonjs/components/EmptyState.js +1 -161
  27. package/lib/commonjs/components/KeyboardPad.js +1 -80
  28. package/lib/commonjs/components/Markdown.js +1 -310
  29. package/lib/commonjs/components/MessageList.js +1 -930
  30. package/lib/commonjs/components/QueuedMessages.js +1 -145
  31. package/lib/commonjs/components/ThinkingStrip.js +1 -223
  32. package/lib/commonjs/components/TypingDots.js +1 -63
  33. package/lib/commonjs/components/markdownParse.js +1 -131
  34. package/lib/commonjs/components/markdownParse.test.js +1 -99
  35. package/lib/commonjs/components/useCopyAction.js +1 -50
  36. package/lib/commonjs/index.js +1 -252
  37. package/lib/commonjs/preset.js +1 -90
  38. package/lib/commonjs/store/activityGroups.js +1 -110
  39. package/lib/commonjs/store/activityGroups.test.js +1 -78
  40. package/lib/commonjs/store/askBuoySettings.js +1 -72
  41. package/lib/commonjs/store/askBuoyStore.js +1 -547
  42. package/lib/commonjs/store/blockPlacement.js +1 -64
  43. package/lib/commonjs/store/blockPlacement.test.js +1 -123
  44. package/lib/commonjs/store/queue.test.js +1 -150
  45. package/lib/commonjs/store/resetConversation.js +1 -77
  46. package/lib/commonjs/store/restorePending.test.js +1 -63
  47. package/lib/commonjs/store/restoredIds.test.js +1 -47
  48. package/lib/commonjs/store/suggestions.js +1 -54
  49. package/lib/commonjs/store/suggestions.test.js +1 -58
  50. package/lib/commonjs/store/systemLine.test.js +1 -77
  51. package/lib/commonjs/store/ticketPrompt.js +1 -17
  52. package/lib/commonjs/store/traceText.js +1 -81
  53. package/lib/commonjs/store/traceText.test.js +1 -112
  54. package/lib/commonjs/store/transcriptPersistence.js +1 -297
  55. package/lib/commonjs/store/transcriptPersistence.test.js +1 -333
  56. package/lib/commonjs/store/turnRendering.test.js +1 -151
  57. package/lib/commonjs/store/useAskBuoy.js +1 -622
  58. package/lib/commonjs/store/useAskBuoySettings.js +1 -14
  59. package/lib/commonjs/sync/askBuoySyncAdapter.js +1 -140
  60. package/lib/commonjs/sync/askBuoySyncAdapter.test.js +1 -141
  61. package/lib/commonjs/sync/wire.js +1 -58
  62. package/lib/commonjs/types.js +1 -6
  63. package/lib/module/blocks/AskBlocks.js +1 -331
  64. package/lib/module/blocks/BlockRenderer.js +1 -257
  65. package/lib/module/blocks/ChromePrototypes.js +1 -503
  66. package/lib/module/blocks/DataBlocks.js +1 -767
  67. package/lib/module/blocks/ExtraBlocks.js +1 -1833
  68. package/lib/module/blocks/MediaBlocks.js +1 -151
  69. package/lib/module/blocks/ReceiptBlocks.js +1 -574
  70. package/lib/module/blocks/blockText.js +1 -55
  71. package/lib/module/blocks/blockText.test.js +1 -53
  72. package/lib/module/blocks/context.js +1 -35
  73. package/lib/module/blocks/icons.js +1 -91
  74. package/lib/module/blocks/index.js +1 -8
  75. package/lib/module/blocks/listRow.test.js +1 -56
  76. package/lib/module/blocks/pageState.js +1 -30
  77. package/lib/module/blocks/pageState.test.js +1 -56
  78. package/lib/module/blocks/primitives.js +1 -445
  79. package/lib/module/blocks/primitivesIndex.js +1 -5
  80. package/lib/module/components/ApprovalCard.js +1 -239
  81. package/lib/module/components/AskBuoyHeader.js +1 -193
  82. package/lib/module/components/AskBuoyIcon.js +1 -8
  83. package/lib/module/components/AskBuoyModal.js +1 -474
  84. package/lib/module/components/AskBuoySettings.js +1 -114
  85. package/lib/module/components/ChangesBar.js +1 -206
  86. package/lib/module/components/Composer.js +1 -250
  87. package/lib/module/components/EmptyState.js +1 -156
  88. package/lib/module/components/KeyboardPad.js +1 -75
  89. package/lib/module/components/Markdown.js +1 -305
  90. package/lib/module/components/MessageList.js +1 -924
  91. package/lib/module/components/QueuedMessages.js +1 -140
  92. package/lib/module/components/ThinkingStrip.js +1 -218
  93. package/lib/module/components/TypingDots.js +1 -58
  94. package/lib/module/components/markdownParse.js +1 -125
  95. package/lib/module/components/markdownParse.test.js +1 -98
  96. package/lib/module/components/useCopyAction.js +1 -46
  97. package/lib/module/index.js +1 -34
  98. package/lib/module/preset.js +1 -73
  99. package/lib/module/store/activityGroups.js +1 -103
  100. package/lib/module/store/activityGroups.test.js +1 -77
  101. package/lib/module/store/askBuoySettings.js +1 -67
  102. package/lib/module/store/askBuoyStore.js +1 -541
  103. package/lib/module/store/blockPlacement.js +1 -59
  104. package/lib/module/store/blockPlacement.test.js +1 -122
  105. package/lib/module/store/queue.test.js +1 -149
  106. package/lib/module/store/resetConversation.js +1 -72
  107. package/lib/module/store/restorePending.test.js +1 -62
  108. package/lib/module/store/restoredIds.test.js +1 -46
  109. package/lib/module/store/suggestions.js +1 -49
  110. package/lib/module/store/suggestions.test.js +1 -57
  111. package/lib/module/store/systemLine.test.js +1 -76
  112. package/lib/module/store/ticketPrompt.js +1 -13
  113. package/lib/module/store/traceText.js +1 -75
  114. package/lib/module/store/traceText.test.js +1 -111
  115. package/lib/module/store/transcriptPersistence.js +1 -287
  116. package/lib/module/store/transcriptPersistence.test.js +1 -332
  117. package/lib/module/store/turnRendering.test.js +1 -150
  118. package/lib/module/store/useAskBuoy.js +1 -616
  119. package/lib/module/store/useAskBuoySettings.js +1 -9
  120. package/lib/module/sync/askBuoySyncAdapter.js +1 -135
  121. package/lib/module/sync/askBuoySyncAdapter.test.js +1 -140
  122. package/lib/module/sync/wire.js +1 -47
  123. package/lib/module/types.js +1 -4
  124. package/lib/typescript/components/ApprovalCard.d.ts +9 -1
  125. package/lib/typescript/preset.d.ts +4 -2
  126. package/lib/typescript/store/askBuoyStore.d.ts +32 -4
  127. package/lib/typescript/store/useAskBuoy.d.ts +3 -2
  128. package/lib/typescript/sync/askBuoySyncAdapter.d.ts +3 -0
  129. package/package.json +9 -9
  130. package/lib/commonjs/blocks/AskBlocks.js.map +0 -1
  131. package/lib/commonjs/blocks/BlockRenderer.js.map +0 -1
  132. package/lib/commonjs/blocks/ChromePrototypes.js.map +0 -1
  133. package/lib/commonjs/blocks/DataBlocks.js.map +0 -1
  134. package/lib/commonjs/blocks/ExtraBlocks.js.map +0 -1
  135. package/lib/commonjs/blocks/MediaBlocks.js.map +0 -1
  136. package/lib/commonjs/blocks/ReceiptBlocks.js.map +0 -1
  137. package/lib/commonjs/blocks/blockText.js.map +0 -1
  138. package/lib/commonjs/blocks/blockText.test.js.map +0 -1
  139. package/lib/commonjs/blocks/context.js.map +0 -1
  140. package/lib/commonjs/blocks/icons.js.map +0 -1
  141. package/lib/commonjs/blocks/index.js.map +0 -1
  142. package/lib/commonjs/blocks/listRow.test.js.map +0 -1
  143. package/lib/commonjs/blocks/pageState.js.map +0 -1
  144. package/lib/commonjs/blocks/pageState.test.js.map +0 -1
  145. package/lib/commonjs/blocks/primitives.js.map +0 -1
  146. package/lib/commonjs/blocks/primitivesIndex.js.map +0 -1
  147. package/lib/commonjs/components/ApprovalCard.js.map +0 -1
  148. package/lib/commonjs/components/AskBuoyHeader.js.map +0 -1
  149. package/lib/commonjs/components/AskBuoyIcon.js.map +0 -1
  150. package/lib/commonjs/components/AskBuoyModal.js.map +0 -1
  151. package/lib/commonjs/components/AskBuoySettings.js.map +0 -1
  152. package/lib/commonjs/components/ChangesBar.js.map +0 -1
  153. package/lib/commonjs/components/Composer.js.map +0 -1
  154. package/lib/commonjs/components/EmptyState.js.map +0 -1
  155. package/lib/commonjs/components/KeyboardPad.js.map +0 -1
  156. package/lib/commonjs/components/Markdown.js.map +0 -1
  157. package/lib/commonjs/components/MessageList.js.map +0 -1
  158. package/lib/commonjs/components/QueuedMessages.js.map +0 -1
  159. package/lib/commonjs/components/ThinkingStrip.js.map +0 -1
  160. package/lib/commonjs/components/TypingDots.js.map +0 -1
  161. package/lib/commonjs/components/markdownParse.js.map +0 -1
  162. package/lib/commonjs/components/markdownParse.test.js.map +0 -1
  163. package/lib/commonjs/components/useCopyAction.js.map +0 -1
  164. package/lib/commonjs/index.js.map +0 -1
  165. package/lib/commonjs/preset.js.map +0 -1
  166. package/lib/commonjs/store/activityGroups.js.map +0 -1
  167. package/lib/commonjs/store/activityGroups.test.js.map +0 -1
  168. package/lib/commonjs/store/askBuoySettings.js.map +0 -1
  169. package/lib/commonjs/store/askBuoyStore.js.map +0 -1
  170. package/lib/commonjs/store/blockPlacement.js.map +0 -1
  171. package/lib/commonjs/store/blockPlacement.test.js.map +0 -1
  172. package/lib/commonjs/store/queue.test.js.map +0 -1
  173. package/lib/commonjs/store/resetConversation.js.map +0 -1
  174. package/lib/commonjs/store/restorePending.test.js.map +0 -1
  175. package/lib/commonjs/store/restoredIds.test.js.map +0 -1
  176. package/lib/commonjs/store/suggestions.js.map +0 -1
  177. package/lib/commonjs/store/suggestions.test.js.map +0 -1
  178. package/lib/commonjs/store/systemLine.test.js.map +0 -1
  179. package/lib/commonjs/store/ticketPrompt.js.map +0 -1
  180. package/lib/commonjs/store/traceText.js.map +0 -1
  181. package/lib/commonjs/store/traceText.test.js.map +0 -1
  182. package/lib/commonjs/store/transcriptPersistence.js.map +0 -1
  183. package/lib/commonjs/store/transcriptPersistence.test.js.map +0 -1
  184. package/lib/commonjs/store/turnRendering.test.js.map +0 -1
  185. package/lib/commonjs/store/useAskBuoy.js.map +0 -1
  186. package/lib/commonjs/store/useAskBuoySettings.js.map +0 -1
  187. package/lib/commonjs/sync/askBuoySyncAdapter.js.map +0 -1
  188. package/lib/commonjs/sync/askBuoySyncAdapter.test.js.map +0 -1
  189. package/lib/commonjs/sync/wire.js.map +0 -1
  190. package/lib/commonjs/types.js.map +0 -1
  191. package/lib/module/blocks/AskBlocks.js.map +0 -1
  192. package/lib/module/blocks/BlockRenderer.js.map +0 -1
  193. package/lib/module/blocks/ChromePrototypes.js.map +0 -1
  194. package/lib/module/blocks/DataBlocks.js.map +0 -1
  195. package/lib/module/blocks/ExtraBlocks.js.map +0 -1
  196. package/lib/module/blocks/MediaBlocks.js.map +0 -1
  197. package/lib/module/blocks/ReceiptBlocks.js.map +0 -1
  198. package/lib/module/blocks/blockText.js.map +0 -1
  199. package/lib/module/blocks/blockText.test.js.map +0 -1
  200. package/lib/module/blocks/context.js.map +0 -1
  201. package/lib/module/blocks/icons.js.map +0 -1
  202. package/lib/module/blocks/index.js.map +0 -1
  203. package/lib/module/blocks/listRow.test.js.map +0 -1
  204. package/lib/module/blocks/pageState.js.map +0 -1
  205. package/lib/module/blocks/pageState.test.js.map +0 -1
  206. package/lib/module/blocks/primitives.js.map +0 -1
  207. package/lib/module/blocks/primitivesIndex.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/components/ApprovalCard.d.ts.map +0 -1
  270. package/lib/typescript/components/AskBuoyHeader.d.ts.map +0 -1
  271. package/lib/typescript/components/AskBuoyIcon.d.ts.map +0 -1
  272. package/lib/typescript/components/AskBuoyModal.d.ts.map +0 -1
  273. package/lib/typescript/components/AskBuoySettings.d.ts.map +0 -1
  274. package/lib/typescript/components/ChangesBar.d.ts.map +0 -1
  275. package/lib/typescript/components/Composer.d.ts.map +0 -1
  276. package/lib/typescript/components/EmptyState.d.ts.map +0 -1
  277. package/lib/typescript/components/KeyboardPad.d.ts.map +0 -1
  278. package/lib/typescript/components/Markdown.d.ts.map +0 -1
  279. package/lib/typescript/components/MessageList.d.ts.map +0 -1
  280. package/lib/typescript/components/QueuedMessages.d.ts.map +0 -1
  281. package/lib/typescript/components/ThinkingStrip.d.ts.map +0 -1
  282. package/lib/typescript/components/TypingDots.d.ts.map +0 -1
  283. package/lib/typescript/components/markdownParse.d.ts.map +0 -1
  284. package/lib/typescript/components/markdownParse.test.d.ts.map +0 -1
  285. package/lib/typescript/components/useCopyAction.d.ts.map +0 -1
  286. package/lib/typescript/index.d.ts.map +0 -1
  287. package/lib/typescript/preset.d.ts.map +0 -1
  288. package/lib/typescript/store/activityGroups.d.ts.map +0 -1
  289. package/lib/typescript/store/activityGroups.test.d.ts.map +0 -1
  290. package/lib/typescript/store/askBuoySettings.d.ts.map +0 -1
  291. package/lib/typescript/store/askBuoyStore.d.ts.map +0 -1
  292. package/lib/typescript/store/blockPlacement.d.ts.map +0 -1
  293. package/lib/typescript/store/blockPlacement.test.d.ts.map +0 -1
  294. package/lib/typescript/store/queue.test.d.ts.map +0 -1
  295. package/lib/typescript/store/resetConversation.d.ts.map +0 -1
  296. package/lib/typescript/store/restorePending.test.d.ts.map +0 -1
  297. package/lib/typescript/store/restoredIds.test.d.ts.map +0 -1
  298. package/lib/typescript/store/suggestions.d.ts.map +0 -1
  299. package/lib/typescript/store/suggestions.test.d.ts.map +0 -1
  300. package/lib/typescript/store/systemLine.test.d.ts.map +0 -1
  301. package/lib/typescript/store/ticketPrompt.d.ts.map +0 -1
  302. package/lib/typescript/store/traceText.d.ts.map +0 -1
  303. package/lib/typescript/store/traceText.test.d.ts.map +0 -1
  304. package/lib/typescript/store/transcriptPersistence.d.ts.map +0 -1
  305. package/lib/typescript/store/transcriptPersistence.test.d.ts.map +0 -1
  306. package/lib/typescript/store/turnRendering.test.d.ts.map +0 -1
  307. package/lib/typescript/store/useAskBuoy.d.ts.map +0 -1
  308. package/lib/typescript/store/useAskBuoySettings.d.ts.map +0 -1
  309. package/lib/typescript/sync/askBuoySyncAdapter.d.ts.map +0 -1
  310. package/lib/typescript/sync/askBuoySyncAdapter.test.d.ts.map +0 -1
  311. package/lib/typescript/sync/wire.d.ts.map +0 -1
  312. 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-queue",
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,ScrollView,StyleSheet,Text,View}from"react-native";import{night,X}from"@buoy-gg/shared-ui";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const MAX_LIST_HEIGHT=132;export function QueuedMessages({items:e,paused:t,onEdit:s,onRemove:o}){return 0===e.length?null:_jsxs(View,{style:styles.wrap,testID:"buoy-ask-buoy-queued",children:[_jsx(ScrollView,{style:styles.list,contentContainerStyle:styles.listContent,keyboardShouldPersistTaps:"handled",children:e.map((e,i)=>_jsxs(View,{style:[styles.row,null!==t&&styles.rowPaused],children:[_jsxs(Pressable,{testID:`buoy-ask-buoy-queue-item-${i}`,accessibilityRole:"button",accessibilityLabel:`Edit queued message: ${e.text}`,onPress:()=>s(e.id),style:({pressed:e})=>[styles.rowBody,e&&styles.pressed],children:[_jsx(Text,{style:styles.ordinal,children:0===i?"NEXT":"THEN"}),_jsx(Text,{style:styles.text,numberOfLines:3,children:e.text})]}),_jsx(Pressable,{testID:`buoy-ask-buoy-queue-remove-${i}`,accessibilityRole:"button",accessibilityLabel:"Remove queued message",onPress:()=>o(e.id),hitSlop:8,style:({pressed:e})=>[styles.remove,e&&styles.pressed],children:_jsx(X,{size:11,color:night.color.textTertiary})})]},e.id))}),_jsx(Text,{style:[styles.hint,null!==t&&styles.hintPaused],testID:"buoy-ask-buoy-queue-hint",children:t??"Sends one at a time when this turn finishes · tap to edit"})]})}const styles=StyleSheet.create({wrap:{paddingHorizontal:night.gutter,paddingTop:8,gap:6,backgroundColor:night.color.bg},list:{maxHeight:132},listContent:{gap:6},row:{flexDirection:"row",alignItems:"center",borderRadius:night.radius.row,borderWidth:StyleSheet.hairlineWidth,borderColor:night.color.border,backgroundColor:night.color.surface},rowPaused:{borderColor:night.color.warning},rowBody:{flex:1,flexDirection:"row",alignItems:"center",gap:8,paddingVertical:7,paddingLeft:10},ordinal:{color:night.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.6,width:30},text:{flex:1,color:night.color.textSecondary,fontSize:night.font.caption,lineHeight:17},remove:{width:32,height:32,alignItems:"center",justifyContent:"center"},pressed:{opacity:.7},hint:{color:night.color.textTertiary,fontSize:night.font.micro},hintPaused:{color:night.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}from"react";import{Pressable,StyleSheet,Text,View}from"react-native";import{Activity,ChevronDown,ChevronRight,night}from"@buoy-gg/shared-ui";import{hasTrace,traceEntries}from"../store/traceText";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";function StepRow({n:t,call:e}){const[i,s]=useState(!1),o="failed"===e.status||"refused"===e.status;return _jsxs(Pressable,{onPress:()=>s(t=>!t),accessibilityRole:"button",accessibilityState:{expanded:i},style:styles.step,children:[_jsxs(View,{style:styles.stepLine,children:[_jsx(Text,{style:styles.stepN,children:t}),_jsxs(Text,{style:[styles.stepName,o&&styles.stepFailed],numberOfLines:1,children:[e.toolId,".",e.action]}),void 0!==e.durationMs?_jsxs(Text,{style:styles.stepMs,children:[e.durationMs,"ms"]}):null,_jsx(Text,{style:[styles.stepStatus,o&&styles.stepFailed],numberOfLines:1,children:"ok"===e.status?e.summary||"done":e.status})]}),i?_jsxs(View,{style:styles.detail,children:[_jsx(Text,{style:styles.detailLabel,children:"SENT"}),_jsx(Text,{style:styles.code,selectable:!0,children:e.params??"no parameters"}),e.result?_jsxs(_Fragment,{children:[_jsx(Text,{style:styles.detailLabel,children:"RETURNED"}),_jsx(Text,{style:styles.code,selectable:!0,children:e.result})]}):null]}):null]})}export function ThinkingStrip({message:t}){const[e,i]=useState(!1);if(!hasTrace(t))return null;const s=traceEntries(t),o=s.filter(t=>"step"===t.kind).length,l=s.length-o,r=[o?`${o} step${1===o?"":"s"}`:null,l?`${l} thought${1===l?"":"s"}`:null,void 0!==t.startedAt&&void 0!==t.endedAt?`${((t.endedAt-t.startedAt)/1e3).toFixed(1)}s`:null,t.usage?`${t.usage.input+t.usage.output} tokens`:null].filter(Boolean).join(" · ");return _jsxs(View,{style:styles.wrap,testID:"buoy-ask-buoy-thinking",children:[_jsxs(Pressable,{testID:"buoy-ask-buoy-thinking-toggle",onPress:()=>i(t=>!t),accessibilityRole:"button",accessibilityLabel:e?"Hide agent thinking":"Show agent thinking",accessibilityState:{expanded:e},style:styles.head,children:[_jsx(Activity,{size:12,color:night.color.textTertiary}),_jsx(Text,{style:styles.headText,children:r}),_jsx(e?ChevronDown:ChevronRight,{size:12,color:night.color.textTertiary})]}),e?_jsxs(View,{style:styles.body,children:[s.map((t,e)=>"thought"===t.kind?_jsx(Text,{style:styles.thought,selectable:!0,children:t.text.trim()},`t${e}`):_jsx(StepRow,{n:t.n,call:t.call},t.call.id)),0===l?_jsx(Text,{style:styles.none,children:"This model reports no reasoning — the steps above are the whole trace."}):null]}):null]})}const styles=StyleSheet.create({wrap:{marginTop:8,borderRadius:night.radius.badge,borderWidth:StyleSheet.hairlineWidth,borderColor:night.color.separator,backgroundColor:night.color.fill,overflow:"hidden"},head:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:7},headText:{flex:1,color:night.color.textTertiary,fontSize:night.font.micro,fontWeight:"600"},body:{borderTopWidth:StyleSheet.hairlineWidth,borderTopColor:night.color.separator},thought:{color:night.color.textSecondary,fontSize:night.font.micro,lineHeight:17,fontStyle:"italic",paddingHorizontal:10,paddingVertical:8},step:{paddingHorizontal:10,paddingVertical:7},stepLine:{flexDirection:"row",alignItems:"center",gap:8},stepN:{color:night.color.textTertiary,fontSize:night.font.micro,width:14},stepName:{flex:1,color:night.color.textSecondary,fontSize:night.font.micro,fontWeight:"600"},stepMs:{color:night.color.textTertiary,fontSize:night.font.micro},stepStatus:{color:night.color.textTertiary,fontSize:night.font.micro,maxWidth:110},stepFailed:{color:night.color.danger},detail:{marginTop:6,marginLeft:22,gap:3},detailLabel:{color:night.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5},code:{color:night.color.textSecondary,fontSize:night.font.micro,lineHeight:16,marginBottom:3},none:{color:night.color.textTertiary,fontSize:night.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,useRef}from"react";import{Animated,Easing,StyleSheet,View}from"react-native";import{night}from"@buoy-gg/shared-ui";import{jsx as _jsx}from"react/jsx-runtime";export function TypingDots(){const e=useRef([0,1,2].map(()=>new Animated.Value(.25))).current;return useEffect(()=>{const t=e.map((e,t)=>Animated.loop(Animated.sequence([Animated.delay(140*t),Animated.timing(e,{toValue:1,duration:320,easing:Easing.inOut(Easing.ease),useNativeDriver:!0}),Animated.timing(e,{toValue:.25,duration:320,easing:Easing.inOut(Easing.ease),useNativeDriver:!0}),Animated.delay(140*(2-t))])));return t.forEach(e=>e.start()),()=>t.forEach(e=>e.stop())},[e]),_jsx(View,{style:styles.wrap,testID:"buoy-ask-buoy-typing",accessibilityLabel:"Thinking",children:e.map((e,t)=>_jsx(Animated.View,{style:[styles.dot,{opacity:e}]},t))})}const styles=StyleSheet.create({wrap:{flexDirection:"row",alignItems:"center",gap:5,paddingVertical:8,paddingHorizontal:2},dot:{width:7,height:7,borderRadius:4,backgroundColor:night.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 isTableRow=t=>/^\s*\|.*\|\s*$/.test(t),isTableRule=t=>/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(t),splitRow=t=>t.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>t.trim()),FENCE=/^\s*```\s*([\w+-]*)\s*$/;export function parseBlocks(t){const e=[];let s=[];const n=()=>{s.length&&e.push({kind:"p",text:s.join(" ")}),s=[]},o=t.split("\n");for(let t=0;t<o.length;t++){const l=o[t].replace(/\s+$/,""),i=FENCE.exec(l);if(i){n();const s=[];let l=t+1,c=!1;for(;l<o.length;){if(/^\s*```\s*$/.test(o[l])){c=!0;break}s.push(o[l]),l++}e.push({kind:"code",lang:i[1]??"",text:s.join("\n"),closed:c}),t=c?l:o.length;continue}if(!l.trim()){n();continue}if(isTableRow(l)&&o[t+1]&&isTableRule(o[t+1])){n();const s=splitRow(l),i=[];let c=t+2;for(;c<o.length&&isTableRow(o[c]);)i.push(splitRow(o[c])),c++;e.push({kind:"table",header:s,rows:i}),t=c-1;continue}const c=/^#{1,6}\s+(.*)$/.exec(l);if(c){n(),e.push({kind:"h",text:c[1]});continue}const r=/^(\s*)([-*•]|\d+[.)])\s+(.*)$/.exec(l);if(r){n();const t=Math.min(2,Math.floor(r[1].length/2)),s=/^\d/.test(r[2])?r[2].replace(")","."):"•";e.push({kind:"li",text:r[3],marker:s,depth:t});continue}s.push(l.trim())}return n(),e}export const TABLE_PREVIEW_ROWS=12;export const TABLE_PREVIEW_COLS=4;export function tableTruncation(t,e){const s=[];return e.length>12&&s.push(`12 of ${e.length} rows`),t.length>4&&s.push(`4 of ${t.length} columns`),s.length?`Showing ${s.join(" · ")}`: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,expect,it}from"vitest";import{parseBlocks,tableTruncation}from"./markdownParse";describe("fenced code",()=>{it("keeps newlines and indentation",()=>{const e=parseBlocks('Here:\n```json\n{\n "qty": 14\n}\n```\n— the qty changed.');expect(e.map(e=>e.kind)).toEqual(["p","code","p"]);const t=e[1];expect("code"===t.kind&&t.text).toBe('{\n "qty": 14\n}'),expect("code"===t.kind&&t.lang).toBe("json"),expect("code"===t.kind&&t.closed).toBe(!0)}),it("renders an unclosed fence as code while the stream is still inside it",()=>{const e=parseBlocks("```\nline one\nline two");expect(e).toHaveLength(1);const t=e[0];expect(t.kind).toBe("code"),expect("code"===t.kind&&t.closed).toBe(!1),expect("code"===t.kind&&t.text).toBe("line one\nline two")}),it("does not treat fence contents as lists or tables",()=>{const e=parseBlocks("```\n- not a bullet\n| a | b |\n|---|---|\n```");expect(e).toHaveLength(1),expect(e[0].kind).toBe("code")})}),describe("tables",()=>{const e=(e,t)=>{const n=Array.from({length:t},(e,t)=>`c${t}`),o=Array.from({length:e},(e,t)=>n.map((e,n)=>`r${t}c${n}`));return{header:n,rows:o}};it("says nothing about a table that fits",()=>{const t=e(12,4);expect(tableTruncation(t.header,t.rows)).toBeNull()}),it("names the rows it cut",()=>{const t=e(30,4);expect(tableTruncation(t.header,t.rows)).toBe("Showing 12 of 30 rows")}),it("names the columns it cut",()=>{const t=e(3,6);expect(tableTruncation(t.header,t.rows)).toBe("Showing 4 of 6 columns")}),it("names both when both are cut",()=>{const t=e(30,6);expect(tableTruncation(t.header,t.rows)).toBe("Showing 12 of 30 rows · 4 of 6 columns")}),it("still parses a pipe table from text",()=>{const e=parseBlocks("| Item | Qty |\n|---|---|\n| Charizard | 14 |\n| Blastoise | 2 |");expect(e).toHaveLength(1);const t=e[0];expect("table"===t.kind&&t.header).toEqual(["Item","Qty"]),expect("table"===t.kind&&t.rows).toEqual([["Charizard","14"],["Blastoise","2"]])})}),describe("everything else still works",()=>{it("paragraphs, headings and lists",()=>{const e=parseBlocks("# Title\n\nSome prose\ncontinues.\n\n- one\n - nested\n1. first");expect(e).toEqual([{kind:"h",text:"Title"},{kind:"p",text:"Some prose continues."},{kind:"li",text:"one",marker:"•",depth:0},{kind:"li",text:"nested",marker:"•",depth:1},{kind:"li",text:"first",marker:"1.",depth:0}])})});