@base44/superagent-native 0.0.1 → 0.0.3

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 (332) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -20
  3. package/lib/commonjs/AgentSettingsPanel.js +155 -62
  4. package/lib/commonjs/AgentSettingsPanel.js.map +1 -1
  5. package/lib/commonjs/AgentSphereIcon.js +14 -118
  6. package/lib/commonjs/AgentSphereIcon.js.map +1 -1
  7. package/lib/commonjs/AttachmentPickerStatusModal.js +5 -4
  8. package/lib/commonjs/AttachmentPickerStatusModal.js.map +1 -1
  9. package/lib/commonjs/ChannelsPanel.js +66 -44
  10. package/lib/commonjs/ChannelsPanel.js.map +1 -1
  11. package/lib/commonjs/ConversationChat.js +38 -13
  12. package/lib/commonjs/ConversationChat.js.map +1 -1
  13. package/lib/commonjs/ConversationComposer.js +18 -13
  14. package/lib/commonjs/ConversationComposer.js.map +1 -1
  15. package/lib/commonjs/ConversationScreen.js +4 -0
  16. package/lib/commonjs/ConversationScreen.js.map +1 -1
  17. package/lib/commonjs/EditorDrawer.js +54 -24
  18. package/lib/commonjs/EditorDrawer.js.map +1 -1
  19. package/lib/commonjs/FilesPanel.js +56 -20
  20. package/lib/commonjs/FilesPanel.js.map +1 -1
  21. package/lib/commonjs/MarkdownText.js +1 -1
  22. package/lib/commonjs/MarkdownText.js.map +1 -1
  23. package/lib/commonjs/MessageActionBar.js +10 -3
  24. package/lib/commonjs/MessageActionBar.js.map +1 -1
  25. package/lib/commonjs/RenameAgentModal.js +2 -1
  26. package/lib/commonjs/RenameAgentModal.js.map +1 -1
  27. package/lib/commonjs/ShareAgentModal.js +11 -10
  28. package/lib/commonjs/ShareAgentModal.js.map +1 -1
  29. package/lib/commonjs/ShareAgentModal.styles.js +2 -2
  30. package/lib/commonjs/ShareAgentModal.styles.js.map +1 -1
  31. package/lib/commonjs/SuperagentHomeScreen.js +44 -12
  32. package/lib/commonjs/SuperagentHomeScreen.js.map +1 -1
  33. package/lib/commonjs/ToolApprovalCard.js +73 -15
  34. package/lib/commonjs/ToolApprovalCard.js.map +1 -1
  35. package/lib/commonjs/ToolCallSummary.js +19 -10
  36. package/lib/commonjs/ToolCallSummary.js.map +1 -1
  37. package/lib/commonjs/agentSphereAssets.js +327 -0
  38. package/lib/commonjs/agentSphereAssets.js.map +1 -0
  39. package/lib/commonjs/agentSphereStyles.js +3 -3
  40. package/lib/commonjs/agentSphereStyles.js.map +1 -1
  41. package/lib/commonjs/apiClient.js +7 -0
  42. package/lib/commonjs/apiClient.js.map +1 -1
  43. package/lib/commonjs/attachmentUpload.js +2 -1
  44. package/lib/commonjs/attachmentUpload.js.map +1 -1
  45. package/lib/commonjs/composerStyles.js +2 -2
  46. package/lib/commonjs/composerStyles.js.map +1 -1
  47. package/lib/commonjs/connectorBrandIcons.generated.js +625 -0
  48. package/lib/commonjs/connectorBrandIcons.generated.js.map +1 -0
  49. package/lib/commonjs/connectorBrandIcons.js +3 -55
  50. package/lib/commonjs/connectorBrandIcons.js.map +1 -1
  51. package/lib/commonjs/connectorCatalog.js +19 -1
  52. package/lib/commonjs/connectorCatalog.js.map +1 -1
  53. package/lib/commonjs/conversationParts.js +5 -4
  54. package/lib/commonjs/conversationParts.js.map +1 -1
  55. package/lib/commonjs/conversationRuntime.js +152 -9
  56. package/lib/commonjs/conversationRuntime.js.map +1 -1
  57. package/lib/commonjs/conversationStyles.js +2 -1
  58. package/lib/commonjs/conversationStyles.js.map +1 -1
  59. package/lib/commonjs/editorShellStyles.js +6 -2
  60. package/lib/commonjs/editorShellStyles.js.map +1 -1
  61. package/lib/commonjs/fileTreeUtils.js +7 -0
  62. package/lib/commonjs/fileTreeUtils.js.map +1 -1
  63. package/lib/commonjs/index.js +7 -0
  64. package/lib/commonjs/index.js.map +1 -1
  65. package/lib/commonjs/markdownStyles.js +2 -2
  66. package/lib/commonjs/markdownStyles.js.map +1 -1
  67. package/lib/commonjs/messageActionStyles.js +2 -2
  68. package/lib/commonjs/messageActionStyles.js.map +1 -1
  69. package/lib/commonjs/realtimeClient.js +4 -1
  70. package/lib/commonjs/realtimeClient.js.map +1 -1
  71. package/lib/commonjs/renameAgentModalStyles.js +2 -2
  72. package/lib/commonjs/renameAgentModalStyles.js.map +1 -1
  73. package/lib/commonjs/screenParts.js +24 -41
  74. package/lib/commonjs/screenParts.js.map +1 -1
  75. package/lib/commonjs/styles.js +32 -21
  76. package/lib/commonjs/styles.js.map +1 -1
  77. package/lib/commonjs/superagentApiClient.js +63 -18
  78. package/lib/commonjs/superagentApiClient.js.map +1 -1
  79. package/lib/commonjs/theme.js +249 -0
  80. package/lib/commonjs/theme.js.map +1 -0
  81. package/lib/commonjs/useSuperagentConversation.js +240 -44
  82. package/lib/commonjs/useSuperagentConversation.js.map +1 -1
  83. package/lib/commonjs/useSuperagentRuntime.js +245 -105
  84. package/lib/commonjs/useSuperagentRuntime.js.map +1 -1
  85. package/lib/module/AgentSettingsPanel.js +157 -64
  86. package/lib/module/AgentSettingsPanel.js.map +1 -1
  87. package/lib/module/AgentSphereIcon.js +15 -118
  88. package/lib/module/AgentSphereIcon.js.map +1 -1
  89. package/lib/module/AttachmentPickerStatusModal.js +6 -5
  90. package/lib/module/AttachmentPickerStatusModal.js.map +1 -1
  91. package/lib/module/ChannelsPanel.js +67 -45
  92. package/lib/module/ChannelsPanel.js.map +1 -1
  93. package/lib/module/ConversationChat.js +38 -13
  94. package/lib/module/ConversationChat.js.map +1 -1
  95. package/lib/module/ConversationComposer.js +18 -13
  96. package/lib/module/ConversationComposer.js.map +1 -1
  97. package/lib/module/ConversationScreen.js +4 -0
  98. package/lib/module/ConversationScreen.js.map +1 -1
  99. package/lib/module/EditorDrawer.js +55 -25
  100. package/lib/module/EditorDrawer.js.map +1 -1
  101. package/lib/module/FilesPanel.js +56 -20
  102. package/lib/module/FilesPanel.js.map +1 -1
  103. package/lib/module/MarkdownText.js +1 -1
  104. package/lib/module/MarkdownText.js.map +1 -1
  105. package/lib/module/MessageActionBar.js +10 -3
  106. package/lib/module/MessageActionBar.js.map +1 -1
  107. package/lib/module/RenameAgentModal.js +2 -1
  108. package/lib/module/RenameAgentModal.js.map +1 -1
  109. package/lib/module/ShareAgentModal.js +11 -10
  110. package/lib/module/ShareAgentModal.js.map +1 -1
  111. package/lib/module/ShareAgentModal.styles.js +2 -2
  112. package/lib/module/ShareAgentModal.styles.js.map +1 -1
  113. package/lib/module/SuperagentHomeScreen.js +45 -13
  114. package/lib/module/SuperagentHomeScreen.js.map +1 -1
  115. package/lib/module/ToolApprovalCard.js +73 -15
  116. package/lib/module/ToolApprovalCard.js.map +1 -1
  117. package/lib/module/ToolCallSummary.js +19 -10
  118. package/lib/module/ToolCallSummary.js.map +1 -1
  119. package/lib/module/agentSphereAssets.js +323 -0
  120. package/lib/module/agentSphereAssets.js.map +1 -0
  121. package/lib/module/agentSphereStyles.js +3 -3
  122. package/lib/module/agentSphereStyles.js.map +1 -1
  123. package/lib/module/apiClient.js +7 -0
  124. package/lib/module/apiClient.js.map +1 -1
  125. package/lib/module/attachmentUpload.js +2 -1
  126. package/lib/module/attachmentUpload.js.map +1 -1
  127. package/lib/module/composerStyles.js +2 -2
  128. package/lib/module/composerStyles.js.map +1 -1
  129. package/lib/module/connectorBrandIcons.generated.js +621 -0
  130. package/lib/module/connectorBrandIcons.generated.js.map +1 -0
  131. package/lib/module/connectorBrandIcons.js +1 -53
  132. package/lib/module/connectorBrandIcons.js.map +1 -1
  133. package/lib/module/connectorCatalog.js +17 -0
  134. package/lib/module/connectorCatalog.js.map +1 -1
  135. package/lib/module/conversationParts.js +5 -4
  136. package/lib/module/conversationParts.js.map +1 -1
  137. package/lib/module/conversationRuntime.js +149 -9
  138. package/lib/module/conversationRuntime.js.map +1 -1
  139. package/lib/module/conversationStyles.js +3 -2
  140. package/lib/module/conversationStyles.js.map +1 -1
  141. package/lib/module/editorShellStyles.js +6 -2
  142. package/lib/module/editorShellStyles.js.map +1 -1
  143. package/lib/module/fileTreeUtils.js +6 -0
  144. package/lib/module/fileTreeUtils.js.map +1 -1
  145. package/lib/module/index.js +1 -0
  146. package/lib/module/index.js.map +1 -1
  147. package/lib/module/markdownStyles.js +2 -2
  148. package/lib/module/markdownStyles.js.map +1 -1
  149. package/lib/module/messageActionStyles.js +2 -2
  150. package/lib/module/messageActionStyles.js.map +1 -1
  151. package/lib/module/realtimeClient.js +4 -1
  152. package/lib/module/realtimeClient.js.map +1 -1
  153. package/lib/module/renameAgentModalStyles.js +2 -2
  154. package/lib/module/renameAgentModalStyles.js.map +1 -1
  155. package/lib/module/screenParts.js +25 -42
  156. package/lib/module/screenParts.js.map +1 -1
  157. package/lib/module/styles.js +32 -21
  158. package/lib/module/styles.js.map +1 -1
  159. package/lib/module/superagentApiClient.js +63 -18
  160. package/lib/module/superagentApiClient.js.map +1 -1
  161. package/lib/module/theme.js +239 -0
  162. package/lib/module/theme.js.map +1 -0
  163. package/lib/module/useSuperagentConversation.js +242 -46
  164. package/lib/module/useSuperagentConversation.js.map +1 -1
  165. package/lib/module/useSuperagentRuntime.js +246 -106
  166. package/lib/module/useSuperagentRuntime.js.map +1 -1
  167. package/lib/typescript/commonjs/AgentSettingsPanel.d.ts.map +1 -1
  168. package/lib/typescript/commonjs/AgentSphereIcon.d.ts.map +1 -1
  169. package/lib/typescript/commonjs/AttachmentPickerStatusModal.d.ts.map +1 -1
  170. package/lib/typescript/commonjs/ChannelsPanel.d.ts.map +1 -1
  171. package/lib/typescript/commonjs/ConversationChat.d.ts +1 -1
  172. package/lib/typescript/commonjs/ConversationChat.d.ts.map +1 -1
  173. package/lib/typescript/commonjs/ConversationComposer.d.ts.map +1 -1
  174. package/lib/typescript/commonjs/ConversationMessageList.d.ts +1 -1
  175. package/lib/typescript/commonjs/ConversationMessageList.d.ts.map +1 -1
  176. package/lib/typescript/commonjs/ConversationScreen.d.ts +2 -1
  177. package/lib/typescript/commonjs/ConversationScreen.d.ts.map +1 -1
  178. package/lib/typescript/commonjs/EditorDrawer.d.ts +1 -1
  179. package/lib/typescript/commonjs/EditorDrawer.d.ts.map +1 -1
  180. package/lib/typescript/commonjs/FilesPanel.d.ts.map +1 -1
  181. package/lib/typescript/commonjs/RenameAgentModal.d.ts.map +1 -1
  182. package/lib/typescript/commonjs/ShareAgentModal.d.ts.map +1 -1
  183. package/lib/typescript/commonjs/ShareAgentModal.styles.d.ts.map +1 -1
  184. package/lib/typescript/commonjs/SuperagentHomeScreen.d.ts.map +1 -1
  185. package/lib/typescript/commonjs/ToolApprovalCard.d.ts +3 -3
  186. package/lib/typescript/commonjs/ToolApprovalCard.d.ts.map +1 -1
  187. package/lib/typescript/commonjs/ToolCallSummary.d.ts +1 -1
  188. package/lib/typescript/commonjs/ToolCallSummary.d.ts.map +1 -1
  189. package/lib/typescript/commonjs/agentSphereAssets.d.ts +2 -0
  190. package/lib/typescript/commonjs/agentSphereAssets.d.ts.map +1 -0
  191. package/lib/typescript/commonjs/agentSphereStyles.d.ts.map +1 -1
  192. package/lib/typescript/commonjs/apiClient.d.ts.map +1 -1
  193. package/lib/typescript/commonjs/composerStyles.d.ts.map +1 -1
  194. package/lib/typescript/commonjs/connectorBrandIcons.d.ts.map +1 -1
  195. package/lib/typescript/commonjs/connectorBrandIcons.generated.d.ts +2 -0
  196. package/lib/typescript/commonjs/connectorBrandIcons.generated.d.ts.map +1 -0
  197. package/lib/typescript/commonjs/connectorCatalog.d.ts +2 -0
  198. package/lib/typescript/commonjs/connectorCatalog.d.ts.map +1 -1
  199. package/lib/typescript/commonjs/conversationParts.d.ts +1 -1
  200. package/lib/typescript/commonjs/conversationParts.d.ts.map +1 -1
  201. package/lib/typescript/commonjs/conversationRuntime.d.ts +9 -3
  202. package/lib/typescript/commonjs/conversationRuntime.d.ts.map +1 -1
  203. package/lib/typescript/commonjs/conversationStyles.d.ts.map +1 -1
  204. package/lib/typescript/commonjs/editorShellStyles.d.ts +4 -0
  205. package/lib/typescript/commonjs/editorShellStyles.d.ts.map +1 -1
  206. package/lib/typescript/commonjs/fileTreeUtils.d.ts +1 -0
  207. package/lib/typescript/commonjs/fileTreeUtils.d.ts.map +1 -1
  208. package/lib/typescript/commonjs/index.d.ts +2 -0
  209. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  210. package/lib/typescript/commonjs/markdownStyles.d.ts.map +1 -1
  211. package/lib/typescript/commonjs/messageActionStyles.d.ts.map +1 -1
  212. package/lib/typescript/commonjs/realtimeClient.d.ts.map +1 -1
  213. package/lib/typescript/commonjs/renameAgentModalStyles.d.ts.map +1 -1
  214. package/lib/typescript/commonjs/screenParts.d.ts +1 -1
  215. package/lib/typescript/commonjs/screenParts.d.ts.map +1 -1
  216. package/lib/typescript/commonjs/styles.d.ts +20 -11
  217. package/lib/typescript/commonjs/styles.d.ts.map +1 -1
  218. package/lib/typescript/commonjs/superagentApiClient.d.ts +2 -1
  219. package/lib/typescript/commonjs/superagentApiClient.d.ts.map +1 -1
  220. package/lib/typescript/commonjs/theme.d.ts +36 -0
  221. package/lib/typescript/commonjs/theme.d.ts.map +1 -0
  222. package/lib/typescript/commonjs/types.d.ts +17 -2
  223. package/lib/typescript/commonjs/types.d.ts.map +1 -1
  224. package/lib/typescript/commonjs/useSuperagentConversation.d.ts +3 -2
  225. package/lib/typescript/commonjs/useSuperagentConversation.d.ts.map +1 -1
  226. package/lib/typescript/commonjs/useSuperagentRuntime.d.ts +5 -2
  227. package/lib/typescript/commonjs/useSuperagentRuntime.d.ts.map +1 -1
  228. package/lib/typescript/module/AgentSettingsPanel.d.ts.map +1 -1
  229. package/lib/typescript/module/AgentSphereIcon.d.ts.map +1 -1
  230. package/lib/typescript/module/AttachmentPickerStatusModal.d.ts.map +1 -1
  231. package/lib/typescript/module/ChannelsPanel.d.ts.map +1 -1
  232. package/lib/typescript/module/ConversationChat.d.ts +1 -1
  233. package/lib/typescript/module/ConversationChat.d.ts.map +1 -1
  234. package/lib/typescript/module/ConversationComposer.d.ts.map +1 -1
  235. package/lib/typescript/module/ConversationMessageList.d.ts +1 -1
  236. package/lib/typescript/module/ConversationMessageList.d.ts.map +1 -1
  237. package/lib/typescript/module/ConversationScreen.d.ts +2 -1
  238. package/lib/typescript/module/ConversationScreen.d.ts.map +1 -1
  239. package/lib/typescript/module/EditorDrawer.d.ts +1 -1
  240. package/lib/typescript/module/EditorDrawer.d.ts.map +1 -1
  241. package/lib/typescript/module/FilesPanel.d.ts.map +1 -1
  242. package/lib/typescript/module/RenameAgentModal.d.ts.map +1 -1
  243. package/lib/typescript/module/ShareAgentModal.d.ts.map +1 -1
  244. package/lib/typescript/module/ShareAgentModal.styles.d.ts.map +1 -1
  245. package/lib/typescript/module/SuperagentHomeScreen.d.ts.map +1 -1
  246. package/lib/typescript/module/ToolApprovalCard.d.ts +3 -3
  247. package/lib/typescript/module/ToolApprovalCard.d.ts.map +1 -1
  248. package/lib/typescript/module/ToolCallSummary.d.ts +1 -1
  249. package/lib/typescript/module/ToolCallSummary.d.ts.map +1 -1
  250. package/lib/typescript/module/agentSphereAssets.d.ts +2 -0
  251. package/lib/typescript/module/agentSphereAssets.d.ts.map +1 -0
  252. package/lib/typescript/module/agentSphereStyles.d.ts.map +1 -1
  253. package/lib/typescript/module/apiClient.d.ts.map +1 -1
  254. package/lib/typescript/module/composerStyles.d.ts.map +1 -1
  255. package/lib/typescript/module/connectorBrandIcons.d.ts.map +1 -1
  256. package/lib/typescript/module/connectorBrandIcons.generated.d.ts +2 -0
  257. package/lib/typescript/module/connectorBrandIcons.generated.d.ts.map +1 -0
  258. package/lib/typescript/module/connectorCatalog.d.ts +2 -0
  259. package/lib/typescript/module/connectorCatalog.d.ts.map +1 -1
  260. package/lib/typescript/module/conversationParts.d.ts +1 -1
  261. package/lib/typescript/module/conversationParts.d.ts.map +1 -1
  262. package/lib/typescript/module/conversationRuntime.d.ts +9 -3
  263. package/lib/typescript/module/conversationRuntime.d.ts.map +1 -1
  264. package/lib/typescript/module/conversationStyles.d.ts.map +1 -1
  265. package/lib/typescript/module/editorShellStyles.d.ts +4 -0
  266. package/lib/typescript/module/editorShellStyles.d.ts.map +1 -1
  267. package/lib/typescript/module/fileTreeUtils.d.ts +1 -0
  268. package/lib/typescript/module/fileTreeUtils.d.ts.map +1 -1
  269. package/lib/typescript/module/index.d.ts +2 -0
  270. package/lib/typescript/module/index.d.ts.map +1 -1
  271. package/lib/typescript/module/markdownStyles.d.ts.map +1 -1
  272. package/lib/typescript/module/messageActionStyles.d.ts.map +1 -1
  273. package/lib/typescript/module/realtimeClient.d.ts.map +1 -1
  274. package/lib/typescript/module/renameAgentModalStyles.d.ts.map +1 -1
  275. package/lib/typescript/module/screenParts.d.ts +1 -1
  276. package/lib/typescript/module/screenParts.d.ts.map +1 -1
  277. package/lib/typescript/module/styles.d.ts +20 -11
  278. package/lib/typescript/module/styles.d.ts.map +1 -1
  279. package/lib/typescript/module/superagentApiClient.d.ts +2 -1
  280. package/lib/typescript/module/superagentApiClient.d.ts.map +1 -1
  281. package/lib/typescript/module/theme.d.ts +36 -0
  282. package/lib/typescript/module/theme.d.ts.map +1 -0
  283. package/lib/typescript/module/types.d.ts +17 -2
  284. package/lib/typescript/module/types.d.ts.map +1 -1
  285. package/lib/typescript/module/useSuperagentConversation.d.ts +3 -2
  286. package/lib/typescript/module/useSuperagentConversation.d.ts.map +1 -1
  287. package/lib/typescript/module/useSuperagentRuntime.d.ts +5 -2
  288. package/lib/typescript/module/useSuperagentRuntime.d.ts.map +1 -1
  289. package/package.json +13 -11
  290. package/src/AgentSettingsPanel.tsx +146 -58
  291. package/src/AgentSphereIcon.tsx +11 -62
  292. package/src/AttachmentPickerStatusModal.tsx +6 -5
  293. package/src/ChannelsPanel.tsx +59 -39
  294. package/src/ConversationChat.tsx +49 -12
  295. package/src/ConversationComposer.tsx +18 -12
  296. package/src/ConversationMessageList.tsx +1 -1
  297. package/src/ConversationScreen.tsx +5 -0
  298. package/src/EditorDrawer.tsx +66 -41
  299. package/src/FilesPanel.tsx +48 -20
  300. package/src/MarkdownText.tsx +1 -1
  301. package/src/MessageActionBar.tsx +9 -3
  302. package/src/RenameAgentModal.tsx +2 -1
  303. package/src/ShareAgentModal.styles.ts +2 -1
  304. package/src/ShareAgentModal.tsx +9 -8
  305. package/src/SuperagentHomeScreen.tsx +45 -10
  306. package/src/ToolApprovalCard.tsx +83 -15
  307. package/src/ToolCallSummary.tsx +22 -13
  308. package/src/agentSphereAssets.ts +325 -0
  309. package/src/agentSphereStyles.ts +3 -2
  310. package/src/apiClient.ts +7 -0
  311. package/src/attachmentUpload.ts +2 -1
  312. package/src/composerStyles.ts +2 -1
  313. package/src/connectorBrandIcons.generated.ts +618 -0
  314. package/src/connectorBrandIcons.tsx +1 -53
  315. package/src/connectorCatalog.ts +24 -0
  316. package/src/conversationParts.tsx +6 -5
  317. package/src/conversationRuntime.ts +166 -11
  318. package/src/conversationStyles.ts +2 -1
  319. package/src/editorShellStyles.ts +6 -1
  320. package/src/fileTreeUtils.ts +13 -0
  321. package/src/index.ts +2 -0
  322. package/src/markdownStyles.ts +2 -1
  323. package/src/messageActionStyles.ts +2 -1
  324. package/src/realtimeClient.ts +7 -1
  325. package/src/renameAgentModalStyles.ts +2 -1
  326. package/src/screenParts.tsx +17 -29
  327. package/src/styles.ts +25 -16
  328. package/src/superagentApiClient.ts +68 -18
  329. package/src/theme.ts +254 -0
  330. package/src/types.ts +22 -2
  331. package/src/useSuperagentConversation.ts +247 -45
  332. package/src/useSuperagentRuntime.ts +244 -107
@@ -0,0 +1,239 @@
1
+ "use strict";
2
+
3
+ import { createContext, useContext } from 'react';
4
+ import { StyleSheet } from 'react-native';
5
+
6
+ /**
7
+ * Theming for the Superagent native package.
8
+ *
9
+ * All stylesheets in this package are authored in the original dark palette;
10
+ * light mode (the default) is derived by remapping those colors through the
11
+ * tables below. `createThemedStyles` builds both StyleSheets up front and
12
+ * returns a proxy that resolves against the active scheme on every property
13
+ * read, so existing `styles.foo` call sites keep working unchanged. The
14
+ * scheme lives in module state synced from the provider in
15
+ * SuperagentHomeScreen during render; nothing in the tree is memoized, so a
16
+ * scheme change at the root re-renders (and re-reads) everything.
17
+ */
18
+
19
+ let currentScheme = 'light';
20
+ export function getSuperagentColorScheme() {
21
+ return currentScheme;
22
+ }
23
+ export function syncSuperagentColorScheme(scheme) {
24
+ currentScheme = scheme;
25
+ }
26
+ export const SuperagentThemeContext = /*#__PURE__*/createContext({
27
+ scheme: 'light',
28
+ setScheme: () => {}
29
+ });
30
+ export function useSuperagentTheme() {
31
+ return useContext(SuperagentThemeContext);
32
+ }
33
+
34
+ // Dark background -> light background.
35
+ const BG_MAP = {
36
+ '#000000': '#F3F3F3',
37
+ '#050505': '#FFFFFF',
38
+ '#070707': '#FFFFFF',
39
+ '#080808': '#FFFFFF',
40
+ '#0A0A0A': '#FFFFFF',
41
+ '#0B0B0C': '#FFFFFF',
42
+ '#0F0F10': '#FFFFFF',
43
+ '#101010': '#FFFFFF',
44
+ '#101012': '#FFFFFF',
45
+ '#111111': '#FFFFFF',
46
+ '#111113': '#FFFFFF',
47
+ '#141414': '#FFFFFF',
48
+ '#151515': '#F4F4F5',
49
+ '#171717': '#F4F4F5',
50
+ '#181818': '#F4F4F5',
51
+ '#1B1B1B': '#F4F4F5',
52
+ '#1F1F22': '#F4F4F5',
53
+ '#1F1F23': '#F4F4F5',
54
+ '#242424': '#F4F4F5',
55
+ '#242427': '#F4F4F5',
56
+ '#252528': '#F4F4F5',
57
+ '#262626': '#F4F4F5',
58
+ '#2A2A2A': '#E4E4E7',
59
+ '#2C2C2E': '#E4E4E7',
60
+ '#3A3A3E': '#E4E4E7',
61
+ '#BDBDC2': '#A1A1AA',
62
+ '#F4F4F5': '#18181B',
63
+ // Cream CTAs become the dark CTA treatment on light surfaces.
64
+ '#F7F3E7': '#18181B',
65
+ '#F4F0E6': '#18181B',
66
+ // Status / accent tints.
67
+ '#11251A': '#DCFCE7',
68
+ '#13231D': '#DCFCE7',
69
+ '#21110A': '#FFEDD5',
70
+ '#1D120D': '#FFEDD5',
71
+ '#1C0F10': '#FEE2E2',
72
+ '#241111': '#FEE2E2',
73
+ '#351516': '#FEE2E2',
74
+ '#102036': '#DBEAFE',
75
+ '#1E1B4B': '#E0E7FF',
76
+ '#312E81': '#E0E7FF'
77
+ };
78
+
79
+ // Dark border -> light border.
80
+ const BORDER_MAP = {
81
+ '#101012': '#E4E4E7',
82
+ '#1F1F23': '#E4E4E7',
83
+ '#242427': '#E4E4E7',
84
+ '#242429': '#E4E4E7',
85
+ '#252529': '#E4E4E7',
86
+ '#27272A': '#E4E4E7',
87
+ '#29292E': '#E4E4E7',
88
+ '#2A2A2A': '#E4E4E7',
89
+ '#2A2A2D': '#E4E4E7',
90
+ '#2A2A2E': '#E4E4E7',
91
+ '#303035': '#E4E4E7',
92
+ '#333333': '#E4E4E7',
93
+ '#333338': '#E4E4E7',
94
+ '#34343A': '#E4E4E7',
95
+ '#353535': '#E4E4E7',
96
+ '#353539': '#E4E4E7',
97
+ '#38383D': '#E4E4E7',
98
+ '#3A3A3C': '#E4E4E7',
99
+ '#3F3F46': '#D4D4D8',
100
+ '#F4F4F5': '#18181B',
101
+ // Status borders.
102
+ '#3B2222': '#FECACA',
103
+ '#552022': '#FECACA',
104
+ '#5F2424': '#FECACA',
105
+ '#3A2317': '#FED7AA',
106
+ '#4A2413': '#FED7AA'
107
+ };
108
+
109
+ // Dark foreground (text / icons) -> light foreground.
110
+ const TEXT_MAP = {
111
+ '#FFFFFF': '#18181B',
112
+ // Home title: near-white in dark mode, #0F0F0F in light (per design spec).
113
+ '#FAFAFA': '#0F0F0F',
114
+ // Dark-on-light-accent foregrounds invert with their CTA surfaces.
115
+ '#111111': '#FFFFFF',
116
+ '#F7F7F7': '#18181B',
117
+ '#F4F4F5': '#18181B',
118
+ '#E4E4E7': '#3F3F46',
119
+ '#DADADA': '#3F3F46',
120
+ '#D4D4D8': '#3F3F46',
121
+ '#C7C7CC': '#52525B',
122
+ '#BDBDC2': '#52525B',
123
+ '#A1A1AA': '#52525B',
124
+ '#8E8E93': '#71717A',
125
+ '#73737A': '#A1A1AA',
126
+ // Status / accent foregrounds tuned for light surfaces.
127
+ '#FCA5A5': '#DC2626',
128
+ '#FECACA': '#B91C1C',
129
+ '#FF6B6B': '#DC2626',
130
+ '#86EFAC': '#15803D',
131
+ '#34D399': '#059669',
132
+ '#FDE68A': '#A16207',
133
+ '#F8D77B': '#A16207',
134
+ '#FDE047': '#A16207',
135
+ '#FBBF24': '#B45309',
136
+ '#C9CAF8': '#4F46E5',
137
+ '#A5B4FC': '#4F46E5',
138
+ '#E0E7FF': '#3730A3',
139
+ '#93C5FD': '#1D4ED8',
140
+ '#8AB4F8': '#1D4ED8'
141
+ };
142
+
143
+ /** Light-mode color for a dark-authored foreground (text / icon) color. */
144
+ export function themedColor(darkColor) {
145
+ if (currentScheme === 'dark') {
146
+ return darkColor;
147
+ }
148
+ return TEXT_MAP[darkColor.toUpperCase()] ?? darkColor;
149
+ }
150
+
151
+ /** Light-mode color for a dark-authored surface (background) color. */
152
+ export function themedSurface(darkColor) {
153
+ if (currentScheme === 'dark') {
154
+ return darkColor;
155
+ }
156
+ return BG_MAP[darkColor.toUpperCase()] ?? darkColor;
157
+ }
158
+
159
+ /** Light-mode color for a dark-authored border color. */
160
+ export function themedBorder(darkColor) {
161
+ if (currentScheme === 'dark') {
162
+ return darkColor;
163
+ }
164
+ return BORDER_MAP[darkColor.toUpperCase()] ?? darkColor;
165
+ }
166
+
167
+ // Brand typography: Wix Madefor, with the original heavy weights stepped
168
+ // down to match the web app's lighter look. Native consumers must bundle the
169
+ // "Wix Madefor Text" font family; the web demo loads it from Google Fonts.
170
+ const SUPERAGENT_FONT_FAMILY = 'Wix Madefor Text';
171
+ const FONT_WEIGHT_MAP = {
172
+ '900': '600',
173
+ '800': '500',
174
+ '700': '500',
175
+ '600': '400',
176
+ bold: '600'
177
+ };
178
+ function applyTypography(style) {
179
+ const isText = 'fontSize' in style || 'fontWeight' in style || 'lineHeight' in style;
180
+ if (!isText) {
181
+ return style;
182
+ }
183
+ const next = {
184
+ ...style
185
+ };
186
+ if (!next.fontFamily) {
187
+ next.fontFamily = SUPERAGENT_FONT_FAMILY;
188
+ }
189
+ const weight = next.fontWeight;
190
+ if (typeof weight === 'string' && FONT_WEIGHT_MAP[weight]) {
191
+ next.fontWeight = FONT_WEIGHT_MAP[weight];
192
+ }
193
+ return next;
194
+ }
195
+ const BG_KEYS = new Set(['backgroundColor']);
196
+ const BORDER_KEYS = new Set(['borderColor', 'borderTopColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor']);
197
+ const TEXT_KEYS = new Set(['color', 'textDecorationColor', 'tintColor']);
198
+ // shadowColor stays dark in both schemes.
199
+
200
+ function toLightStyle(style) {
201
+ const light = {};
202
+ for (const [key, value] of Object.entries(style)) {
203
+ if (typeof value === 'string' && value.startsWith('#')) {
204
+ const upper = value.toUpperCase();
205
+ if (BG_KEYS.has(key)) {
206
+ light[key] = BG_MAP[upper] ?? value;
207
+ continue;
208
+ }
209
+ if (BORDER_KEYS.has(key)) {
210
+ light[key] = BORDER_MAP[upper] ?? value;
211
+ continue;
212
+ }
213
+ if (TEXT_KEYS.has(key)) {
214
+ light[key] = TEXT_MAP[upper] ?? value;
215
+ continue;
216
+ }
217
+ }
218
+ light[key] = value;
219
+ }
220
+ return light;
221
+ }
222
+
223
+ /**
224
+ * Drop-in replacement for StyleSheet.create: takes dark-authored styles and
225
+ * returns a proxy resolving each style against the active color scheme.
226
+ */
227
+ export function createThemedStyles(base) {
228
+ const typographyBase = Object.fromEntries(Object.entries(base).map(([name, style]) => [name, applyTypography(style)]));
229
+ const dark = StyleSheet.create(typographyBase);
230
+ const lightBase = Object.fromEntries(Object.entries(typographyBase).map(([name, style]) => [name, toLightStyle(style)]));
231
+ const light = StyleSheet.create(lightBase);
232
+ return new Proxy(dark, {
233
+ get(_, property) {
234
+ const sheets = currentScheme === 'dark' ? dark : light;
235
+ return sheets[property];
236
+ }
237
+ });
238
+ }
239
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContext","useContext","StyleSheet","currentScheme","getSuperagentColorScheme","syncSuperagentColorScheme","scheme","SuperagentThemeContext","setScheme","useSuperagentTheme","BG_MAP","BORDER_MAP","TEXT_MAP","themedColor","darkColor","toUpperCase","themedSurface","themedBorder","SUPERAGENT_FONT_FAMILY","FONT_WEIGHT_MAP","bold","applyTypography","style","isText","next","fontFamily","weight","fontWeight","BG_KEYS","Set","BORDER_KEYS","TEXT_KEYS","toLightStyle","light","key","value","Object","entries","startsWith","upper","has","createThemedStyles","base","typographyBase","fromEntries","map","name","dark","create","lightBase","Proxy","get","_","property","sheets"],"sourceRoot":"../../src","sources":["theme.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;AACjD,SAASC,UAAU,QAAQ,cAAc;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,IAAIC,aAAoC,GAAG,OAAO;AAElD,OAAO,SAASC,wBAAwBA,CAAA,EAA0B;EAChE,OAAOD,aAAa;AACtB;AAEA,OAAO,SAASE,yBAAyBA,CAACC,MAA6B,EAAE;EACvEH,aAAa,GAAGG,MAAM;AACxB;AAEA,OAAO,MAAMC,sBAAsB,gBAAGP,aAAa,CAGhD;EAAEM,MAAM,EAAE,OAAO;EAAEE,SAAS,EAAEA,CAAA,KAAM,CAAC;AAAE,CAAC,CAAC;AAE5C,OAAO,SAASC,kBAAkBA,CAAA,EAAG;EACnC,OAAOR,UAAU,CAACM,sBAAsB,CAAC;AAC3C;;AAEA;AACA,MAAMG,MAA8B,GAAG;EACrC,SAAS,EAAE,SAAS;EACpB,SAAS,EAAE,SAAS;EACpB,SAAS,EAAE,SAAS;EACpB,SAAS,EAAE,SAAS;EACpB,SAAS,EAAE,SAAS;EACpB,SAAS,EAAE,SAAS;EACpB,SAAS,EAAE,SAAS;EACpB,SAAS,EAAE,SAAS;EACpB,SAAS,EAAE,SAAS;EACpB,SAAS,EAAE,SAAS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AAO,CAACM,cAAc,CAAC,CAACE,GAAG,CAAC,CAAC,CAACC,IAAI,EAAExB,KAAK,CAAC,KAAK,CAACwB,IAAI,EAAEd,YAAY,CAACV,KAAgC,CAAC,CAAC,CAC9G,CAAC;EACD,MAAMW,KAAK,GAAG/B,UAAU,CAAC8C,MAAM,CAACC,SAAyB,CAAC;EAE1D,OAAO,IAAIC,KAAK,CAACH,IAAI,EAAE;IACrBI,GAAGA,CAACC,CAAC,EAAEC,QAAQ,EAAE;MACf,MAAMC,MAAM,GAAGnD,aAAa,KAAK,MAAM,GAAG4C,IAAI,GAAGd,KAAK;MACtD,OAAOqB,MAAM,CAACD,QAAQ,CAAY;IACpC;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
- import { AUTO_GREET_MESSAGE, MESSAGES_PAGE_SIZE } from "./constants.js";
5
- import { countAssistantResponses, createErrorMessage, createUserMessage, getMessageCursor, hasNewAssistantResponse, isQueuedResponse, isVisibleMessage, mergeMessage, normalizeMessages, pollConversation, refreshConversation, sendWithFallback } from "./conversationRuntime.js";
4
+ import { MESSAGES_PAGE_SIZE } from "./constants.js";
5
+ import { countAssistantResponses, createErrorMessage, createUserMessage, getMessageCursor, hasNewAssistantResponse, hasRunningToolCall, isQueuedResponse, isVisibleMessage, mergeConversationSnapshot, mergeMessage, normalizeMessages, pollConversation, pollQueuedSend, refreshConversation, sendWithFallback } from "./conversationRuntime.js";
6
6
  export function useSuperagentConversation({
7
7
  agentId,
8
8
  apiClient,
9
9
  realtimeClient,
10
+ currentUserId,
10
11
  fallbackMessages,
11
12
  fallbackSending,
12
13
  onAgentMessageDone,
@@ -21,6 +22,36 @@ export function useSuperagentConversation({
21
22
  const [initError, setInitError] = useState(null);
22
23
  const [hasMoreMessages, setHasMoreMessages] = useState(false);
23
24
  const sendGenerationRef = useRef(0);
25
+ const pollIntervalRef = useRef(null);
26
+ const loadingPreviousRef = useRef(false);
27
+ const settleTimeoutRef = useRef(null);
28
+ const messagesRef = useRef(messages);
29
+ const onAgentMessageDoneRef = useRef(onAgentMessageDone);
30
+ const onConversationSettledRef = useRef(onConversationSettled);
31
+ useEffect(() => {
32
+ messagesRef.current = messages;
33
+ }, [messages]);
34
+ useEffect(() => {
35
+ onAgentMessageDoneRef.current = onAgentMessageDone;
36
+ onConversationSettledRef.current = onConversationSettled;
37
+ }, [onAgentMessageDone, onConversationSettled]);
38
+
39
+ // Cancel any in-flight poll/settle timers — called on each new send and on unmount.
40
+ const clearPendingSettlers = useCallback(() => {
41
+ if (pollIntervalRef.current) {
42
+ clearInterval(pollIntervalRef.current);
43
+ pollIntervalRef.current = null;
44
+ }
45
+ if (settleTimeoutRef.current) {
46
+ clearTimeout(settleTimeoutRef.current);
47
+ settleTimeoutRef.current = null;
48
+ }
49
+ }, []);
50
+
51
+ // Clear any active poll interval / settle timeout when the hook unmounts.
52
+ useEffect(() => {
53
+ return () => clearPendingSettlers();
54
+ }, [clearPendingSettlers]);
24
55
  useEffect(() => {
25
56
  if (!apiClient) setMessages(fallbackMessages);
26
57
  }, [apiClient, fallbackMessages]);
@@ -28,6 +59,13 @@ export function useSuperagentConversation({
28
59
  if (!apiClient) return;
29
60
  const client = apiClient;
30
61
  let cancelled = false;
62
+
63
+ // Clear the previous agent/client's conversation up front so a stale id or
64
+ // thread can't linger while the new one loads — or, if the reload fails, be
65
+ // shown or receive sends (conversationUnavailable only blocks with no id).
66
+ setConversationId(null);
67
+ setMessages([]);
68
+ setHasMoreMessages(false);
31
69
  async function initConversation() {
32
70
  setIsLoading(true);
33
71
  setInitError(null);
@@ -46,7 +84,12 @@ export function useSuperagentConversation({
46
84
  setMessages(normalizeMessages(conversation.messages ?? []));
47
85
  setHasMoreMessages(Boolean(page.has_more ?? page.hasMore));
48
86
  if ((conversation.messages ?? []).length === 0) {
49
- await client.addMessage(conversation.id, createUserMessage(AUTO_GREET_MESSAGE));
87
+ // Seed the intro via bootstrap-intro (hidden seed, no sandbox acquisition)
88
+ // instead of sending a visible "Hey!" through the full /messages path —
89
+ // opening an empty chat shouldn't stall on a cold sandbox or burn a
90
+ // tool-capable turn. The assistant intro arrives via realtime / a later
91
+ // refresh, so we don't block on it here.
92
+ await client.bootstrapIntro(conversation.id);
50
93
  if (cancelled) return;
51
94
  await refreshConversation(client, conversation.id, setMessages);
52
95
  }
@@ -65,54 +108,121 @@ export function useSuperagentConversation({
65
108
  if (!realtimeClient || !conversationId) return undefined;
66
109
  return realtimeClient.subscribeToConversation(conversationId, {
67
110
  onMessage(message) {
111
+ // Don't clear the sending/stop state on intermediate assistant messages
112
+ // (tool-call steps or streamed content arrive before the turn is done).
113
+ // The turn ends on `agent_done` (onAgentDone) or the 5s settle fallback.
68
114
  setMessages(current => mergeMessage(current, message));
69
- if (message.role === 'assistant' && (message.content || message.toolCalls?.length || message.tool_calls?.length)) {
70
- setIsSending(false);
71
- }
72
115
  },
73
116
  onConversation(conversation) {
74
117
  if (conversation.id !== conversationId) return;
75
- setMessages(normalizeMessages(conversation.messages ?? []));
118
+ const incoming = normalizeMessages(conversation.messages ?? []);
119
+ setMessages(current => mergeConversationSnapshot(current, incoming));
76
120
  },
77
- onAgentDone() {
78
- setIsSending(false);
79
- onAgentMessageDone?.();
80
- if (apiClient) {
81
- refreshConversation(apiClient, conversationId, setMessages).then(() => onConversationSettled?.()).catch(() => {});
82
- } else {
83
- onConversationSettled?.();
121
+ onAgentDone(payload) {
122
+ // Shared conversations: the backend tags agent_done with the sender's
123
+ // platform user id. Ignore completions from OTHER collaborators so a
124
+ // teammate's finishing run doesn't clear THIS user's sending state or fire
125
+ // their completion callbacks early (matches the web client).
126
+ if (payload?.sender_platform_user_id && currentUserId && payload.sender_platform_user_id !== currentUserId) {
127
+ return;
84
128
  }
129
+ // Agent finished via realtime — cancel the 5s settle fallback so
130
+ // onConversationSettled doesn't also fire when the timer elapses.
131
+ if (settleTimeoutRef.current) {
132
+ clearTimeout(settleTimeoutRef.current);
133
+ settleTimeoutRef.current = null;
134
+ }
135
+ // Guard the busy-state clear against a newer send superseding this turn
136
+ // while we refresh/poll: only clear if no later send has started since
137
+ // (mirrors setSendingForCurrentSend in sendMessage).
138
+ const sendGeneration = sendGenerationRef.current;
139
+ const setSendingIfCurrent = value => {
140
+ if (sendGenerationRef.current === sendGeneration) setIsSending(value);
141
+ };
142
+ const settle = () => {
143
+ setSendingIfCurrent(false);
144
+ setQueuedMessages([]);
145
+ onAgentMessageDoneRef.current?.();
146
+ onConversationSettledRef.current?.();
147
+ };
148
+ if (!apiClient) {
149
+ settle();
150
+ return;
151
+ }
152
+ const handOffToPoll = assistantCountBefore => {
153
+ // Keep the busy state and let the bounded poll finish the turn (it
154
+ // retries refreshes and settles once no tool is running or the cap is
155
+ // hit), matching the no-realtime poll and 5s settle paths.
156
+ if (pollIntervalRef.current) clearInterval(pollIntervalRef.current);
157
+ pollIntervalRef.current = pollConversation(apiClient, conversationId, setMessages, setSendingIfCurrent, assistantCountBefore, () => {
158
+ setQueuedMessages([]);
159
+ onConversationSettledRef.current?.();
160
+ }, () => onAgentMessageDoneRef.current?.());
161
+ };
162
+ refreshConversation(apiClient, conversationId, setMessages).then(refreshed => {
163
+ // agent_done arrived while a tool is still running in the snapshot —
164
+ // don't settle yet, let the poll loop finish it.
165
+ if (hasRunningToolCall(refreshed)) {
166
+ handOffToPoll(countAssistantResponses(refreshed));
167
+ return;
168
+ }
169
+ settle();
170
+ }).catch(() => {
171
+ // The final refresh failed, so we can't tell whether a tool is still
172
+ // running — hand off to the bounded poll instead of clearing the busy
173
+ // state blind (it will settle on completion or the hard cap).
174
+ handOffToPoll(countAssistantResponses(messagesRef.current));
175
+ });
85
176
  },
86
177
  onReconnect() {
178
+ // A reconnect means the transient socket error cleared — drop the
179
+ // "something went wrong" state so it doesn't linger as a failed load.
180
+ setInitError(null);
87
181
  if (apiClient) refreshConversation(apiClient, conversationId, setMessages).catch(() => {});
88
182
  },
89
183
  onError(error) {
90
184
  setInitError(error instanceof Error ? error.message : 'Realtime connection failed');
91
185
  }
92
186
  });
93
- }, [apiClient, conversationId, onAgentMessageDone, onConversationSettled, realtimeClient]);
187
+ }, [apiClient, conversationId, currentUserId, realtimeClient]);
94
188
  const visibleMessages = useMemo(() => messages.filter((message, index) => isVisibleMessage(message, index)), [messages]);
189
+
190
+ // Resolves true when the send was accepted (queued/sent), false when it failed
191
+ // before reaching the conversation — so the composer can restore the draft.
95
192
  const sendMessage = useCallback(async (content, options = {}) => {
96
193
  const trimmedContent = content.trim();
97
194
  const fileUrls = options.fileUrls?.filter(Boolean) ?? [];
98
- if (!trimmedContent && fileUrls.length === 0) return;
99
- const assistantCountBefore = countAssistantResponses(messages);
195
+ if (!trimmedContent && fileUrls.length === 0) return false;
196
+
197
+ // A new send supersedes any pending poll/settle timers from the previous one.
198
+ clearPendingSettlers();
199
+ const assistantCountBefore = countAssistantResponses(messagesRef.current);
100
200
  const userMessage = createUserMessage(trimmedContent, {
101
201
  fileUrls,
102
202
  replyTo: options.replyTo
103
203
  });
104
204
  setMessages(current => [...current, userMessage]);
105
205
  if (!apiClient || !conversationId) {
106
- if (!onSendMessage) return;
206
+ if (!onSendMessage) {
207
+ // No send path yet (no fallback handler, or the conversation is still
208
+ // loading) — drop the optimistic bubble so the turn doesn't look sent.
209
+ setMessages(current => current.filter(message => message.id !== userMessage.id));
210
+ return false;
211
+ }
107
212
  const sendGeneration = sendGenerationRef.current + 1;
108
213
  sendGenerationRef.current = sendGeneration;
109
214
  const setSendingForCurrentSend = value => {
110
215
  if (sendGenerationRef.current === sendGeneration) setIsSending(value);
111
216
  };
112
217
  setIsSending(true);
113
- const hasAssistantResponse = await sendWithFallback(agentId, trimmedContent, fileUrls, options.replyTo, onSendMessage, setMessages, setSendingForCurrentSend);
114
- if (hasAssistantResponse) onAgentMessageDone?.();
115
- return;
218
+ const {
219
+ delivered,
220
+ hasAssistantResponse
221
+ } = await sendWithFallback(agentId, trimmedContent, fileUrls, options.replyTo, onSendMessage, setMessages, setSendingForCurrentSend, userMessage.id);
222
+ if (hasAssistantResponse) onAgentMessageDoneRef.current?.();
223
+ // Report actual delivery so the composer restores the draft on a rejected
224
+ // fallback send instead of silently dropping the user's text/attachments.
225
+ return delivered;
116
226
  }
117
227
  const sendGeneration = sendGenerationRef.current + 1;
118
228
  sendGenerationRef.current = sendGeneration;
@@ -121,6 +231,47 @@ export function useSuperagentConversation({
121
231
  };
122
232
  setIsSending(true);
123
233
  try {
234
+ // Wait for the turn to complete: poll without realtime, otherwise a 5s
235
+ // fallback in case agent_done never arrives.
236
+ const armSettleFallback = () => {
237
+ if (!realtimeClient) {
238
+ pollIntervalRef.current = pollConversation(apiClient, conversationId, setMessages, setSendingForCurrentSend, assistantCountBefore, () => {
239
+ setQueuedMessages([]);
240
+ onConversationSettledRef.current?.();
241
+ }, () => onAgentMessageDoneRef.current?.());
242
+ } else {
243
+ settleTimeoutRef.current = setTimeout(async () => {
244
+ settleTimeoutRef.current = null;
245
+ // agent_done is late — hand off to the bounded poll loop, which keeps
246
+ // "sending" until tools finish (or the hard cap), instead of clearing
247
+ // it mid-turn.
248
+ const handOffToPoll = () => {
249
+ if (pollIntervalRef.current) clearInterval(pollIntervalRef.current);
250
+ pollIntervalRef.current = pollConversation(apiClient, conversationId, setMessages, setSendingForCurrentSend, assistantCountBefore, () => {
251
+ setQueuedMessages([]);
252
+ onConversationSettledRef.current?.();
253
+ }, () => onAgentMessageDoneRef.current?.());
254
+ };
255
+ try {
256
+ const refreshed = await refreshConversation(apiClient, conversationId, setMessages);
257
+ if (hasRunningToolCall(refreshed)) {
258
+ handOffToPoll();
259
+ return;
260
+ }
261
+ } catch {
262
+ // Refresh failed — we can't tell whether a tool is still running, so
263
+ // hand off to the bounded poll rather than clearing the busy state
264
+ // blind (it retries and settles on completion or the hard cap).
265
+ handOffToPoll();
266
+ return;
267
+ }
268
+ setSendingForCurrentSend(false);
269
+ setQueuedMessages([]);
270
+ onAgentMessageDoneRef.current?.();
271
+ onConversationSettledRef.current?.();
272
+ }, 5000);
273
+ }
274
+ };
124
275
  const response = await apiClient.addMessage(conversationId, userMessage);
125
276
  if (isQueuedResponse(response)) {
126
277
  setQueuedMessages(current => [...current, {
@@ -128,29 +279,55 @@ export function useSuperagentConversation({
128
279
  content: userMessage.content,
129
280
  position: current.length
130
281
  }]);
282
+ // Another turn holds the conversation lock. Wait for OUR message to drain
283
+ // from the backend queue before settling — otherwise the running turn's
284
+ // completion would clear isSending / the queued strip early and let another
285
+ // send start while this one is still pending. pollQueuedSend re-baselines and
286
+ // hands off to the normal response poll once our turn actually starts.
287
+ if (pollIntervalRef.current) clearInterval(pollIntervalRef.current);
288
+ pollIntervalRef.current = pollQueuedSend(apiClient, conversationId, userMessage.id, setMessages, setSendingForCurrentSend, interval => {
289
+ pollIntervalRef.current = interval;
290
+ }, () => {
291
+ setQueuedMessages([]);
292
+ onConversationSettledRef.current?.();
293
+ }, () => onAgentMessageDoneRef.current?.());
131
294
  } else {
132
- const refreshedMessages = await refreshConversation(apiClient, conversationId, setMessages);
133
- if (!realtimeClient) {
134
- if (hasNewAssistantResponse(refreshedMessages, assistantCountBefore)) {
135
- setSendingForCurrentSend(false);
136
- onAgentMessageDone?.();
137
- onConversationSettled?.();
138
- } else {
139
- pollConversation(apiClient, conversationId, setMessages, setSendingForCurrentSend, assistantCountBefore, onConversationSettled, onAgentMessageDone);
140
- }
295
+ let refreshedMessages;
296
+ try {
297
+ refreshedMessages = await refreshConversation(apiClient, conversationId, setMessages);
298
+ } catch {
299
+ // addMessage already succeeded (a non-queued send returns only after the
300
+ // agent is invoked), so the turn IS delivered. A failed post-send refresh
301
+ // must NOT drop the optimistic row or report failure — that would make
302
+ // ConversationChat restore the draft and the user resend, duplicating the
303
+ // message. Hand off to the bounded poll/settle loop and report delivered.
304
+ armSettleFallback();
305
+ return true;
306
+ }
307
+ // Only complete immediately if a new assistant reply landed AND no tool is
308
+ // still running — otherwise hand off to armSettleFallback (pollConversation
309
+ // without realtime), which keeps "sending" until tools finish. Matches the
310
+ // poll/settle paths so tool-using turns don't drop the busy state early.
311
+ if (!realtimeClient && hasNewAssistantResponse(refreshedMessages, assistantCountBefore) && !hasRunningToolCall(refreshedMessages)) {
312
+ setSendingForCurrentSend(false);
313
+ setQueuedMessages([]);
314
+ onAgentMessageDoneRef.current?.();
315
+ onConversationSettledRef.current?.();
141
316
  } else {
142
- setTimeout(() => {
143
- setSendingForCurrentSend(false);
144
- onConversationSettled?.();
145
- }, 5000);
317
+ armSettleFallback();
146
318
  }
147
319
  }
320
+ return true;
148
321
  } catch (error) {
322
+ // The optimistic bubble never reached the server (addMessage threw), so drop
323
+ // it and surface the error in its place — otherwise the turn looks sent and a
324
+ // later refresh/resend could duplicate it. Mirrors the no-send-path above.
149
325
  const errorMessage = createErrorMessage(error);
150
- setMessages(current => [...current, errorMessage]);
326
+ setMessages(current => [...current.filter(message => message.id !== userMessage.id), errorMessage]);
151
327
  setSendingForCurrentSend(false);
328
+ return false;
152
329
  }
153
- }, [agentId, apiClient, conversationId, messages, onAgentMessageDone, onConversationSettled, onSendMessage, realtimeClient]);
330
+ }, [agentId, apiClient, clearPendingSettlers, conversationId, onSendMessage, realtimeClient]);
154
331
  const deleteMessage = useCallback(async messageId => {
155
332
  if (!messageId || messageId === 'welcome') return false;
156
333
  if (!apiClient || !conversationId) {
@@ -159,15 +336,22 @@ export function useSuperagentConversation({
159
336
  }
160
337
  try {
161
338
  await apiClient.deleteMessage(conversationId, messageId);
339
+ // Remove locally before refreshing: mergeConversationSnapshot keeps rows
340
+ // missing from the server snapshot, so without this the just-deleted
341
+ // message would be resurrected.
342
+ setMessages(current => current.filter(message => message.id !== messageId));
162
343
  await refreshConversation(apiClient, conversationId, setMessages);
163
344
  return true;
164
- } catch (error) {
165
- setInitError(error instanceof Error ? error.message : 'Failed to delete message');
345
+ } catch {
346
+ // A failed delete is not a load failure — don't drive the "something went
347
+ // wrong" panel (it would persist). Signal failure via the return value so
348
+ // the caller can surface it.
166
349
  return false;
167
350
  }
168
351
  }, [apiClient, conversationId]);
169
352
  const stop = useCallback(async () => {
170
353
  sendGenerationRef.current += 1;
354
+ clearPendingSettlers();
171
355
  if (!apiClient || !conversationId) {
172
356
  setIsSending(false);
173
357
  return;
@@ -176,21 +360,33 @@ export function useSuperagentConversation({
176
360
  setQueuedMessages([]);
177
361
  await apiClient.stopConversation(conversationId);
178
362
  await refreshConversation(apiClient, conversationId, setMessages);
179
- }, [apiClient, conversationId]);
363
+ }, [apiClient, clearPendingSettlers, conversationId]);
180
364
  const loadPrevious = useCallback(async () => {
365
+ if (loadingPreviousRef.current) return;
181
366
  const before = getMessageCursor(messages[0]);
182
367
  if (!apiClient || !conversationId || !before) return;
183
- const page = await apiClient.getMessages(conversationId, {
184
- limit: MESSAGES_PAGE_SIZE,
185
- before
186
- });
187
- setMessages(current => [...normalizeMessages(page.messages), ...current]);
188
- setHasMoreMessages(Boolean(page.has_more ?? page.hasMore));
368
+ loadingPreviousRef.current = true;
369
+ try {
370
+ const page = await apiClient.getMessages(conversationId, {
371
+ limit: MESSAGES_PAGE_SIZE,
372
+ before
373
+ });
374
+ setMessages(current => [...normalizeMessages(page.messages), ...current]);
375
+ setHasMoreMessages(Boolean(page.has_more ?? page.hasMore));
376
+ } catch {
377
+ // Pagination failed — swallow so it isn't an unhandled rejection from the
378
+ // button, and leave hasMoreMessages as-is so the user can retry.
379
+ } finally {
380
+ loadingPreviousRef.current = false;
381
+ }
189
382
  }, [apiClient, conversationId, messages]);
190
383
  const submitToolCallInput = useCallback(async (toolCallId, approve, extraUserInput, originRequestId) => {
191
384
  if (!apiClient || !conversationId) return null;
192
385
  const updated = await apiClient.submitToolCallInput(conversationId, toolCallId, approve, extraUserInput, originRequestId);
193
- if (updated.messages) setMessages(normalizeMessages(updated.messages));
386
+ if (updated.messages) {
387
+ const incoming = normalizeMessages(updated.messages);
388
+ setMessages(current => mergeConversationSnapshot(current, incoming));
389
+ }
194
390
  onConversationSettled?.();
195
391
  return updated;
196
392
  }, [apiClient, conversationId, onConversationSettled]);