@@ -6,7 +6,7 @@ import * as React from 'react';
6
6
import flow from 'lodash/flow' ;
7
7
import { useIntl } from 'react-intl' ;
8
8
import classNames from 'classnames' ;
9
- import { AgentsProvider , BoxAiAgentSelectorWithApi } from '@box/box-ai-agent-selector' ;
9
+ import { BoxAiAgentSelectorWithApi , useAgents } from '@box/box-ai-agent-selector' ;
10
10
import { IconButton , Tooltip } from '@box/blueprint-web' ;
11
11
import { ArrowsExpand } from '@box/blueprint-web-assets/icons/Fill' ;
12
12
import {
@@ -65,6 +65,7 @@ function BoxAISidebarContent(props: ApiWrapperProps) {
65
65
setCacheValue,
66
66
userInfo,
67
67
} = React . useContext ( BoxAISidebarContext ) ;
68
+ const { agents, requestState, selectedAgent } = useAgents ( ) ;
68
69
const { questions : cacheQuestions } = cache ;
69
70
70
71
if ( cache . encodedSession !== encodedSession ) {
@@ -75,6 +76,10 @@ function BoxAISidebarContent(props: ApiWrapperProps) {
75
76
setCacheValue ( 'questions' , questions ) ;
76
77
}
77
78
79
+ if ( cache . agents . selectedAgent !== selectedAgent ) {
80
+ setCacheValue ( 'agents' , { agents, requestState, selectedAgent } ) ;
81
+ }
82
+
78
83
const handleModalClose = ( ) => {
79
84
setIsModalOpen ( false ) ;
80
85
} ;
@@ -152,61 +157,59 @@ function BoxAISidebarContent(props: ApiWrapperProps) {
152
157
) ;
153
158
154
159
return (
155
- < AgentsProvider >
156
- < >
157
- < SidebarContent
158
- actions = { renderActions ( ) }
159
- className = { classNames ( 'bcs-BoxAISidebar' , { 'with-modal-open' : isModalOpen } ) }
160
- elementId = { elementId }
161
- sidebarView = { SIDEBAR_VIEW_BOXAI }
162
- >
163
- < div className = "bcs-BoxAISidebar-content" >
164
- < BoxAiContentAnswers
165
- className = "bcs-BoxAISidebar-contentAnswers"
166
- contentType = { formatMessage ( messages . sidebarBoxAIContent ) }
167
- hostAppName = { hostAppName }
168
- isAIStudioAgentSelectorEnabled = { isAIStudioAgentSelectorEnabled }
169
- isFeedbackEnabled = { isFeedbackEnabled }
170
- isStopResponseEnabled = { isStopResponseEnabled }
171
- items = { items }
172
- questions = { questions }
173
- stopQuestion = { stopQuestion }
174
- submitQuestion = { sendQuestion }
175
- userInfo = { userInfo }
176
- variant = "sidebar"
177
- recordAction = { recordAction }
178
- { ...rest }
179
- />
180
- </ div >
181
- </ SidebarContent >
182
- < IntelligenceModal
183
- contentName = { contentName }
184
- contentType = { formatMessage ( messages . sidebarBoxAIContent ) }
185
- extension = { fileExtension }
186
- getAIStudioAgents = { getAIStudioAgents }
187
- hostAppName = { hostAppName }
188
- isAIStudioAgentSelectorEnabled = { isAIStudioAgentSelectorEnabled }
189
- isFeedbackEnabled = { isFeedbackEnabled }
190
- isResetChatEnabled = { isResetChatEnabled }
191
- isStopResponseEnabled = { isStopResponseEnabled }
192
- items = { items }
193
- itemSize = { itemSize }
194
- onClearAction = { onClearAction }
195
- onOpenChange = { handleModalClose }
196
- onSelectAgent = { onSelectAgent }
197
- open = { isModalOpen }
198
- questions = { questions }
199
- recordAction = { isModalOpen ? recordAction : undefined }
200
- showLoadingIndicator = { false }
201
- stopPropagationOnEsc
202
- submitQuestion = { sendQuestion }
203
- userInfo = { userInfo }
204
- variant = "collapsible"
205
- { ...rest }
206
- shouldRenderProviders = { false }
207
- />
208
- </ >
209
- </ AgentsProvider >
160
+ < >
161
+ < SidebarContent
162
+ actions = { renderActions ( ) }
163
+ className = { classNames ( 'bcs-BoxAISidebar' , { 'with-modal-open' : isModalOpen } ) }
164
+ elementId = { elementId }
165
+ sidebarView = { SIDEBAR_VIEW_BOXAI }
166
+ >
167
+ < div className = "bcs-BoxAISidebar-content" >
168
+ < BoxAiContentAnswers
169
+ className = "bcs-BoxAISidebar-contentAnswers"
170
+ contentType = { formatMessage ( messages . sidebarBoxAIContent ) }
171
+ hostAppName = { hostAppName }
172
+ isAIStudioAgentSelectorEnabled = { isAIStudioAgentSelectorEnabled }
173
+ isFeedbackEnabled = { isFeedbackEnabled }
174
+ isStopResponseEnabled = { isStopResponseEnabled }
175
+ items = { items }
176
+ questions = { questions }
177
+ stopQuestion = { stopQuestion }
178
+ submitQuestion = { sendQuestion }
179
+ userInfo = { userInfo }
180
+ variant = "sidebar"
181
+ recordAction = { recordAction }
182
+ { ...rest }
183
+ />
184
+ </ div >
185
+ </ SidebarContent >
186
+ < IntelligenceModal
187
+ contentName = { contentName }
188
+ contentType = { formatMessage ( messages . sidebarBoxAIContent ) }
189
+ extension = { fileExtension }
190
+ getAIStudioAgents = { getAIStudioAgents }
191
+ hostAppName = { hostAppName }
192
+ isAIStudioAgentSelectorEnabled = { isAIStudioAgentSelectorEnabled }
193
+ isFeedbackEnabled = { isFeedbackEnabled }
194
+ isResetChatEnabled = { isResetChatEnabled }
195
+ isStopResponseEnabled = { isStopResponseEnabled }
196
+ items = { items }
197
+ itemSize = { itemSize }
198
+ onClearAction = { onClearAction }
199
+ onOpenChange = { handleModalClose }
200
+ onSelectAgent = { onSelectAgent }
201
+ open = { isModalOpen }
202
+ questions = { questions }
203
+ recordAction = { isModalOpen ? recordAction : undefined }
204
+ showLoadingIndicator = { false }
205
+ stopPropagationOnEsc
206
+ submitQuestion = { sendQuestion }
207
+ userInfo = { userInfo }
208
+ variant = "collapsible"
209
+ { ...rest }
210
+ shouldRenderProviders = { false }
211
+ />
212
+ </ >
210
213
) ;
211
214
}
212
215
0 commit comments