@@ -13,69 +13,74 @@ import { DOCUMENT_SUGGESTED_QUESTIONS, SPREADSHEET_FILE_EXTENSIONS } from '../co
1313import messages from '../common/content-answers/messages' ;
1414
1515export interface BoxAISidebarContextValues {
16- cache : { encodedSession ?: string | null , questions ?: QuestionType [ ] } ,
17- contentName : string ,
18- elementId : string ,
19- recordAction : ( params : RecordActionType ) => void ,
20- setCacheValue : ( key : 'encodedSession' | 'questions' , value : string | null | QuestionType [ ] ) => void ,
21- userInfo : { name : string , avatarUrl : string } ,
22- } ;
16+ cache : { encodedSession ?: string | null ; questions ?: QuestionType [ ] } ;
17+ contentName : string ;
18+ elementId : string ;
19+ isStopResponseEnabled : boolean ;
20+ recordAction : ( params : RecordActionType ) => void ;
21+ setCacheValue : ( key : 'encodedSession' | 'questions' , value : string | null | QuestionType [ ] ) => void ;
22+ userInfo : { name : string ; avatarUrl : string } ;
23+ }
2324
2425export const BoxAISidebarContext = React . createContext < BoxAISidebarContextValues > ( {
2526 cache : null ,
2627 contentName : '' ,
2728 elementId : '' ,
29+ isStopResponseEnabled : false ,
2830 recordAction : noop ,
2931 setCacheValue : noop ,
30- userInfo : { name : '' , avatarUrl : '' } ,
32+ userInfo : { name : '' , avatarUrl : '' } ,
3133} ) ;
3234
3335export interface BoxAISidebarProps {
34- contentName : string ,
35- cache : { encodedSession ?: string | null , questions ?: QuestionType [ ] } ,
36- createSessionRequest : ( payload : Record < string , unknown > , itemID : string ) => Promise < unknown > ,
37- elementId : string ,
36+ contentName : string ;
37+ cache : { encodedSession ?: string | null ; questions ?: QuestionType [ ] } ;
38+ createSessionRequest : ( payload : Record < string , unknown > , itemID : string ) => Promise < unknown > ;
39+ elementId : string ;
3840 fetchTimeout : Record < string , unknown > ;
39- fileExtension : string ,
40- fileID : string ,
41- getAgentConfig : ( payload : Record < string , unknown > ) => Promise < unknown > ,
42- getAIStudioAgents : ( ) => Promise < unknown > ,
43- getAnswer : ( payload : Record < string , unknown > ,
41+ fileExtension : string ;
42+ fileID : string ;
43+ getAgentConfig : ( payload : Record < string , unknown > ) => Promise < unknown > ;
44+ getAIStudioAgents : ( ) => Promise < unknown > ;
45+ getAnswer : (
46+ payload : Record < string , unknown > ,
4447 itemID ?: string ,
4548 itemIDs ?: Array < string > ,
46- state ?: Record < string , unknown > ) => Promise < unknown > ,
49+ state ?: Record < string , unknown > ,
50+ ) => Promise < unknown > ;
4751 getAnswerStreaming : (
4852 payload : Record < string , unknown > ,
4953 itemID ?: string ,
5054 itemIDs ?: Array < string > ,
5155 abortController ?: AbortController ,
5256 state ?: Record < string , unknown > ,
53- ) => Promise < unknown > ,
54- getSuggestedQuestions : ( itemID : string ) => Promise < unknown > | null ,
55- hostAppName : string ,
56- isAgentSelectorEnabled : boolean ,
57- isAIStudioAgentSelectorEnabled : boolean ,
58- isCitationsEnabled : boolean ,
59- isDebugModeEnabled : boolean ,
60- isIntelligentQueryMode : boolean ,
61- isMarkdownEnabled : boolean ,
62- isResetChatEnabled : boolean ,
63- isStopResponseEnabled : boolean ,
64- isStreamingEnabled : boolean ,
65- userInfo : { name : '' , avatarUrl : '' } ,
66- recordAction : ( params : RecordActionType ) => void ,
67- setCacheValue : ( key : 'encodedSession' | 'questions' , value : string | null | QuestionType [ ] ) => void ,
57+ ) => Promise < unknown > ;
58+ getSuggestedQuestions : ( itemID : string ) => Promise < unknown > | null ;
59+ hostAppName : string ;
60+ isAgentSelectorEnabled : boolean ;
61+ isAIStudioAgentSelectorEnabled : boolean ;
62+ isCitationsEnabled : boolean ;
63+ isDebugModeEnabled : boolean ;
64+ isIntelligentQueryMode : boolean ;
65+ isMarkdownEnabled : boolean ;
66+ isResetChatEnabled : boolean ;
67+ isStopResponseEnabled ? : boolean ;
68+ isStreamingEnabled : boolean ;
69+ userInfo : { name : '' ; avatarUrl : '' } ;
70+ recordAction : ( params : RecordActionType ) => void ;
71+ setCacheValue : ( key : 'encodedSession' | 'questions' , value : string | null | QuestionType [ ] ) => void ;
6872}
6973
7074const BoxAISidebar = ( props : BoxAISidebarProps ) => {
7175 const {
7276 cache,
7377 contentName,
74- elementId,
78+ elementId,
7579 fileExtension,
7680 fileID,
7781 getSuggestedQuestions,
7882 isIntelligentQueryMode,
83+ isStopResponseEnabled,
7984 recordAction,
8085 setCacheValue,
8186 userInfo,
@@ -84,9 +89,9 @@ const BoxAISidebar = (props: BoxAISidebarProps) => {
8489 const { questions } = cache ;
8590 const { formatMessage } = useIntl ( ) ;
8691 let questionsWithoutInProgress = questions ;
87- if ( questions . length > 0 && ! questions [ questions . length - 1 ] . isCompleted ) {
92+ if ( questions . length > 0 && ! questions [ questions . length - 1 ] . isCompleted ) {
8893 // pass only fully completed questions to not show loading indicator of question where we canceled API request
89- questionsWithoutInProgress = questionsWithoutInProgress . slice ( 0 , - 1 ) ;
94+ questionsWithoutInProgress = questionsWithoutInProgress . slice ( 0 , - 1 ) ;
9095 }
9196
9297 const localizedQuestions = DOCUMENT_SUGGESTED_QUESTIONS . map ( question => ( {
@@ -107,19 +112,22 @@ const BoxAISidebar = (props: BoxAISidebarProps) => {
107112 return (
108113 // BoxAISidebarContent is using withApiWrapper that is not passing all provided props,
109114 // that's why we need to use provider to pass other props
110- < BoxAISidebarContext . Provider value = { { cache, contentName, elementId, setCacheValue, recordAction, userInfo} } >
115+ < BoxAISidebarContext . Provider
116+ value = { { cache, contentName, elementId, isStopResponseEnabled, setCacheValue, recordAction, userInfo } }
117+ >
111118 < BoxAISidebarContent
119+ isStopResponseEnabled = { isStopResponseEnabled }
112120 itemID = { fileID }
113121 itemIDs = { [ fileID ] }
114- restoredQuestions = { questionsWithoutInProgress }
122+ restoredQuestions = { questionsWithoutInProgress }
115123 restoredSession = { cache . encodedSession }
116- suggestedQuestions = { getSuggestedQuestions === null ? localizedQuestions : [ ] }
124+ suggestedQuestions = { getSuggestedQuestions === null ? localizedQuestions : [ ] }
117125 warningNotice = { spreadsheetNotice }
118126 warningNoticeAriaLabel = { formatMessage ( messages . welcomeMessageSpreadsheetNoticeAriaLabel ) }
119- { ...rest }
127+ { ...rest }
120128 />
121129 </ BoxAISidebarContext . Provider >
122130 ) ;
123- }
131+ } ;
124132
125133export default BoxAISidebar ;
0 commit comments