@@ -489,7 +489,7 @@ const chatStore = create<ChatStore>()(
489489
490490 }
491491 if ( targetTaskIndex !== - 1 ) {
492- console . log ( "targetTaskIndex" , targetTaskIndex , state )
492+ console . log ( "targetTaskIndex" , targetTaskIndex , state )
493493 taskRunning [ targetTaskIndex ] . status = state === "DONE" ? "completed" : "failed" ;
494494 }
495495 setTaskRunning ( taskId , taskRunning )
@@ -612,17 +612,16 @@ const chatStore = create<ChatStore>()(
612612 }
613613
614614
615- // If the state is "waiting", only mark it in the agent's task list and do not add it to taskRunning
615+ // Handle task assignment to taskAssigning based on state
616616 if ( taskState === "waiting" ) {
617617 if ( ! taskAssigning [ assigneeAgentIndex ] . tasks . find ( item => item . id === task_id ) ) {
618618 taskAssigning [ assigneeAgentIndex ] . tasks . push ( task ?? { id : task_id , content, status : "waiting" } ) ;
619619 }
620620 setTaskAssigning ( taskId , [ ...taskAssigning ] ) ;
621- return ; // Return early, do not add to the running queue
622- }
623621
622+ }
624623 // The following logic is for when the task actually starts executing (running)
625- if ( taskAssigning && taskAssigning [ assigneeAgentIndex ] ) {
624+ else if ( taskAssigning && taskAssigning [ assigneeAgentIndex ] ) {
626625 // Check if task already exists in the agent's task list
627626 const existingTaskIndex = taskAssigning [ assigneeAgentIndex ] . tasks . findIndex ( item => item . id === task_id ) ;
628627
@@ -649,19 +648,22 @@ const chatStore = create<ChatStore>()(
649648 // Only update or add to taskRunning, never duplicate
650649 if ( taskRunningIndex === - 1 ) {
651650 // Task not in taskRunning, add it
651+ if ( task ) {
652+ task . status = taskState === "waiting" ? "waiting" : "running" ;
653+ }
652654 taskRunning ! . push (
653655 task ?? {
654656 id : task_id ,
655657 content,
656- status : " ",
658+ status : taskState === "waiting" ? "waiting" : "running ",
657659 agent : JSON . parse ( JSON . stringify ( taskAgent ) ) ,
658660 }
659661 ) ;
660662 } else {
661663 // Task already in taskRunning, update it
662664 taskRunning ! [ taskRunningIndex ] = {
663665 ...taskRunning ! [ taskRunningIndex ] ,
664- status : " ",
666+ status : taskState === "waiting" ? "waiting" : "running ",
665667 agent : JSON . parse ( JSON . stringify ( taskAgent ) ) ,
666668 } ;
667669 }
0 commit comments