@@ -432,7 +432,6 @@ export class CopilotRemoteAgentManager extends Disposable {
432432 outcome : 'success'
433433 } ) ;
434434
435- this . _onDidChangeChatSessions . fire ( ) ;
436435 const viewLocationSetting = vscode . workspace . getConfiguration ( 'chat' ) . get ( 'agentSessionsViewLocation' ) ;
437436 const pr = await ( async ( ) => {
438437 const capi = await this . copilotApi ;
@@ -696,13 +695,6 @@ export class CopilotRemoteAgentManager extends Disposable {
696695 return await Promise . all ( codingAgentPRs . map ( async session => {
697696 const timeline = await session . getCopilotTimelineEvents ( session ) ;
698697 const status = copilotEventToStatus ( mostRecentCopilotEvent ( timeline ) ) ;
699- if ( status !== CopilotPRStatus . Completed && status !== CopilotPRStatus . Failed ) {
700- const disposable = session . onDidChange ( ( ) => {
701- this . _onDidChangeChatSessions . fire ( ) ;
702- disposable . dispose ( ) ; // Clean up listener after firing
703- } ) ;
704- this . _register ( disposable ) ;
705- }
706698 const tooltip = await issueMarkdown ( session , this . context , this . repositoriesManager ) ;
707699 return {
708700 id : `${ session . number } ` ,
@@ -897,6 +889,7 @@ export class CopilotRemoteAgentManager extends Disposable {
897889 return new Promise < void > ( ( resolve , reject ) => {
898890 let cancellationListener : vscode . Disposable | undefined ;
899891 let isCompleted = false ;
892+ let previous_state : SessionInfo [ 'state' ] | undefined ;
900893
901894 const complete = async ( ) => {
902895 if ( isCompleted ) {
@@ -948,6 +941,10 @@ export class CopilotRemoteAgentManager extends Disposable {
948941 // Get session logs
949942 const logs = await capi . getLogsFromSession ( sessionId ) ;
950943
944+ if ( previous_state !== sessionInfo . state ) {
945+ this . refreshChatSessions ( ) ;
946+ }
947+ previous_state = sessionInfo . state ;
951948 // Check if session is still in progress
952949 if ( sessionInfo . state !== 'in_progress' ) {
953950 if ( logs . length > lastProcessedLength ) {
0 commit comments