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