Skip to content

Commit d38018c

Browse files
authored
Adding logs to chat sessions provider (#7761)
1 parent 59ecc74 commit d38018c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/github/copilotPrWatcher.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { debounce } from '../common/async';
88
import { COPILOT_ACCOUNTS } from '../common/comment';
99
import { COPILOT_LOGINS, copilotEventToStatus, CopilotPRStatus } from '../common/copilot';
1010
import { Disposable } from '../common/lifecycle';
11+
import Logger from '../common/logger';
1112
import { PR_SETTINGS_NAMESPACE, QUERIES } from '../common/settingKeys';
1213
import { FolderRepositoryManager } from './folderRepositoryManager';
1314
import { PRType } from './interface';
@@ -26,6 +27,7 @@ export interface CodingAgentPRAndStatus {
2627
}
2728

2829
export class CopilotStateModel extends Disposable {
30+
public static ID = 'CopilotStateModel';
2931
private _isInitialized = false;
3032
private readonly _states: Map<string, CodingAgentPRAndStatus> = new Map();
3133
private readonly _showNotification: Set<string> = new Set();
@@ -295,6 +297,7 @@ export class CopilotPRWatcher extends Disposable {
295297
this._model.set(changes);
296298
if (!this._model.isInitialized) {
297299
if ((initialized === this._reposManager.folderManagers.length) && (this._reposManager.folderManagers.length > 0)) {
300+
Logger.debug(`Copilot PR state initialized with ${this._model.keys().length} PRs`, CopilotStateModel.ID);
298301
this._model.setInitialized();
299302
}
300303
return true;

src/github/copilotRemoteAgent.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,7 @@ export class CopilotRemoteAgentManager extends Disposable {
862862
let codingAgentPRs: CodingAgentPRAndStatus[] = [];
863863
if (this._stateModel.isInitialized) {
864864
codingAgentPRs = this._stateModel.all;
865+
Logger.debug(`Fetched PRs from state model: ${codingAgentPRs.length}`, CopilotRemoteAgentManager.ID);
865866
} else {
866867
this.codingAgentPRsPromise = this.codingAgentPRsPromise ?? new Promise<CodingAgentPRAndStatus[]>(async (resolve) => {
867868
try {
@@ -879,6 +880,7 @@ export class CopilotRemoteAgentManager extends Disposable {
879880
}
880881
});
881882
codingAgentPRs = await this.codingAgentPRsPromise;
883+
Logger.debug(`Fetched PRs from API: ${codingAgentPRs.length}`, CopilotRemoteAgentManager.ID);
882884
}
883885
return await Promise.all(codingAgentPRs.map(async prAndStatus => {
884886
const timestampNumber = new Date(prAndStatus.item.createdAt).getTime();
@@ -907,6 +909,8 @@ export class CopilotRemoteAgentManager extends Disposable {
907909
}));
908910
} catch (error) {
909911
Logger.error(`Failed to provide coding agents information: ${error}`, CopilotRemoteAgentManager.ID);
912+
} finally {
913+
this.codingAgentPRsPromise = undefined;
910914
}
911915
return [];
912916
}

0 commit comments

Comments
 (0)