Skip to content

Commit 339c446

Browse files
authored
Adding icons to chat sessions (#7394)
1 parent 9202ded commit 339c446

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

src/github/copilotRemoteAgent.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import vscode from 'vscode';
6+
import vscode, { ThemeIcon } from 'vscode';
77
import { Repository } from '../api/api';
8-
import { COPILOT_LOGINS, CopilotPRStatus } from '../common/copilot';
8+
import { COPILOT_LOGINS, copilotEventToStatus, CopilotPRStatus, mostRecentCopilotEvent } from '../common/copilot';
99
import { commands } from '../common/executeCommands';
1010
import { Disposable } from '../common/lifecycle';
1111
import Logger from '../common/logger';
@@ -738,17 +738,37 @@ export class CopilotRemoteAgentManager extends Disposable {
738738
}
739739

740740
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+
}
742751
return {
743752
id: `${session.id}`,
744753
label: session.title || `Session ${session.id}`,
745-
iconPath: undefined,
754+
iconPath: this.getIconForSession(status),
746755
pullRequest: session
747756
};
748-
});
757+
}));
749758
} catch (error) {
750759
Logger.error(`Failed to provide coding agents information: ${error}`, CopilotRemoteAgentManager.ID);
751760
}
752761
return [];
753762
}
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+
}
754774
}

0 commit comments

Comments
 (0)