@stack-spot/ai-chat-widget 1.38.2-beta.2 → 2.0.0-beta.1
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/CHANGELOG.md +33 -32
- package/dist/StackspotAIWidget.d.ts +14 -2
- package/dist/StackspotAIWidget.d.ts.map +1 -1
- package/dist/StackspotAIWidget.js +7 -8
- package/dist/StackspotAIWidget.js.map +1 -1
- package/dist/app-metadata.json +13 -5
- package/dist/chat-interceptors/quick-commands.js +3 -3
- package/dist/chat-interceptors/quick-commands.js.map +1 -1
- package/dist/components/AdaptiveTextArea.d.ts +1 -1
- package/dist/components/AdaptiveTextArea.d.ts.map +1 -1
- package/dist/components/AdaptiveTextArea.js +1 -1
- package/dist/components/AdaptiveTextArea.js.map +1 -1
- package/dist/components/AgentCard/AgentCardCreate.d.ts.map +1 -1
- package/dist/components/AgentCard/AgentCardCreate.js +4 -5
- package/dist/components/AgentCard/AgentCardCreate.js.map +1 -1
- package/dist/components/AgentCard/index.d.ts.map +1 -1
- package/dist/components/AgentCard/index.js +5 -6
- package/dist/components/AgentCard/index.js.map +1 -1
- package/dist/components/ButtonFavorite.d.ts +8 -7
- package/dist/components/ButtonFavorite.d.ts.map +1 -1
- package/dist/components/ButtonFavorite.js +5 -14
- package/dist/components/ButtonFavorite.js.map +1 -1
- package/dist/components/Code.d.ts.map +1 -1
- package/dist/components/Code.js +11 -9
- package/dist/components/Code.js.map +1 -1
- package/dist/components/ComponentNavigator.d.ts.map +1 -1
- package/dist/components/ComponentNavigator.js +2 -4
- package/dist/components/ComponentNavigator.js.map +1 -1
- package/dist/components/FadingOverflow.d.ts.map +1 -1
- package/dist/components/FadingOverflow.js +3 -4
- package/dist/components/FadingOverflow.js.map +1 -1
- package/dist/components/FileDescription.d.ts.map +1 -1
- package/dist/components/FileDescription.js +3 -4
- package/dist/components/FileDescription.js.map +1 -1
- package/dist/components/HistoryList.d.ts.map +1 -1
- package/dist/components/HistoryList.js +3 -1
- package/dist/components/HistoryList.js.map +1 -1
- package/dist/components/ListResource.js +3 -3
- package/dist/components/ListResource.js.map +1 -1
- package/dist/components/Markdown.js +1 -1
- package/dist/components/Markdown.js.map +1 -1
- package/dist/components/Modal.d.ts.map +1 -1
- package/dist/components/Modal.js +2 -4
- package/dist/components/Modal.js.map +1 -1
- package/dist/components/QuickStartButton.d.ts +2 -3
- package/dist/components/QuickStartButton.d.ts.map +1 -1
- package/dist/components/QuickStartButton.js +4 -3
- package/dist/components/QuickStartButton.js.map +1 -1
- package/dist/components/RightPanelForm.d.ts.map +1 -1
- package/dist/components/RightPanelForm.js +20 -13
- package/dist/components/RightPanelForm.js.map +1 -1
- package/dist/components/RightPanelTabs.d.ts +1 -4
- package/dist/components/RightPanelTabs.d.ts.map +1 -1
- package/dist/components/RightPanelTabs.js +4 -16
- package/dist/components/RightPanelTabs.js.map +1 -1
- package/dist/components/Selector/index.d.ts.map +1 -1
- package/dist/components/Selector/index.js +5 -8
- package/dist/components/Selector/index.js.map +1 -1
- package/dist/components/Selector/styled.d.ts.map +1 -1
- package/dist/components/Selector/styled.js +8 -5
- package/dist/components/Selector/styled.js.map +1 -1
- package/dist/components/StackedBadge.js +5 -5
- package/dist/components/StackedBadge.js.map +1 -1
- package/dist/components/TabManager.d.ts.map +1 -1
- package/dist/components/TabManager.js +9 -32
- package/dist/components/TabManager.js.map +1 -1
- package/dist/components/ToolBadge.d.ts +3 -8
- package/dist/components/ToolBadge.d.ts.map +1 -1
- package/dist/components/ToolBadge.js +23 -99
- package/dist/components/ToolBadge.js.map +1 -1
- package/dist/components/WorkspaceTabNavigator.d.ts.map +1 -1
- package/dist/components/WorkspaceTabNavigator.js +7 -9
- package/dist/components/WorkspaceTabNavigator.js.map +1 -1
- package/dist/components/form/DescribedCheckboxGroup.d.ts +24 -2
- package/dist/components/form/DescribedCheckboxGroup.d.ts.map +1 -1
- package/dist/components/form/DescribedCheckboxGroup.js +46 -29
- package/dist/components/form/DescribedCheckboxGroup.js.map +1 -1
- package/dist/components/form/DescribedRadioGroup.d.ts +24 -4
- package/dist/components/form/DescribedRadioGroup.d.ts.map +1 -1
- package/dist/components/form/DescribedRadioGroup.js +39 -18
- package/dist/components/form/DescribedRadioGroup.js.map +1 -1
- package/dist/context/hooks.d.ts +6 -1
- package/dist/context/hooks.d.ts.map +1 -1
- package/dist/context/hooks.js +4 -1
- package/dist/context/hooks.js.map +1 -1
- package/dist/hooks/midnight-update-view.d.ts +5 -0
- package/dist/hooks/midnight-update-view.d.ts.map +1 -0
- package/dist/hooks/midnight-update-view.js +30 -0
- package/dist/hooks/midnight-update-view.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/layout.css +0 -26
- package/dist/right-panel/DefaultPanel.d.ts.map +1 -1
- package/dist/right-panel/DefaultPanel.js +2 -4
- package/dist/right-panel/DefaultPanel.js.map +1 -1
- package/dist/state/ChatEntry.d.ts +3 -4
- package/dist/state/ChatEntry.d.ts.map +1 -1
- package/dist/state/ChatEntry.js.map +1 -1
- package/dist/state/constants.d.ts.map +1 -1
- package/dist/state/constants.js +1 -0
- package/dist/state/constants.js.map +1 -1
- package/dist/types.d.ts +8 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/tools.d.ts +9 -3
- package/dist/utils/tools.d.ts.map +1 -1
- package/dist/utils/tools.js +1 -6
- package/dist/utils/tools.js.map +1 -1
- package/dist/views/Agents/AgentDescription.d.ts.map +1 -1
- package/dist/views/Agents/AgentDescription.js +8 -13
- package/dist/views/Agents/AgentDescription.js.map +1 -1
- package/dist/views/Agents/AgentsPanel.d.ts.map +1 -1
- package/dist/views/Agents/AgentsPanel.js +7 -7
- package/dist/views/Agents/AgentsPanel.js.map +1 -1
- package/dist/views/Agents/AgentsTab.d.ts.map +1 -1
- package/dist/views/Agents/AgentsTab.js +30 -29
- package/dist/views/Agents/AgentsTab.js.map +1 -1
- package/dist/views/Agents/dictionary.d.ts +1 -1
- package/dist/views/Agents/useAgentFavorites.js +3 -3
- package/dist/views/Agents/useAgentFavorites.js.map +1 -1
- package/dist/views/Chat/AgentInfo.d.ts.map +1 -1
- package/dist/views/Chat/AgentInfo.js +3 -5
- package/dist/views/Chat/AgentInfo.js.map +1 -1
- package/dist/views/Chat/ChatMessage.d.ts +24 -2
- package/dist/views/Chat/ChatMessage.d.ts.map +1 -1
- package/dist/views/Chat/ChatMessage.js +36 -47
- package/dist/views/Chat/ChatMessage.js.map +1 -1
- package/dist/views/Chat/ChatMessages.d.ts +1 -1
- package/dist/views/Chat/ChatMessages.d.ts.map +1 -1
- package/dist/views/Chat/ChatMessages.js +2 -2
- package/dist/views/Chat/ChatMessages.js.map +1 -1
- package/dist/views/Chat/StepsList.d.ts.map +1 -1
- package/dist/views/Chat/StepsList.js +10 -10
- package/dist/views/Chat/StepsList.js.map +1 -1
- package/dist/views/Chat/index.d.ts +1 -1
- package/dist/views/Chat/index.d.ts.map +1 -1
- package/dist/views/Chat/index.js +2 -2
- package/dist/views/Chat/index.js.map +1 -1
- package/dist/views/Chat/styled.d.ts.map +1 -1
- package/dist/views/Chat/styled.js +11 -16
- package/dist/views/Chat/styled.js.map +1 -1
- package/dist/views/ChatHistory/HistoryItem.d.ts.map +1 -1
- package/dist/views/ChatHistory/HistoryItem.js +10 -48
- package/dist/views/ChatHistory/HistoryItem.js.map +1 -1
- package/dist/views/ChatHistory/index.js +1 -1
- package/dist/views/ChatHistory/index.js.map +1 -1
- package/dist/views/ChatHistory/styled.d.ts.map +1 -1
- package/dist/views/ChatHistory/styled.js +3 -5
- package/dist/views/ChatHistory/styled.js.map +1 -1
- package/dist/views/ChatHistory/utils.d.ts +7 -0
- package/dist/views/ChatHistory/utils.d.ts.map +1 -1
- package/dist/views/ChatHistory/utils.js +40 -1
- package/dist/views/ChatHistory/utils.js.map +1 -1
- package/dist/views/ChatTabSelection.d.ts +6 -1
- package/dist/views/ChatTabSelection.d.ts.map +1 -1
- package/dist/views/ChatTabSelection.js +13 -8
- package/dist/views/ChatTabSelection.js.map +1 -1
- package/dist/views/Editor.d.ts.map +1 -1
- package/dist/views/Editor.js +6 -12
- package/dist/views/Editor.js.map +1 -1
- package/dist/views/Home/BuiltInAgent.d.ts.map +1 -1
- package/dist/views/Home/BuiltInAgent.js +2 -3
- package/dist/views/Home/BuiltInAgent.js.map +1 -1
- package/dist/views/Home/CustomAgent.js +3 -3
- package/dist/views/Home/CustomAgent.js.map +1 -1
- package/dist/views/Home/index.js +2 -2
- package/dist/views/Home/index.js.map +1 -1
- package/dist/views/Home/styled.d.ts.map +1 -1
- package/dist/views/Home/styled.js +21 -22
- package/dist/views/Home/styled.js.map +1 -1
- package/dist/views/KSDocument.d.ts.map +1 -1
- package/dist/views/KSDocument.js +3 -4
- package/dist/views/KSDocument.js.map +1 -1
- package/dist/views/KnowledgeSources.d.ts.map +1 -1
- package/dist/views/KnowledgeSources.js +14 -36
- package/dist/views/KnowledgeSources.js.map +1 -1
- package/dist/views/MessageInput/AgentSelector.d.ts.map +1 -1
- package/dist/views/MessageInput/AgentSelector.js +7 -5
- package/dist/views/MessageInput/AgentSelector.js.map +1 -1
- package/dist/views/MessageInput/ButtonAgent.d.ts.map +1 -1
- package/dist/views/MessageInput/ButtonAgent.js +4 -5
- package/dist/views/MessageInput/ButtonAgent.js.map +1 -1
- package/dist/views/MessageInput/ButtonBar.d.ts.map +1 -1
- package/dist/views/MessageInput/ButtonBar.js +2 -4
- package/dist/views/MessageInput/ButtonBar.js.map +1 -1
- package/dist/views/MessageInput/ContextBar.d.ts.map +1 -1
- package/dist/views/MessageInput/ContextBar.js +3 -6
- package/dist/views/MessageInput/ContextBar.js.map +1 -1
- package/dist/views/MessageInput/QuickCommandSelector.js +2 -2
- package/dist/views/MessageInput/QuickCommandSelector.js.map +1 -1
- package/dist/views/MessageInput/SelectContent.d.ts.map +1 -1
- package/dist/views/MessageInput/SelectContent.js +30 -29
- package/dist/views/MessageInput/SelectContent.js.map +1 -1
- package/dist/views/MessageInput/UploadDragNDrop.d.ts.map +1 -1
- package/dist/views/MessageInput/UploadDragNDrop.js +2 -3
- package/dist/views/MessageInput/UploadDragNDrop.js.map +1 -1
- package/dist/views/MessageInput/dictionary.d.ts +1 -1
- package/dist/views/MessageInput/index.d.ts +2 -1
- package/dist/views/MessageInput/index.d.ts.map +1 -1
- package/dist/views/MessageInput/index.js +5 -6
- package/dist/views/MessageInput/index.js.map +1 -1
- package/dist/views/MessageInput/styled.d.ts +1 -3
- package/dist/views/MessageInput/styled.d.ts.map +1 -1
- package/dist/views/MessageInput/styled.js +11 -15
- package/dist/views/MessageInput/styled.js.map +1 -1
- package/dist/views/MinimizedHeader.d.ts.map +1 -1
- package/dist/views/MinimizedHeader.js +3 -4
- package/dist/views/MinimizedHeader.js.map +1 -1
- package/dist/views/Resources.d.ts.map +1 -1
- package/dist/views/Resources.js +11 -8
- package/dist/views/Resources.js.map +1 -1
- package/dist/views/Stacks.d.ts.map +1 -1
- package/dist/views/Stacks.js +23 -28
- package/dist/views/Stacks.js.map +1 -1
- package/dist/views/Steps/FlowChart/NodeStep.d.ts.map +1 -1
- package/dist/views/Steps/FlowChart/NodeStep.js +3 -3
- package/dist/views/Steps/FlowChart/NodeStep.js.map +1 -1
- package/dist/views/Steps/StepModal.d.ts.map +1 -1
- package/dist/views/Steps/StepModal.js +4 -6
- package/dist/views/Steps/StepModal.js.map +1 -1
- package/dist/views/Steps/dictionary.d.ts +1 -1
- package/dist/views/Steps/index.d.ts.map +1 -1
- package/dist/views/Steps/index.js +3 -4
- package/dist/views/Steps/index.js.map +1 -1
- package/dist/views/Steps/utils.d.ts +2 -1
- package/dist/views/Steps/utils.d.ts.map +1 -1
- package/dist/views/Steps/utils.js +8 -8
- package/dist/views/Steps/utils.js.map +1 -1
- package/dist/views/Tools.js +1 -1
- package/dist/views/Tools.js.map +1 -1
- package/dist/views/Workspaces/WorkspacesTab.d.ts.map +1 -1
- package/dist/views/Workspaces/WorkspacesTab.js +7 -10
- package/dist/views/Workspaces/WorkspacesTab.js.map +1 -1
- package/dist/views/Workspaces/index.js +4 -2
- package/dist/views/Workspaces/index.js.map +1 -1
- package/package.json +5 -3
- package/src/StackspotAIWidget.tsx +51 -37
- package/src/app-metadata.json +13 -5
- package/src/chat-interceptors/quick-commands.ts +3 -3
- package/src/components/AdaptiveTextArea.tsx +1 -1
- package/src/components/AgentCard/AgentCardCreate.tsx +4 -7
- package/src/components/AgentCard/index.tsx +7 -7
- package/src/components/ButtonFavorite.tsx +20 -47
- package/src/components/Code.tsx +31 -36
- package/src/components/ComponentNavigator.tsx +4 -8
- package/src/components/FadingOverflow.tsx +6 -7
- package/src/components/FileDescription.tsx +14 -10
- package/src/components/HistoryList.tsx +4 -1
- package/src/components/ListResource.tsx +5 -5
- package/src/components/Markdown.tsx +1 -1
- package/src/components/Modal.tsx +2 -4
- package/src/components/QuickStartButton.tsx +5 -4
- package/src/components/RightPanelForm.tsx +20 -13
- package/src/components/RightPanelTabs.tsx +4 -32
- package/src/components/Selector/index.tsx +17 -13
- package/src/components/Selector/styled.ts +8 -5
- package/src/components/StackedBadge.tsx +5 -5
- package/src/components/TabManager.tsx +31 -55
- package/src/components/ToolBadge.tsx +48 -129
- package/src/components/WorkspaceTabNavigator.tsx +22 -25
- package/src/components/form/DescribedCheckboxGroup.tsx +90 -65
- package/src/components/form/DescribedRadioGroup.tsx +78 -46
- package/src/context/hooks.ts +4 -1
- package/src/hooks/midnight-update-view.ts +36 -0
- package/src/index.ts +4 -2
- package/src/layout.css +0 -26
- package/src/right-panel/DefaultPanel.tsx +3 -7
- package/src/state/ChatEntry.ts +3 -4
- package/src/state/constants.ts +2 -1
- package/src/types.ts +9 -3
- package/src/utils/tools.ts +3 -12
- package/src/views/Agents/AgentDescription.tsx +20 -36
- package/src/views/Agents/AgentsPanel.tsx +11 -12
- package/src/views/Agents/AgentsTab.tsx +38 -57
- package/src/views/Agents/useAgentFavorites.ts +3 -3
- package/src/views/Chat/AgentInfo.tsx +7 -6
- package/src/views/Chat/ChatMessage.tsx +163 -145
- package/src/views/Chat/ChatMessages.tsx +2 -1
- package/src/views/Chat/StepsList.tsx +10 -11
- package/src/views/Chat/index.tsx +9 -2
- package/src/views/Chat/styled.ts +11 -16
- package/src/views/ChatHistory/HistoryItem.tsx +15 -54
- package/src/views/ChatHistory/index.tsx +1 -1
- package/src/views/ChatHistory/styled.ts +3 -5
- package/src/views/ChatHistory/utils.ts +43 -2
- package/src/views/ChatTabSelection.tsx +18 -10
- package/src/views/Editor.tsx +9 -14
- package/src/views/Home/BuiltInAgent.tsx +7 -8
- package/src/views/Home/CustomAgent.tsx +3 -3
- package/src/views/Home/index.tsx +2 -2
- package/src/views/Home/styled.ts +21 -22
- package/src/views/KSDocument.tsx +7 -8
- package/src/views/KnowledgeSources.tsx +24 -66
- package/src/views/MessageInput/AgentSelector.tsx +10 -8
- package/src/views/MessageInput/ButtonAgent.tsx +24 -12
- package/src/views/MessageInput/ButtonBar.tsx +25 -21
- package/src/views/MessageInput/ContextBar.tsx +16 -14
- package/src/views/MessageInput/QuickCommandSelector.tsx +2 -2
- package/src/views/MessageInput/SelectContent.tsx +39 -62
- package/src/views/MessageInput/UploadDragNDrop.tsx +2 -5
- package/src/views/MessageInput/index.tsx +8 -9
- package/src/views/MessageInput/styled.ts +12 -16
- package/src/views/MinimizedHeader.tsx +5 -7
- package/src/views/Resources.tsx +31 -30
- package/src/views/Stacks.tsx +31 -54
- package/src/views/Steps/FlowChart/NodeStep.tsx +6 -4
- package/src/views/Steps/StepModal.tsx +14 -18
- package/src/views/Steps/index.tsx +4 -5
- package/src/views/Steps/utils.tsx +9 -9
- package/src/views/Tools.tsx +0 -1
- package/src/views/Workspaces/WorkspacesTab.tsx +17 -21
- package/src/views/Workspaces/index.tsx +4 -2
- package/dist/components/Accordion.d.ts +0 -20
- package/dist/components/Accordion.d.ts.map +0 -1
- package/dist/components/Accordion.js +0 -51
- package/dist/components/Accordion.js.map +0 -1
- package/dist/components/FallbackBoundary/ErrorBoundary.d.ts +0 -33
- package/dist/components/FallbackBoundary/ErrorBoundary.d.ts.map +0 -1
- package/dist/components/FallbackBoundary/ErrorBoundary.js +0 -52
- package/dist/components/FallbackBoundary/ErrorBoundary.js.map +0 -1
- package/dist/components/FallbackBoundary/Loading.d.ts +0 -2
- package/dist/components/FallbackBoundary/Loading.d.ts.map +0 -1
- package/dist/components/FallbackBoundary/Loading.js +0 -12
- package/dist/components/FallbackBoundary/Loading.js.map +0 -1
- package/dist/components/FallbackBoundary/index.d.ts +0 -17
- package/dist/components/FallbackBoundary/index.d.ts.map +0 -1
- package/dist/components/FallbackBoundary/index.js +0 -9
- package/dist/components/FallbackBoundary/index.js.map +0 -1
- package/dist/components/IconInput.d.ts +0 -10
- package/dist/components/IconInput.d.ts.map +0 -1
- package/dist/components/IconInput.js +0 -61
- package/dist/components/IconInput.js.map +0 -1
- package/dist/components/OverlayMenu.d.ts +0 -21
- package/dist/components/OverlayMenu.d.ts.map +0 -1
- package/dist/components/OverlayMenu.js +0 -79
- package/dist/components/OverlayMenu.js.map +0 -1
- package/dist/components/ProgressBar.d.ts +0 -37
- package/dist/components/ProgressBar.d.ts.map +0 -1
- package/dist/components/ProgressBar.js +0 -131
- package/dist/components/ProgressBar.js.map +0 -1
- package/dist/components/Tooltip/Tooltip.d.ts +0 -37
- package/dist/components/Tooltip/Tooltip.d.ts.map +0 -1
- package/dist/components/Tooltip/Tooltip.js +0 -30
- package/dist/components/Tooltip/Tooltip.js.map +0 -1
- package/dist/components/Tooltip/TooltipAPI.d.ts +0 -29
- package/dist/components/Tooltip/TooltipAPI.d.ts.map +0 -1
- package/dist/components/Tooltip/TooltipAPI.js +0 -107
- package/dist/components/Tooltip/TooltipAPI.js.map +0 -1
- package/dist/components/Tooltip/context.d.ts +0 -5
- package/dist/components/Tooltip/context.d.ts.map +0 -1
- package/dist/components/Tooltip/context.js +0 -18
- package/dist/components/Tooltip/context.js.map +0 -1
- package/dist/components/Tooltip/index.d.ts +0 -3
- package/dist/components/Tooltip/index.d.ts.map +0 -1
- package/dist/components/Tooltip/index.js +0 -3
- package/dist/components/Tooltip/index.js.map +0 -1
- package/dist/components/Tooltip/style.d.ts +0 -4
- package/dist/components/Tooltip/style.d.ts.map +0 -1
- package/dist/components/Tooltip/style.js +0 -22
- package/dist/components/Tooltip/style.js.map +0 -1
- package/dist/components/Tooltip/types.d.ts +0 -27
- package/dist/components/Tooltip/types.d.ts.map +0 -1
- package/dist/components/Tooltip/types.js +0 -2
- package/dist/components/Tooltip/types.js.map +0 -1
- package/src/components/Accordion.tsx +0 -75
- package/src/components/FallbackBoundary/ErrorBoundary.tsx +0 -71
- package/src/components/FallbackBoundary/Loading.tsx +0 -14
- package/src/components/FallbackBoundary/index.tsx +0 -26
- package/src/components/IconInput.tsx +0 -73
- package/src/components/OverlayMenu.tsx +0 -133
- package/src/components/ProgressBar.tsx +0 -183
- package/src/components/Tooltip/Tooltip.tsx +0 -78
- package/src/components/Tooltip/TooltipAPI.ts +0 -101
- package/src/components/Tooltip/context.tsx +0 -24
- package/src/components/Tooltip/index.ts +0 -2
- package/src/components/Tooltip/style.tsx +0 -24
- package/src/components/Tooltip/types.ts +0 -28
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import { agentToolsClient } from '@stack-spot/portal-network'
|
|
3
3
|
|
|
4
4
|
export function useAgentFavorites() {
|
|
5
|
-
const useFavorites = () => agentToolsClient.agents.useQuery({ visibility: 'favorite' })
|
|
5
|
+
const useFavorites = () => agentToolsClient.agents.useQuery({ request: { visibility: 'favorite' } })
|
|
6
6
|
const [addFavorite, pendingAddFav] = agentToolsClient.addFavorite.useMutation()
|
|
7
7
|
const [removeFavorite, pendingRemoveFav] = agentToolsClient.removeFavorite.useMutation()
|
|
8
8
|
|
|
9
9
|
const removeFavoriteAgent = async (idOrSlug?: string) => {
|
|
10
10
|
try {
|
|
11
11
|
await removeFavorite({ agentId: idOrSlug || '' })
|
|
12
|
-
await agentToolsClient.agents.invalidate({ visibility: 'favorite' })
|
|
12
|
+
await agentToolsClient.agents.invalidate({ request: { visibility: 'favorite' } })
|
|
13
13
|
} catch (error) {
|
|
14
14
|
// eslint-disable-next-line no-console
|
|
15
15
|
console.error(error)
|
|
@@ -19,7 +19,7 @@ export function useAgentFavorites() {
|
|
|
19
19
|
const addFavoriteAgent = async (idOrSlug?: string) => {
|
|
20
20
|
try {
|
|
21
21
|
await addFavorite({ agentId: idOrSlug || '' })
|
|
22
|
-
await agentToolsClient.agents.invalidate({ visibility: 'favorite' })
|
|
22
|
+
await agentToolsClient.agents.invalidate({ request: { visibility: 'favorite' } })
|
|
23
23
|
} catch (error) {
|
|
24
24
|
// eslint-disable-next-line no-console
|
|
25
25
|
console.error(error)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Icon } from '@stack-spot/citric-icons'
|
|
2
|
+
import { ImageWithFallback, Text } from '@stack-spot/citric-react'
|
|
3
3
|
import { LabeledWithImage } from '../../state/types'
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
@@ -12,10 +12,11 @@ interface Props {
|
|
|
12
12
|
*/
|
|
13
13
|
export const AgentInfo = ({ agent, icon }: Props) => (
|
|
14
14
|
<>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
<ImageWithFallback
|
|
16
|
+
src={agent?.image ?? ''}
|
|
17
|
+
className="custom-agent-image"
|
|
18
|
+
fallback={<div className="default-image-wrapper">{icon ?? <Icon icon="Agent" className="agent-image" />}</div>}
|
|
19
|
+
/>
|
|
19
20
|
<Text appearance="body2">{agent?.label}</Text>
|
|
20
21
|
</>
|
|
21
22
|
)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Avatar, AvatarGroup, Badge, IconButton, Tooltip } from '@citric/ui'
|
|
1
|
+
import { Icon } from '@stack-spot/citric-icons'
|
|
2
|
+
import { Alert, Badge, Button, CheckboxGroup, Column, IconButton, ImageBox, ImageWithFallback, Input, RadioGroup, Row, Text, Tooltip } from '@stack-spot/citric-react'
|
|
4
3
|
import { agentToolsClient } from '@stack-spot/portal-network'
|
|
5
|
-
import { listToClass } from '@stack-spot/portal-theme'
|
|
4
|
+
import { listToClass, theme } from '@stack-spot/portal-theme'
|
|
6
5
|
import { Dictionary, useTranslate } from '@stack-spot/portal-translate'
|
|
7
6
|
import { groupBy } from 'lodash'
|
|
8
7
|
import { createElement, Dispatch, useCallback, useMemo, useRef, useState } from 'react'
|
|
@@ -11,6 +10,7 @@ import 'react-international-phone/style.css'
|
|
|
11
10
|
import { FileDescription } from '../../components/FileDescription'
|
|
12
11
|
import { Markdown } from '../../components/Markdown'
|
|
13
12
|
import { useChatEntry, useCurrentChat, useWidget } from '../../context/hooks'
|
|
13
|
+
import { useMidnightUpdateView } from '../../hooks/midnight-update-view'
|
|
14
14
|
import { ChatEntry, SerializableAction, TextChatEntry } from '../../state/ChatEntry'
|
|
15
15
|
import { useDateFormatter } from '../../utils/date'
|
|
16
16
|
import { toolById } from '../../utils/tools'
|
|
@@ -19,6 +19,21 @@ import { useChatScrollToBottomEffect } from './chat-scroll'
|
|
|
19
19
|
import { onCopyAll, onCopyCode, onLikeOrDislike } from './events'
|
|
20
20
|
import { StepsList } from './StepsList'
|
|
21
21
|
|
|
22
|
+
export interface CustomRenderResult {
|
|
23
|
+
/**
|
|
24
|
+
* The React Element to render.
|
|
25
|
+
*/
|
|
26
|
+
content: React.ReactElement,
|
|
27
|
+
/**
|
|
28
|
+
* If set to "prepend" or "append", instead of replacing the default rendering of the message, it will complement it, by rendering this
|
|
29
|
+
* custom content in addition to the default rendering.
|
|
30
|
+
*
|
|
31
|
+
* - prepend: place the custom content before the default rendering;
|
|
32
|
+
* - append: place the custom content after the default rendering.
|
|
33
|
+
*/
|
|
34
|
+
mode: 'prepend' | 'append' | 'replace',
|
|
35
|
+
}
|
|
36
|
+
|
|
22
37
|
export interface CustomMessage {
|
|
23
38
|
/**
|
|
24
39
|
* React component to render before each message in the chat. It receives the message as a prop.
|
|
@@ -28,6 +43,14 @@ export interface CustomMessage {
|
|
|
28
43
|
* React component to render after each message in the chat. It receives the message as a prop.
|
|
29
44
|
*/
|
|
30
45
|
afterMessage?: React.FC<{ message: ChatEntry }>,
|
|
46
|
+
/**
|
|
47
|
+
* A custom message renderer. The custom message can replace or complement the original message.
|
|
48
|
+
*
|
|
49
|
+
* @param message the message to render.
|
|
50
|
+
* @returns a CustomRenderResult or undefined. If undefined, no custom message is added to the view and the default message renderer is
|
|
51
|
+
* used.
|
|
52
|
+
*/
|
|
53
|
+
customRenderer?: (message: TextChatEntry) => CustomRenderResult | undefined,
|
|
31
54
|
}
|
|
32
55
|
|
|
33
56
|
interface Props extends CustomMessage {
|
|
@@ -57,49 +80,47 @@ interface RenderInputsEntryProps {
|
|
|
57
80
|
|
|
58
81
|
const RenderInputsEntry = ({ isLast, entry, value, setValue, labels, setLabels }: RenderInputsEntryProps) => {
|
|
59
82
|
const chat = useCurrentChat()
|
|
83
|
+
const [radioValue, setRadioValue] = useState<Required<TextChatEntry>['options'][number] | undefined>()
|
|
84
|
+
const [checkboxValue, setCheckboxValue] = useState<Required<TextChatEntry>['options']>([])
|
|
60
85
|
|
|
61
86
|
const renderInputs = () => {
|
|
62
87
|
if (entry.type === 'input-text') {
|
|
63
|
-
return <Input
|
|
88
|
+
return <Input
|
|
89
|
+
name={entry.name}
|
|
64
90
|
value={value[0] ?? ''}
|
|
65
|
-
|
|
91
|
+
style={{ maxWidth: '500px' }}
|
|
66
92
|
autoFocus
|
|
67
|
-
{...entry.validations}
|
|
93
|
+
{...entry.validations}
|
|
94
|
+
onChange={v => setValue([v])}
|
|
95
|
+
required={entry.required}
|
|
96
|
+
/>
|
|
68
97
|
}
|
|
69
98
|
|
|
70
99
|
if (entry.type === 'input-radio') {
|
|
71
|
-
return <
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
required={true} sx={{ height: '30px' }} />
|
|
89
|
-
</Box>
|
|
90
|
-
}
|
|
91
|
-
</Flex>
|
|
92
|
-
</Box>
|
|
93
|
-
))}
|
|
94
|
-
</Flex>
|
|
100
|
+
return <RadioGroup
|
|
101
|
+
value={radioValue}
|
|
102
|
+
onChange={(v) => {
|
|
103
|
+
setRadioValue(v)
|
|
104
|
+
setValue([v.label])
|
|
105
|
+
v.value && setLabels([v.value])
|
|
106
|
+
}}
|
|
107
|
+
options={entry.options ?? []}
|
|
108
|
+
renderKey={o => `${o.value}_${o.label}`}
|
|
109
|
+
renderLabel={o => (
|
|
110
|
+
<Row gap={3} w="50%">
|
|
111
|
+
<Text>{o.label}</Text>
|
|
112
|
+
{o.hasInput && o.value && labels.findIndex((label) => label === o.value) !== -1 &&
|
|
113
|
+
<Input name={entry.name} onChange={v => setValue([v])} required style={{ height: '30px', width: '33%' }} />}
|
|
114
|
+
</Row>
|
|
115
|
+
)}
|
|
116
|
+
/>
|
|
95
117
|
}
|
|
96
118
|
|
|
97
119
|
if (entry.type === 'button-list') {
|
|
98
|
-
return <
|
|
120
|
+
return <Row className="button-group" gap="8px">
|
|
99
121
|
{entry.options?.map((item) => <Button
|
|
100
122
|
key={item.label}
|
|
101
123
|
colorScheme={item.color}
|
|
102
|
-
style={{ margin: 0 }}
|
|
103
124
|
onClick={() => {
|
|
104
125
|
item.value && chat.pushMessage(
|
|
105
126
|
ChatEntry.createUserEntry(item.value, false, entry.name, item?.label ? [item?.label] : undefined),
|
|
@@ -107,46 +128,46 @@ const RenderInputsEntry = ({ isLast, entry, value, setValue, labels, setLabels }
|
|
|
107
128
|
}}
|
|
108
129
|
>
|
|
109
130
|
{item.label}
|
|
110
|
-
</Button>)
|
|
111
|
-
|
|
131
|
+
</Button>)}
|
|
132
|
+
</Row>
|
|
112
133
|
}
|
|
113
134
|
|
|
114
135
|
if (entry.type === 'input-checkbox') {
|
|
115
|
-
return <
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
136
|
+
return <CheckboxGroup
|
|
137
|
+
value={checkboxValue}
|
|
138
|
+
onChange={(v) => {
|
|
139
|
+
setCheckboxValue(v)
|
|
140
|
+
setValue(v.map(i => i.label))
|
|
141
|
+
setLabels(v.map(i => i.value).filter(i => !!i) as string[])
|
|
142
|
+
}}
|
|
143
|
+
options={entry.options ?? []}
|
|
144
|
+
renderKey={o => `${o.value}_${o.label}`}
|
|
145
|
+
renderLabel={o => (
|
|
146
|
+
<Row gap={3}>
|
|
147
|
+
<Text>{o.label}</Text>
|
|
148
|
+
{o.hasInput && o.value && labels.findIndex((label) => label === o.value)!== -1 &&
|
|
149
|
+
<div style={{ width: '33%' }}>
|
|
150
|
+
<Input
|
|
151
|
+
name={entry.name}
|
|
152
|
+
{...entry.validations}
|
|
153
|
+
onChange={(v) => {
|
|
154
|
+
const customIndex = value.findIndex(v => !entry.options?.map(o => o.label).includes(v))
|
|
155
|
+
if (customIndex === -1) {
|
|
156
|
+
setValue([...value, v])
|
|
157
|
+
} else {
|
|
158
|
+
const newValue = [...value]
|
|
159
|
+
newValue[customIndex] = v
|
|
160
|
+
setValue(newValue)
|
|
161
|
+
}
|
|
162
|
+
}}
|
|
163
|
+
required={true}
|
|
164
|
+
style={{ height: '30px' }}
|
|
165
|
+
/>
|
|
166
|
+
</div>
|
|
124
167
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
<Box w={4} ml={2}>
|
|
129
|
-
<Input
|
|
130
|
-
name={entry.name}
|
|
131
|
-
{...entry.validations}
|
|
132
|
-
onChange={(data) => {
|
|
133
|
-
const customIndex = value.findIndex(v => !entry.options?.map(o => o.label).includes(v))
|
|
134
|
-
if (customIndex === -1) {
|
|
135
|
-
setValue([...value, data.target.value])
|
|
136
|
-
} else {
|
|
137
|
-
const newValue = [...value]
|
|
138
|
-
newValue[customIndex] = data.target.value
|
|
139
|
-
setValue(newValue)
|
|
140
|
-
}
|
|
141
|
-
}}
|
|
142
|
-
required={true}
|
|
143
|
-
sx={{ height: '30px' }}
|
|
144
|
-
/>
|
|
145
|
-
</Box>
|
|
146
|
-
}
|
|
147
|
-
</Flex>
|
|
148
|
-
))}
|
|
149
|
-
</Flex>
|
|
168
|
+
</Row>
|
|
169
|
+
)}
|
|
170
|
+
/>
|
|
150
171
|
}
|
|
151
172
|
|
|
152
173
|
if (entry.type === 'input-phone') {
|
|
@@ -161,24 +182,24 @@ const RenderInputsEntry = ({ isLast, entry, value, setValue, labels, setLabels }
|
|
|
161
182
|
return <p className="plain-text">{entry.content}</p>
|
|
162
183
|
}
|
|
163
184
|
|
|
164
|
-
return <
|
|
165
|
-
<Text appearance="body2"
|
|
185
|
+
return <Column gap={4}>
|
|
186
|
+
<Text appearance="body2">{entry.content}</Text>
|
|
166
187
|
{isLast && renderInputs()}
|
|
167
|
-
</
|
|
188
|
+
</Column>
|
|
168
189
|
}
|
|
169
190
|
|
|
170
191
|
const UserInfo = ({ entry }: { entry: TextChatEntry }) => {
|
|
171
192
|
switch (entry.agentType) {
|
|
172
193
|
case 'user': return
|
|
173
194
|
case 'bot': return <AgentInfo agent={entry.agent} />
|
|
174
|
-
case 'system': return <AgentInfo agent={{ id: 'system', label: 'System' }} icon={<Cog />} />
|
|
195
|
+
case 'system': return <AgentInfo agent={{ id: 'system', label: 'System' }} icon={<Icon icon="Cog" />} />
|
|
175
196
|
}
|
|
176
197
|
}
|
|
177
198
|
|
|
178
199
|
/**
|
|
179
200
|
* Renders a message (ChatEntry) in the chat.
|
|
180
201
|
*/
|
|
181
|
-
export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage }: Props) => {
|
|
202
|
+
export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage, customRenderer }: Props) => {
|
|
182
203
|
const t = useTranslate(dictionary)
|
|
183
204
|
const [liked, setLiked] = useState<boolean | undefined>()
|
|
184
205
|
const [value, setValue] = useState<string[]>(message.getValue()?.initialValue ?? [])
|
|
@@ -199,6 +220,7 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage }: Pr
|
|
|
199
220
|
const [showUserButtonCopy, setShowUserButtonCopy] = useState(false)
|
|
200
221
|
|
|
201
222
|
useChatScrollToBottomEffect(ref, [entry])
|
|
223
|
+
useMidnightUpdateView()
|
|
202
224
|
|
|
203
225
|
const detailKS = useCallback(({ name, slug, documentScore, documentId }: Required<TextChatEntry>['knowledgeSources'][number]) => {
|
|
204
226
|
widget.set('currentKSInPanel', { name, slug, score: documentScore, documentId })
|
|
@@ -285,16 +307,24 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage }: Pr
|
|
|
285
307
|
}
|
|
286
308
|
|
|
287
309
|
const renderContent = () => {
|
|
310
|
+
const custom = customRenderer?.(entry)
|
|
311
|
+
if (custom?.mode === 'replace') return custom.content
|
|
312
|
+
|
|
288
313
|
if (entry.type === 'md') {
|
|
289
314
|
return <>
|
|
290
315
|
{renderUploads()}
|
|
316
|
+
{custom?.mode === 'prepend' && custom.content}
|
|
291
317
|
<Markdown onCopyCode={(code) => onCopyCode(code, entry.messageId ?? '', chat)}>{entry.content}</Markdown>
|
|
318
|
+
{custom?.mode === 'append' && custom.content}
|
|
292
319
|
{renderActions()}
|
|
293
320
|
</>
|
|
294
321
|
}
|
|
322
|
+
|
|
295
323
|
if (entry.type === 'text') {
|
|
296
324
|
return <>
|
|
325
|
+
{custom?.mode === 'prepend' && custom.content}
|
|
297
326
|
<p className="plain-text">{entry.content}</p>
|
|
327
|
+
{custom?.mode === 'append' && custom.content}
|
|
298
328
|
{renderUploads()}
|
|
299
329
|
{renderActions()}
|
|
300
330
|
</>
|
|
@@ -302,24 +332,17 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage }: Pr
|
|
|
302
332
|
|
|
303
333
|
return <form>
|
|
304
334
|
<RenderInputsEntry entry={entry} isLast={isLast} value={value} setValue={setValue} setLabels={setLabels} labels={labels} />
|
|
305
|
-
<
|
|
335
|
+
<div style={{ marginTop: theme.spacing[4] }}>
|
|
306
336
|
{renderActions()}
|
|
307
|
-
</
|
|
337
|
+
</div>
|
|
308
338
|
</form>
|
|
309
339
|
}
|
|
310
340
|
|
|
311
|
-
// function openToolsPanel() {
|
|
312
|
-
// widget.set('currentMessageInPanel', { chatId: chat.id, messageId: message.id })
|
|
313
|
-
// widget.set('panel', 'tools')
|
|
314
|
-
// }
|
|
315
|
-
|
|
316
341
|
function openResourcesPanel() {
|
|
317
342
|
widget.set('currentMessageInPanel', { chatId: chat.id, messageId: message.id })
|
|
318
343
|
widget.set('panel', 'resources')
|
|
319
344
|
}
|
|
320
345
|
|
|
321
|
-
|
|
322
|
-
|
|
323
346
|
return (entry.content || entry.error || !!entry.steps?.length || entry.upload?.length) && (
|
|
324
347
|
<li key={entry.messageId} className={entry.agentType} ref={ref}>
|
|
325
348
|
<div className="chat-message-container"
|
|
@@ -331,7 +354,7 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage }: Pr
|
|
|
331
354
|
{(entry.content || entry.steps || entry.upload?.length) && (
|
|
332
355
|
<div className={listToClass(['message-content', entry.card && 'card', entry.type])}>
|
|
333
356
|
{!!entry.badges?.length && <div className="badges">
|
|
334
|
-
{entry.badges.map((b, index) => <Badge key={index}
|
|
357
|
+
{entry.badges.map((b, index) => <Badge key={index} colorPalette={b.color ?? 'cyan'} appearance="square">{b.label}</Badge>)}
|
|
335
358
|
</div>}
|
|
336
359
|
{renderContent()}
|
|
337
360
|
|
|
@@ -339,12 +362,7 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage }: Pr
|
|
|
339
362
|
</div>
|
|
340
363
|
)}
|
|
341
364
|
|
|
342
|
-
{entry.error &&
|
|
343
|
-
<div className="error">
|
|
344
|
-
<IconBox size="xs"><TimesCircle /></IconBox>
|
|
345
|
-
<Text appearance="microtext1">{entry.error}</Text>
|
|
346
|
-
</div>
|
|
347
|
-
)}
|
|
365
|
+
{entry.error && <Alert type="error">{entry.error}</Alert>}
|
|
348
366
|
</div>
|
|
349
367
|
{afterMessage && createElement(afterMessage, { message })}
|
|
350
368
|
{/* {!!entry.tools?.length && <StackedBadge
|
|
@@ -356,13 +374,14 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage }: Pr
|
|
|
356
374
|
label={t.tools}
|
|
357
375
|
images={entry.tools.slice(0, 3).map((id) => {
|
|
358
376
|
const tool = toolById(id, toolKits)
|
|
359
|
-
return { key: id, name: tool?.name || id, icon: <Cog />, url: tool?.image }
|
|
377
|
+
return { key: id, name: tool?.name || id, icon: <Icon icon="Cog" />, url: tool?.image }
|
|
360
378
|
})}
|
|
361
379
|
onClick={openToolsPanel}
|
|
380
|
+
style={{ marginTop: '12px', width: 'fit-content' }}
|
|
362
381
|
/>} */}
|
|
363
382
|
|
|
364
383
|
{!!entry.knowledgeSources?.length && <div className="ks-box">
|
|
365
|
-
<Text appearance="microtext1"
|
|
384
|
+
<Text appearance="microtext1" color="light.700">Knowledge Sources:</Text>
|
|
366
385
|
<ul>{entry.knowledgeSources.map((ks, index) => (
|
|
367
386
|
<li key={index}>
|
|
368
387
|
<Button size="sm" colorScheme="light" onClick={() => detailKS(ks)}>{ks.name}</Button>
|
|
@@ -371,62 +390,66 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage }: Pr
|
|
|
371
390
|
</div>}
|
|
372
391
|
|
|
373
392
|
{(!!agentsTools?.length || !!entry.tools?.length) && <div className="tools-box">
|
|
374
|
-
<
|
|
393
|
+
<Button appearance="none" onClick={openResourcesPanel} aria-label={t.openResourcesPanel}>
|
|
375
394
|
{agentsTools?.map((agent) => (
|
|
376
|
-
<
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
395
|
+
<ImageBox key={agent.id} className="agent-info-avatar-resource">
|
|
396
|
+
<ImageWithFallback
|
|
397
|
+
src={agent.avatar ?? undefined}
|
|
398
|
+
fallback={<Icon icon="Agent" />}
|
|
399
|
+
alt={agent.name}
|
|
400
|
+
aria-label={agent.name}
|
|
401
|
+
title={agent.name}
|
|
402
|
+
/>
|
|
403
|
+
</ImageBox>
|
|
381
404
|
))}
|
|
382
405
|
{entry.tools?.map((id) => {
|
|
383
406
|
const tool = toolById(id, toolKits)
|
|
384
407
|
return (
|
|
385
|
-
<
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
408
|
+
<ImageBox key={id} className="agent-info-avatar-resource">
|
|
409
|
+
<ImageWithFallback
|
|
410
|
+
src={tool?.image}
|
|
411
|
+
fallback={<Icon icon="Cog" />}
|
|
412
|
+
alt={tool?.name}
|
|
413
|
+
aria-label={tool?.name}
|
|
414
|
+
title={tool?.name}
|
|
415
|
+
/>
|
|
416
|
+
</ImageBox>
|
|
390
417
|
)})}
|
|
391
|
-
|
|
392
|
-
</AvatarGroup>
|
|
418
|
+
</Button>
|
|
393
419
|
</div>}
|
|
394
420
|
|
|
395
421
|
{shouldShowFooter && <div className="message-footer">
|
|
396
422
|
{entry.agentType === 'bot' && !entry.error && <div className="message-actions">
|
|
397
423
|
{entry.type === 'md' && (
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
<Check />
|
|
408
|
-
</IconButton>
|
|
409
|
-
</Tooltip>
|
|
410
|
-
) : (
|
|
411
|
-
<IconButton
|
|
412
|
-
appearance="square"
|
|
413
|
-
color="light"
|
|
414
|
-
title={t.copy}
|
|
415
|
-
aria-label={t.copy}
|
|
416
|
-
onClick={handleCopy}
|
|
417
|
-
>
|
|
418
|
-
<Copy />
|
|
419
|
-
</IconButton>
|
|
420
|
-
)
|
|
424
|
+
<IconButton
|
|
425
|
+
icon="Copy"
|
|
426
|
+
className="copy-btn"
|
|
427
|
+
appearance="square"
|
|
428
|
+
title={t.copy}
|
|
429
|
+
aria-label={t.copy}
|
|
430
|
+
feedback={t.copied}
|
|
431
|
+
onClick={handleCopy}
|
|
432
|
+
/>
|
|
421
433
|
)}
|
|
422
434
|
{entry.messageId && (
|
|
423
435
|
<>
|
|
424
|
-
<IconButton
|
|
425
|
-
{liked === true ?
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
{
|
|
429
|
-
|
|
436
|
+
<IconButton
|
|
437
|
+
group={liked === true ? 'fill' : 'outline'}
|
|
438
|
+
icon="Like"
|
|
439
|
+
appearance="square"
|
|
440
|
+
title={t.like}
|
|
441
|
+
aria-label={t.like}
|
|
442
|
+
onClick={like}
|
|
443
|
+
/>
|
|
444
|
+
<IconButton
|
|
445
|
+
group={liked === false ? 'fill' : 'outline'}
|
|
446
|
+
icon="Dislike"
|
|
447
|
+
appearance="square"
|
|
448
|
+
color="light"
|
|
449
|
+
title={t.dislike}
|
|
450
|
+
aria-label={t.dislike}
|
|
451
|
+
onClick={dislike}
|
|
452
|
+
/>
|
|
430
453
|
</>
|
|
431
454
|
)}
|
|
432
455
|
</div>}
|
|
@@ -434,37 +457,33 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage }: Pr
|
|
|
434
457
|
{entry.agentType === 'user' && (
|
|
435
458
|
<div className="message-actions">
|
|
436
459
|
{copied ? (
|
|
437
|
-
<Tooltip
|
|
460
|
+
<Tooltip content={t.copied} position={'left'}>
|
|
438
461
|
<IconButton
|
|
462
|
+
icon="Check"
|
|
439
463
|
appearance="square"
|
|
440
|
-
colorBg="light"
|
|
441
464
|
title={t.copied}
|
|
442
465
|
aria-label={t.copied}
|
|
443
466
|
size="sm"
|
|
444
|
-
|
|
445
|
-
<Check />
|
|
446
|
-
</IconButton>
|
|
467
|
+
/>
|
|
447
468
|
</Tooltip>
|
|
448
469
|
) : (
|
|
449
470
|
showUserButtonCopy && (
|
|
450
471
|
<div className="action-bar">
|
|
451
472
|
<IconButton
|
|
473
|
+
icon="Copy"
|
|
452
474
|
appearance="square"
|
|
453
|
-
color="light"
|
|
454
475
|
title={t.copy}
|
|
455
476
|
aria-label={t.copy}
|
|
456
477
|
onClick={handleCopy}
|
|
457
478
|
size="sm"
|
|
458
|
-
|
|
459
|
-
<Copy className="copy-btn"/>
|
|
460
|
-
</IconButton>
|
|
479
|
+
/>
|
|
461
480
|
</div>
|
|
462
481
|
)
|
|
463
482
|
)}
|
|
464
483
|
</div>
|
|
465
484
|
)}
|
|
466
485
|
|
|
467
|
-
<Text
|
|
486
|
+
<Text appearance="microtext1" className="chat-date">
|
|
468
487
|
{dateFormatter.formatForChatMessage(date)}
|
|
469
488
|
</Text>
|
|
470
489
|
</div>}
|
|
@@ -481,7 +500,6 @@ const dictionary = {
|
|
|
481
500
|
tools: 'Tools',
|
|
482
501
|
openToolsPanel: 'Open the tools panel to see more details.',
|
|
483
502
|
openResourcesPanel: 'Open the resources panel to see more details.',
|
|
484
|
-
|
|
485
503
|
copied: 'Copied',
|
|
486
504
|
},
|
|
487
505
|
pt: {
|
|
@@ -11,7 +11,7 @@ interface Props extends CustomMessage {
|
|
|
11
11
|
/**
|
|
12
12
|
* Renders all messages of a chat.
|
|
13
13
|
*/
|
|
14
|
-
export const ChatMessages = ({ chatId, username, beforeMessage, afterMessage }: Props) => {
|
|
14
|
+
export const ChatMessages = ({ chatId, username, beforeMessage, afterMessage, customRenderer }: Props) => {
|
|
15
15
|
const messages = useChatMessages(chatId)
|
|
16
16
|
const items = useMemo(
|
|
17
17
|
() => messages.map((m, index) => <ChatMessage
|
|
@@ -21,6 +21,7 @@ export const ChatMessages = ({ chatId, username, beforeMessage, afterMessage }:
|
|
|
21
21
|
isLast={index === messages.length - 1}
|
|
22
22
|
beforeMessage={beforeMessage}
|
|
23
23
|
afterMessage={afterMessage}
|
|
24
|
+
customRenderer={customRenderer}
|
|
24
25
|
/>),
|
|
25
26
|
[messages],
|
|
26
27
|
)
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { LoadingCircular } from '@citric/ui'
|
|
1
|
+
import { Icon } from '@stack-spot/citric-icons'
|
|
2
|
+
import { Button, ProgressCircular, Text } from '@stack-spot/citric-react'
|
|
4
3
|
import { AnimatedHeight } from '@stack-spot/portal-components/AnimatedHeight'
|
|
5
4
|
import { ChatStep, StepChatStep } from '@stack-spot/portal-network'
|
|
5
|
+
import { theme } from '@stack-spot/portal-theme'
|
|
6
6
|
import { Dictionary, useTranslate } from '@stack-spot/portal-translate'
|
|
7
7
|
import { findLastIndex } from 'lodash'
|
|
8
8
|
import { useState } from 'react'
|
|
9
9
|
import { useWidget } from '../../context/hooks'
|
|
10
|
-
import { PropsOf } from '../../types'
|
|
11
10
|
|
|
12
11
|
interface Props {
|
|
13
12
|
steps: ChatStep[],
|
|
@@ -23,12 +22,12 @@ interface StepProps {
|
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
function getStatusIcon(status: ChatStep['status']) {
|
|
26
|
-
const
|
|
25
|
+
const iconProps = { style: { color: theme.color.light[700] }, size: 'xs' } as const
|
|
27
26
|
switch (status) {
|
|
28
|
-
case 'error': return <
|
|
29
|
-
case 'success': return <
|
|
30
|
-
case 'pending': return <
|
|
31
|
-
case 'running': return <
|
|
27
|
+
case 'error': return <Icon group="fill" icon="TimesCircle" {...iconProps} />
|
|
28
|
+
case 'success': return <Icon group="fill" icon="CheckCircle" {...iconProps} />
|
|
29
|
+
case 'pending': return <Icon icon="Spaces" {...iconProps} />
|
|
30
|
+
case 'running': return <ProgressCircular className="loading" colorScheme="inverse" size="xs" />
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
33
|
|
|
@@ -37,7 +36,7 @@ const Step = ({ step, index, total, onClick }: StepProps) => {
|
|
|
37
36
|
return (
|
|
38
37
|
<li tabIndex={onClick ? 0 : undefined} onClick={onClick} role={onClick ? 'button' : 'listitem'}>
|
|
39
38
|
<div className="step-status-icon">{getStatusIcon(step.status)}</div>
|
|
40
|
-
<Text className="step-title" appearance="microtext1"
|
|
39
|
+
<Text className="step-title" appearance="microtext1" color="light.700">
|
|
41
40
|
{t.step} {index}/{total}: {step.input}
|
|
42
41
|
</Text>
|
|
43
42
|
</li>
|
|
@@ -74,7 +73,7 @@ export const StepsList = ({ steps, chatId, messageId }: Props) => {
|
|
|
74
73
|
{isExpanded && <div className="step-actions">
|
|
75
74
|
<Button colorScheme="light" size="sm" onClick={() => setExpanded(false)}>{t.hideSteps}</Button>
|
|
76
75
|
<Button colorScheme="light" size="sm" className="icon-button details" onClick={openToolsPanel}>
|
|
77
|
-
<
|
|
76
|
+
<Icon group="fill" icon="Play" size="xs" />
|
|
78
77
|
{t.detailed}
|
|
79
78
|
</Button>
|
|
80
79
|
</div>}
|
package/src/views/Chat/index.tsx
CHANGED
|
@@ -12,7 +12,14 @@ interface Props extends CustomMessage {
|
|
|
12
12
|
/**
|
|
13
13
|
* Renders the chat panel, with all of its messages.
|
|
14
14
|
*/
|
|
15
|
-
export const Chat = ({ username, beforeMessage, afterMessage }: Props) => {
|
|
15
|
+
export const Chat = ({ username, beforeMessage, afterMessage, customRenderer }: Props) => {
|
|
16
16
|
const { active } = useChatTabs()
|
|
17
|
-
return <ChatMessages
|
|
17
|
+
return <ChatMessages
|
|
18
|
+
key={active.id}
|
|
19
|
+
chatId={active.id}
|
|
20
|
+
username={username}
|
|
21
|
+
beforeMessage={beforeMessage}
|
|
22
|
+
afterMessage={afterMessage}
|
|
23
|
+
customRenderer={customRenderer}
|
|
24
|
+
/>
|
|
18
25
|
}
|