From fde52a5db2a59d399fc0feb7360940489e306bad Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 25 Nov 2025 21:23:48 +0100 Subject: [PATCH] agent sessions - filter empty chats in the view pane, not globally (#279434) * agent sessions - filter empty chats in the view pane, not globally This fixes an issue where we no longer track progress per session. * ci --- .../localAgentSessionsProvider.ts | 13 ++++------- .../contrib/chat/browser/chatViewPane.ts | 13 +++++++++++ .../localAgentSessionsProvider.test.ts | 23 ------------------- 3 files changed, 17 insertions(+), 32 deletions(-) diff --git a/src/vs/workbench/contrib/chat/browser/agentSessions/localAgentSessionsProvider.ts b/src/vs/workbench/contrib/chat/browser/agentSessions/localAgentSessionsProvider.ts index 0e30aa5f30f..0417764c485 100644 --- a/src/vs/workbench/contrib/chat/browser/agentSessions/localAgentSessionsProvider.ts +++ b/src/vs/workbench/contrib/chat/browser/agentSessions/localAgentSessionsProvider.ts @@ -2,7 +2,6 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { coalesce } from '../../../../../base/common/arrays.js'; import { CancellationToken } from '../../../../../base/common/cancellation.js'; import { Codicon } from '../../../../../base/common/codicons.js'; import { Emitter } from '../../../../../base/common/event.js'; @@ -149,7 +148,7 @@ export class LocalAgentsSessionsProvider extends Disposable implements IChatSess if (!token.isCancellationRequested) { const history = await this.getHistoryItems(); - sessions.push(...history.filter(h => !sessionsByResource.has(h.resource))); + sessions.push(...history.filter(historyItem => !sessionsByResource.has(historyItem.resource))); } return sessions; @@ -157,24 +156,20 @@ export class LocalAgentsSessionsProvider extends Disposable implements IChatSess private async getHistoryItems(): Promise { try { - const allHistory = await this.chatService.getHistorySessionItems(); - return coalesce(allHistory.map(history => this.toChatSessionItem(history))); + const historyItems = await this.chatService.getHistorySessionItems(); + return historyItems.map(history => this.toChatSessionItem(history)); } catch (error) { return []; } } - private toChatSessionItem(chat: IChatDetail): ChatSessionItemWithProvider | undefined { + private toChatSessionItem(chat: IChatDetail): ChatSessionItemWithProvider { const model = this.chatService.getSession(chat.sessionResource); let description: string | undefined; let startTime: number | undefined; let endTime: number | undefined; if (model) { - if (!model.hasRequests) { - return undefined; // ignore sessions without requests - } - const lastResponse = model.getRequests().at(-1)?.response; description = this.chatSessionsService.getSessionDescription(model); diff --git a/src/vs/workbench/contrib/chat/browser/chatViewPane.ts b/src/vs/workbench/contrib/chat/browser/chatViewPane.ts index e4a0335a721..e8406f1f763 100644 --- a/src/vs/workbench/contrib/chat/browser/chatViewPane.ts +++ b/src/vs/workbench/contrib/chat/browser/chatViewPane.ts @@ -45,6 +45,7 @@ import { localize } from '../../../../nls.js'; import { ChatViewWelcomeController, IViewWelcomeDelegate } from './viewsWelcome/chatViewWelcomeController.js'; import { AgentSessionsControl } from './agentSessions/agentSessionsControl.js'; import { ICommandService } from '../../../../platform/commands/common/commands.js'; +import { Event } from '../../../../base/common/event.js'; interface IChatViewPaneState extends Partial { sessionId?: string; @@ -253,11 +254,23 @@ export class ChatViewPane extends ViewPane implements IViewWelcomeDelegate { } private createSessionsControl(parent: HTMLElement): void { + const that = this; // Sessions Control this.sessionsContainer = parent.appendChild($('.agent-sessions-container')); this.sessionsControl = this._register(this.instantiationService.createInstance(AgentSessionsControl, this.sessionsContainer, { allowOpenSessionsInPanel: true, + filter: { + onDidChange: Event.None, + exclude(session) { + const model = that.chatService.getSession(session.resource); + if (model && !model.hasRequests) { + return true; // exclude sessions without requests + } + + return false; + }, + } })); // Link to Sessions View diff --git a/src/vs/workbench/contrib/chat/test/browser/localAgentSessionsProvider.test.ts b/src/vs/workbench/contrib/chat/test/browser/localAgentSessionsProvider.test.ts index afb3accda0e..f59e409182c 100644 --- a/src/vs/workbench/contrib/chat/test/browser/localAgentSessionsProvider.test.ts +++ b/src/vs/workbench/contrib/chat/test/browser/localAgentSessionsProvider.test.ts @@ -367,29 +367,6 @@ suite('LocalAgentsSessionsProvider', () => { }); }); - test('should ignore sessions without requests', async () => { - return runWithFakedTimers({}, async () => { - const provider = createProvider(); - - const sessionResource = LocalChatSessionUri.forSession('empty-session'); - const mockModel = createMockChatModel({ - sessionResource, - hasRequests: false - }); - - mockChatService.addSession(sessionResource, mockModel); - mockChatService.setLiveSessionItems([{ - sessionResource, - title: 'Empty Session', - lastMessageDate: Date.now(), - isActive: true - }]); - - const sessions = await provider.provideChatSessionItems(CancellationToken.None); - assert.strictEqual(sessions.length, 0); - }); - }); - test('should provide history session items', async () => { return runWithFakedTimers({}, async () => { const provider = createProvider();