@@ -46,7 +46,10 @@ import {
4646} from "@/lib/parallel-chat-requests" ;
4747import { useStartProvisionalChat } from "@/lib/start-provisional-chat" ;
4848import { useChatActions , useChatStoreApi } from "@/lib/stores/base" ;
49- import { useLastMessageId } from "@/lib/stores/hooks-base" ;
49+ import {
50+ useLastMessageId ,
51+ useLastMessageMetadata ,
52+ } from "@/lib/stores/hooks-base" ;
5053import { useAddMessageToTree } from "@/lib/stores/hooks-threads" ;
5154import { ANONYMOUS_LIMITS } from "@/lib/types/anonymous" ;
5255import { cn } from "@/lib/utils" ;
@@ -57,6 +60,7 @@ import { useTRPC } from "@/trpc/react";
5760import { ConnectorsDropdown } from "./connectors-dropdown" ;
5861import { LexicalChatInput } from "./lexical-chat-input" ;
5962import { ModelSelector } from "./model-selector" ;
63+ import { getResponseAwareStatus } from "./parallel-response-status" ;
6064import { ResponsiveTools } from "./responsive-tools" ;
6165import {
6266 DropdownMenu ,
@@ -117,12 +121,18 @@ function PureMultimodalInput({
117121 const currentRoute = useCurrentChatRoute ( ) ;
118122 const startProvisionalChat = useStartProvisionalChat ( chatId ) ;
119123 const {
124+ setStatus,
120125 setMessages,
121126 sendMessage,
122127 startRun,
123128 stop : stopHelper ,
124129 } = useChatActions < ChatMessage > ( ) ;
125130 const lastMessageId = useLastMessageId ( ) ;
131+ const lastMessageMetadata = useLastMessageMetadata ( ) ;
132+ const responseAwareStatus = getResponseAwareStatus (
133+ status ,
134+ lastMessageMetadata ? { metadata : lastMessageMetadata } : null
135+ ) ;
126136 const {
127137 editorRef,
128138 selectedTool,
@@ -223,7 +233,7 @@ function PureMultimodalInput({
223233 if ( isModelDisallowedForAnonymous ) {
224234 return { enabled : false , message : "Log in to use this model" } ;
225235 }
226- if ( status !== "ready" && status !== "error" ) {
236+ if ( responseAwareStatus !== "ready" && responseAwareStatus !== "error" ) {
227237 return {
228238 enabled : false ,
229239 message : "Please wait for the model to finish its response!" ,
@@ -248,7 +258,7 @@ function PureMultimodalInput({
248258 isModelDisallowedForAnonymous ,
249259 isParallelModelRequest ,
250260 session ?. user ,
251- status ,
261+ responseAwareStatus ,
252262 uploadQueue . length ,
253263 ] ) ;
254264
@@ -385,6 +395,7 @@ function PureMultimodalInput({
385395 }
386396
387397 if ( primaryRequest ) {
398+ setStatus ( "submitted" ) ;
388399 sendMessage ( message , {
389400 body : {
390401 ...createParallelRequestBody ( primaryRequest , true ) ,
@@ -423,6 +434,7 @@ function PureMultimodalInput({
423434 toast . error ( "Failed to complete all parallel responses" ) ;
424435 } ) ;
425436 } else {
437+ setStatus ( "submitted" ) ;
426438 sendMessage (
427439 message ,
428440 currentRoute . projectId
@@ -454,6 +466,7 @@ function PureMultimodalInput({
454466 parallelResponsesEnabled ,
455467 selectedTool ,
456468 sendMessage ,
469+ setStatus ,
457470 startProvisionalChat ,
458471 startRun ,
459472 trimMessagesInEditMode ,
@@ -531,7 +544,7 @@ function PureMultimodalInput({
531544
532545 const handlePaste = useCallback (
533546 async ( event : React . ClipboardEvent ) => {
534- if ( status !== "ready" ) {
547+ if ( responseAwareStatus !== "ready" ) {
535548 return ;
536549 }
537550
@@ -589,7 +602,7 @@ function PureMultimodalInput({
589602 [
590603 setAttachments ,
591604 processFiles ,
592- status ,
605+ responseAwareStatus ,
593606 session ,
594607 uploadFile ,
595608 attachmentsEnabled ,
@@ -644,7 +657,7 @@ function PureMultimodalInput({
644657 }
645658 } ,
646659 noClick : true , // Prevent click to open file dialog since we have the button
647- disabled : status !== "ready" || ! attachmentsEnabled ,
660+ disabled : responseAwareStatus !== "ready" || ! attachmentsEnabled ,
648661 noDrag : ! attachmentsEnabled ,
649662 accept : acceptedTypes ,
650663 } ) ;
@@ -758,7 +771,7 @@ function PureMultimodalInput({
758771 selectedModelSelection = { selectedModelSelection }
759772 selectedTool = { selectedTool }
760773 setSelectedTool = { setSelectedTool }
761- status = { status }
774+ status = { responseAwareStatus }
762775 submission = { submission }
763776 submitForm = { submitForm }
764777 />
0 commit comments