@stack-spot/ai-chat-widget 2.2.0-beta.1 → 2.2.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +6 -20
  2. package/dist/app-metadata.json +5 -5
  3. package/dist/chat-interceptors/send-message.d.ts.map +1 -1
  4. package/dist/chat-interceptors/send-message.js +1 -125
  5. package/dist/chat-interceptors/send-message.js.map +1 -1
  6. package/dist/state/ChatEntry.d.ts +1 -1
  7. package/dist/state/ChatEntry.d.ts.map +1 -1
  8. package/dist/state/ChatEntry.js +1 -2
  9. package/dist/state/ChatEntry.js.map +1 -1
  10. package/dist/state/ChatState.d.ts +0 -8
  11. package/dist/state/ChatState.d.ts.map +1 -1
  12. package/dist/state/ChatState.js.map +1 -1
  13. package/dist/utils/chat.d.ts.map +1 -1
  14. package/dist/utils/chat.js +0 -1
  15. package/dist/utils/chat.js.map +1 -1
  16. package/dist/views/Chat/ChatMessage.d.ts +1 -1
  17. package/dist/views/Chat/ChatMessage.d.ts.map +1 -1
  18. package/dist/views/Chat/ChatMessage.js +6 -21
  19. package/dist/views/Chat/ChatMessage.js.map +1 -1
  20. package/dist/views/Chat/StepsList.d.ts +2 -12
  21. package/dist/views/Chat/StepsList.d.ts.map +1 -1
  22. package/dist/views/Chat/StepsList.js +21 -155
  23. package/dist/views/Chat/StepsList.js.map +1 -1
  24. package/dist/views/Chat/styled.d.ts.map +1 -1
  25. package/dist/views/Chat/styled.js +10 -17
  26. package/dist/views/Chat/styled.js.map +1 -1
  27. package/dist/views/MessageInput/ButtonBar.d.ts.map +1 -1
  28. package/dist/views/MessageInput/ButtonBar.js +1 -2
  29. package/dist/views/MessageInput/ButtonBar.js.map +1 -1
  30. package/dist/views/MessageInput/dictionary.d.ts +1 -1
  31. package/dist/views/MessageInput/styled.d.ts +0 -3
  32. package/dist/views/MessageInput/styled.d.ts.map +1 -1
  33. package/dist/views/MessageInput/styled.js +0 -12
  34. package/dist/views/MessageInput/styled.js.map +1 -1
  35. package/dist/views/Steps/FlowChart/NodeStep.js +1 -1
  36. package/dist/views/Steps/FlowChart/NodeStep.js.map +1 -1
  37. package/dist/views/Steps/FlowChart/layout.d.ts +1 -1
  38. package/dist/views/Steps/FlowChart/layout.d.ts.map +1 -1
  39. package/dist/views/Steps/FlowChart/layout.js +0 -1
  40. package/dist/views/Steps/FlowChart/layout.js.map +1 -1
  41. package/dist/views/Steps/FlowChart/types.d.ts +1 -1
  42. package/dist/views/Steps/FlowChart/types.d.ts.map +1 -1
  43. package/dist/views/Steps/StepModal.js +2 -2
  44. package/dist/views/Steps/StepModal.js.map +1 -1
  45. package/dist/views/Steps/dictionary.d.ts +1 -1
  46. package/dist/views/Steps/utils.d.ts +1 -1
  47. package/dist/views/Steps/utils.d.ts.map +1 -1
  48. package/package.json +3 -3
  49. package/src/app-metadata.json +5 -5
  50. package/src/chat-interceptors/send-message.ts +2 -137
  51. package/src/state/ChatEntry.ts +1 -2
  52. package/src/state/ChatState.ts +0 -8
  53. package/src/utils/chat.ts +0 -1
  54. package/src/views/Chat/ChatMessage.tsx +5 -25
  55. package/src/views/Chat/StepsList.tsx +48 -337
  56. package/src/views/Chat/styled.ts +10 -17
  57. package/src/views/MessageInput/ButtonBar.tsx +0 -2
  58. package/src/views/MessageInput/styled.ts +0 -12
  59. package/src/views/Steps/FlowChart/NodeStep.tsx +1 -1
  60. package/src/views/Steps/FlowChart/layout.ts +0 -1
  61. package/src/views/Steps/FlowChart/types.ts +1 -1
  62. package/src/views/Steps/StepModal.tsx +2 -2
  63. package/dist/utils/planning-tool.d.ts +0 -17
  64. package/dist/utils/planning-tool.d.ts.map +0 -1
  65. package/dist/utils/planning-tool.js +0 -32
  66. package/dist/utils/planning-tool.js.map +0 -1
  67. package/dist/utils/update-tool-step.d.ts +0 -3
  68. package/dist/utils/update-tool-step.d.ts.map +0 -1
  69. package/dist/utils/update-tool-step.js +0 -23
  70. package/dist/utils/update-tool-step.js.map +0 -1
  71. package/dist/views/MessageInput/ModelSwitcher.d.ts +0 -2
  72. package/dist/views/MessageInput/ModelSwitcher.d.ts.map +0 -1
  73. package/dist/views/MessageInput/ModelSwitcher.js +0 -77
  74. package/dist/views/MessageInput/ModelSwitcher.js.map +0 -1
  75. package/src/utils/planning-tool.ts +0 -41
  76. package/src/utils/update-tool-step.tsx +0 -27
  77. package/src/views/MessageInput/ModelSwitcher.tsx +0 -127
@@ -2,6 +2,6 @@ import { WithIcon } from '@stack-spot/citric-icons';
2
2
  import { ChatStep } from '@stack-spot/portal-network';
3
3
  export declare function getStatusIcon(status: ChatStep['status']): import("react/jsx-runtime").JSX.Element | null;
4
4
  export declare function getTypeIcon(type: ChatStep['type']): WithIcon;
5
- export declare function getTitle(translation: Record<'planning' | 'step' | 'answer', string>, step: ChatStep | undefined, index: number): string | undefined;
5
+ export declare function getTitle(translation: Record<'planning' | 'step' | 'answer', string>, step: ChatStep | undefined, index: number): string;
6
6
  export declare function toPrecision(n: number, precisionDigits?: number): number;
7
7
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/views/Steps/utils.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAGrD,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,kDAOvD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,QAAQ,CAK5D;AAED,wBAAgB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,GAAG,QAAQ,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,sBAO9H;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,SAAI,UAGzD"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/views/Steps/utils.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAGrD,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,kDAOvD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,QAAQ,CAK5D;AAED,wBAAgB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,GAAG,QAAQ,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,UAO9H;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,SAAI,UAGzD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stack-spot/ai-chat-widget",
3
- "version": "2.2.0-beta.1",
3
+ "version": "2.2.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,12 +11,12 @@
11
11
  },
12
12
  "peerDependencies": {
13
13
  "@stack-spot/citric-react": "^0.36.0",
14
- "@stack-spot/citric-icons": "^0.2.3",
14
+ "@stack-spot/citric-icons": "^0.2.2",
15
15
  "@stack-spot/portal-theme": "^1.2.1",
16
16
  "@citric/core": "^6.4.0",
17
17
  "@stack-spot/portal-components": "^2.26.0",
18
18
  "@citric/icons": "^5.13.0",
19
- "@stack-spot/portal-network": "0.189.0-beta.1",
19
+ "@stack-spot/portal-network": "0.181.0",
20
20
  "@citric/ui": "^6.10.2",
21
21
  "@stack-spot/portal-translate": "^2.1.0",
22
22
  "lodash": "^4.17.0",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stack-spot/ai-chat-widget",
3
- "version": "2.2.0-beta.1",
4
- "date": "Mon Oct 27 2025 19:05:06 GMT+0000 (Coordinated Universal Time)",
3
+ "version": "2.2.1",
4
+ "date": "Mon Oct 27 2025 20:27:26 GMT+0000 (Coordinated Universal Time)",
5
5
  "dependencies": [
6
6
  {
7
7
  "name": "@stack-spot/app-metadata",
@@ -109,11 +109,11 @@
109
109
  },
110
110
  {
111
111
  "name": "@stack-spot/citric-icons",
112
- "version": "0.2.3"
112
+ "version": "0.2.2"
113
113
  },
114
114
  {
115
115
  "name": "@stack-spot/citric-react",
116
- "version": "0.36.0(@stack-spot/citric-icons@0.2.3)(@stack-spot/portal-theme@1.2.1(@citric/core@6.4.0(lodash@4.17.21)(react@18.2.0)(styled-components@6.1.10(react-dom@18.2.0(react@18.2.0))(react@18.2.0)))(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(styled-components@6.1.10(react-dom@18.2.0(react@18.2.0))(react@18.2.0)))(@stack-spot/portal-translate@2.1.0(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(lodash@4.17.21)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)"
116
+ "version": "0.36.0(@stack-spot/citric-icons@0.2.2)(@stack-spot/portal-theme@1.2.1(@citric/core@6.4.0(lodash@4.17.21)(react@18.2.0)(styled-components@6.1.10(react-dom@18.2.0(react@18.2.0))(react@18.2.0)))(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(styled-components@6.1.10(react-dom@18.2.0(react@18.2.0))(react@18.2.0)))(@stack-spot/portal-translate@2.1.0(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(lodash@4.17.21)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)"
117
117
  },
118
118
  {
119
119
  "name": "@stack-spot/portal-components",
@@ -121,7 +121,7 @@
121
121
  },
122
122
  {
123
123
  "name": "@stack-spot/portal-network",
124
- "version": "0.189.0-beta.1(@stack-spot/auth@6.1.0)(@stack-spot/opa@2.5.0(@stack-spot/auth@6.1.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@stack-spot/portal-translate@2.1.0(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@tanstack/react-query@5.59.16(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0)"
124
+ "version": "0.181.0(@stack-spot/auth@6.1.0)(@stack-spot/opa@2.5.0(@stack-spot/auth@6.1.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@stack-spot/portal-translate@2.1.0(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@tanstack/react-query@5.59.16(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0)"
125
125
  },
126
126
  {
127
127
  "name": "@stack-spot/portal-theme",
@@ -1,13 +1,11 @@
1
- import { AgentInfo, aiClient, ChatResponseWithSteps, ChatStep, StackspotAPIError, StreamCanceledError } from '@stack-spot/portal-network'
1
+ import { aiClient, ChatResponseWithSteps, StackspotAPIError, StreamCanceledError } from '@stack-spot/portal-network'
2
2
  import { ChatResponse3 } from '@stack-spot/portal-network/api/ai'
3
- import { findLast } from 'lodash'
4
3
  import { ChatEntry, KnowledgeSource, TextChatEntry } from '../state/ChatEntry'
5
4
  import { ChatState } from '../state/ChatState'
6
5
  import { LabeledWithImage } from '../state/types'
7
6
  import { buildConversationContext } from '../utils/chat'
8
7
  import { treatHTMLInErrorMessage } from '../utils/error'
9
8
  import { genericSourcesToKnowledgeSources } from '../utils/knowledge-source'
10
- import { planningToolDictionaryHelper } from '../utils/planning-tool'
11
9
 
12
10
  /**
13
11
  * Transforms a chat response from the backend into a chat entry that can be added to the chat.
@@ -24,7 +22,7 @@ function createEntryValueFromChatResponse(
24
22
  agent: LabeledWithImage | undefined,
25
23
  includeDate = false,
26
24
  ): TextChatEntry {
27
- const entry= {
25
+ return {
28
26
  agentType: 'bot',
29
27
  type: 'md',
30
28
  content: response.answer ?? '',
@@ -35,7 +33,6 @@ function createEntryValueFromChatResponse(
35
33
  steps: response.steps,
36
34
  tools: response.tools,
37
35
  }
38
- return entry as TextChatEntry
39
36
  }
40
37
 
41
38
  function buildPrompt(content: string, data?: any) {
@@ -64,18 +61,6 @@ export async function sendMessageInterceptor(entry: ChatEntry, chat: ChatState,
64
61
  chat.set('label', content || entry.getValue().upload?.[0]?.name || 'Chat')
65
62
  chat.untitled = false
66
63
  }
67
-
68
- //Verify if the last planning in the messages has status awaiting_approval
69
- const messages = chat.getMessages()
70
- const lastPlanningAwaiting = findLast(messages, item => {
71
- const steps = item.getValue().steps
72
- if (steps) {
73
- const hasPlanning = steps.find((step) => step.type === 'planning')
74
- return hasPlanning ? hasPlanning.status === 'awaiting_approval' : false
75
- }
76
- return false
77
- })
78
-
79
64
  const stream = aiClient.sendChatMessage({ context, user_prompt: buildPrompt(content, data) })
80
65
  signal.addEventListener('abort', () => stream.cancel())
81
66
  const botEntry = ChatEntry.createStreamedBotEntry()
@@ -84,135 +69,15 @@ export async function sendMessageInterceptor(entry: ChatEntry, chat: ChatState,
84
69
  chat.pushMessage(botEntry)
85
70
  }
86
71
  let knowledgeSources: KnowledgeSource[] | undefined
87
-
88
- const updatePlanningMessage = () => {
89
- if (lastPlanningAwaiting) {
90
- const originalItem = messages.find((message) => message.id === lastPlanningAwaiting.id)
91
- const originalItemValue = originalItem?.getValue()
92
- originalItemValue?.steps?.map((step) => {
93
- if (step.type === 'planning' && step.status === 'awaiting_approval') {
94
- step.status = 'success'
95
- }
96
- })
97
- originalItem?.setValue({ ...originalItemValue as TextChatEntry })
98
- }
99
- }
100
-
101
- const updateStepMessage = (step: ChatStep) => {
102
- if (lastPlanningAwaiting) {
103
- const originalItem = messages.find((message) => message.id === lastPlanningAwaiting.id)
104
- const originalItemValue = originalItem?.getValue()
105
- originalItemValue?.steps?.filter((messageStep) => {
106
- if (messageStep.id === step.id) {
107
- messageStep = { ...step }
108
- }
109
- })
110
- originalItem?.setValue({ ...originalItemValue as TextChatEntry })
111
- }
112
- }
113
-
114
- const updateToolStatus = (agentInfo: AgentInfo) => {
115
- const executionId = agentInfo.id
116
- if (executionId) {
117
- //Update message with type step which contains the planning steps
118
- const messageId = planningToolDictionaryHelper.getMessageIdPlanningStepFromToolExecutionId(executionId)
119
- const originalItem = messages.find((message) => `${message.id}` === messageId)
120
- const originalItemValue = originalItem?.getValue()
121
- let update = false
122
- const status = agentInfo.action === 'start' ? 'running' : 'success'
123
- const step = originalItemValue?.steps?.find(step => step.type === 'step' && step.attempts?.[0].tools?.[0].executionId === executionId)
124
- if (step && step.status !== status) {
125
- step.status = status
126
- update = true
127
- }
128
- if (update) {
129
- originalItem?.setValue({ ...originalItemValue as TextChatEntry })
130
- }
131
-
132
- //Updates message with type tool which contains the actually tool steps
133
- //We only want to show tools banner when they are awaiting_approval, by removing the step
134
- // we avoid the entire bot message to be visible
135
- const toolMessageId = planningToolDictionaryHelper.getMessageIdToolStepFromToolExecutionId(executionId)
136
- const toolOriginalItem = messages.find((message) => `${message.id}` === toolMessageId)
137
- const toolOriginalItemValue = toolOriginalItem?.getValue()
138
- const toolStep = toolOriginalItemValue?.steps?.find(step =>
139
- step.type === 'tool' && step.attempts?.[0].tools?.[0].executionId === executionId)
140
- update = false
141
- if (toolOriginalItemValue && toolStep && toolStep.status !== status) {
142
- toolOriginalItemValue.steps = undefined
143
- update = true
144
- }
145
- if (update) {
146
- toolOriginalItem?.setValue({ ...toolOriginalItemValue as TextChatEntry })
147
- }
148
- }
149
- }
150
-
151
72
  stream.onChange(value => {
152
- if (value.agent_info?.type === 'planning') {
153
- if (value.agent_info.action === 'start') {
154
- chat.set('isPlaning', true)
155
- } else {
156
- chat.set('isPlaning', false)
157
- }
158
- }
159
-
160
73
  if (value.sources?.length !== knowledgeSources?.length && chat.get('features').showSourcesInResponse) {
161
74
  knowledgeSources = genericSourcesToKnowledgeSources(value.sources)
162
75
  }
163
-
164
- if (lastPlanningAwaiting && value.steps) {
165
- value.steps?.map(step => {
166
- if (step.type === 'planning') {
167
- updatePlanningMessage()
168
- } else if (step.type === 'step') {
169
- updateStepMessage(step)
170
- }
171
- })
172
- }
173
-
174
- if (value.agent_info?.type === 'tool' && value.agent_info?.action !== 'awaiting_approval') {
175
- updateToolStatus(value.agent_info)
176
- }
177
-
178
- if (value.steps) {
179
- const tool = findLast(value.steps, (item) => item.type === 'tool')
180
-
181
- if (tool && tool.status === 'running') {
182
- const messageId = planningToolDictionaryHelper.getMessageIdPlanningStepFromToolExecutionId(tool.id)
183
- const originalItem = messages.find((message) => `${message.id}` === messageId)
184
- const originalItemValue = originalItem?.getValue()
185
- let update = false
186
- const step = originalItemValue?.steps?.find(step => step.type === 'step')
187
- if (step && step.attempts?.[0].tools?.[0].executionId === tool.id) {
188
- step.attempts?.map((attempt, i) => {
189
- const newAttempt = tool.attempts?.[i]
190
- if (!newAttempt) return
191
- attempt.tools?.map((origTool, j) => {
192
- const newTool = newAttempt.tools?.[j]
193
- if (!newTool || origTool.executionId !== newTool.executionId) return origTool
194
- update = true
195
- return { ...origTool, ...newTool }
196
- })
197
- })
198
- }
199
- if (update) {
200
- originalItem?.setValue({ ...originalItemValue as TextChatEntry })
201
- }
202
- }
203
- }
204
-
205
76
  botEntry.setValue(createEntryValueFromChatResponse(value, knowledgeSources, chat.get('agent')))
206
77
  })
207
-
208
78
  let finalValue: Partial<ChatResponse3> | undefined
209
79
  try {
210
80
  finalValue = await stream.getValue()
211
- if (lastPlanningAwaiting) {
212
- const value = lastPlanningAwaiting.getValue()
213
- value.content = finalValue.answer || value.content
214
- lastPlanningAwaiting.setValue(value)
215
- }
216
81
  // if the streaming feature is not enabled, we only add the chat entry once the streaming has finished
217
82
  if (!chat.get('features').streaming) {
218
83
  chat.pushMessage(botEntry)
@@ -205,14 +205,13 @@ export class ChatEntry {
205
205
  * @param hiddenContent the message's content.
206
206
  * @returns a new ChatEntry.
207
207
  */
208
- static createUserEntry(content: string, isMd = false, fieldName?: string, hiddenContent?: string[], data?: any) {
208
+ static createUserEntry(content: string, isMd = false, fieldName?: string, hiddenContent?: string[]) {
209
209
  return new ChatEntry({
210
210
  agentType: 'user',
211
211
  type: isMd ? 'md' : 'text',
212
212
  content,
213
213
  name: fieldName,
214
214
  hiddenContent,
215
- data,
216
215
  updated: new Date().toISOString(),
217
216
  })
218
217
  }
@@ -33,10 +33,6 @@ export interface ChatPropertiesWithOptionalFeatures {
33
33
  * Whether or not the chat is in a loading state.
34
34
  */
35
35
  isLoading?: boolean,
36
- /**
37
- * Whether or not the chat is planning.
38
- */
39
- isPlaning?: boolean,
40
36
  /**
41
37
  * The value of the next message. This is the value of the text typed in the textarea below the chat.
42
38
  */
@@ -59,10 +55,6 @@ export interface ChatPropertiesWithOptionalFeatures {
59
55
  * If a feature is marked as false, it's disabled, otherwise it's enabled.
60
56
  */
61
57
  features?: Partial<ChatFeatures>,
62
- /**
63
- * The current LLM (Large Language Model) being used for this chat.
64
- */
65
- selected_model_id?: string,
66
58
  }
67
59
 
68
60
  export interface ChatProperties extends ChatPropertiesWithOptionalFeatures {
package/src/utils/chat.ts CHANGED
@@ -26,6 +26,5 @@ export function buildConversationContext(state: ChatState, message?: ChatEntry):
26
26
  platform: 'web-widget',
27
27
  platform_version: navigator.userAgent,
28
28
  stackspot_ai_version: appData.version,
29
- selected_model_id: state.get('selected_model_id'),
30
29
  }
31
30
  }
@@ -9,7 +9,7 @@ import { PhoneInput } from 'react-international-phone'
9
9
  import 'react-international-phone/style.css'
10
10
  import { FileDescription } from '../../components/FileDescription'
11
11
  import { Markdown } from '../../components/Markdown'
12
- import { useChatEntry, useChatMessages, useCurrentChat, useCurrentChatState, useWidget } from '../../context/hooks'
12
+ import { useChatEntry, useCurrentChat, useWidget } from '../../context/hooks'
13
13
  import { useMidnightUpdateView } from '../../hooks/midnight-update-view'
14
14
  import { ChatEntry, SerializableAction, TextChatEntry } from '../../state/ChatEntry'
15
15
  import { useDateFormatter } from '../../utils/date'
@@ -17,7 +17,7 @@ import { toolById } from '../../utils/tools'
17
17
  import { AgentInfo } from './AgentInfo'
18
18
  import { useChatScrollToBottomEffect } from './chat-scroll'
19
19
  import { onCopyAll, onCopyCode, onLikeOrDislike } from './events'
20
- import { StepsList, StepsPlaceholder, ViewToolsDetails } from './StepsList'
20
+ import { StepsList } from './StepsList'
21
21
 
22
22
  export interface CustomRenderResult {
23
23
  /**
@@ -218,21 +218,7 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage, cust
218
218
  { searchAgentsRequest: { ids: entry.tools || [''] } }, { enabled: !!entry.tools })
219
219
  const [copied, setCopied] = useState(false)
220
220
  const [showUserButtonCopy, setShowUserButtonCopy] = useState(false)
221
- const isPlanning = useCurrentChatState('isPlaning') ?? false
222
-
223
- // when we have a steps but we are not showing any content of the step
224
- // (because it is a tool and the user has already answered the question)
225
- // we do not want to show an avatar with empty content, so we hide the entire message
226
- const toolsStep = entry.steps?.find(s => s.type === 'tool')
227
- const messages = useChatMessages(chat.id)
228
- const userHasAlreadyAnswered = useMemo(() => {
229
- const messageIndex = messages.findIndex((messageItem) => messageItem.id === message.id)
230
- if (messages.length-1 === messageIndex) return false
231
- const nextMessage = messages[messageIndex+1].getValue()
232
- return nextMessage.agentType === 'user'
233
- }, [messages, messages.length])
234
- const isMessageHidden = toolsStep && userHasAlreadyAnswered
235
-
221
+
236
222
  useChatScrollToBottomEffect(ref, [entry])
237
223
  useMidnightUpdateView()
238
224
 
@@ -357,8 +343,7 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage, cust
357
343
  widget.set('panel', 'resources')
358
344
  }
359
345
 
360
- return (entry.content || entry.error || !!entry.steps?.length ||
361
- entry.upload?.length) && (!isMessageHidden || !toolsStep || isPlanning) && (
346
+ return (entry.content || entry.error || !!entry.steps?.length || entry.upload?.length) && (
362
347
  <li key={entry.messageId} className={entry.agentType} ref={ref}>
363
348
  <div className="chat-message-container"
364
349
  onMouseEnter={entry.agentType === 'user' ? () => setShowUserButtonCopy(true) : undefined}
@@ -371,15 +356,11 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage, cust
371
356
  {!!entry.badges?.length && <div className="badges">
372
357
  {entry.badges.map((b, index) => <Badge key={index} colorPalette={b.color ?? 'cyan'} appearance="square">{b.label}</Badge>)}
373
358
  </div>}
374
-
375
- {!!entry.steps?.length && <StepsList steps={entry.steps} chatId={chat.id} messageId={message.id}
376
- userHasAlreadyAnswered={userHasAlreadyAnswered} />}
377
-
378
359
  {renderContent()}
379
360
 
361
+ {!!entry.steps?.length && <StepsList steps={entry.steps} chatId={chat.id} messageId={message.id} />}
380
362
  </div>
381
363
  )}
382
- {isPlanning && entry.agentType === 'bot' && isLast && <StepsPlaceholder /> }
383
364
 
384
365
  {entry.error && <Alert type="error">{entry.error}</Alert>}
385
366
  </div>
@@ -435,7 +416,6 @@ export const ChatMessage = ({ message, isLast, beforeMessage, afterMessage, cust
435
416
  </ImageBox>
436
417
  )})}
437
418
  </Button>
438
- <ViewToolsDetails chatId={chat.id} />
439
419
  </div>}
440
420
 
441
421
  {shouldShowFooter && <div className="message-footer">