@@ -390,6 +390,11 @@ export class SessionService {
390390 throw new Error ( "Failed to create task run. Please try again." ) ;
391391 }
392392
393+ // Signal that the local run is now in progress
394+ auth . client
395+ . updateTaskRun ( taskId , taskRun . id , { status : "in_progress" } )
396+ . catch ( ( err ) => log . warn ( "Failed to update task run status" , { err } ) ) ;
397+
393398 const result = await trpcVanilla . agent . start . mutate ( {
394399 taskId,
395400 taskRunId : taskRun . id ,
@@ -457,6 +462,17 @@ export class SessionService {
457462 const session = sessionStoreSetters . getSessionByTaskId ( taskId ) ;
458463 if ( ! session ) return ;
459464
465+ // Update remote status based on session state
466+ const auth = useAuthStore . getState ( ) ;
467+ if ( auth . client ) {
468+ const status = session . isPromptPending ? "failed" : "completed" ;
469+ auth . client
470+ . updateTaskRun ( taskId , session . taskRunId , { status } )
471+ . catch ( ( err ) =>
472+ log . warn ( "Failed to update task run status on disconnect" , { err } ) ,
473+ ) ;
474+ }
475+
460476 try {
461477 await trpcVanilla . agent . cancel . mutate ( {
462478 sessionId : session . taskRunId ,
@@ -674,6 +690,20 @@ export class SessionService {
674690 notifyPromptComplete ( session . taskTitle , stopReason ) ;
675691 }
676692
693+ // Update remote task run status when agent turn completes with no pending work
694+ if ( session . messageQueue . length === 0 ) {
695+ const auth = useAuthStore . getState ( ) ;
696+ if ( auth . client ) {
697+ auth . client
698+ . updateTaskRun ( session . taskId , taskRunId , { status : "completed" } )
699+ . catch ( ( err ) =>
700+ log . warn ( "Failed to update task run status to completed" , {
701+ err,
702+ } ) ,
703+ ) ;
704+ }
705+ }
706+
677707 // Process queued messages after turn completes - send all as one prompt
678708 if ( session . messageQueue . length > 0 && session . status === "connected" ) {
679709 setTimeout ( ( ) => {
@@ -896,6 +926,16 @@ export class SessionService {
896926 promptStartedAt : Date . now ( ) ,
897927 } ) ;
898928
929+ // Ensure task run status reflects active work
930+ const auth = useAuthStore . getState ( ) ;
931+ if ( auth . client ) {
932+ auth . client
933+ . updateTaskRun ( session . taskId , session . taskRunId , {
934+ status : "in_progress" ,
935+ } )
936+ . catch ( ( err ) => log . warn ( "Failed to update task run status" , { err } ) ) ;
937+ }
938+
899939 try {
900940 const result = await trpcVanilla . agent . prompt . mutate ( {
901941 sessionId : session . taskRunId ,
0 commit comments