@assistant-ui/react 0.14.16 → 0.14.19

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 (380) hide show
  1. package/dist/client/ExternalThread.d.ts +5 -3
  2. package/dist/client/ExternalThread.d.ts.map +1 -1
  3. package/dist/client/ExternalThread.js +745 -255
  4. package/dist/client/ExternalThread.js.map +1 -1
  5. package/dist/client/InMemoryThreadList.d.ts +1 -1
  6. package/dist/client/InMemoryThreadList.d.ts.map +1 -1
  7. package/dist/client/InMemoryThreadList.js +299 -113
  8. package/dist/client/InMemoryThreadList.js.map +1 -1
  9. package/dist/client/SingleThreadList.d.ts +1 -6
  10. package/dist/client/SingleThreadList.d.ts.map +1 -1
  11. package/dist/client/SingleThreadList.js +143 -55
  12. package/dist/client/SingleThreadList.js.map +1 -1
  13. package/dist/context/ReadonlyStore.js.map +1 -1
  14. package/dist/context/providers/MessageProvider.js +38 -5
  15. package/dist/context/providers/MessageProvider.js.map +1 -1
  16. package/dist/context/providers/ThreadViewportProvider.js +76 -20
  17. package/dist/context/providers/ThreadViewportProvider.js.map +1 -1
  18. package/dist/context/react/ThreadViewportContext.js.map +1 -1
  19. package/dist/context/react/utils/createContextHook.js.map +1 -1
  20. package/dist/context/react/utils/createContextStoreHook.js +17 -2
  21. package/dist/context/react/utils/createContextStoreHook.js.map +1 -1
  22. package/dist/context/react/utils/createStateHookForRuntime.js.map +1 -1
  23. package/dist/context/react/utils/ensureBinding.js.map +1 -1
  24. package/dist/context/react/utils/useRuntimeState.js +18 -2
  25. package/dist/context/react/utils/useRuntimeState.js.map +1 -1
  26. package/dist/context/stores/ThreadViewport.js.map +1 -1
  27. package/dist/devtools/DevToolsHooks.js.map +1 -1
  28. package/dist/hooks/useMessageQuote.js.map +1 -1
  29. package/dist/hooks/useMessageTiming.js +4 -1
  30. package/dist/hooks/useMessageTiming.js.map +1 -1
  31. package/dist/hooks/useToolCallElapsed.d.ts +23 -0
  32. package/dist/hooks/useToolCallElapsed.d.ts.map +1 -0
  33. package/dist/hooks/useToolCallElapsed.js +72 -0
  34. package/dist/hooks/useToolCallElapsed.js.map +1 -0
  35. package/dist/index.d.ts +6 -2
  36. package/dist/index.js +5 -1
  37. package/dist/internal.js.map +1 -1
  38. package/dist/legacy-runtime/AssistantRuntimeProvider.js +46 -10
  39. package/dist/legacy-runtime/AssistantRuntimeProvider.js.map +1 -1
  40. package/dist/legacy-runtime/cloud/auiV0.js.map +1 -1
  41. package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.js +27 -6
  42. package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.js.map +1 -1
  43. package/dist/legacy-runtime/hooks/AssistantContext.js +13 -2
  44. package/dist/legacy-runtime/hooks/AssistantContext.js.map +1 -1
  45. package/dist/legacy-runtime/hooks/AttachmentContext.js +9 -1
  46. package/dist/legacy-runtime/hooks/AttachmentContext.js.map +1 -1
  47. package/dist/legacy-runtime/hooks/ComposerContext.js +9 -1
  48. package/dist/legacy-runtime/hooks/ComposerContext.js.map +1 -1
  49. package/dist/legacy-runtime/hooks/MessageContext.js +12 -2
  50. package/dist/legacy-runtime/hooks/MessageContext.js.map +1 -1
  51. package/dist/legacy-runtime/hooks/MessagePartContext.js +9 -1
  52. package/dist/legacy-runtime/hooks/MessagePartContext.js.map +1 -1
  53. package/dist/legacy-runtime/hooks/ThreadContext.js +33 -5
  54. package/dist/legacy-runtime/hooks/ThreadContext.js.map +1 -1
  55. package/dist/legacy-runtime/hooks/ThreadListItemContext.js +9 -1
  56. package/dist/legacy-runtime/hooks/ThreadListItemContext.js.map +1 -1
  57. package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.js +3 -3
  58. package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.js.map +1 -1
  59. package/dist/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.js +71 -31
  60. package/dist/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.js.map +1 -1
  61. package/dist/legacy-runtime/runtime-cores/assistant-transport/runManager.js.map +1 -1
  62. package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js +24 -16
  63. package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
  64. package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.js +17 -12
  65. package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.js.map +1 -1
  66. package/dist/legacy-runtime/runtime-cores/assistant-transport/useLatestRef.js +17 -3
  67. package/dist/legacy-runtime/runtime-cores/assistant-transport/useLatestRef.js.map +1 -1
  68. package/dist/mcp-apps/McpAppRenderer.d.ts +2 -10
  69. package/dist/mcp-apps/McpAppRenderer.d.ts.map +1 -1
  70. package/dist/mcp-apps/McpAppRenderer.js +9 -8
  71. package/dist/mcp-apps/McpAppRenderer.js.map +1 -1
  72. package/dist/mcp-apps/McpAppsRemoteHost.d.ts +1 -8
  73. package/dist/mcp-apps/McpAppsRemoteHost.d.ts.map +1 -1
  74. package/dist/mcp-apps/McpAppsRemoteHost.js +6 -5
  75. package/dist/mcp-apps/McpAppsRemoteHost.js.map +1 -1
  76. package/dist/mcp-apps/app-frame.js +33 -14
  77. package/dist/mcp-apps/app-frame.js.map +1 -1
  78. package/dist/mcp-apps/bridge.js.map +1 -1
  79. package/dist/mcp-apps/types.js.map +1 -1
  80. package/dist/mcp-apps/utils.js.map +1 -1
  81. package/dist/model-context/frame/useAssistantFrameHost.js +32 -14
  82. package/dist/model-context/frame/useAssistantFrameHost.js.map +1 -1
  83. package/dist/model-context/makeAssistantVisible.js +64 -26
  84. package/dist/model-context/makeAssistantVisible.js.map +1 -1
  85. package/dist/primitives/actionBar/ActionBarCopy.js +94 -20
  86. package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
  87. package/dist/primitives/actionBar/ActionBarEdit.js.map +1 -1
  88. package/dist/primitives/actionBar/ActionBarExportMarkdown.js +105 -37
  89. package/dist/primitives/actionBar/ActionBarExportMarkdown.js.map +1 -1
  90. package/dist/primitives/actionBar/ActionBarFeedbackNegative.js +60 -11
  91. package/dist/primitives/actionBar/ActionBarFeedbackNegative.js.map +1 -1
  92. package/dist/primitives/actionBar/ActionBarFeedbackPositive.js +60 -11
  93. package/dist/primitives/actionBar/ActionBarFeedbackPositive.js.map +1 -1
  94. package/dist/primitives/actionBar/ActionBarInteractionContext.js +3 -1
  95. package/dist/primitives/actionBar/ActionBarInteractionContext.js.map +1 -1
  96. package/dist/primitives/actionBar/ActionBarReload.js.map +1 -1
  97. package/dist/primitives/actionBar/ActionBarRoot.js +84 -25
  98. package/dist/primitives/actionBar/ActionBarRoot.js.map +1 -1
  99. package/dist/primitives/actionBar/ActionBarSpeak.js.map +1 -1
  100. package/dist/primitives/actionBar/ActionBarStopSpeaking.js +45 -14
  101. package/dist/primitives/actionBar/ActionBarStopSpeaking.js.map +1 -1
  102. package/dist/primitives/actionBar/useActionBarFloatStatus.js +22 -10
  103. package/dist/primitives/actionBar/useActionBarFloatStatus.js.map +1 -1
  104. package/dist/primitives/actionBar.js.map +1 -1
  105. package/dist/primitives/actionBarMore/ActionBarMoreContent.js +44 -7
  106. package/dist/primitives/actionBarMore/ActionBarMoreContent.js.map +1 -1
  107. package/dist/primitives/actionBarMore/ActionBarMoreItem.js +28 -6
  108. package/dist/primitives/actionBarMore/ActionBarMoreItem.js.map +1 -1
  109. package/dist/primitives/actionBarMore/ActionBarMoreRoot.js +103 -36
  110. package/dist/primitives/actionBarMore/ActionBarMoreRoot.js.map +1 -1
  111. package/dist/primitives/actionBarMore/ActionBarMoreSeparator.js +28 -6
  112. package/dist/primitives/actionBarMore/ActionBarMoreSeparator.js.map +1 -1
  113. package/dist/primitives/actionBarMore/ActionBarMoreTrigger.js +28 -6
  114. package/dist/primitives/actionBarMore/ActionBarMoreTrigger.js.map +1 -1
  115. package/dist/primitives/actionBarMore/scope.js.map +1 -1
  116. package/dist/primitives/actionBarMore.js.map +1 -1
  117. package/dist/primitives/assistantModal/AssistantModalAnchor.js +27 -6
  118. package/dist/primitives/assistantModal/AssistantModalAnchor.js.map +1 -1
  119. package/dist/primitives/assistantModal/AssistantModalContent.js +71 -10
  120. package/dist/primitives/assistantModal/AssistantModalContent.js.map +1 -1
  121. package/dist/primitives/assistantModal/AssistantModalRoot.js +93 -26
  122. package/dist/primitives/assistantModal/AssistantModalRoot.js.map +1 -1
  123. package/dist/primitives/assistantModal/AssistantModalTrigger.js +27 -6
  124. package/dist/primitives/assistantModal/AssistantModalTrigger.js.map +1 -1
  125. package/dist/primitives/assistantModal/scope.js.map +1 -1
  126. package/dist/primitives/assistantModal.js.map +1 -1
  127. package/dist/primitives/attachment/AttachmentName.js +13 -1
  128. package/dist/primitives/attachment/AttachmentName.js.map +1 -1
  129. package/dist/primitives/attachment/AttachmentRemove.js +11 -4
  130. package/dist/primitives/attachment/AttachmentRemove.js.map +1 -1
  131. package/dist/primitives/attachment/AttachmentRoot.js +13 -4
  132. package/dist/primitives/attachment/AttachmentRoot.js.map +1 -1
  133. package/dist/primitives/attachment/AttachmentThumb.js +20 -9
  134. package/dist/primitives/attachment/AttachmentThumb.js.map +1 -1
  135. package/dist/primitives/attachment.js.map +1 -1
  136. package/dist/primitives/branchPicker/BranchPickerCount.js +14 -2
  137. package/dist/primitives/branchPicker/BranchPickerCount.js.map +1 -1
  138. package/dist/primitives/branchPicker/BranchPickerNext.js.map +1 -1
  139. package/dist/primitives/branchPicker/BranchPickerNumber.js +14 -2
  140. package/dist/primitives/branchPicker/BranchPickerNumber.js.map +1 -1
  141. package/dist/primitives/branchPicker/BranchPickerPrevious.js.map +1 -1
  142. package/dist/primitives/branchPicker/BranchPickerRoot.js +34 -6
  143. package/dist/primitives/branchPicker/BranchPickerRoot.js.map +1 -1
  144. package/dist/primitives/branchPicker.js.map +1 -1
  145. package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js +16 -5
  146. package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js.map +1 -1
  147. package/dist/primitives/chainOfThought/ChainOfThoughtRoot.js +13 -4
  148. package/dist/primitives/chainOfThought/ChainOfThoughtRoot.js.map +1 -1
  149. package/dist/primitives/chainOfThought.js.map +1 -1
  150. package/dist/primitives/composer/ComposerAddAttachment.js +37 -24
  151. package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
  152. package/dist/primitives/composer/ComposerAttachmentDropzone.js +124 -49
  153. package/dist/primitives/composer/ComposerAttachmentDropzone.js.map +1 -1
  154. package/dist/primitives/composer/ComposerCancel.js.map +1 -1
  155. package/dist/primitives/composer/ComposerDictate.js.map +1 -1
  156. package/dist/primitives/composer/ComposerDictationTranscript.js +32 -7
  157. package/dist/primitives/composer/ComposerDictationTranscript.js.map +1 -1
  158. package/dist/primitives/composer/ComposerInput.js +29 -29
  159. package/dist/primitives/composer/ComposerInput.js.map +1 -1
  160. package/dist/primitives/composer/ComposerInputPluginContext.js +71 -25
  161. package/dist/primitives/composer/ComposerInputPluginContext.js.map +1 -1
  162. package/dist/primitives/composer/ComposerQuote.js +92 -23
  163. package/dist/primitives/composer/ComposerQuote.js.map +1 -1
  164. package/dist/primitives/composer/ComposerRoot.js +45 -11
  165. package/dist/primitives/composer/ComposerRoot.js.map +1 -1
  166. package/dist/primitives/composer/ComposerSend.js +9 -2
  167. package/dist/primitives/composer/ComposerSend.js.map +1 -1
  168. package/dist/primitives/composer/ComposerStopDictation.js +15 -5
  169. package/dist/primitives/composer/ComposerStopDictation.js.map +1 -1
  170. package/dist/primitives/composer/trigger/TriggerPopover.d.ts.map +1 -1
  171. package/dist/primitives/composer/trigger/TriggerPopover.js +215 -75
  172. package/dist/primitives/composer/trigger/TriggerPopover.js.map +1 -1
  173. package/dist/primitives/composer/trigger/TriggerPopoverAction.js.map +1 -1
  174. package/dist/primitives/composer/trigger/TriggerPopoverBack.js +35 -7
  175. package/dist/primitives/composer/trigger/TriggerPopoverBack.js.map +1 -1
  176. package/dist/primitives/composer/trigger/TriggerPopoverCategories.js +134 -28
  177. package/dist/primitives/composer/trigger/TriggerPopoverCategories.js.map +1 -1
  178. package/dist/primitives/composer/trigger/TriggerPopoverDirective.js.map +1 -1
  179. package/dist/primitives/composer/trigger/TriggerPopoverItems.js +132 -28
  180. package/dist/primitives/composer/trigger/TriggerPopoverItems.js.map +1 -1
  181. package/dist/primitives/composer/trigger/TriggerPopoverResource.d.ts +2 -10
  182. package/dist/primitives/composer/trigger/TriggerPopoverResource.d.ts.map +1 -1
  183. package/dist/primitives/composer/trigger/TriggerPopoverResource.js +126 -53
  184. package/dist/primitives/composer/trigger/TriggerPopoverResource.js.map +1 -1
  185. package/dist/primitives/composer/trigger/TriggerPopoverRootContext.js +181 -78
  186. package/dist/primitives/composer/trigger/TriggerPopoverRootContext.js.map +1 -1
  187. package/dist/primitives/composer/trigger/detectTrigger.js.map +1 -1
  188. package/dist/primitives/composer/trigger/index.js.map +1 -1
  189. package/dist/primitives/composer/trigger/triggerDetectionResource.d.ts +2 -6
  190. package/dist/primitives/composer/trigger/triggerDetectionResource.d.ts.map +1 -1
  191. package/dist/primitives/composer/trigger/triggerDetectionResource.js +30 -15
  192. package/dist/primitives/composer/trigger/triggerDetectionResource.js.map +1 -1
  193. package/dist/primitives/composer/trigger/triggerKeyboardResource.d.ts +2 -17
  194. package/dist/primitives/composer/trigger/triggerKeyboardResource.d.ts.map +1 -1
  195. package/dist/primitives/composer/trigger/triggerKeyboardResource.js +117 -59
  196. package/dist/primitives/composer/trigger/triggerKeyboardResource.js.map +1 -1
  197. package/dist/primitives/composer/trigger/triggerNavigationResource.d.ts +2 -10
  198. package/dist/primitives/composer/trigger/triggerNavigationResource.d.ts.map +1 -1
  199. package/dist/primitives/composer/trigger/triggerNavigationResource.js +204 -71
  200. package/dist/primitives/composer/trigger/triggerNavigationResource.js.map +1 -1
  201. package/dist/primitives/composer/trigger/triggerSelectionResource.d.ts +2 -10
  202. package/dist/primitives/composer/trigger/triggerSelectionResource.d.ts.map +1 -1
  203. package/dist/primitives/composer/trigger/triggerSelectionResource.js +51 -14
  204. package/dist/primitives/composer/trigger/triggerSelectionResource.js.map +1 -1
  205. package/dist/primitives/composer.js.map +1 -1
  206. package/dist/primitives/dropdownMenuRenderPrimitives.js.map +1 -1
  207. package/dist/primitives/error/ErrorMessage.js +28 -6
  208. package/dist/primitives/error/ErrorMessage.js.map +1 -1
  209. package/dist/primitives/error/ErrorRoot.js +14 -5
  210. package/dist/primitives/error/ErrorRoot.js.map +1 -1
  211. package/dist/primitives/error.js.map +1 -1
  212. package/dist/primitives/message/MessageError.js +2 -1
  213. package/dist/primitives/message/MessageError.js.map +1 -1
  214. package/dist/primitives/message/MessageIf.js +50 -20
  215. package/dist/primitives/message/MessageIf.js.map +1 -1
  216. package/dist/primitives/message/MessageParts.js +41 -7
  217. package/dist/primitives/message/MessageParts.js.map +1 -1
  218. package/dist/primitives/message/MessagePartsGrouped.js +399 -94
  219. package/dist/primitives/message/MessagePartsGrouped.js.map +1 -1
  220. package/dist/primitives/message/MessageRoot.js +197 -65
  221. package/dist/primitives/message/MessageRoot.js.map +1 -1
  222. package/dist/primitives/message.js.map +1 -1
  223. package/dist/primitives/messagePart/MessagePartImage.js +15 -5
  224. package/dist/primitives/messagePart/MessagePartImage.js.map +1 -1
  225. package/dist/primitives/messagePart/MessagePartText.d.ts +5 -2
  226. package/dist/primitives/messagePart/MessagePartText.d.ts.map +1 -1
  227. package/dist/primitives/messagePart/MessagePartText.js +35 -7
  228. package/dist/primitives/messagePart/MessagePartText.js.map +1 -1
  229. package/dist/primitives/messagePart/useMessagePartData.js +5 -4
  230. package/dist/primitives/messagePart/useMessagePartData.js.map +1 -1
  231. package/dist/primitives/messagePart/useMessagePartFile.js +5 -4
  232. package/dist/primitives/messagePart/useMessagePartFile.js.map +1 -1
  233. package/dist/primitives/messagePart/useMessagePartImage.js +5 -4
  234. package/dist/primitives/messagePart/useMessagePartImage.js.map +1 -1
  235. package/dist/primitives/messagePart/useMessagePartReasoning.js +5 -4
  236. package/dist/primitives/messagePart/useMessagePartReasoning.js.map +1 -1
  237. package/dist/primitives/messagePart/useMessagePartSource.js +5 -4
  238. package/dist/primitives/messagePart/useMessagePartSource.js.map +1 -1
  239. package/dist/primitives/messagePart/useMessagePartText.js +5 -4
  240. package/dist/primitives/messagePart/useMessagePartText.js.map +1 -1
  241. package/dist/primitives/messagePart.js.map +1 -1
  242. package/dist/primitives/queueItem/QueueItemRemove.js +11 -4
  243. package/dist/primitives/queueItem/QueueItemRemove.js.map +1 -1
  244. package/dist/primitives/queueItem/QueueItemSteer.js +11 -4
  245. package/dist/primitives/queueItem/QueueItemSteer.js.map +1 -1
  246. package/dist/primitives/queueItem/QueueItemText.js +20 -6
  247. package/dist/primitives/queueItem/QueueItemText.js.map +1 -1
  248. package/dist/primitives/queueItem.js.map +1 -1
  249. package/dist/primitives/reasoning/useScrollLock.js +61 -34
  250. package/dist/primitives/reasoning/useScrollLock.js.map +1 -1
  251. package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js +56 -16
  252. package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js.map +1 -1
  253. package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js +120 -59
  254. package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js.map +1 -1
  255. package/dist/primitives/selectionToolbar.js.map +1 -1
  256. package/dist/primitives/suggestion/SuggestionDescription.js +20 -6
  257. package/dist/primitives/suggestion/SuggestionDescription.js.map +1 -1
  258. package/dist/primitives/suggestion/SuggestionTitle.js +20 -6
  259. package/dist/primitives/suggestion/SuggestionTitle.js.map +1 -1
  260. package/dist/primitives/suggestion/SuggestionTrigger.js +39 -26
  261. package/dist/primitives/suggestion/SuggestionTrigger.js.map +1 -1
  262. package/dist/primitives/suggestion.js.map +1 -1
  263. package/dist/primitives/thread/ThreadEmpty.js +6 -2
  264. package/dist/primitives/thread/ThreadEmpty.js.map +1 -1
  265. package/dist/primitives/thread/ThreadIf.js +32 -10
  266. package/dist/primitives/thread/ThreadIf.js.map +1 -1
  267. package/dist/primitives/thread/ThreadRoot.js +13 -4
  268. package/dist/primitives/thread/ThreadRoot.js.map +1 -1
  269. package/dist/primitives/thread/ThreadScrollToBottom.js +24 -6
  270. package/dist/primitives/thread/ThreadScrollToBottom.js.map +1 -1
  271. package/dist/primitives/thread/ThreadSuggestion.js +18 -6
  272. package/dist/primitives/thread/ThreadSuggestion.js.map +1 -1
  273. package/dist/primitives/thread/ThreadViewport.js +185 -47
  274. package/dist/primitives/thread/ThreadViewport.js.map +1 -1
  275. package/dist/primitives/thread/ThreadViewportFooter.js +22 -9
  276. package/dist/primitives/thread/ThreadViewportFooter.js.map +1 -1
  277. package/dist/primitives/thread/topAnchor/computeTopAnchorSlack.js.map +1 -1
  278. package/dist/primitives/thread/topAnchor/createReserveObservers.js.map +1 -1
  279. package/dist/primitives/thread/topAnchor/mountTopAnchorReserve.js.map +1 -1
  280. package/dist/primitives/thread/topAnchor/topAnchorTurn.js.map +1 -1
  281. package/dist/primitives/thread/topAnchor/topAnchorUtils.js.map +1 -1
  282. package/dist/primitives/thread/topAnchor/useTopAnchorReserve.js +19 -4
  283. package/dist/primitives/thread/topAnchor/useTopAnchorReserve.js.map +1 -1
  284. package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts.map +1 -1
  285. package/dist/primitives/thread/useThreadViewportAutoScroll.js +21 -16
  286. package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
  287. package/dist/primitives/thread.js.map +1 -1
  288. package/dist/primitives/threadList/ThreadListLoadMore.js.map +1 -1
  289. package/dist/primitives/threadList/ThreadListNew.js +53 -11
  290. package/dist/primitives/threadList/ThreadListNew.js.map +1 -1
  291. package/dist/primitives/threadList/ThreadListRoot.js +13 -4
  292. package/dist/primitives/threadList/ThreadListRoot.js.map +1 -1
  293. package/dist/primitives/threadList.js.map +1 -1
  294. package/dist/primitives/threadListItem/ThreadListItemArchive.js.map +1 -1
  295. package/dist/primitives/threadListItem/ThreadListItemDelete.js.map +1 -1
  296. package/dist/primitives/threadListItem/ThreadListItemRoot.js +26 -7
  297. package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
  298. package/dist/primitives/threadListItem/ThreadListItemTrigger.js.map +1 -1
  299. package/dist/primitives/threadListItem/ThreadListItemUnarchive.js.map +1 -1
  300. package/dist/primitives/threadListItem.js.map +1 -1
  301. package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js +44 -7
  302. package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js.map +1 -1
  303. package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.js +28 -6
  304. package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.js.map +1 -1
  305. package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.js +25 -5
  306. package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.js.map +1 -1
  307. package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.js +28 -6
  308. package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.js.map +1 -1
  309. package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.js +28 -6
  310. package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.js.map +1 -1
  311. package/dist/primitives/threadListItemMore/scope.js.map +1 -1
  312. package/dist/primitives/threadListItemMore.js.map +1 -1
  313. package/dist/sandbox-host/SandboxHost.js.map +1 -1
  314. package/dist/tests/remote-thread-list-test-helpers.js.map +1 -1
  315. package/dist/tests/setup.js.map +1 -1
  316. package/dist/unstable/useComposerInputHistory.d.ts +30 -0
  317. package/dist/unstable/useComposerInputHistory.d.ts.map +1 -0
  318. package/dist/unstable/useComposerInputHistory.js +117 -0
  319. package/dist/unstable/useComposerInputHistory.js.map +1 -0
  320. package/dist/unstable/useMentionAdapter.js.map +1 -1
  321. package/dist/unstable/useMessageStallDetection.d.ts +29 -0
  322. package/dist/unstable/useMessageStallDetection.d.ts.map +1 -0
  323. package/dist/unstable/useMessageStallDetection.js +69 -0
  324. package/dist/unstable/useMessageStallDetection.js.map +1 -0
  325. package/dist/unstable/useSlashCommandAdapter.js.map +1 -1
  326. package/dist/utils/Primitive.js +57 -12
  327. package/dist/utils/Primitive.js.map +1 -1
  328. package/dist/utils/createActionButton.js +23 -7
  329. package/dist/utils/createActionButton.js.map +1 -1
  330. package/dist/utils/getSelectionMessageId.js.map +1 -1
  331. package/dist/utils/hooks/useManagedRef.js +16 -8
  332. package/dist/utils/hooks/useManagedRef.js.map +1 -1
  333. package/dist/utils/hooks/useMediaQuery.js +25 -10
  334. package/dist/utils/hooks/useMediaQuery.js.map +1 -1
  335. package/dist/utils/hooks/useOnResizeContent.js +29 -19
  336. package/dist/utils/hooks/useOnResizeContent.js.map +1 -1
  337. package/dist/utils/hooks/useOnScrollToBottom.js +20 -4
  338. package/dist/utils/hooks/useOnScrollToBottom.js.map +1 -1
  339. package/dist/utils/hooks/useSizeHandle.js +23 -15
  340. package/dist/utils/hooks/useSizeHandle.js.map +1 -1
  341. package/dist/utils/json/is-json-equal.js.map +1 -1
  342. package/dist/utils/json/is-json.js.map +1 -1
  343. package/dist/utils/smooth/SmoothContext.js +41 -11
  344. package/dist/utils/smooth/SmoothContext.js.map +1 -1
  345. package/dist/utils/smooth/useSmooth.d.ts +40 -2
  346. package/dist/utils/smooth/useSmooth.d.ts.map +1 -1
  347. package/dist/utils/smooth/useSmooth.js +52 -13
  348. package/dist/utils/smooth/useSmooth.js.map +1 -1
  349. package/dist/utils/useToolArgsFieldStatus.d.ts +2 -2
  350. package/dist/utils/useToolArgsFieldStatus.d.ts.map +1 -1
  351. package/dist/utils/useToolArgsFieldStatus.js +13 -5
  352. package/dist/utils/useToolArgsFieldStatus.js.map +1 -1
  353. package/package.json +6 -6
  354. package/src/client/ExternalThread.ts +146 -74
  355. package/src/client/InMemoryThreadList.ts +23 -21
  356. package/src/client/SingleThreadList.ts +29 -27
  357. package/src/hooks/useToolCallElapsed.ts +52 -0
  358. package/src/index.ts +19 -0
  359. package/src/mcp-apps/McpAppRenderer.tsx +5 -3
  360. package/src/mcp-apps/McpAppsRemoteHost.ts +5 -3
  361. package/src/primitives/composer/ComposerInput.test.tsx +1 -1
  362. package/src/primitives/composer/ComposerInput.tsx +3 -3
  363. package/src/primitives/composer/trigger/TriggerPopover.tsx +4 -5
  364. package/src/primitives/composer/trigger/TriggerPopoverResource.ts +5 -3
  365. package/src/primitives/composer/trigger/triggerDetectionResource.ts +21 -21
  366. package/src/primitives/composer/trigger/triggerKeyboardResource.test.ts +5 -4
  367. package/src/primitives/composer/trigger/triggerKeyboardResource.ts +99 -101
  368. package/src/primitives/composer/trigger/triggerNavigationResource.ts +92 -98
  369. package/src/primitives/composer/trigger/triggerSelectionResource.ts +76 -76
  370. package/src/primitives/messagePart/MessagePartText.tsx +3 -2
  371. package/src/primitives/reasoning/useScrollLock.ts +25 -2
  372. package/src/primitives/thread/useThreadViewportAutoScroll.ts +8 -0
  373. package/src/tests/external-thread-branches.test.tsx +160 -0
  374. package/src/tests/shouldContinue.test.ts +33 -0
  375. package/src/tests/toolCallTiming.test.tsx +221 -0
  376. package/src/unstable/useComposerInputHistory.test.tsx +201 -0
  377. package/src/unstable/useComposerInputHistory.ts +160 -0
  378. package/src/unstable/useMessageStallDetection.ts +91 -0
  379. package/src/utils/smooth/useSmooth.test.tsx +95 -0
  380. package/src/utils/smooth/useSmooth.ts +82 -10
@@ -1 +1 @@
1
- {"version":3,"file":"computeTopAnchorSlack.js","names":[],"sources":["../../../../src/primitives/thread/topAnchor/computeTopAnchorSlack.ts"],"sourcesContent":["\"use client\";\n\nexport type ComputeTopAnchorTargetOptions = {\n viewport: HTMLElement;\n anchor: HTMLElement;\n tallerThan: number;\n visibleHeight: number;\n};\n\nexport type ComputeTopAnchorReserveOptions = ComputeTopAnchorTargetOptions & {\n reserve: HTMLElement;\n};\n\ntype ComputeTopAnchorSlackOptions = ComputeTopAnchorTargetOptions & {\n scrollHeight: number;\n};\n\nconst getDocumentOffsetTop = (element: HTMLElement): number => {\n let top = 0;\n let current: HTMLElement | null = element;\n\n while (current) {\n top += current.offsetTop;\n current = current.offsetParent as HTMLElement | null;\n }\n\n return top;\n};\n\nconst getLayoutOffsetTop = (\n element: HTMLElement,\n ancestor: HTMLElement,\n): number => {\n // Use layout geometry, not visual rects, so entrance transforms/animations\n // on the anchor do not shift the scroll target while they settle.\n let top = 0;\n let current: HTMLElement | null = element;\n\n while (current && current !== ancestor) {\n top += current.offsetTop;\n current = current.offsetParent as HTMLElement | null;\n }\n\n if (current === ancestor) return top;\n\n return getDocumentOffsetTop(element) - getDocumentOffsetTop(ancestor);\n};\n\n/**\n * Compute the scroll position that pins the anchor (last user message) to the\n * top of the viewport. For tall user messages the anchor is intentionally\n * over-scrolled so only `visibleHeight` of it remains visible, leaving room\n * for the assistant message below.\n *\n * Depends only on the anchor's offset within the scroll content; never reads\n * `viewport.scrollHeight` (which is volatile while the assistant message\n * streams in).\n */\nexport const computeTopAnchorTargetScrollTop = ({\n viewport,\n anchor,\n tallerThan,\n visibleHeight,\n}: ComputeTopAnchorTargetOptions): number => {\n const anchorTop = getLayoutOffsetTop(anchor, viewport);\n const anchorHeight = anchor.offsetHeight;\n const visibleAnchorHeight =\n anchorHeight <= tallerThan ? anchorHeight : visibleHeight;\n\n return anchorTop + Math.max(0, anchorHeight - visibleAnchorHeight);\n};\n\nconst computeTopAnchorSlack = ({\n scrollHeight,\n ...targetOptions\n}: ComputeTopAnchorSlackOptions): number => {\n const { viewport } = targetOptions;\n const targetScrollTop = computeTopAnchorTargetScrollTop(targetOptions);\n const targetScrollHeight = targetScrollTop + viewport.clientHeight;\n\n return Math.max(0, targetScrollHeight - scrollHeight);\n};\n\nexport const computeTopAnchorReserve = ({\n viewport,\n reserve,\n ...targetOptions\n}: ComputeTopAnchorReserveOptions): number => {\n return computeTopAnchorSlack({\n viewport,\n ...targetOptions,\n scrollHeight: viewport.scrollHeight - reserve.offsetHeight,\n });\n};\n"],"mappings":";;AAiBA,MAAM,wBAAwB,YAAiC;CAC7D,IAAI,MAAM;CACV,IAAI,UAA8B;CAElC,OAAO,SAAS;EACd,OAAO,QAAQ;EACf,UAAU,QAAQ;CACpB;CAEA,OAAO;AACT;AAEA,MAAM,sBACJ,SACA,aACW;CAGX,IAAI,MAAM;CACV,IAAI,UAA8B;CAElC,OAAO,WAAW,YAAY,UAAU;EACtC,OAAO,QAAQ;EACf,UAAU,QAAQ;CACpB;CAEA,IAAI,YAAY,UAAU,OAAO;CAEjC,OAAO,qBAAqB,OAAO,IAAI,qBAAqB,QAAQ;AACtE;;;;;;;;;;;AAYA,MAAa,mCAAmC,EAC9C,UACA,QACA,YACA,oBAC2C;CAC3C,MAAM,YAAY,mBAAmB,QAAQ,QAAQ;CACrD,MAAM,eAAe,OAAO;CAI5B,OAAO,YAAY,KAAK,IAAI,GAAG,gBAF7B,gBAAgB,aAAa,eAAe,cAEmB;AACnE;AAEA,MAAM,yBAAyB,EAC7B,cACA,GAAG,oBACuC;CAC1C,MAAM,EAAE,aAAa;CAErB,MAAM,qBADkB,gCAAgC,aACf,IAAI,SAAS;CAEtD,OAAO,KAAK,IAAI,GAAG,qBAAqB,YAAY;AACtD;AAEA,MAAa,2BAA2B,EACtC,UACA,SACA,GAAG,oBACyC;CAC5C,OAAO,sBAAsB;EAC3B;EACA,GAAG;EACH,cAAc,SAAS,eAAe,QAAQ;CAChD,CAAC;AACH"}
1
+ {"version":3,"file":"computeTopAnchorSlack.js","names":["ComputeTopAnchorTargetOptions","viewport","HTMLElement","anchor","tallerThan","visibleHeight","ComputeTopAnchorReserveOptions","reserve","ComputeTopAnchorSlackOptions","scrollHeight","getDocumentOffsetTop","element","top","current","offsetTop","offsetParent","getLayoutOffsetTop","ancestor","computeTopAnchorTargetScrollTop","anchorTop","anchorHeight","offsetHeight","visibleAnchorHeight","Math","max","computeTopAnchorSlack","targetOptions","targetScrollTop","targetScrollHeight","clientHeight","computeTopAnchorReserve"],"sources":["../../../../src/primitives/thread/topAnchor/computeTopAnchorSlack.ts"],"sourcesContent":["\"use client\";\n\nexport type ComputeTopAnchorTargetOptions = {\n viewport: HTMLElement;\n anchor: HTMLElement;\n tallerThan: number;\n visibleHeight: number;\n};\n\nexport type ComputeTopAnchorReserveOptions = ComputeTopAnchorTargetOptions & {\n reserve: HTMLElement;\n};\n\ntype ComputeTopAnchorSlackOptions = ComputeTopAnchorTargetOptions & {\n scrollHeight: number;\n};\n\nconst getDocumentOffsetTop = (element: HTMLElement): number => {\n let top = 0;\n let current: HTMLElement | null = element;\n\n while (current) {\n top += current.offsetTop;\n current = current.offsetParent as HTMLElement | null;\n }\n\n return top;\n};\n\nconst getLayoutOffsetTop = (\n element: HTMLElement,\n ancestor: HTMLElement,\n): number => {\n // Use layout geometry, not visual rects, so entrance transforms/animations\n // on the anchor do not shift the scroll target while they settle.\n let top = 0;\n let current: HTMLElement | null = element;\n\n while (current && current !== ancestor) {\n top += current.offsetTop;\n current = current.offsetParent as HTMLElement | null;\n }\n\n if (current === ancestor) return top;\n\n return getDocumentOffsetTop(element) - getDocumentOffsetTop(ancestor);\n};\n\n/**\n * Compute the scroll position that pins the anchor (last user message) to the\n * top of the viewport. For tall user messages the anchor is intentionally\n * over-scrolled so only `visibleHeight` of it remains visible, leaving room\n * for the assistant message below.\n *\n * Depends only on the anchor's offset within the scroll content; never reads\n * `viewport.scrollHeight` (which is volatile while the assistant message\n * streams in).\n */\nexport const computeTopAnchorTargetScrollTop = ({\n viewport,\n anchor,\n tallerThan,\n visibleHeight,\n}: ComputeTopAnchorTargetOptions): number => {\n const anchorTop = getLayoutOffsetTop(anchor, viewport);\n const anchorHeight = anchor.offsetHeight;\n const visibleAnchorHeight =\n anchorHeight <= tallerThan ? anchorHeight : visibleHeight;\n\n return anchorTop + Math.max(0, anchorHeight - visibleAnchorHeight);\n};\n\nconst computeTopAnchorSlack = ({\n scrollHeight,\n ...targetOptions\n}: ComputeTopAnchorSlackOptions): number => {\n const { viewport } = targetOptions;\n const targetScrollTop = computeTopAnchorTargetScrollTop(targetOptions);\n const targetScrollHeight = targetScrollTop + viewport.clientHeight;\n\n return Math.max(0, targetScrollHeight - scrollHeight);\n};\n\nexport const computeTopAnchorReserve = ({\n viewport,\n reserve,\n ...targetOptions\n}: ComputeTopAnchorReserveOptions): number => {\n return computeTopAnchorSlack({\n viewport,\n ...targetOptions,\n scrollHeight: viewport.scrollHeight - reserve.offsetHeight,\n });\n};\n"],"mappings":";;AAiBA,MAAMU,wBAAwBC,YAAiC;CAC7D,IAAIC,MAAM;CACV,IAAIC,UAA8BF;CAElC,OAAOE,SAAS;EACdD,OAAOC,QAAQC;EACfD,UAAUA,QAAQE;CACpB;CAEA,OAAOH;AACT;AAEA,MAAMI,sBACJL,SACAM,aACW;CAGX,IAAIL,MAAM;CACV,IAAIC,UAA8BF;CAElC,OAAOE,WAAWA,YAAYI,UAAU;EACtCL,OAAOC,QAAQC;EACfD,UAAUA,QAAQE;CACpB;CAEA,IAAIF,YAAYI,UAAU,OAAOL;CAEjC,OAAOF,qBAAqBC,OAAO,IAAID,qBAAqBO,QAAQ;AACtE;;;;;;;;;;;AAYA,MAAaC,mCAAmC,EAC9CjB,UACAE,QACAC,YACAC,oBAC2C;CAC3C,MAAMc,YAAYH,mBAAmBb,QAAQF,QAAQ;CACrD,MAAMmB,eAAejB,OAAOkB;CAI5B,OAAOF,YAAYI,KAAKC,IAAI,GAAGJ,gBAF7BA,gBAAgBhB,aAAagB,eAAef,cAEmB;AACnE;AAEA,MAAMoB,yBAAyB,EAC7BhB,cACA,GAAGiB,oBACuC;CAC1C,MAAM,EAAEzB,aAAayB;CAErB,MAAME,qBADkBV,gCAAgCQ,aAC7BC,IAAkB1B,SAAS4B;CAEtD,OAAON,KAAKC,IAAI,GAAGI,qBAAqBnB,YAAY;AACtD;AAEA,MAAaqB,2BAA2B,EACtC7B,UACAM,SACA,GAAGmB,oBACyC;CAC5C,OAAOD,sBAAsB;EAC3BxB;EACA,GAAGyB;EACHjB,cAAcR,SAASQ,eAAeF,QAAQc;CAChD,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"createReserveObservers.js","names":[],"sources":["../../../../src/primitives/thread/topAnchor/createReserveObservers.ts"],"sourcesContent":["\"use client\";\n\nexport const createReserveObservers = (onChange: () => void) => {\n const resizeObserver = new ResizeObserver(onChange);\n const mutationObserver = new MutationObserver(onChange);\n\n let observedViewport: HTMLElement | null = null;\n let observedAnchor: HTMLElement | null = null;\n let observedTarget: HTMLElement | null = null;\n\n const disconnect = () => {\n resizeObserver.disconnect();\n mutationObserver.disconnect();\n observedViewport = null;\n observedAnchor = null;\n observedTarget = null;\n };\n\n return {\n target: (\n viewport: HTMLElement,\n anchor: HTMLElement,\n target: HTMLElement,\n ) => {\n if (\n observedViewport === viewport &&\n observedAnchor === anchor &&\n observedTarget === target\n ) {\n return;\n }\n\n disconnect();\n\n resizeObserver.observe(viewport);\n resizeObserver.observe(anchor);\n resizeObserver.observe(target);\n mutationObserver.observe(target, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n\n observedViewport = viewport;\n observedAnchor = anchor;\n observedTarget = target;\n },\n disconnect,\n };\n};\n"],"mappings":";;AAEA,MAAa,0BAA0B,aAAyB;CAC9D,MAAM,iBAAiB,IAAI,eAAe,QAAQ;CAClD,MAAM,mBAAmB,IAAI,iBAAiB,QAAQ;CAEtD,IAAI,mBAAuC;CAC3C,IAAI,iBAAqC;CACzC,IAAI,iBAAqC;CAEzC,MAAM,mBAAmB;EACvB,eAAe,WAAW;EAC1B,iBAAiB,WAAW;EAC5B,mBAAmB;EACnB,iBAAiB;EACjB,iBAAiB;CACnB;CAEA,OAAO;EACL,SACE,UACA,QACA,WACG;GACH,IACE,qBAAqB,YACrB,mBAAmB,UACnB,mBAAmB,QAEnB;GAGF,WAAW;GAEX,eAAe,QAAQ,QAAQ;GAC/B,eAAe,QAAQ,MAAM;GAC7B,eAAe,QAAQ,MAAM;GAC7B,iBAAiB,QAAQ,QAAQ;IAC/B,WAAW;IACX,SAAS;IACT,eAAe;GACjB,CAAC;GAED,mBAAmB;GACnB,iBAAiB;GACjB,iBAAiB;EACnB;EACA;CACF;AACF"}
1
+ {"version":3,"file":"createReserveObservers.js","names":["createReserveObservers","onChange","resizeObserver","ResizeObserver","mutationObserver","MutationObserver","observedViewport","HTMLElement","observedAnchor","observedTarget","disconnect","target","viewport","anchor","observe","childList","subtree","characterData"],"sources":["../../../../src/primitives/thread/topAnchor/createReserveObservers.ts"],"sourcesContent":["\"use client\";\n\nexport const createReserveObservers = (onChange: () => void) => {\n const resizeObserver = new ResizeObserver(onChange);\n const mutationObserver = new MutationObserver(onChange);\n\n let observedViewport: HTMLElement | null = null;\n let observedAnchor: HTMLElement | null = null;\n let observedTarget: HTMLElement | null = null;\n\n const disconnect = () => {\n resizeObserver.disconnect();\n mutationObserver.disconnect();\n observedViewport = null;\n observedAnchor = null;\n observedTarget = null;\n };\n\n return {\n target: (\n viewport: HTMLElement,\n anchor: HTMLElement,\n target: HTMLElement,\n ) => {\n if (\n observedViewport === viewport &&\n observedAnchor === anchor &&\n observedTarget === target\n ) {\n return;\n }\n\n disconnect();\n\n resizeObserver.observe(viewport);\n resizeObserver.observe(anchor);\n resizeObserver.observe(target);\n mutationObserver.observe(target, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n\n observedViewport = viewport;\n observedAnchor = anchor;\n observedTarget = target;\n },\n disconnect,\n };\n};\n"],"mappings":";;AAEA,MAAaA,0BAA0BC,aAAyB;CAC9D,MAAMC,iBAAiB,IAAIC,eAAeF,QAAQ;CAClD,MAAMG,mBAAmB,IAAIC,iBAAiBJ,QAAQ;CAEtD,IAAIK,mBAAuC;CAC3C,IAAIE,iBAAqC;CACzC,IAAIC,iBAAqC;CAEzC,MAAMC,mBAAmB;EACvBR,eAAeQ,WAAW;EAC1BN,iBAAiBM,WAAW;EAC5BJ,mBAAmB;EACnBE,iBAAiB;EACjBC,iBAAiB;CACnB;CAEA,OAAO;EACLE,SACEC,UACAC,QACAF,WACG;GACH,IACEL,qBAAqBM,YACrBJ,mBAAmBK,UACnBJ,mBAAmBE,QAEnB;GAGFD,WAAW;GAEXR,eAAeY,QAAQF,QAAQ;GAC/BV,eAAeY,QAAQD,MAAM;GAC7BX,eAAeY,QAAQH,MAAM;GAC7BP,iBAAiBU,QAAQH,QAAQ;IAC/BI,WAAW;IACXC,SAAS;IACTC,eAAe;GACjB,CAAC;GAEDX,mBAAmBM;GACnBJ,iBAAiBK;GACjBJ,iBAAiBE;EACnB;EACAD;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"mountTopAnchorReserve.js","names":[],"sources":["../../../../src/primitives/thread/topAnchor/mountTopAnchorReserve.ts"],"sourcesContent":["\"use client\";\n\nimport {\n computeTopAnchorReserve,\n computeTopAnchorTargetScrollTop,\n} from \"./computeTopAnchorSlack\";\nimport { createReserveObservers } from \"./createReserveObservers\";\nimport {\n createReserveElement,\n getAnchorId,\n setReserveHeight,\n snapScrollTop,\n} from \"./topAnchorUtils\";\n\n/**\n * Minimal slice of `ThreadViewportStore` that the top-anchor reserve needs.\n * Decoupling from the full store keeps `mountTopAnchorReserve` testable in\n * isolation and re-usable from any consumer that can adapt to this shape.\n */\nexport type TopAnchorStore = {\n getState(): {\n turnAnchor: \"top\" | \"bottom\";\n element: {\n viewport: HTMLElement | null;\n anchor: HTMLElement | null;\n target: HTMLElement | null;\n };\n targetConfig: {\n tallerThan: number;\n visibleHeight: number;\n } | null;\n };\n subscribe(fn: () => void): () => void;\n};\n\nconst createFrameScheduler = (fn: () => void) => {\n let frame: number | null = null;\n\n return {\n schedule: () => {\n if (frame !== null) return;\n frame = requestAnimationFrame(() => {\n frame = null;\n fn();\n });\n },\n cancel: () => {\n if (frame !== null) {\n cancelAnimationFrame(frame);\n frame = null;\n }\n },\n };\n};\n\nexport const mountTopAnchorReserve = (store: TopAnchorStore) => {\n let reserve: HTMLElement | null = null;\n let lastScrolledAnchorId: string | undefined;\n\n function apply() {\n const state = store.getState();\n const { viewport, anchor, target } = state.element;\n const clamp = state.targetConfig;\n\n if (\n state.turnAnchor !== \"top\" ||\n !viewport ||\n !anchor ||\n !target ||\n !clamp\n ) {\n observers.disconnect();\n if (reserve) {\n setReserveHeight(reserve, 0);\n reserve.remove();\n }\n return;\n }\n\n reserve ??= createReserveElement();\n\n if (\n reserve.parentElement !== target.parentElement ||\n reserve.previousElementSibling !== target\n ) {\n target.after(reserve);\n }\n\n observers.target(viewport, anchor, target);\n\n const reserveChanged = setReserveHeight(\n reserve,\n computeTopAnchorReserve({ viewport, anchor, reserve, ...clamp }),\n );\n\n if (reserveChanged) {\n scheduler.schedule();\n return;\n }\n\n const anchorId = getAnchorId(anchor);\n if (anchorId !== undefined && lastScrolledAnchorId === anchorId) return;\n\n const targetScrollTop = snapScrollTop(\n computeTopAnchorTargetScrollTop({ viewport, anchor, ...clamp }),\n );\n\n if (Math.abs(viewport.scrollTop - targetScrollTop) > 1) {\n viewport.scrollTo({ top: targetScrollTop, behavior: \"smooth\" });\n }\n\n if (anchorId !== undefined) lastScrolledAnchorId = anchorId;\n }\n\n const scheduler = createFrameScheduler(apply);\n const observers = createReserveObservers(scheduler.schedule);\n\n scheduler.schedule();\n const unsubscribe = store.subscribe(scheduler.schedule);\n\n return () => {\n scheduler.cancel();\n unsubscribe();\n observers.disconnect();\n reserve?.remove();\n };\n};\n"],"mappings":";;;;;AAmCA,MAAM,wBAAwB,OAAmB;CAC/C,IAAI,QAAuB;CAE3B,OAAO;EACL,gBAAgB;GACd,IAAI,UAAU,MAAM;GACpB,QAAQ,4BAA4B;IAClC,QAAQ;IACR,GAAG;GACL,CAAC;EACH;EACA,cAAc;GACZ,IAAI,UAAU,MAAM;IAClB,qBAAqB,KAAK;IAC1B,QAAQ;GACV;EACF;CACF;AACF;AAEA,MAAa,yBAAyB,UAA0B;CAC9D,IAAI,UAA8B;CAClC,IAAI;CAEJ,SAAS,QAAQ;EACf,MAAM,QAAQ,MAAM,SAAS;EAC7B,MAAM,EAAE,UAAU,QAAQ,WAAW,MAAM;EAC3C,MAAM,QAAQ,MAAM;EAEpB,IACE,MAAM,eAAe,SACrB,CAAC,YACD,CAAC,UACD,CAAC,UACD,CAAC,OACD;GACA,UAAU,WAAW;GACrB,IAAI,SAAS;IACX,iBAAiB,SAAS,CAAC;IAC3B,QAAQ,OAAO;GACjB;GACA;EACF;EAEA,YAAY,qBAAqB;EAEjC,IACE,QAAQ,kBAAkB,OAAO,iBACjC,QAAQ,2BAA2B,QAEnC,OAAO,MAAM,OAAO;EAGtB,UAAU,OAAO,UAAU,QAAQ,MAAM;EAOzC,IALuB,iBACrB,SACA,wBAAwB;GAAE;GAAU;GAAQ;GAAS,GAAG;EAAM,CAAC,CAGhD,GAAG;GAClB,UAAU,SAAS;GACnB;EACF;EAEA,MAAM,WAAW,YAAY,MAAM;EACnC,IAAI,aAAa,KAAA,KAAa,yBAAyB,UAAU;EAEjE,MAAM,kBAAkB,cACtB,gCAAgC;GAAE;GAAU;GAAQ,GAAG;EAAM,CAAC,CAChE;EAEA,IAAI,KAAK,IAAI,SAAS,YAAY,eAAe,IAAI,GACnD,SAAS,SAAS;GAAE,KAAK;GAAiB,UAAU;EAAS,CAAC;EAGhE,IAAI,aAAa,KAAA,GAAW,uBAAuB;CACrD;CAEA,MAAM,YAAY,qBAAqB,KAAK;CAC5C,MAAM,YAAY,uBAAuB,UAAU,QAAQ;CAE3D,UAAU,SAAS;CACnB,MAAM,cAAc,MAAM,UAAU,UAAU,QAAQ;CAEtD,aAAa;EACX,UAAU,OAAO;EACjB,YAAY;EACZ,UAAU,WAAW;EACrB,SAAS,OAAO;CAClB;AACF"}
1
+ {"version":3,"file":"mountTopAnchorReserve.js","names":["computeTopAnchorReserve","computeTopAnchorTargetScrollTop","createReserveObservers","createReserveElement","getAnchorId","setReserveHeight","snapScrollTop","TopAnchorStore","getState","turnAnchor","element","viewport","HTMLElement","anchor","target","targetConfig","tallerThan","visibleHeight","subscribe","fn","createFrameScheduler","frame","schedule","requestAnimationFrame","cancel","cancelAnimationFrame","mountTopAnchorReserve","store","reserve","lastScrolledAnchorId","apply","state","clamp","observers","disconnect","remove","parentElement","previousElementSibling","after","reserveChanged","scheduler","anchorId","undefined","targetScrollTop","Math","abs","scrollTop","scrollTo","top","behavior","unsubscribe"],"sources":["../../../../src/primitives/thread/topAnchor/mountTopAnchorReserve.ts"],"sourcesContent":["\"use client\";\n\nimport {\n computeTopAnchorReserve,\n computeTopAnchorTargetScrollTop,\n} from \"./computeTopAnchorSlack\";\nimport { createReserveObservers } from \"./createReserveObservers\";\nimport {\n createReserveElement,\n getAnchorId,\n setReserveHeight,\n snapScrollTop,\n} from \"./topAnchorUtils\";\n\n/**\n * Minimal slice of `ThreadViewportStore` that the top-anchor reserve needs.\n * Decoupling from the full store keeps `mountTopAnchorReserve` testable in\n * isolation and re-usable from any consumer that can adapt to this shape.\n */\nexport type TopAnchorStore = {\n getState(): {\n turnAnchor: \"top\" | \"bottom\";\n element: {\n viewport: HTMLElement | null;\n anchor: HTMLElement | null;\n target: HTMLElement | null;\n };\n targetConfig: {\n tallerThan: number;\n visibleHeight: number;\n } | null;\n };\n subscribe(fn: () => void): () => void;\n};\n\nconst createFrameScheduler = (fn: () => void) => {\n let frame: number | null = null;\n\n return {\n schedule: () => {\n if (frame !== null) return;\n frame = requestAnimationFrame(() => {\n frame = null;\n fn();\n });\n },\n cancel: () => {\n if (frame !== null) {\n cancelAnimationFrame(frame);\n frame = null;\n }\n },\n };\n};\n\nexport const mountTopAnchorReserve = (store: TopAnchorStore) => {\n let reserve: HTMLElement | null = null;\n let lastScrolledAnchorId: string | undefined;\n\n function apply() {\n const state = store.getState();\n const { viewport, anchor, target } = state.element;\n const clamp = state.targetConfig;\n\n if (\n state.turnAnchor !== \"top\" ||\n !viewport ||\n !anchor ||\n !target ||\n !clamp\n ) {\n observers.disconnect();\n if (reserve) {\n setReserveHeight(reserve, 0);\n reserve.remove();\n }\n return;\n }\n\n reserve ??= createReserveElement();\n\n if (\n reserve.parentElement !== target.parentElement ||\n reserve.previousElementSibling !== target\n ) {\n target.after(reserve);\n }\n\n observers.target(viewport, anchor, target);\n\n const reserveChanged = setReserveHeight(\n reserve,\n computeTopAnchorReserve({ viewport, anchor, reserve, ...clamp }),\n );\n\n if (reserveChanged) {\n scheduler.schedule();\n return;\n }\n\n const anchorId = getAnchorId(anchor);\n if (anchorId !== undefined && lastScrolledAnchorId === anchorId) return;\n\n const targetScrollTop = snapScrollTop(\n computeTopAnchorTargetScrollTop({ viewport, anchor, ...clamp }),\n );\n\n if (Math.abs(viewport.scrollTop - targetScrollTop) > 1) {\n viewport.scrollTo({ top: targetScrollTop, behavior: \"smooth\" });\n }\n\n if (anchorId !== undefined) lastScrolledAnchorId = anchorId;\n }\n\n const scheduler = createFrameScheduler(apply);\n const observers = createReserveObservers(scheduler.schedule);\n\n scheduler.schedule();\n const unsubscribe = store.subscribe(scheduler.schedule);\n\n return () => {\n scheduler.cancel();\n unsubscribe();\n observers.disconnect();\n reserve?.remove();\n };\n};\n"],"mappings":";;;;;AAmCA,MAAMoB,wBAAwBD,OAAmB;CAC/C,IAAIE,QAAuB;CAE3B,OAAO;EACLC,gBAAgB;GACd,IAAID,UAAU,MAAM;GACpBA,QAAQE,4BAA4B;IAClCF,QAAQ;IACRF,GAAG;GACL,CAAC;EACH;EACAK,cAAc;GACZ,IAAIH,UAAU,MAAM;IAClBI,qBAAqBJ,KAAK;IAC1BA,QAAQ;GACV;EACF;CACF;AACF;AAEA,MAAaK,yBAAyBC,UAA0B;CAC9D,IAAIC,UAA8B;CAClC,IAAIC;CAEJ,SAASC,QAAQ;EACf,MAAMC,QAAQJ,MAAMnB,SAAS;EAC7B,MAAM,EAAEG,UAAUE,QAAQC,WAAWiB,MAAMrB;EAC3C,MAAMsB,QAAQD,MAAMhB;EAEpB,IACEgB,MAAMtB,eAAe,SACrB,CAACE,YACD,CAACE,UACD,CAACC,UACD,CAACkB,OACD;GACAC,UAAUC,WAAW;GACrB,IAAIN,SAAS;IACXvB,iBAAiBuB,SAAS,CAAC;IAC3BA,QAAQO,OAAO;GACjB;GACA;EACF;EAEAP,YAAYzB,qBAAqB;EAEjC,IACEyB,QAAQQ,kBAAkBtB,OAAOsB,iBACjCR,QAAQS,2BAA2BvB,QAEnCA,OAAOwB,MAAMV,OAAO;EAGtBK,UAAUnB,OAAOH,UAAUE,QAAQC,MAAM;EAOzC,IALuBT,iBACrBuB,SACA5B,wBAAwB;GAAEW;GAAUE;GAAQe;GAAS,GAAGI;EAAM,CAAC,CAG7DO,GAAgB;GAClBC,UAAUlB,SAAS;GACnB;EACF;EAEA,MAAMmB,WAAWrC,YAAYS,MAAM;EACnC,IAAI4B,aAAaC,KAAAA,KAAab,yBAAyBY,UAAU;EAEjE,MAAME,kBAAkBrC,cACtBL,gCAAgC;GAAEU;GAAUE;GAAQ,GAAGmB;EAAM,CAAC,CAChE;EAEA,IAAIY,KAAKC,IAAIlC,SAASmC,YAAYH,eAAe,IAAI,GACnDhC,SAASoC,SAAS;GAAEC,KAAKL;GAAiBM,UAAU;EAAS,CAAC;EAGhE,IAAIR,aAAaC,KAAAA,GAAWb,uBAAuBY;CACrD;CAEA,MAAMD,YAAYpB,qBAAqBU,KAAK;CAC5C,MAAMG,YAAY/B,uBAAuBsC,UAAUlB,QAAQ;CAE3DkB,UAAUlB,SAAS;CACnB,MAAM4B,cAAcvB,MAAMT,UAAUsB,UAAUlB,QAAQ;CAEtD,aAAa;EACXkB,UAAUhB,OAAO;EACjB0B,YAAY;EACZjB,UAAUC,WAAW;EACrBN,SAASO,OAAO;CAClB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"topAnchorTurn.js","names":[],"sources":["../../../../src/primitives/thread/topAnchor/topAnchorTurn.ts"],"sourcesContent":["\"use client\";\n\ntype TopAnchorTurnMessage = {\n readonly id: string;\n readonly role: string;\n};\n\nexport const getActiveTopAnchorTurn = ({\n isRunning,\n messages,\n}: {\n readonly isRunning: boolean;\n readonly messages: readonly TopAnchorTurnMessage[];\n}) => {\n if (!isRunning) return null;\n\n const target = messages.at(-1);\n const anchor = messages.at(-2);\n if (anchor?.role !== \"user\" || target?.role !== \"assistant\") return null;\n\n return { anchorId: anchor.id, targetId: target.id };\n};\n\nexport const getActiveTopAnchorAnchorId = (\n options: Parameters<typeof getActiveTopAnchorTurn>[0],\n) => getActiveTopAnchorTurn(options)?.anchorId;\n\nexport const getActiveTopAnchorTargetId = (\n options: Parameters<typeof getActiveTopAnchorTurn>[0],\n) => getActiveTopAnchorTurn(options)?.targetId;\n"],"mappings":";;AAOA,MAAa,0BAA0B,EACrC,WACA,eAII;CACJ,IAAI,CAAC,WAAW,OAAO;CAEvB,MAAM,SAAS,SAAS,GAAG,EAAE;CAC7B,MAAM,SAAS,SAAS,GAAG,EAAE;CAC7B,IAAI,QAAQ,SAAS,UAAU,QAAQ,SAAS,aAAa,OAAO;CAEpE,OAAO;EAAE,UAAU,OAAO;EAAI,UAAU,OAAO;CAAG;AACpD;AAEA,MAAa,8BACX,YACG,uBAAuB,OAAO,CAAC,EAAE;AAEtC,MAAa,8BACX,YACG,uBAAuB,OAAO,CAAC,EAAE"}
1
+ {"version":3,"file":"topAnchorTurn.js","names":["TopAnchorTurnMessage","id","role","getActiveTopAnchorTurn","isRunning","messages","target","at","anchor","anchorId","targetId","getActiveTopAnchorAnchorId","options","Parameters","getActiveTopAnchorTargetId"],"sources":["../../../../src/primitives/thread/topAnchor/topAnchorTurn.ts"],"sourcesContent":["\"use client\";\n\ntype TopAnchorTurnMessage = {\n readonly id: string;\n readonly role: string;\n};\n\nexport const getActiveTopAnchorTurn = ({\n isRunning,\n messages,\n}: {\n readonly isRunning: boolean;\n readonly messages: readonly TopAnchorTurnMessage[];\n}) => {\n if (!isRunning) return null;\n\n const target = messages.at(-1);\n const anchor = messages.at(-2);\n if (anchor?.role !== \"user\" || target?.role !== \"assistant\") return null;\n\n return { anchorId: anchor.id, targetId: target.id };\n};\n\nexport const getActiveTopAnchorAnchorId = (\n options: Parameters<typeof getActiveTopAnchorTurn>[0],\n) => getActiveTopAnchorTurn(options)?.anchorId;\n\nexport const getActiveTopAnchorTargetId = (\n options: Parameters<typeof getActiveTopAnchorTurn>[0],\n) => getActiveTopAnchorTurn(options)?.targetId;\n"],"mappings":";;AAOA,MAAaG,0BAA0B,EACrCC,WACAC,eAII;CACJ,IAAI,CAACD,WAAW,OAAO;CAEvB,MAAME,SAASD,SAASE,GAAG,EAAE;CAC7B,MAAMC,SAASH,SAASE,GAAG,EAAE;CAC7B,IAAIC,QAAQN,SAAS,UAAUI,QAAQJ,SAAS,aAAa,OAAO;CAEpE,OAAO;EAAEO,UAAUD,OAAOP;EAAIS,UAAUJ,OAAOL;CAAG;AACpD;AAEA,MAAaU,8BACXC,YACGT,uBAAuBS,OAAO,CAAC,EAAEH;AAEtC,MAAaK,8BACXF,YACGT,uBAAuBS,OAAO,CAAC,EAAEF"}
@@ -1 +1 @@
1
- {"version":3,"file":"topAnchorUtils.js","names":[],"sources":["../../../../src/primitives/thread/topAnchor/topAnchorUtils.ts"],"sourcesContent":["\"use client\";\n\n/**\n * Convert a supported CSS length string (`px`, `em`, `rem`) into pixels,\n * resolving font-relative units against the supplied element's computed style.\n * Unsupported or malformed values disable the tall-message clamp.\n *\n * Part of the top-anchor package's public input contract: consumers may pass\n * clamp configuration as supported CSS-length strings, and this function is the\n * single place that converts them into the pixel values the package operates on.\n */\nexport const parseCssLength = (value: string, element: HTMLElement): number => {\n const match = value.trim().match(/^(\\d+(?:\\.\\d+)?|\\.\\d+)(em|px|rem)$/);\n if (!match) return Number.POSITIVE_INFINITY;\n\n const num = Number(match[1]);\n const unit = match[2];\n\n if (unit === \"px\") return num;\n if (unit === \"em\") {\n const fontSize = parseFloat(getComputedStyle(element).fontSize) || 16;\n return num * fontSize;\n }\n if (unit === \"rem\") {\n const rootFontSize =\n parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;\n return num * rootFontSize;\n }\n return Number.POSITIVE_INFINITY;\n};\n\nexport const getAnchorId = (anchor: HTMLElement) => anchor.dataset.messageId;\n\nexport const createReserveElement = () => {\n const reserve = document.createElement(\"div\");\n reserve.dataset.auiTopAnchorReserve = \"\";\n reserve.style.height = \"0px\";\n reserve.style.flexShrink = \"0\";\n reserve.style.pointerEvents = \"none\";\n reserve.setAttribute(\"aria-hidden\", \"true\");\n\n return reserve;\n};\n\nexport const setReserveHeight = (reserve: HTMLElement, height: number) => {\n const nextHeight = `${height}px`;\n if (reserve.style.height !== nextHeight) {\n reserve.style.height = nextHeight;\n return true;\n }\n\n return false;\n};\n\nexport const snapScrollTop = (top: number) => {\n const pixelRatio = window.devicePixelRatio || 1;\n return Math.round(top * pixelRatio) / pixelRatio;\n};\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,kBAAkB,OAAe,YAAiC;CAC7E,MAAM,QAAQ,MAAM,KAAK,CAAC,CAAC,MAAM,oCAAoC;CACrE,IAAI,CAAC,OAAO,OAAO,OAAO;CAE1B,MAAM,MAAM,OAAO,MAAM,EAAE;CAC3B,MAAM,OAAO,MAAM;CAEnB,IAAI,SAAS,MAAM,OAAO;CAC1B,IAAI,SAAS,MAEX,OAAO,OADU,WAAW,iBAAiB,OAAO,CAAC,CAAC,QAAQ,KAAK;CAGrE,IAAI,SAAS,OAGX,OAAO,OADL,WAAW,iBAAiB,SAAS,eAAe,CAAC,CAAC,QAAQ,KAAK;CAGvE,OAAO,OAAO;AAChB;AAEA,MAAa,eAAe,WAAwB,OAAO,QAAQ;AAEnE,MAAa,6BAA6B;CACxC,MAAM,UAAU,SAAS,cAAc,KAAK;CAC5C,QAAQ,QAAQ,sBAAsB;CACtC,QAAQ,MAAM,SAAS;CACvB,QAAQ,MAAM,aAAa;CAC3B,QAAQ,MAAM,gBAAgB;CAC9B,QAAQ,aAAa,eAAe,MAAM;CAE1C,OAAO;AACT;AAEA,MAAa,oBAAoB,SAAsB,WAAmB;CACxE,MAAM,aAAa,GAAG,OAAO;CAC7B,IAAI,QAAQ,MAAM,WAAW,YAAY;EACvC,QAAQ,MAAM,SAAS;EACvB,OAAO;CACT;CAEA,OAAO;AACT;AAEA,MAAa,iBAAiB,QAAgB;CAC5C,MAAM,aAAa,OAAO,oBAAoB;CAC9C,OAAO,KAAK,MAAM,MAAM,UAAU,IAAI;AACxC"}
1
+ {"version":3,"file":"topAnchorUtils.js","names":["parseCssLength","value","element","HTMLElement","match","trim","Number","POSITIVE_INFINITY","num","unit","fontSize","parseFloat","getComputedStyle","rootFontSize","document","documentElement","getAnchorId","anchor","dataset","messageId","createReserveElement","reserve","createElement","auiTopAnchorReserve","style","height","flexShrink","pointerEvents","setAttribute","setReserveHeight","nextHeight","snapScrollTop","top","pixelRatio","window","devicePixelRatio","Math","round"],"sources":["../../../../src/primitives/thread/topAnchor/topAnchorUtils.ts"],"sourcesContent":["\"use client\";\n\n/**\n * Convert a supported CSS length string (`px`, `em`, `rem`) into pixels,\n * resolving font-relative units against the supplied element's computed style.\n * Unsupported or malformed values disable the tall-message clamp.\n *\n * Part of the top-anchor package's public input contract: consumers may pass\n * clamp configuration as supported CSS-length strings, and this function is the\n * single place that converts them into the pixel values the package operates on.\n */\nexport const parseCssLength = (value: string, element: HTMLElement): number => {\n const match = value.trim().match(/^(\\d+(?:\\.\\d+)?|\\.\\d+)(em|px|rem)$/);\n if (!match) return Number.POSITIVE_INFINITY;\n\n const num = Number(match[1]);\n const unit = match[2];\n\n if (unit === \"px\") return num;\n if (unit === \"em\") {\n const fontSize = parseFloat(getComputedStyle(element).fontSize) || 16;\n return num * fontSize;\n }\n if (unit === \"rem\") {\n const rootFontSize =\n parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;\n return num * rootFontSize;\n }\n return Number.POSITIVE_INFINITY;\n};\n\nexport const getAnchorId = (anchor: HTMLElement) => anchor.dataset.messageId;\n\nexport const createReserveElement = () => {\n const reserve = document.createElement(\"div\");\n reserve.dataset.auiTopAnchorReserve = \"\";\n reserve.style.height = \"0px\";\n reserve.style.flexShrink = \"0\";\n reserve.style.pointerEvents = \"none\";\n reserve.setAttribute(\"aria-hidden\", \"true\");\n\n return reserve;\n};\n\nexport const setReserveHeight = (reserve: HTMLElement, height: number) => {\n const nextHeight = `${height}px`;\n if (reserve.style.height !== nextHeight) {\n reserve.style.height = nextHeight;\n return true;\n }\n\n return false;\n};\n\nexport const snapScrollTop = (top: number) => {\n const pixelRatio = window.devicePixelRatio || 1;\n return Math.round(top * pixelRatio) / pixelRatio;\n};\n"],"mappings":";;;;;;;;;;;AAWA,MAAaA,kBAAkBC,OAAeC,YAAiC;CAC7E,MAAME,QAAQH,MAAMI,KAAK,CAAC,CAACD,MAAM,oCAAoC;CACrE,IAAI,CAACA,OAAO,OAAOE,OAAOC;CAE1B,MAAMC,MAAMF,OAAOF,MAAM,EAAE;CAC3B,MAAMK,OAAOL,MAAM;CAEnB,IAAIK,SAAS,MAAM,OAAOD;CAC1B,IAAIC,SAAS,MAEX,OAAOD,OADUG,WAAWC,iBAAiBV,OAAO,CAAC,CAACQ,QAAQ,KAAK;CAGrE,IAAID,SAAS,OAGX,OAAOD,OADLG,WAAWC,iBAAiBE,SAASC,eAAe,CAAC,CAACL,QAAQ,KAAK;CAGvE,OAAOJ,OAAOC;AAChB;AAEA,MAAaS,eAAeC,WAAwBA,OAAOC,QAAQC;AAEnE,MAAaC,6BAA6B;CACxC,MAAMC,UAAUP,SAASQ,cAAc,KAAK;CAC5CD,QAAQH,QAAQK,sBAAsB;CACtCF,QAAQG,MAAMC,SAAS;CACvBJ,QAAQG,MAAME,aAAa;CAC3BL,QAAQG,MAAMG,gBAAgB;CAC9BN,QAAQO,aAAa,eAAe,MAAM;CAE1C,OAAOP;AACT;AAEA,MAAaQ,oBAAoBR,SAAsBI,WAAmB;CACxE,MAAMK,aAAa,GAAGL,OAAM;CAC5B,IAAIJ,QAAQG,MAAMC,WAAWK,YAAY;EACvCT,QAAQG,MAAMC,SAASK;EACvB,OAAO;CACT;CAEA,OAAO;AACT;AAEA,MAAaC,iBAAiBC,QAAgB;CAC5C,MAAMC,aAAaC,OAAOC,oBAAoB;CAC9C,OAAOC,KAAKC,MAAML,MAAMC,UAAU,IAAIA;AACxC"}
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { useThreadViewportStore } from "../../../context/react/ThreadViewportContext.js";
3
3
  import { mountTopAnchorReserve } from "./mountTopAnchorReserve.js";
4
+ import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
4
5
  import { useLayoutEffect } from "@assistant-ui/tap/react-shim";
5
6
  //#region src/primitives/thread/topAnchor/useTopAnchorReserve.ts
6
7
  /**
@@ -9,11 +10,25 @@ import { useLayoutEffect } from "@assistant-ui/tap/react-shim";
9
10
  * the reserve `<div>` is appended next to the streaming assistant message.
10
11
  */
11
12
  const useTopAnchorReserve = (enabled) => {
13
+ const $ = c(4);
12
14
  const threadViewportStore = useThreadViewportStore();
13
- useLayoutEffect(() => {
14
- if (!enabled) return;
15
- return mountTopAnchorReserve(threadViewportStore);
16
- }, [enabled, threadViewportStore]);
15
+ let t0;
16
+ let t1;
17
+ if ($[0] !== enabled || $[1] !== threadViewportStore) {
18
+ t0 = () => {
19
+ if (!enabled) return;
20
+ return mountTopAnchorReserve(threadViewportStore);
21
+ };
22
+ t1 = [enabled, threadViewportStore];
23
+ $[0] = enabled;
24
+ $[1] = threadViewportStore;
25
+ $[2] = t0;
26
+ $[3] = t1;
27
+ } else {
28
+ t0 = $[2];
29
+ t1 = $[3];
30
+ }
31
+ useLayoutEffect(t0, t1);
17
32
  };
18
33
  //#endregion
19
34
  export { useTopAnchorReserve };
@@ -1 +1 @@
1
- {"version":3,"file":"useTopAnchorReserve.js","names":[],"sources":["../../../../src/primitives/thread/topAnchor/useTopAnchorReserve.ts"],"sourcesContent":["\"use client\";\n\nimport { useLayoutEffect } from \"react\";\nimport { useThreadViewportStore } from \"../../../context/react/ThreadViewportContext\";\nimport { mountTopAnchorReserve } from \"./mountTopAnchorReserve\";\n\n/**\n * Mounts the top-turn-anchor reserve element against the active\n * `ThreadViewport` store. Call this from inside the scrollable viewport so\n * the reserve `<div>` is appended next to the streaming assistant message.\n */\nexport const useTopAnchorReserve = (enabled: boolean) => {\n const threadViewportStore = useThreadViewportStore();\n\n useLayoutEffect(() => {\n if (!enabled) return;\n return mountTopAnchorReserve(threadViewportStore);\n }, [enabled, threadViewportStore]);\n};\n"],"mappings":";;;;;;;;;;AAWA,MAAa,uBAAuB,YAAqB;CACvD,MAAM,sBAAsB,uBAAuB;CAEnD,sBAAsB;EACpB,IAAI,CAAC,SAAS;EACd,OAAO,sBAAsB,mBAAmB;CAClD,GAAG,CAAC,SAAS,mBAAmB,CAAC;AACnC"}
1
+ {"version":3,"file":"useTopAnchorReserve.js","names":["c","_c","useLayoutEffect","useThreadViewportStore","mountTopAnchorReserve","useTopAnchorReserve","enabled","$","threadViewportStore","t0","t1"],"sources":["../../../../src/primitives/thread/topAnchor/useTopAnchorReserve.ts"],"sourcesContent":["\"use client\";\n\nimport { useLayoutEffect } from \"react\";\nimport { useThreadViewportStore } from \"../../../context/react/ThreadViewportContext\";\nimport { mountTopAnchorReserve } from \"./mountTopAnchorReserve\";\n\n/**\n * Mounts the top-turn-anchor reserve element against the active\n * `ThreadViewport` store. Call this from inside the scrollable viewport so\n * the reserve `<div>` is appended next to the streaming assistant message.\n */\nexport const useTopAnchorReserve = (enabled: boolean) => {\n const threadViewportStore = useThreadViewportStore();\n\n useLayoutEffect(() => {\n if (!enabled) return;\n return mountTopAnchorReserve(threadViewportStore);\n }, [enabled, threadViewportStore]);\n};\n"],"mappings":";;;;;;;;;;;AAWA,MAAaK,uBAAsBC,YAAA;CAAA,MAAAC,IAAAN,EAAA,CAAA;CACjC,MAAAO,sBAA4BL,uBAAuB;CAAE,IAAAM;CAAA,IAAAC;CAAA,IAAAH,EAAA,OAAAD,WAAAC,EAAA,OAAAC,qBAAA;EAErCC,WAAA;GACd,IAAI,CAACH,SAAO;GAAS,OACdF,sBAAsBI,mBAAmB;EAAC;EAChDE,KAAA,CAACJ,SAASE,mBAAmB;EAACD,EAAA,KAAAD;EAAAC,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAA;EAAAD,KAAAF,EAAA;EAAAG,KAAAH,EAAA;CAAA;CAHjCL,gBAAgBO,IAGbC,EAA8B;AAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useThreadViewportAutoScroll.d.ts","names":[],"sources":["../../../src/primitives/thread/useThreadViewportAutoScroll.ts"],"mappings":";;;kBAWiB,2BAAA;EAAA,KACH,OAAA;IADG;;;;;;IAQb,UAAA;IAcA;;;AAO4B;AAIhC;IAlBI,wBAAA;IAkMH;;;;;IA3LG,0BAAA;IAgBD;;;;;IATC,4BAAA;EAAA;AAAA;AAAA,cAIS,2BAAA,oBAAgD,WAAA;EAAa,UAAA;EAAA,wBAAA;EAAA,0BAAA;EAAA;AAAA,GAKvE,2BAAA,CAA4B,OAAA,KAAU,WAAA,CAAY,QAAA"}
1
+ {"version":3,"file":"useThreadViewportAutoScroll.d.ts","names":[],"sources":["../../../src/primitives/thread/useThreadViewportAutoScroll.ts"],"mappings":";;;kBAWiB,2BAAA;EAAA,KACH,OAAA;IADG;;;;;;IAQb,UAAA;IAcA;;;AAO4B;AAIhC;IAlBI,wBAAA;IA0MH;;;;;IAnMG,0BAAA;IAgBD;;;;;IATC,4BAAA;EAAA;AAAA;AAAA,cAIS,2BAAA,oBAAgD,WAAA;EAAa,UAAA;EAAA,wBAAA;EAAA,0BAAA;EAAA;AAAA,GAKvE,2BAAA,CAA4B,OAAA,KAAU,WAAA,CAAY,QAAA"}
@@ -29,12 +29,12 @@ const useThreadViewportAutoScroll = ({ autoScroll, scrollToBottomOnRunStart = tr
29
29
  behavior
30
30
  });
31
31
  }, []);
32
- const scheduleScrollToBottom = useCallback((behavior) => {
33
- scrollingToBottomBehaviorRef.current = behavior;
32
+ const scheduleScrollToBottom = useCallback((behavior_0) => {
33
+ scrollingToBottomBehaviorRef.current = behavior_0;
34
34
  if (scheduledFrameRef.current !== null) cancelAnimationFrame(scheduledFrameRef.current);
35
35
  scheduledFrameRef.current = requestAnimationFrame(() => {
36
36
  scheduledFrameRef.current = null;
37
- scrollToBottom(behavior);
37
+ scrollToBottom(behavior_0);
38
38
  });
39
39
  }, [scrollToBottom]);
40
40
  useLayoutEffect(() => () => {
@@ -45,23 +45,23 @@ const useThreadViewportAutoScroll = ({ autoScroll, scrollToBottomOnRunStart = tr
45
45
  return state.turnAnchor === "top" && state.element.viewport === divRef.current && state.element.anchor !== null;
46
46
  }, [threadViewportStore]);
47
47
  const handleScroll = () => {
48
- const div = divRef.current;
49
- if (!div) return;
48
+ const div_0 = divRef.current;
49
+ if (!div_0) return;
50
50
  const isAtBottom = threadViewportStore.getState().isAtBottom;
51
- const newIsAtBottom = Math.abs(div.scrollHeight - div.scrollTop - div.clientHeight) <= 1 || div.scrollHeight <= div.clientHeight;
52
- if (!newIsAtBottom && lastScrollTop.current < div.scrollTop) {} else {
51
+ const newIsAtBottom = Math.abs(div_0.scrollHeight - div_0.scrollTop - div_0.clientHeight) <= 1 || div_0.scrollHeight <= div_0.clientHeight;
52
+ if (!newIsAtBottom && lastScrollTop.current < div_0.scrollTop) {} else {
53
53
  if (newIsAtBottom) {
54
- if (div.scrollHeight > div.clientHeight + 1) scrollingToBottomBehaviorRef.current = null;
55
- } else if (lastScrollTop.current > div.scrollTop && lastScrollHeight.current === div.scrollHeight) scrollingToBottomBehaviorRef.current = null;
54
+ if (div_0.scrollHeight > div_0.clientHeight + 1) scrollingToBottomBehaviorRef.current = null;
55
+ } else if (lastScrollTop.current > div_0.scrollTop && lastScrollHeight.current === div_0.scrollHeight) scrollingToBottomBehaviorRef.current = null;
56
56
  if ((newIsAtBottom || scrollingToBottomBehaviorRef.current === null) && newIsAtBottom !== isAtBottom) writableStore(threadViewportStore).setState({ isAtBottom: newIsAtBottom });
57
57
  }
58
- lastScrollTop.current = div.scrollTop;
59
- lastScrollHeight.current = div.scrollHeight;
58
+ lastScrollTop.current = div_0.scrollTop;
59
+ lastScrollHeight.current = div_0.scrollHeight;
60
60
  };
61
61
  const resizeRef = useOnResizeContent(() => {
62
- const div = divRef.current;
63
- if (!div) return;
64
- const { scrollHeight, clientHeight } = div;
62
+ const div_1 = divRef.current;
63
+ if (!div_1) return;
64
+ const { scrollHeight, clientHeight } = div_1;
65
65
  if (scrollHeight === lastObservedScrollHeight.current && clientHeight === lastObservedClientHeight.current) return;
66
66
  lastObservedScrollHeight.current = scrollHeight;
67
67
  lastObservedClientHeight.current = clientHeight;
@@ -72,9 +72,14 @@ const useThreadViewportAutoScroll = ({ autoScroll, scrollToBottomOnRunStart = tr
72
72
  handleScroll();
73
73
  });
74
74
  const scrollRef = useManagedRef((el) => {
75
+ const cancelPendingScrollToBottom = () => {
76
+ scrollingToBottomBehaviorRef.current = null;
77
+ };
75
78
  el.addEventListener("scroll", handleScroll);
79
+ el.addEventListener("pointerdown", cancelPendingScrollToBottom);
76
80
  return () => {
77
81
  el.removeEventListener("scroll", handleScroll);
82
+ el.removeEventListener("pointerdown", cancelPendingScrollToBottom);
78
83
  };
79
84
  });
80
85
  useLayoutEffect(() => {
@@ -92,8 +97,8 @@ const useThreadViewportAutoScroll = ({ autoScroll, scrollToBottomOnRunStart = tr
92
97
  scheduleScrollToBottom,
93
98
  scrollToBottomOnInitialize
94
99
  ]);
95
- useOnScrollToBottom(({ behavior }) => {
96
- scrollToBottom(behavior);
100
+ useOnScrollToBottom(({ behavior: behavior_1 }) => {
101
+ scrollToBottom(behavior_1);
97
102
  });
98
103
  useAuiEvent("thread.runStart", () => {
99
104
  if (!scrollToBottomOnRunStart) return;
@@ -1 +1 @@
1
- {"version":3,"file":"useThreadViewportAutoScroll.js","names":[],"sources":["../../../src/primitives/thread/useThreadViewportAutoScroll.ts"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { useCallback, useLayoutEffect, useRef, type RefCallback } from \"react\";\nimport { useAuiEvent, useAuiState } from \"@assistant-ui/store\";\nimport { useOnResizeContent } from \"../../utils/hooks/useOnResizeContent\";\nimport { useOnScrollToBottom } from \"../../utils/hooks/useOnScrollToBottom\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { writableStore } from \"../../context/ReadonlyStore\";\nimport { useThreadViewportStore } from \"../../context/react/ThreadViewportContext\";\n\nexport namespace useThreadViewportAutoScroll {\n export type Options = {\n /**\n * Whether to automatically scroll to the bottom when new messages are added.\n * When enabled, the viewport will automatically scroll to show the latest content.\n *\n * Default false if `turnAnchor` is \"top\", otherwise defaults to true.\n */\n autoScroll?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when a new run starts.\n *\n * Defaults to true.\n */\n scrollToBottomOnRunStart?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when messages first appear in the thread.\n *\n * Defaults to true.\n */\n scrollToBottomOnInitialize?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when switching to a different thread.\n *\n * Defaults to true.\n */\n scrollToBottomOnThreadSwitch?: boolean | undefined;\n };\n}\n\nexport const useThreadViewportAutoScroll = <TElement extends HTMLElement>({\n autoScroll,\n scrollToBottomOnRunStart = true,\n scrollToBottomOnInitialize = true,\n scrollToBottomOnThreadSwitch = true,\n}: useThreadViewportAutoScroll.Options): RefCallback<TElement> => {\n const divRef = useRef<TElement>(null);\n const hasMessages = useAuiState((s) => s.thread.messages.length > 0);\n const initializeScrollRequestedRef = useRef(false);\n const scheduledFrameRef = useRef<number | null>(null);\n\n const threadViewportStore = useThreadViewportStore();\n if (autoScroll === undefined) {\n autoScroll = threadViewportStore.getState().turnAnchor !== \"top\";\n }\n\n const lastScrollTop = useRef<number>(0);\n const lastScrollHeight = useRef<number>(0);\n const lastObservedScrollHeight = useRef<number>(0);\n const lastObservedClientHeight = useRef<number>(0);\n\n // Pending bottom-scroll intent. Planted by initialize/run-start/switch/button\n // triggers, cleared when handleScroll confirms we reached bottom, or when the\n // user actively scrolls up while content size is stable.\n const scrollingToBottomBehaviorRef = useRef<ScrollBehavior | null>(null);\n\n const scrollToBottom = useCallback((behavior: ScrollBehavior) => {\n const div = divRef.current;\n if (!div) return;\n\n scrollingToBottomBehaviorRef.current = behavior;\n div.scrollTo({ top: div.scrollHeight, behavior });\n }, []);\n\n const scheduleScrollToBottom = useCallback(\n (behavior: ScrollBehavior) => {\n scrollingToBottomBehaviorRef.current = behavior;\n if (scheduledFrameRef.current !== null) {\n cancelAnimationFrame(scheduledFrameRef.current);\n }\n scheduledFrameRef.current = requestAnimationFrame(() => {\n scheduledFrameRef.current = null;\n scrollToBottom(behavior);\n });\n },\n [scrollToBottom],\n );\n\n useLayoutEffect(\n () => () => {\n if (scheduledFrameRef.current !== null) {\n cancelAnimationFrame(scheduledFrameRef.current);\n }\n },\n [],\n );\n\n const hasActiveTopAnchor = useCallback(() => {\n const state = threadViewportStore.getState();\n return (\n state.turnAnchor === \"top\" &&\n state.element.viewport === divRef.current &&\n state.element.anchor !== null\n );\n }, [threadViewportStore]);\n\n const handleScroll = () => {\n const div = divRef.current;\n if (!div) return;\n\n const isAtBottom = threadViewportStore.getState().isAtBottom;\n const newIsAtBottom =\n Math.abs(div.scrollHeight - div.scrollTop - div.clientHeight) <= 1 ||\n div.scrollHeight <= div.clientHeight;\n\n const isInFlightDownwardScroll =\n !newIsAtBottom && lastScrollTop.current < div.scrollTop;\n if (isInFlightDownwardScroll) {\n // no-op: a smooth scroll-to-bottom fires many midpoint scroll events\n // before landing, don't flicker isAtBottom or clear intent mid-animation\n } else {\n if (newIsAtBottom) {\n // newIsAtBottom is ambiguous when the viewport doesn't overflow —\n // keep intent alive until content can actually scroll\n const viewportOverflows = div.scrollHeight > div.clientHeight + 1;\n if (viewportOverflows) {\n scrollingToBottomBehaviorRef.current = null;\n }\n } else if (\n lastScrollTop.current > div.scrollTop &&\n lastScrollHeight.current === div.scrollHeight\n ) {\n // scrollHeight equality rules out content-driven shifts being misread as user scroll-up\n scrollingToBottomBehaviorRef.current = null;\n }\n\n const shouldUpdate =\n newIsAtBottom || scrollingToBottomBehaviorRef.current === null;\n\n if (shouldUpdate && newIsAtBottom !== isAtBottom) {\n writableStore(threadViewportStore).setState({\n isAtBottom: newIsAtBottom,\n });\n }\n }\n\n lastScrollTop.current = div.scrollTop;\n lastScrollHeight.current = div.scrollHeight;\n };\n\n const resizeRef = useOnResizeContent(() => {\n const div = divRef.current;\n if (!div) return;\n\n const { scrollHeight, clientHeight } = div;\n if (\n scrollHeight === lastObservedScrollHeight.current &&\n clientHeight === lastObservedClientHeight.current\n ) {\n return;\n }\n lastObservedScrollHeight.current = scrollHeight;\n lastObservedClientHeight.current = clientHeight;\n\n const scrollBehavior = scrollingToBottomBehaviorRef.current;\n if (scrollBehavior && hasActiveTopAnchor()) {\n // Let the top-anchor reserve own scrolling while a run starts to avoid a bottom-scroll race.\n scrollingToBottomBehaviorRef.current = null;\n } else if (scrollBehavior) {\n scrollToBottom(scrollBehavior);\n } else if (autoScroll && threadViewportStore.getState().isAtBottom) {\n scrollToBottom(\"instant\");\n }\n\n handleScroll();\n });\n\n const scrollRef = useManagedRef<HTMLElement>((el) => {\n el.addEventListener(\"scroll\", handleScroll);\n return () => {\n el.removeEventListener(\"scroll\", handleScroll);\n };\n });\n\n useLayoutEffect(() => {\n if (!scrollToBottomOnInitialize) return;\n if (!hasMessages) {\n initializeScrollRequestedRef.current = false;\n return;\n }\n if (initializeScrollRequestedRef.current) return;\n\n initializeScrollRequestedRef.current = true;\n // defer to an in-flight run (e.g. first message on a new thread) that\n // already planted intent — otherwise we'd downgrade its \"auto\" to \"instant\"\n if (scrollingToBottomBehaviorRef.current !== null) return;\n scheduleScrollToBottom(\"instant\");\n }, [hasMessages, scheduleScrollToBottom, scrollToBottomOnInitialize]);\n\n useOnScrollToBottom(({ behavior }) => {\n scrollToBottom(behavior);\n });\n\n useAuiEvent(\"thread.runStart\", () => {\n if (!scrollToBottomOnRunStart) return;\n if (threadViewportStore.getState().turnAnchor === \"top\") return;\n scheduleScrollToBottom(\"auto\");\n });\n\n useAuiEvent(\"threadListItem.switchedTo\", () => {\n if (!scrollToBottomOnThreadSwitch) return;\n scheduleScrollToBottom(\"instant\");\n });\n\n const autoScrollRef = useComposedRefs<TElement>(resizeRef, scrollRef, divRef);\n return autoScrollRef as RefCallback<TElement>;\n};\n"],"mappings":"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"}
1
+ {"version":3,"file":"useThreadViewportAutoScroll.js","names":["useComposedRefs","useCallback","useLayoutEffect","useRef","RefCallback","useAuiEvent","useAuiState","useOnResizeContent","useOnScrollToBottom","useManagedRef","writableStore","useThreadViewportStore","useThreadViewportAutoScroll","Options","autoScroll","scrollToBottomOnRunStart","scrollToBottomOnInitialize","scrollToBottomOnThreadSwitch","HTMLElement","TElement","divRef","hasMessages","s","thread","messages","length","initializeScrollRequestedRef","scheduledFrameRef","threadViewportStore","undefined","getState","turnAnchor","lastScrollTop","lastScrollHeight","lastObservedScrollHeight","lastObservedClientHeight","scrollingToBottomBehaviorRef","ScrollBehavior","scrollToBottom","behavior","div","current","scrollTo","top","scrollHeight","scheduleScrollToBottom","cancelAnimationFrame","requestAnimationFrame","hasActiveTopAnchor","state","element","viewport","anchor","handleScroll","isAtBottom","newIsAtBottom","Math","abs","scrollTop","clientHeight","isInFlightDownwardScroll","viewportOverflows","shouldUpdate","setState","resizeRef","scrollBehavior","scrollRef","el","cancelPendingScrollToBottom","addEventListener","removeEventListener","autoScrollRef"],"sources":["../../../src/primitives/thread/useThreadViewportAutoScroll.ts"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { useCallback, useLayoutEffect, useRef, type RefCallback } from \"react\";\nimport { useAuiEvent, useAuiState } from \"@assistant-ui/store\";\nimport { useOnResizeContent } from \"../../utils/hooks/useOnResizeContent\";\nimport { useOnScrollToBottom } from \"../../utils/hooks/useOnScrollToBottom\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { writableStore } from \"../../context/ReadonlyStore\";\nimport { useThreadViewportStore } from \"../../context/react/ThreadViewportContext\";\n\nexport namespace useThreadViewportAutoScroll {\n export type Options = {\n /**\n * Whether to automatically scroll to the bottom when new messages are added.\n * When enabled, the viewport will automatically scroll to show the latest content.\n *\n * Default false if `turnAnchor` is \"top\", otherwise defaults to true.\n */\n autoScroll?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when a new run starts.\n *\n * Defaults to true.\n */\n scrollToBottomOnRunStart?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when messages first appear in the thread.\n *\n * Defaults to true.\n */\n scrollToBottomOnInitialize?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when switching to a different thread.\n *\n * Defaults to true.\n */\n scrollToBottomOnThreadSwitch?: boolean | undefined;\n };\n}\n\nexport const useThreadViewportAutoScroll = <TElement extends HTMLElement>({\n autoScroll,\n scrollToBottomOnRunStart = true,\n scrollToBottomOnInitialize = true,\n scrollToBottomOnThreadSwitch = true,\n}: useThreadViewportAutoScroll.Options): RefCallback<TElement> => {\n const divRef = useRef<TElement>(null);\n const hasMessages = useAuiState((s) => s.thread.messages.length > 0);\n const initializeScrollRequestedRef = useRef(false);\n const scheduledFrameRef = useRef<number | null>(null);\n\n const threadViewportStore = useThreadViewportStore();\n if (autoScroll === undefined) {\n autoScroll = threadViewportStore.getState().turnAnchor !== \"top\";\n }\n\n const lastScrollTop = useRef<number>(0);\n const lastScrollHeight = useRef<number>(0);\n const lastObservedScrollHeight = useRef<number>(0);\n const lastObservedClientHeight = useRef<number>(0);\n\n // Pending bottom-scroll intent. Planted by initialize/run-start/switch/button\n // triggers, cleared when handleScroll confirms we reached bottom, or when the\n // user actively scrolls up while content size is stable.\n const scrollingToBottomBehaviorRef = useRef<ScrollBehavior | null>(null);\n\n const scrollToBottom = useCallback((behavior: ScrollBehavior) => {\n const div = divRef.current;\n if (!div) return;\n\n scrollingToBottomBehaviorRef.current = behavior;\n div.scrollTo({ top: div.scrollHeight, behavior });\n }, []);\n\n const scheduleScrollToBottom = useCallback(\n (behavior: ScrollBehavior) => {\n scrollingToBottomBehaviorRef.current = behavior;\n if (scheduledFrameRef.current !== null) {\n cancelAnimationFrame(scheduledFrameRef.current);\n }\n scheduledFrameRef.current = requestAnimationFrame(() => {\n scheduledFrameRef.current = null;\n scrollToBottom(behavior);\n });\n },\n [scrollToBottom],\n );\n\n useLayoutEffect(\n () => () => {\n if (scheduledFrameRef.current !== null) {\n cancelAnimationFrame(scheduledFrameRef.current);\n }\n },\n [],\n );\n\n const hasActiveTopAnchor = useCallback(() => {\n const state = threadViewportStore.getState();\n return (\n state.turnAnchor === \"top\" &&\n state.element.viewport === divRef.current &&\n state.element.anchor !== null\n );\n }, [threadViewportStore]);\n\n const handleScroll = () => {\n const div = divRef.current;\n if (!div) return;\n\n const isAtBottom = threadViewportStore.getState().isAtBottom;\n const newIsAtBottom =\n Math.abs(div.scrollHeight - div.scrollTop - div.clientHeight) <= 1 ||\n div.scrollHeight <= div.clientHeight;\n\n const isInFlightDownwardScroll =\n !newIsAtBottom && lastScrollTop.current < div.scrollTop;\n if (isInFlightDownwardScroll) {\n // no-op: a smooth scroll-to-bottom fires many midpoint scroll events\n // before landing, don't flicker isAtBottom or clear intent mid-animation\n } else {\n if (newIsAtBottom) {\n // newIsAtBottom is ambiguous when the viewport doesn't overflow —\n // keep intent alive until content can actually scroll\n const viewportOverflows = div.scrollHeight > div.clientHeight + 1;\n if (viewportOverflows) {\n scrollingToBottomBehaviorRef.current = null;\n }\n } else if (\n lastScrollTop.current > div.scrollTop &&\n lastScrollHeight.current === div.scrollHeight\n ) {\n // scrollHeight equality rules out content-driven shifts being misread as user scroll-up\n scrollingToBottomBehaviorRef.current = null;\n }\n\n const shouldUpdate =\n newIsAtBottom || scrollingToBottomBehaviorRef.current === null;\n\n if (shouldUpdate && newIsAtBottom !== isAtBottom) {\n writableStore(threadViewportStore).setState({\n isAtBottom: newIsAtBottom,\n });\n }\n }\n\n lastScrollTop.current = div.scrollTop;\n lastScrollHeight.current = div.scrollHeight;\n };\n\n const resizeRef = useOnResizeContent(() => {\n const div = divRef.current;\n if (!div) return;\n\n const { scrollHeight, clientHeight } = div;\n if (\n scrollHeight === lastObservedScrollHeight.current &&\n clientHeight === lastObservedClientHeight.current\n ) {\n return;\n }\n lastObservedScrollHeight.current = scrollHeight;\n lastObservedClientHeight.current = clientHeight;\n\n const scrollBehavior = scrollingToBottomBehaviorRef.current;\n if (scrollBehavior && hasActiveTopAnchor()) {\n // Let the top-anchor reserve own scrolling while a run starts to avoid a bottom-scroll race.\n scrollingToBottomBehaviorRef.current = null;\n } else if (scrollBehavior) {\n scrollToBottom(scrollBehavior);\n } else if (autoScroll && threadViewportStore.getState().isAtBottom) {\n scrollToBottom(\"instant\");\n }\n\n handleScroll();\n });\n\n const scrollRef = useManagedRef<HTMLElement>((el) => {\n // A pointer gesture invalidates pending bottom-scroll intent; otherwise an\n // intent kept alive by a non-overflowing thread (see handleScroll) hijacks\n // the next content growth, e.g. expanding a collapsible tool call.\n const cancelPendingScrollToBottom = () => {\n scrollingToBottomBehaviorRef.current = null;\n };\n el.addEventListener(\"scroll\", handleScroll);\n el.addEventListener(\"pointerdown\", cancelPendingScrollToBottom);\n return () => {\n el.removeEventListener(\"scroll\", handleScroll);\n el.removeEventListener(\"pointerdown\", cancelPendingScrollToBottom);\n };\n });\n\n useLayoutEffect(() => {\n if (!scrollToBottomOnInitialize) return;\n if (!hasMessages) {\n initializeScrollRequestedRef.current = false;\n return;\n }\n if (initializeScrollRequestedRef.current) return;\n\n initializeScrollRequestedRef.current = true;\n // defer to an in-flight run (e.g. first message on a new thread) that\n // already planted intent — otherwise we'd downgrade its \"auto\" to \"instant\"\n if (scrollingToBottomBehaviorRef.current !== null) return;\n scheduleScrollToBottom(\"instant\");\n }, [hasMessages, scheduleScrollToBottom, scrollToBottomOnInitialize]);\n\n useOnScrollToBottom(({ behavior }) => {\n scrollToBottom(behavior);\n });\n\n useAuiEvent(\"thread.runStart\", () => {\n if (!scrollToBottomOnRunStart) return;\n if (threadViewportStore.getState().turnAnchor === \"top\") return;\n scheduleScrollToBottom(\"auto\");\n });\n\n useAuiEvent(\"threadListItem.switchedTo\", () => {\n if (!scrollToBottomOnThreadSwitch) return;\n scheduleScrollToBottom(\"instant\");\n });\n\n const autoScrollRef = useComposedRefs<TElement>(resizeRef, scrollRef, divRef);\n return autoScrollRef as RefCallback<TElement>;\n};\n"],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"thread.js","names":[],"sources":["../../src/primitives/thread.ts"],"sourcesContent":["export { ThreadPrimitiveRoot as Root } from \"./thread/ThreadRoot\";\nexport { ThreadPrimitiveEmpty as Empty } from \"./thread/ThreadEmpty\";\nexport { ThreadPrimitiveIf as If } from \"./thread/ThreadIf\";\nexport { ThreadPrimitiveViewport as Viewport } from \"./thread/ThreadViewport\";\nexport { ThreadPrimitiveViewportProvider as ViewportProvider } from \"../context/providers/ThreadViewportProvider\";\nexport { ThreadPrimitiveViewportFooter as ViewportFooter } from \"./thread/ThreadViewportFooter\";\nexport { ThreadPrimitiveMessages as Messages } from \"./thread/ThreadMessages\";\nexport { ThreadPrimitiveMessageByIndex as MessageByIndex } from \"./thread/ThreadMessages\";\nexport { ThreadPrimitiveScrollToBottom as ScrollToBottom } from \"./thread/ThreadScrollToBottom\";\nexport { ThreadPrimitiveSuggestion as Suggestion } from \"./thread/ThreadSuggestion\";\nexport {\n ThreadPrimitiveSuggestions as Suggestions,\n ThreadPrimitiveSuggestionByIndex as SuggestionByIndex,\n} from \"./thread/ThreadSuggestions\";\n"],"mappings":""}
1
+ {"version":3,"file":"thread.js","names":["ThreadPrimitiveRoot","Root","ThreadPrimitiveEmpty","Empty","ThreadPrimitiveIf","If","ThreadPrimitiveViewport","Viewport","ThreadPrimitiveViewportProvider","ViewportProvider","ThreadPrimitiveViewportFooter","ViewportFooter","ThreadPrimitiveMessages","Messages","ThreadPrimitiveMessageByIndex","MessageByIndex","ThreadPrimitiveScrollToBottom","ScrollToBottom","ThreadPrimitiveSuggestion","Suggestion","ThreadPrimitiveSuggestions","Suggestions","ThreadPrimitiveSuggestionByIndex","SuggestionByIndex"],"sources":["../../src/primitives/thread.ts"],"sourcesContent":["export { ThreadPrimitiveRoot as Root } from \"./thread/ThreadRoot\";\nexport { ThreadPrimitiveEmpty as Empty } from \"./thread/ThreadEmpty\";\nexport { ThreadPrimitiveIf as If } from \"./thread/ThreadIf\";\nexport { ThreadPrimitiveViewport as Viewport } from \"./thread/ThreadViewport\";\nexport { ThreadPrimitiveViewportProvider as ViewportProvider } from \"../context/providers/ThreadViewportProvider\";\nexport { ThreadPrimitiveViewportFooter as ViewportFooter } from \"./thread/ThreadViewportFooter\";\nexport { ThreadPrimitiveMessages as Messages } from \"./thread/ThreadMessages\";\nexport { ThreadPrimitiveMessageByIndex as MessageByIndex } from \"./thread/ThreadMessages\";\nexport { ThreadPrimitiveScrollToBottom as ScrollToBottom } from \"./thread/ThreadScrollToBottom\";\nexport { ThreadPrimitiveSuggestion as Suggestion } from \"./thread/ThreadSuggestion\";\nexport {\n ThreadPrimitiveSuggestions as Suggestions,\n ThreadPrimitiveSuggestionByIndex as SuggestionByIndex,\n} from \"./thread/ThreadSuggestions\";\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadListLoadMore.js","names":["useThreadListLoadMore","useThreadListLoadMoreBehavior"],"sources":["../../../src/primitives/threadList/ThreadListLoadMore.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useThreadListLoadMore as useThreadListLoadMoreBehavior } from \"@assistant-ui/core/react\";\n\nconst useThreadListLoadMore = () => {\n const { loadMore, disabled } = useThreadListLoadMoreBehavior();\n if (disabled) return null;\n return loadMore;\n};\n\nexport namespace ThreadListPrimitiveLoadMore {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadListLoadMore>;\n}\n\nexport const ThreadListPrimitiveLoadMore = createActionButton(\n \"ThreadListPrimitive.LoadMore\",\n useThreadListLoadMore,\n);\n"],"mappings":";;;;AASA,MAAMA,gCAA8B;CAClC,MAAM,EAAE,UAAU,aAAaC,sBAA8B;CAC7D,IAAI,UAAU,OAAO;CACrB,OAAO;AACT;AAOA,MAAa,8BAA8B,mBACzC,gCACAD,uBACF"}
1
+ {"version":3,"file":"ThreadListLoadMore.js","names":["ActionButtonElement","ActionButtonProps","createActionButton","useThreadListLoadMore","useThreadListLoadMoreBehavior","loadMore","disabled","ThreadListPrimitiveLoadMore","Element","Props"],"sources":["../../../src/primitives/threadList/ThreadListLoadMore.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useThreadListLoadMore as useThreadListLoadMoreBehavior } from \"@assistant-ui/core/react\";\n\nconst useThreadListLoadMore = () => {\n const { loadMore, disabled } = useThreadListLoadMoreBehavior();\n if (disabled) return null;\n return loadMore;\n};\n\nexport namespace ThreadListPrimitiveLoadMore {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadListLoadMore>;\n}\n\nexport const ThreadListPrimitiveLoadMore = createActionButton(\n \"ThreadListPrimitive.LoadMore\",\n useThreadListLoadMore,\n);\n"],"mappings":";;;;AASA,MAAMG,gCAAwB;CAC5B,MAAA,EAAAE,UAAAC,aAA+BF,sBAA8B;CAC7D,IAAIE,UAAQ,OAAS;CAAK,OACnBD;AAAQ;AAQjB,MAAaE,8BAA8BL,mBACzC,gCACAC,uBACF"}
@@ -1,27 +1,69 @@
1
1
  "use client";
2
2
  import { Primitive } from "../../utils/Primitive.js";
3
3
  import { useAuiState } from "@assistant-ui/store";
4
+ import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
4
5
  import { useThreadListNew } from "@assistant-ui/core/react";
5
6
  import { forwardRef } from "@assistant-ui/tap/react-shim";
6
7
  import { jsx } from "react/jsx-runtime";
7
8
  import { composeEventHandlers } from "@radix-ui/primitive";
8
9
  //#region src/primitives/threadList/ThreadListNew.tsx
9
- const ThreadListPrimitiveNew = forwardRef(({ onClick, disabled, ...props }, forwardedRef) => {
10
- const isMain = useAuiState((s) => s.threads.newThreadId === s.threads.mainThreadId);
10
+ const ThreadListPrimitiveNew = forwardRef((t0, forwardedRef) => {
11
+ const $ = c(15);
12
+ let disabled;
13
+ let onClick;
14
+ let props;
15
+ if ($[0] !== t0) {
16
+ ({onClick, disabled, ...props} = t0);
17
+ $[0] = t0;
18
+ $[1] = disabled;
19
+ $[2] = onClick;
20
+ $[3] = props;
21
+ } else {
22
+ disabled = $[1];
23
+ onClick = $[2];
24
+ props = $[3];
25
+ }
26
+ const isMain = useAuiState(_temp);
11
27
  const { switchToNewThread } = useThreadListNew();
12
- return /* @__PURE__ */ jsx(Primitive.button, {
13
- type: "button",
14
- ...isMain ? {
28
+ let t1;
29
+ if ($[4] !== isMain) {
30
+ t1 = isMain ? {
15
31
  "data-active": "true",
16
32
  "aria-current": "true"
17
- } : null,
18
- ...props,
19
- ref: forwardedRef,
20
- disabled,
21
- onClick: composeEventHandlers(onClick, switchToNewThread)
22
- });
33
+ } : null;
34
+ $[4] = isMain;
35
+ $[5] = t1;
36
+ } else t1 = $[5];
37
+ let t2;
38
+ if ($[6] !== onClick || $[7] !== switchToNewThread) {
39
+ t2 = composeEventHandlers(onClick, switchToNewThread);
40
+ $[6] = onClick;
41
+ $[7] = switchToNewThread;
42
+ $[8] = t2;
43
+ } else t2 = $[8];
44
+ let t3;
45
+ if ($[9] !== disabled || $[10] !== forwardedRef || $[11] !== props || $[12] !== t1 || $[13] !== t2) {
46
+ t3 = /* @__PURE__ */ jsx(Primitive.button, {
47
+ type: "button",
48
+ ...t1,
49
+ ...props,
50
+ ref: forwardedRef,
51
+ disabled,
52
+ onClick: t2
53
+ });
54
+ $[9] = disabled;
55
+ $[10] = forwardedRef;
56
+ $[11] = props;
57
+ $[12] = t1;
58
+ $[13] = t2;
59
+ $[14] = t3;
60
+ } else t3 = $[14];
61
+ return t3;
23
62
  });
24
63
  ThreadListPrimitiveNew.displayName = "ThreadListPrimitive.New";
64
+ function _temp(s) {
65
+ return s.threads.newThreadId === s.threads.mainThreadId;
66
+ }
25
67
  //#endregion
26
68
  export { ThreadListPrimitiveNew };
27
69
 
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadListNew.js","names":["useThreadListNewBehavior"],"sources":["../../../src/primitives/threadList/ThreadListNew.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n ActionButtonElement,\n ActionButtonProps,\n} from \"../../utils/createActionButton\";\nimport { forwardRef } from \"react\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useThreadListNew as useThreadListNewBehavior } from \"@assistant-ui/core/react\";\n\nexport namespace ThreadListPrimitiveNew {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<() => void>;\n}\n\nexport const ThreadListPrimitiveNew = forwardRef<\n ThreadListPrimitiveNew.Element,\n ThreadListPrimitiveNew.Props\n>(({ onClick, disabled, ...props }, forwardedRef) => {\n const isMain = useAuiState(\n (s) => s.threads.newThreadId === s.threads.mainThreadId,\n );\n\n const { switchToNewThread } = useThreadListNewBehavior();\n\n return (\n <Primitive.button\n type=\"button\"\n {...(isMain ? { \"data-active\": \"true\", \"aria-current\": \"true\" } : null)}\n {...props}\n ref={forwardedRef}\n disabled={disabled}\n onClick={composeEventHandlers(onClick, switchToNewThread)}\n />\n );\n});\n\nThreadListPrimitiveNew.displayName = \"ThreadListPrimitive.New\";\n"],"mappings":";;;;;;;;AAiBA,MAAa,yBAAyB,YAGnC,EAAE,SAAS,UAAU,GAAG,SAAS,iBAAiB;CACnD,MAAM,SAAS,aACZ,MAAM,EAAE,QAAQ,gBAAgB,EAAE,QAAQ,YAC7C;CAEA,MAAM,EAAE,sBAAsBA,iBAAyB;CAEvD,OACE,oBAAC,UAAU,QAAX;EACE,MAAK;EACL,GAAK,SAAS;GAAE,eAAe;GAAQ,gBAAgB;EAAO,IAAI;EAClE,GAAI;EACJ,KAAK;EACK;EACV,SAAS,qBAAqB,SAAS,iBAAiB;CACzD,CAAA;AAEL,CAAC;AAED,uBAAuB,cAAc"}
1
+ {"version":3,"file":"ThreadListNew.js","names":["c","_c","ActionButtonElement","ActionButtonProps","forwardRef","Primitive","composeEventHandlers","useAuiState","useThreadListNew","useThreadListNewBehavior","ThreadListPrimitiveNew","Element","Props","t0","forwardedRef","$","disabled","onClick","props","isMain","_temp","switchToNewThread","t1","t2","t3","displayName","s","threads","newThreadId","mainThreadId"],"sources":["../../../src/primitives/threadList/ThreadListNew.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n ActionButtonElement,\n ActionButtonProps,\n} from \"../../utils/createActionButton\";\nimport { forwardRef } from \"react\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useThreadListNew as useThreadListNewBehavior } from \"@assistant-ui/core/react\";\n\nexport namespace ThreadListPrimitiveNew {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<() => void>;\n}\n\nexport const ThreadListPrimitiveNew = forwardRef<\n ThreadListPrimitiveNew.Element,\n ThreadListPrimitiveNew.Props\n>(({ onClick, disabled, ...props }, forwardedRef) => {\n const isMain = useAuiState(\n (s) => s.threads.newThreadId === s.threads.mainThreadId,\n );\n\n const { switchToNewThread } = useThreadListNewBehavior();\n\n return (\n <Primitive.button\n type=\"button\"\n {...(isMain ? { \"data-active\": \"true\", \"aria-current\": \"true\" } : null)}\n {...props}\n ref={forwardedRef}\n disabled={disabled}\n onClick={composeEventHandlers(onClick, switchToNewThread)}\n />\n );\n});\n\nThreadListPrimitiveNew.displayName = \"ThreadListPrimitive.New\";\n"],"mappings":";;;;;;;;;AAiBA,MAAaU,yBAAyBN,YAGpCS,IAAAC,iBAAA;CAAA,MAAAC,IAAAd,EAAA,EAAA;CAAA,IAAAe;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAH,EAAA,OAAAF,IAAA;EAAC,CAAA,CAAAI,SAAAD,aAAAE,SAAAL;EAA+BE,EAAA,KAAAF;EAAAE,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAA;EAAAF,WAAAD,EAAA;EAAAE,UAAAF,EAAA;EAAAG,QAAAH,EAAA;CAAA;CAChC,MAAAI,SAAeZ,YACba,KACF;CAEA,MAAA,EAAAC,sBAA8BZ,iBAAyB;CAAE,IAAAa;CAAA,IAAAP,EAAA,OAAAI,QAAA;EAKhDG,KAAAH,SAAA;GAAA,eAA0B;GAAM,gBAAkB;EAAc,IAAhE;EAAiEJ,EAAA,KAAAI;EAAAJ,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,IAAAQ;CAAA,IAAAR,EAAA,OAAAE,WAAAF,EAAA,OAAAM,mBAAA;EAI7DE,KAAAjB,qBAAqBW,SAASI,iBAAiB;EAACN,EAAA,KAAAE;EAAAF,EAAA,KAAAM;EAAAN,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,IAAAS;CAAA,IAAAT,EAAA,OAAAC,YAAAD,EAAA,QAAAD,gBAAAC,EAAA,QAAAG,SAAAH,EAAA,QAAAO,MAAAP,EAAA,QAAAQ,IAAA;EAN3DC,KAAA,oBAAA,UAAA,QAAA;GACO,MAAA;GAAQ,GACRF;GAAiE,GAClEJ;GACCJ,KAAAA;GACKE;GACD,SAAAO;EAAgD,CAAA;EACzDR,EAAA,KAAAC;EAAAD,EAAA,MAAAD;EAAAC,EAAA,MAAAG;EAAAH,EAAA,MAAAO;EAAAP,EAAA,MAAAQ;EAAAR,EAAA,MAAAS;CAAA,OAAAA,KAAAT,EAAA;CAAA,OAPFS;AAOE,CAEL;AAEDd,uBAAuBe,cAAc;AAnBnC,SAAAL,MAAAM,GAAA;CAAA,OAESA,EAACC,QAAQC,gBAAiBF,EAACC,QAAQE;AAAa"}
@@ -1,13 +1,22 @@
1
1
  "use client";
2
2
  import { Primitive } from "../../utils/Primitive.js";
3
+ import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
3
4
  import { forwardRef } from "@assistant-ui/tap/react-shim";
4
5
  import { jsx } from "react/jsx-runtime";
5
6
  //#region src/primitives/threadList/ThreadListRoot.tsx
6
7
  const ThreadListPrimitiveRoot = forwardRef((props, ref) => {
7
- return /* @__PURE__ */ jsx(Primitive.div, {
8
- ...props,
9
- ref
10
- });
8
+ const $ = c(3);
9
+ let t0;
10
+ if ($[0] !== props || $[1] !== ref) {
11
+ t0 = /* @__PURE__ */ jsx(Primitive.div, {
12
+ ...props,
13
+ ref
14
+ });
15
+ $[0] = props;
16
+ $[1] = ref;
17
+ $[2] = t0;
18
+ } else t0 = $[2];
19
+ return t0;
11
20
  });
12
21
  ThreadListPrimitiveRoot.displayName = "ThreadListPrimitive.Root";
13
22
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadListRoot.js","names":[],"sources":["../../../src/primitives/threadList/ThreadListRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\n\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport namespace ThreadListPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = PrimitiveDivProps;\n}\n\nexport const ThreadListPrimitiveRoot = forwardRef<\n ThreadListPrimitiveRoot.Element,\n ThreadListPrimitiveRoot.Props\n>((props, ref) => {\n return <Primitive.div {...props} ref={ref} />;\n});\n\nThreadListPrimitiveRoot.displayName = \"ThreadListPrimitive.Root\";\n"],"mappings":";;;;;AAgBA,MAAa,0BAA0B,YAGpC,OAAO,QAAQ;CAChB,OAAO,oBAAC,UAAU,KAAX;EAAe,GAAI;EAAY;CAAM,CAAA;AAC9C,CAAC;AAED,wBAAwB,cAAc"}
1
+ {"version":3,"file":"ThreadListRoot.js","names":["c","_c","Primitive","ComponentPropsWithoutRef","ComponentRef","forwardRef","PrimitiveDivProps","div","ThreadListPrimitiveRoot","Element","Props","props","ref","$","t0","displayName"],"sources":["../../../src/primitives/threadList/ThreadListRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\n\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport namespace ThreadListPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = PrimitiveDivProps;\n}\n\nexport const ThreadListPrimitiveRoot = forwardRef<\n ThreadListPrimitiveRoot.Element,\n ThreadListPrimitiveRoot.Props\n>((props, ref) => {\n return <Primitive.div {...props} ref={ref} />;\n});\n\nThreadListPrimitiveRoot.displayName = \"ThreadListPrimitive.Root\";\n"],"mappings":";;;;;;AAgBA,MAAaQ,0BAA0BH,YAGrCM,OAAAC,QAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CAAA,IAAAa;CAAA,IAAAD,EAAA,OAAAF,SAAAE,EAAA,OAAAD,KAAA;EACOE,KAAA,oBAAA,UAAA,KAAA;GAAA,GAAmBH;GAAYC;EAAG,CAAA;EAAIC,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAAA,OAAtCC;AAAsC,CAC9C;AAEDN,wBAAwBO,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"threadList.js","names":[],"sources":["../../src/primitives/threadList.ts"],"sourcesContent":["export { ThreadListPrimitiveNew as New } from \"./threadList/ThreadListNew\";\nexport { ThreadListPrimitiveItems as Items } from \"./threadList/ThreadListItems\";\nexport { ThreadListPrimitiveItemByIndex as ItemByIndex } from \"./threadList/ThreadListItems\";\nexport { ThreadListPrimitiveLoadMore as LoadMore } from \"./threadList/ThreadListLoadMore\";\nexport { ThreadListPrimitiveRoot as Root } from \"./threadList/ThreadListRoot\";\n"],"mappings":""}
1
+ {"version":3,"file":"threadList.js","names":["ThreadListPrimitiveNew","New","ThreadListPrimitiveItems","Items","ThreadListPrimitiveItemByIndex","ItemByIndex","ThreadListPrimitiveLoadMore","LoadMore","ThreadListPrimitiveRoot","Root"],"sources":["../../src/primitives/threadList.ts"],"sourcesContent":["export { ThreadListPrimitiveNew as New } from \"./threadList/ThreadListNew\";\nexport { ThreadListPrimitiveItems as Items } from \"./threadList/ThreadListItems\";\nexport { ThreadListPrimitiveItemByIndex as ItemByIndex } from \"./threadList/ThreadListItems\";\nexport { ThreadListPrimitiveLoadMore as LoadMore } from \"./threadList/ThreadListLoadMore\";\nexport { ThreadListPrimitiveRoot as Root } from \"./threadList/ThreadListRoot\";\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadListItemArchive.js","names":["useThreadListItemArchive","useThreadListItemArchiveBehavior"],"sources":["../../../src/primitives/threadListItem/ThreadListItemArchive.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useThreadListItemArchive as useThreadListItemArchiveBehavior } from \"@assistant-ui/core/react\";\n\nconst useThreadListItemArchive = () => {\n const { archive } = useThreadListItemArchiveBehavior();\n return archive;\n};\n\nexport namespace ThreadListItemPrimitiveArchive {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadListItemArchive>;\n}\n\nexport const ThreadListItemPrimitiveArchive = createActionButton(\n \"ThreadListItemPrimitive.Archive\",\n useThreadListItemArchive,\n);\n"],"mappings":";;;;AASA,MAAMA,mCAAiC;CACrC,MAAM,EAAE,YAAYC,yBAAiC;CACrD,OAAO;AACT;AAOA,MAAa,iCAAiC,mBAC5C,mCACAD,0BACF"}
1
+ {"version":3,"file":"ThreadListItemArchive.js","names":["ActionButtonElement","ActionButtonProps","createActionButton","useThreadListItemArchive","useThreadListItemArchiveBehavior","archive","ThreadListItemPrimitiveArchive","Element","Props"],"sources":["../../../src/primitives/threadListItem/ThreadListItemArchive.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useThreadListItemArchive as useThreadListItemArchiveBehavior } from \"@assistant-ui/core/react\";\n\nconst useThreadListItemArchive = () => {\n const { archive } = useThreadListItemArchiveBehavior();\n return archive;\n};\n\nexport namespace ThreadListItemPrimitiveArchive {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadListItemArchive>;\n}\n\nexport const ThreadListItemPrimitiveArchive = createActionButton(\n \"ThreadListItemPrimitive.Archive\",\n useThreadListItemArchive,\n);\n"],"mappings":";;;;AASA,MAAMG,mCAA2B;CAC/B,MAAA,EAAAE,YAAoBD,yBAAiC;CAAE,OAChDC;AAAO;AAQhB,MAAaC,iCAAiCJ,mBAC5C,mCACAC,0BACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadListItemDelete.js","names":["useThreadListItemDelete","useThreadListItemDeleteBehavior"],"sources":["../../../src/primitives/threadListItem/ThreadListItemDelete.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useThreadListItemDelete as useThreadListItemDeleteBehavior } from \"@assistant-ui/core/react\";\n\nconst useThreadListItemDelete = () => {\n const { delete: deleteThread } = useThreadListItemDeleteBehavior();\n return deleteThread;\n};\n\nexport namespace ThreadListItemPrimitiveDelete {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadListItemDelete>;\n}\n\nexport const ThreadListItemPrimitiveDelete = createActionButton(\n \"ThreadListItemPrimitive.Delete\",\n useThreadListItemDelete,\n);\n"],"mappings":";;;;AASA,MAAMA,kCAAgC;CACpC,MAAM,EAAE,QAAQ,iBAAiBC,wBAAgC;CACjE,OAAO;AACT;AAOA,MAAa,gCAAgC,mBAC3C,kCACAD,yBACF"}
1
+ {"version":3,"file":"ThreadListItemDelete.js","names":["ActionButtonElement","ActionButtonProps","createActionButton","useThreadListItemDelete","useThreadListItemDeleteBehavior","delete","deleteThread","ThreadListItemPrimitiveDelete","Element","Props"],"sources":["../../../src/primitives/threadListItem/ThreadListItemDelete.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useThreadListItemDelete as useThreadListItemDeleteBehavior } from \"@assistant-ui/core/react\";\n\nconst useThreadListItemDelete = () => {\n const { delete: deleteThread } = useThreadListItemDeleteBehavior();\n return deleteThread;\n};\n\nexport namespace ThreadListItemPrimitiveDelete {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadListItemDelete>;\n}\n\nexport const ThreadListItemPrimitiveDelete = createActionButton(\n \"ThreadListItemPrimitive.Delete\",\n useThreadListItemDelete,\n);\n"],"mappings":";;;;AASA,MAAMG,kCAA0B;CAC9B,MAAA,EAAAE,QAAAC,iBAAiCF,wBAAgC;CAAE,OAC5DE;AAAY;AAQrB,MAAaC,gCAAgCL,mBAC3C,kCACAC,yBACF"}
@@ -1,21 +1,40 @@
1
1
  "use client";
2
2
  import { Primitive } from "../../utils/Primitive.js";
3
3
  import { useAuiState } from "@assistant-ui/store";
4
+ import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
4
5
  import { forwardRef } from "@assistant-ui/tap/react-shim";
5
6
  import { jsx } from "react/jsx-runtime";
6
7
  //#region src/primitives/threadListItem/ThreadListItemRoot.tsx
7
8
  const ThreadListItemPrimitiveRoot = forwardRef((props, ref) => {
8
- const isMain = useAuiState((s) => s.threads.mainThreadId === s.threadListItem.id);
9
- return /* @__PURE__ */ jsx(Primitive.div, {
10
- ...isMain ? {
9
+ const $ = c(6);
10
+ const isMain = useAuiState(_temp);
11
+ let t0;
12
+ if ($[0] !== isMain) {
13
+ t0 = isMain ? {
11
14
  "data-active": "true",
12
15
  "aria-current": "true"
13
- } : null,
14
- ...props,
15
- ref
16
- });
16
+ } : null;
17
+ $[0] = isMain;
18
+ $[1] = t0;
19
+ } else t0 = $[1];
20
+ let t1;
21
+ if ($[2] !== props || $[3] !== ref || $[4] !== t0) {
22
+ t1 = /* @__PURE__ */ jsx(Primitive.div, {
23
+ ...t0,
24
+ ...props,
25
+ ref
26
+ });
27
+ $[2] = props;
28
+ $[3] = ref;
29
+ $[4] = t0;
30
+ $[5] = t1;
31
+ } else t1 = $[5];
32
+ return t1;
17
33
  });
18
34
  ThreadListItemPrimitiveRoot.displayName = "ThreadListItemPrimitive.Root";
35
+ function _temp(s) {
36
+ return s.threads.mainThreadId === s.threadListItem.id;
37
+ }
19
38
  //#endregion
20
39
  export { ThreadListItemPrimitiveRoot };
21
40
 
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadListItemRoot.js","names":[],"sources":["../../../src/primitives/threadListItem/ThreadListItemRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport namespace ThreadListItemPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = PrimitiveDivProps;\n}\n\nexport const ThreadListItemPrimitiveRoot = forwardRef<\n ThreadListItemPrimitiveRoot.Element,\n ThreadListItemPrimitiveRoot.Props\n>((props, ref) => {\n const isMain = useAuiState(\n (s) => s.threads.mainThreadId === s.threadListItem.id,\n );\n\n return (\n <Primitive.div\n {...(isMain ? { \"data-active\": \"true\", \"aria-current\": \"true\" } : null)}\n {...props}\n ref={ref}\n />\n );\n});\n\nThreadListItemPrimitiveRoot.displayName = \"ThreadListItemPrimitive.Root\";\n"],"mappings":";;;;;;AAiBA,MAAa,8BAA8B,YAGxC,OAAO,QAAQ;CAChB,MAAM,SAAS,aACZ,MAAM,EAAE,QAAQ,iBAAiB,EAAE,eAAe,EACrD;CAEA,OACE,oBAAC,UAAU,KAAX;EACE,GAAK,SAAS;GAAE,eAAe;GAAQ,gBAAgB;EAAO,IAAI;EAClE,GAAI;EACC;CACN,CAAA;AAEL,CAAC;AAED,4BAA4B,cAAc"}
1
+ {"version":3,"file":"ThreadListItemRoot.js","names":["c","_c","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","useAuiState","PrimitiveDivProps","div","ThreadListItemPrimitiveRoot","Element","Props","props","ref","$","isMain","_temp","t0","t1","displayName","s","threads","mainThreadId","threadListItem","id"],"sources":["../../../src/primitives/threadListItem/ThreadListItemRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\ntype PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;\n\nexport namespace ThreadListItemPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = PrimitiveDivProps;\n}\n\nexport const ThreadListItemPrimitiveRoot = forwardRef<\n ThreadListItemPrimitiveRoot.Element,\n ThreadListItemPrimitiveRoot.Props\n>((props, ref) => {\n const isMain = useAuiState(\n (s) => s.threads.mainThreadId === s.threadListItem.id,\n );\n\n return (\n <Primitive.div\n {...(isMain ? { \"data-active\": \"true\", \"aria-current\": \"true\" } : null)}\n {...props}\n ref={ref}\n />\n );\n});\n\nThreadListItemPrimitiveRoot.displayName = \"ThreadListItemPrimitive.Root\";\n"],"mappings":";;;;;;;AAiBA,MAAaS,8BAA8BL,YAGzCQ,OAAAC,QAAA;CAAA,MAAAC,IAAAb,EAAA,CAAA;CACA,MAAAc,SAAeT,YACbU,KACF;CAAE,IAAAC;CAAA,IAAAH,EAAA,OAAAC,QAAA;EAIOE,KAAAF,SAAA;GAAA,eAA0B;GAAM,gBAAkB;EAAc,IAAhE;EAAiED,EAAA,KAAAC;EAAAD,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAA,IAAAI;CAAA,IAAAJ,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAG,IAAA;EADxEC,KAAA,oBAAA,UAAA,KAAA;GAAA,GACOD;GAAiE,GAClEL;GACCC;EAAG,CAAA;EACRC,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,OAJFI;AAIE,CAEL;AAEDT,4BAA4BU,cAAc;AAdxC,SAAAH,MAAAI,GAAA;CAAA,OAESA,EAACC,QAAQC,iBAAkBF,EAACG,eAAeC;AAAG"}
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadListItemTrigger.js","names":["useThreadListItemTrigger","useThreadListItemTriggerBehavior"],"sources":["../../../src/primitives/threadListItem/ThreadListItemTrigger.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useThreadListItemTrigger as useThreadListItemTriggerBehavior } from \"@assistant-ui/core/react\";\n\nconst useThreadListItemTrigger = () => {\n const { switchTo } = useThreadListItemTriggerBehavior();\n return switchTo;\n};\n\nexport namespace ThreadListItemPrimitiveTrigger {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadListItemTrigger>;\n}\n\nexport const ThreadListItemPrimitiveTrigger = createActionButton(\n \"ThreadListItemPrimitive.Trigger\",\n useThreadListItemTrigger,\n);\n"],"mappings":";;;;AASA,MAAMA,mCAAiC;CACrC,MAAM,EAAE,aAAaC,yBAAiC;CACtD,OAAO;AACT;AAOA,MAAa,iCAAiC,mBAC5C,mCACAD,0BACF"}
1
+ {"version":3,"file":"ThreadListItemTrigger.js","names":["ActionButtonElement","ActionButtonProps","createActionButton","useThreadListItemTrigger","useThreadListItemTriggerBehavior","switchTo","ThreadListItemPrimitiveTrigger","Element","Props"],"sources":["../../../src/primitives/threadListItem/ThreadListItemTrigger.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useThreadListItemTrigger as useThreadListItemTriggerBehavior } from \"@assistant-ui/core/react\";\n\nconst useThreadListItemTrigger = () => {\n const { switchTo } = useThreadListItemTriggerBehavior();\n return switchTo;\n};\n\nexport namespace ThreadListItemPrimitiveTrigger {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadListItemTrigger>;\n}\n\nexport const ThreadListItemPrimitiveTrigger = createActionButton(\n \"ThreadListItemPrimitive.Trigger\",\n useThreadListItemTrigger,\n);\n"],"mappings":";;;;AASA,MAAMG,mCAA2B;CAC/B,MAAA,EAAAE,aAAqBD,yBAAiC;CAAE,OACjDC;AAAQ;AAQjB,MAAaC,iCAAiCJ,mBAC5C,mCACAC,0BACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadListItemUnarchive.js","names":["useThreadListItemUnarchive","useThreadListItemUnarchiveBehavior"],"sources":["../../../src/primitives/threadListItem/ThreadListItemUnarchive.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useThreadListItemUnarchive as useThreadListItemUnarchiveBehavior } from \"@assistant-ui/core/react\";\n\nconst useThreadListItemUnarchive = () => {\n const { unarchive } = useThreadListItemUnarchiveBehavior();\n return unarchive;\n};\n\nexport namespace ThreadListItemPrimitiveUnarchive {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadListItemUnarchive>;\n}\n\nexport const ThreadListItemPrimitiveUnarchive = createActionButton(\n \"ThreadListItemPrimitive.Unarchive\",\n useThreadListItemUnarchive,\n);\n"],"mappings":";;;;AASA,MAAMA,qCAAmC;CACvC,MAAM,EAAE,cAAcC,2BAAmC;CACzD,OAAO;AACT;AAOA,MAAa,mCAAmC,mBAC9C,qCACAD,4BACF"}
1
+ {"version":3,"file":"ThreadListItemUnarchive.js","names":["ActionButtonElement","ActionButtonProps","createActionButton","useThreadListItemUnarchive","useThreadListItemUnarchiveBehavior","unarchive","ThreadListItemPrimitiveUnarchive","Element","Props"],"sources":["../../../src/primitives/threadListItem/ThreadListItemUnarchive.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useThreadListItemUnarchive as useThreadListItemUnarchiveBehavior } from \"@assistant-ui/core/react\";\n\nconst useThreadListItemUnarchive = () => {\n const { unarchive } = useThreadListItemUnarchiveBehavior();\n return unarchive;\n};\n\nexport namespace ThreadListItemPrimitiveUnarchive {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadListItemUnarchive>;\n}\n\nexport const ThreadListItemPrimitiveUnarchive = createActionButton(\n \"ThreadListItemPrimitive.Unarchive\",\n useThreadListItemUnarchive,\n);\n"],"mappings":";;;;AASA,MAAMG,qCAA6B;CACjC,MAAA,EAAAE,cAAsBD,2BAAmC;CAAE,OACpDC;AAAS;AAQlB,MAAaC,mCAAmCJ,mBAC9C,qCACAC,4BACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"threadListItem.js","names":[],"sources":["../../src/primitives/threadListItem.ts"],"sourcesContent":["export { ThreadListItemPrimitiveRoot as Root } from \"./threadListItem/ThreadListItemRoot\";\nexport { ThreadListItemPrimitiveArchive as Archive } from \"./threadListItem/ThreadListItemArchive\";\nexport { ThreadListItemPrimitiveUnarchive as Unarchive } from \"./threadListItem/ThreadListItemUnarchive\";\nexport { ThreadListItemPrimitiveDelete as Delete } from \"./threadListItem/ThreadListItemDelete\";\nexport { ThreadListItemPrimitiveTrigger as Trigger } from \"./threadListItem/ThreadListItemTrigger\";\nexport { ThreadListItemPrimitiveTitle as Title } from \"./threadListItem/ThreadListItemTitle\";\n"],"mappings":""}
1
+ {"version":3,"file":"threadListItem.js","names":["ThreadListItemPrimitiveRoot","Root","ThreadListItemPrimitiveArchive","Archive","ThreadListItemPrimitiveUnarchive","Unarchive","ThreadListItemPrimitiveDelete","Delete","ThreadListItemPrimitiveTrigger","Trigger","ThreadListItemPrimitiveTitle","Title"],"sources":["../../src/primitives/threadListItem.ts"],"sourcesContent":["export { ThreadListItemPrimitiveRoot as Root } from \"./threadListItem/ThreadListItemRoot\";\nexport { ThreadListItemPrimitiveArchive as Archive } from \"./threadListItem/ThreadListItemArchive\";\nexport { ThreadListItemPrimitiveUnarchive as Unarchive } from \"./threadListItem/ThreadListItemUnarchive\";\nexport { ThreadListItemPrimitiveDelete as Delete } from \"./threadListItem/ThreadListItemDelete\";\nexport { ThreadListItemPrimitiveTrigger as Trigger } from \"./threadListItem/ThreadListItemTrigger\";\nexport { ThreadListItemPrimitiveTitle as Title } from \"./threadListItem/ThreadListItemTitle\";\n"],"mappings":""}