3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
- import vscode from 'vscode' ;
6
+ import vscode , { ThemeIcon } from 'vscode' ;
7
7
import { Repository } from '../api/api' ;
8
- import { COPILOT_LOGINS , CopilotPRStatus } from '../common/copilot' ;
8
+ import { COPILOT_LOGINS , copilotEventToStatus , CopilotPRStatus , mostRecentCopilotEvent } from '../common/copilot' ;
9
9
import { commands } from '../common/executeCommands' ;
10
10
import { Disposable } from '../common/lifecycle' ;
11
11
import Logger from '../common/logger' ;
@@ -738,17 +738,37 @@ export class CopilotRemoteAgentManager extends Disposable {
738
738
}
739
739
740
740
const sessions = await capi . getAllCodingAgentPRs ( this . repositoriesManager ) ;
741
- return sessions . map ( session => {
741
+ return await Promise . all ( sessions . map ( async session => {
742
+ const timeline = await session . getTimelineEvents ( session ) ;
743
+ const status = copilotEventToStatus ( mostRecentCopilotEvent ( timeline ) ) ;
744
+ if ( status !== CopilotPRStatus . Completed && status !== CopilotPRStatus . Failed ) {
745
+ const disposable = session . onDidChange ( ( ) => {
746
+ this . _onDidChangeChatSessions . fire ( ) ;
747
+ disposable . dispose ( ) ; // Clean up listener after firing
748
+ } ) ;
749
+ this . _register ( disposable ) ;
750
+ }
742
751
return {
743
752
id : `${ session . id } ` ,
744
753
label : session . title || `Session ${ session . id } ` ,
745
- iconPath : undefined ,
754
+ iconPath : this . getIconForSession ( status ) ,
746
755
pullRequest : session
747
756
} ;
748
- } ) ;
757
+ } ) ) ;
749
758
} catch ( error ) {
750
759
Logger . error ( `Failed to provide coding agents information: ${ error } ` , CopilotRemoteAgentManager . ID ) ;
751
760
}
752
761
return [ ] ;
753
762
}
763
+
764
+ private getIconForSession ( status : CopilotPRStatus ) : ThemeIcon {
765
+ switch ( status ) {
766
+ case CopilotPRStatus . Completed :
767
+ return new ThemeIcon ( 'pass-filled' , new vscode . ThemeColor ( 'testing.iconPassed' ) ) ;
768
+ case CopilotPRStatus . Failed :
769
+ return new ThemeIcon ( 'close' , new vscode . ThemeColor ( 'testing.iconFailed' ) ) ;
770
+ default :
771
+ return new ThemeIcon ( 'circle-filled' , new vscode . ThemeColor ( 'list.warningForeground' ) ) ;
772
+ }
773
+ }
754
774
}
0 commit comments