Skip to content

Commit 3af7905

Browse files
authored
Merge pull request #2462 from microsoft/osortega/fix-cloud-cache
Fix for cached cloud sessions
2 parents 3c34714 + c638e35 commit 3af7905

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/extension/chatSessions/vscode-node/copilotCloudSessionsProvider.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,14 +328,25 @@ export class CopilotCloudSessionsProvider extends Disposable implements vscode.C
328328
}
329329
}
330330

331-
async provideChatSessionItems(token: vscode.CancellationToken): Promise<vscode.ChatSessionItem[]> {
332-
// Return cached items if available
333-
if (this.cachedSessionItems) {
331+
private async overrideWithCache(): Promise<vscode.ChatSessionItem[] | undefined> {
332+
// Return cache only if is already being tracked
333+
if (this.cachedSessionItems && this.activeSessionIds.size > 0) {
334334
return this.cachedSessionItems;
335335
}
336336

337+
// Multiple calls should return the same promise as long as it's pending
337338
if (this.chatSessionItemsPromise) {
338-
return this.chatSessionItemsPromise;
339+
return await this.chatSessionItemsPromise;
340+
}
341+
342+
// No cache, refresh
343+
return undefined;
344+
}
345+
346+
async provideChatSessionItems(token: vscode.CancellationToken): Promise<vscode.ChatSessionItem[]> {
347+
const cache = await this.overrideWithCache();
348+
if (cache) {
349+
return cache;
339350
}
340351
this.chatSessionItemsPromise = (async () => {
341352
const repoId = await getRepoId(this._gitService);

0 commit comments

Comments
 (0)