@@ -13,69 +13,74 @@ import { DOCUMENT_SUGGESTED_QUESTIONS, SPREADSHEET_FILE_EXTENSIONS } from '../co
13
13
import messages from '../common/content-answers/messages' ;
14
14
15
15
export 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
+ }
23
24
24
25
export const BoxAISidebarContext = React . createContext < BoxAISidebarContextValues > ( {
25
26
cache : null ,
26
27
contentName : '' ,
27
28
elementId : '' ,
29
+ isStopResponseEnabled : false ,
28
30
recordAction : noop ,
29
31
setCacheValue : noop ,
30
- userInfo : { name : '' , avatarUrl : '' } ,
32
+ userInfo : { name : '' , avatarUrl : '' } ,
31
33
} ) ;
32
34
33
35
export 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 ;
38
40
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 > ,
44
47
itemID ?: string ,
45
48
itemIDs ?: Array < string > ,
46
- state ?: Record < string , unknown > ) => Promise < unknown > ,
49
+ state ?: Record < string , unknown > ,
50
+ ) => Promise < unknown > ;
47
51
getAnswerStreaming : (
48
52
payload : Record < string , unknown > ,
49
53
itemID ?: string ,
50
54
itemIDs ?: Array < string > ,
51
55
abortController ?: AbortController ,
52
56
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 ;
68
72
}
69
73
70
74
const BoxAISidebar = ( props : BoxAISidebarProps ) => {
71
75
const {
72
76
cache,
73
77
contentName,
74
- elementId,
78
+ elementId,
75
79
fileExtension,
76
80
fileID,
77
81
getSuggestedQuestions,
78
82
isIntelligentQueryMode,
83
+ isStopResponseEnabled,
79
84
recordAction,
80
85
setCacheValue,
81
86
userInfo,
@@ -84,9 +89,9 @@ const BoxAISidebar = (props: BoxAISidebarProps) => {
84
89
const { questions } = cache ;
85
90
const { formatMessage } = useIntl ( ) ;
86
91
let questionsWithoutInProgress = questions ;
87
- if ( questions . length > 0 && ! questions [ questions . length - 1 ] . isCompleted ) {
92
+ if ( questions . length > 0 && ! questions [ questions . length - 1 ] . isCompleted ) {
88
93
// 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 ) ;
90
95
}
91
96
92
97
const localizedQuestions = DOCUMENT_SUGGESTED_QUESTIONS . map ( question => ( {
@@ -107,19 +112,22 @@ const BoxAISidebar = (props: BoxAISidebarProps) => {
107
112
return (
108
113
// BoxAISidebarContent is using withApiWrapper that is not passing all provided props,
109
114
// 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
+ >
111
118
< BoxAISidebarContent
119
+ isStopResponseEnabled = { isStopResponseEnabled }
112
120
itemID = { fileID }
113
121
itemIDs = { [ fileID ] }
114
- restoredQuestions = { questionsWithoutInProgress }
122
+ restoredQuestions = { questionsWithoutInProgress }
115
123
restoredSession = { cache . encodedSession }
116
- suggestedQuestions = { getSuggestedQuestions === null ? localizedQuestions : [ ] }
124
+ suggestedQuestions = { getSuggestedQuestions === null ? localizedQuestions : [ ] }
117
125
warningNotice = { spreadsheetNotice }
118
126
warningNoticeAriaLabel = { formatMessage ( messages . welcomeMessageSpreadsheetNoticeAriaLabel ) }
119
- { ...rest }
127
+ { ...rest }
120
128
/>
121
129
</ BoxAISidebarContext . Provider >
122
130
) ;
123
- }
131
+ } ;
124
132
125
133
export default BoxAISidebar ;
0 commit comments