File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { Sender } from "@ant-design/x";
66function DefaultPromptInput ( {
77 value,
88 isPromptRunning,
9+ isResponseStreaming,
910 onSenderChange,
1011 onSubmit,
1112 onCancel,
@@ -25,7 +26,7 @@ function DefaultPromptInput({
2526 actions = { ( _ , info ) => {
2627 const { SendButton, LoadingButton } = info . components ;
2728
28- if ( isPromptRunning ) {
29+ if ( isPromptRunning && ! isResponseStreaming ) {
2930 return (
3031 < Tooltip title = "Stop" >
3132 < LoadingButton variant = "text" color = "secondary" shape = "default" />
@@ -64,6 +65,7 @@ function DefaultPromptInput({
6465DefaultPromptInput . propTypes = {
6566 value : PropTypes . string . isRequired ,
6667 isPromptRunning : PropTypes . bool . isRequired ,
68+ isResponseStreaming : PropTypes . bool ,
6769 onSenderChange : PropTypes . func . isRequired ,
6870 onSubmit : PropTypes . func . isRequired ,
6971 onCancel : PropTypes . func . isRequired ,
Original file line number Diff line number Diff line change @@ -246,6 +246,13 @@ const ExistingChat = memo(function ExistingChat({
246246 return - 1 ;
247247 } , [ chatMessages , chatIntents ] ) ;
248248
249+ // Check if response is actively streaming (thought chain done, response started)
250+ const isResponseStreaming = useMemo ( ( ) => {
251+ if ( ! chatMessages ?. length ) return false ;
252+ const lastMessage = chatMessages ?. [ chatMessages . length - 1 ] ;
253+ return isPromptRunning && lastMessage ?. response ?. length > 0 ;
254+ } , [ chatMessages , isPromptRunning ] ) ;
255+
249256 useEffect ( ( ) => {
250257 if ( chatMessages . length ) {
251258 setLastChatMessageId (
@@ -454,6 +461,7 @@ const ExistingChat = memo(function ExistingChat({
454461 < InputPrompt
455462 savePrompt = { handleSavePrompt }
456463 isPromptRunning = { isPromptRunning }
464+ isResponseStreaming = { isResponseStreaming }
457465 chatIntents = { chatIntents }
458466 selectedChatIntent = { selectedChatIntent }
459467 setSelectedChatIntent = { setSelectedChatIntent }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ const InputPrompt = memo(function InputPrompt({
1010 savePrompt,
1111 isNewChat = false ,
1212 isPromptRunning,
13+ isResponseStreaming = false ,
1314 chatIntents,
1415 selectedChatIntent,
1516 setSelectedChatIntent,
@@ -209,6 +210,7 @@ const InputPrompt = memo(function InputPrompt({
209210 value = { value }
210211 editorHeight = { editorHeight }
211212 isPromptRunning = { isPromptRunning }
213+ isResponseStreaming = { isResponseStreaming }
212214 onSenderChange = { handleSenderChange }
213215 onSubmit = { handleSubmit }
214216 onEditorMount = { handleEditorMount }
@@ -252,6 +254,7 @@ InputPrompt.propTypes = {
252254 savePrompt : PropTypes . func . isRequired ,
253255 isNewChat : PropTypes . bool ,
254256 isPromptRunning : PropTypes . bool . isRequired ,
257+ isResponseStreaming : PropTypes . bool ,
255258 chatIntents : PropTypes . array . isRequired ,
256259 selectedChatIntent : PropTypes . string ,
257260 setSelectedChatIntent : PropTypes . func . isRequired ,
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ const MonacoPromptInput = memo(function MonacoPromptInput({
1212 value,
1313 editorHeight,
1414 isPromptRunning,
15+ isResponseStreaming,
1516 onEditorMount,
1617 onMonacoChange,
1718 onSubmit,
@@ -159,9 +160,8 @@ const MonacoPromptInput = memo(function MonacoPromptInput({
159160 return (
160161 < div className = "monaco-editor-wrapper" >
161162 { editorContent }
162-
163163 < div className = "monaco-editor-send" >
164- { isPromptRunning ? (
164+ { isPromptRunning && ! isResponseStreaming ? (
165165 < Tooltip title = "Stop" >
166166 < Button type = "text" icon = { < CloseOutlined /> } onClick = { onCancel } />
167167 </ Tooltip >
@@ -204,6 +204,7 @@ MonacoPromptInput.propTypes = {
204204 value : PropTypes . string . isRequired ,
205205 editorHeight : PropTypes . number . isRequired ,
206206 isPromptRunning : PropTypes . bool . isRequired ,
207+ isResponseStreaming : PropTypes . bool ,
207208 onEditorMount : PropTypes . func ,
208209 onMonacoChange : PropTypes . func . isRequired ,
209210 onSubmit : PropTypes . func . isRequired ,
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ const PromptInput = memo(function PromptInput({
1010 value,
1111 editorHeight,
1212 isPromptRunning,
13+ isResponseStreaming,
1314 onSenderChange,
1415 onSubmit,
1516 onEditorMount,
@@ -34,6 +35,7 @@ const PromptInput = memo(function PromptInput({
3435 < DefaultPromptInput
3536 value = { value }
3637 isPromptRunning = { isPromptRunning }
38+ isResponseStreaming = { isResponseStreaming }
3739 onSenderChange = { onSenderChange }
3840 onSubmit = { onSubmit }
3941 onCancel = { onCancel }
@@ -49,6 +51,7 @@ const PromptInput = memo(function PromptInput({
4951 value = { value }
5052 editorHeight = { editorHeight }
5153 isPromptRunning = { isPromptRunning }
54+ isResponseStreaming = { isResponseStreaming }
5255 onEditorMount = { onEditorMount }
5356 onMonacoChange = { onMonacoChange }
5457 onSubmit = { onSubmit }
@@ -70,6 +73,7 @@ PromptInput.propTypes = {
7073 value : PropTypes . string . isRequired ,
7174 editorHeight : PropTypes . number . isRequired ,
7275 isPromptRunning : PropTypes . bool . isRequired ,
76+ isResponseStreaming : PropTypes . bool ,
7377 onSenderChange : PropTypes . func . isRequired ,
7478 onSubmit : PropTypes . func . isRequired ,
7579 onEditorMount : PropTypes . func . isRequired ,
You can’t perform that action at this time.
0 commit comments