From 970e6fb2ba4c4e8fb82fa24b0bb20b03ba4a3dd6 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 19 Mar 2026 18:27:16 +0100 Subject: [PATCH] sessions - allow to collapse section headers (#303228) --- .../agentSessions.contribution.ts | 3 ++- .../browser/agentSessions/agentSessions.ts | 2 ++ .../agentSessions/agentSessionsActions.ts | 19 +++++++++++++++++++ .../agentSessions/agentSessionsControl.ts | 15 ++++++++++++++- 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessions.contribution.ts b/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessions.contribution.ts index 4000cefb73b..61ef7f44865 100644 --- a/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessions.contribution.ts +++ b/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessions.contribution.ts @@ -16,7 +16,7 @@ import { IAgentSessionsService, AgentSessionsService } from './agentSessionsServ import { LocalAgentsSessionsController } from './localAgentSessionsController.js'; import { registerWorkbenchContribution2, WorkbenchPhase } from '../../../../common/contributions.js'; import { ISubmenuItem, MenuId, MenuRegistry, registerAction2 } from '../../../../../platform/actions/common/actions.js'; -import { ArchiveAgentSessionAction, ArchiveAgentSessionSectionAction, UnarchiveAgentSessionAction, OpenAgentSessionInEditorGroupAction, OpenAgentSessionInNewEditorGroupAction, OpenAgentSessionInNewWindowAction, ShowAgentSessionsSidebar, HideAgentSessionsSidebar, ToggleAgentSessionsSidebar, RefreshAgentSessionsViewerAction, FindAgentSessionInViewerAction, MarkAgentSessionUnreadAction, MarkAgentSessionReadAction, FocusAgentSessionsAction, SetAgentSessionsOrientationStackedAction, SetAgentSessionsOrientationSideBySideAction, PickAgentSessionAction, ArchiveAllAgentSessionsAction, MarkAllAgentSessionsReadAction, RenameAgentSessionAction, DeleteAgentSessionAction, DeleteAllLocalSessionsAction, MarkAgentSessionSectionReadAction, ToggleShowAgentSessionsAction, UnarchiveAgentSessionSectionAction, PinAgentSessionAction, UnpinAgentSessionAction } from './agentSessionsActions.js'; +import { ArchiveAgentSessionAction, ArchiveAgentSessionSectionAction, UnarchiveAgentSessionAction, OpenAgentSessionInEditorGroupAction, OpenAgentSessionInNewEditorGroupAction, OpenAgentSessionInNewWindowAction, ShowAgentSessionsSidebar, HideAgentSessionsSidebar, ToggleAgentSessionsSidebar, RefreshAgentSessionsViewerAction, FindAgentSessionInViewerAction, MarkAgentSessionUnreadAction, MarkAgentSessionReadAction, FocusAgentSessionsAction, SetAgentSessionsOrientationStackedAction, SetAgentSessionsOrientationSideBySideAction, PickAgentSessionAction, ArchiveAllAgentSessionsAction, MarkAllAgentSessionsReadAction, RenameAgentSessionAction, DeleteAgentSessionAction, DeleteAllLocalSessionsAction, MarkAgentSessionSectionReadAction, ToggleShowAgentSessionsAction, UnarchiveAgentSessionSectionAction, PinAgentSessionAction, UnpinAgentSessionAction, CollapseAllAgentSessionSectionsAction } from './agentSessionsActions.js'; import { AgentSessionsQuickAccessProvider, AGENT_SESSIONS_QUICK_ACCESS_PREFIX } from './agentSessionsQuickAccess.js'; //#region Actions and Menus @@ -28,6 +28,7 @@ registerAction2(MarkAllAgentSessionsReadAction); registerAction2(ArchiveAgentSessionSectionAction); registerAction2(UnarchiveAgentSessionSectionAction); registerAction2(MarkAgentSessionSectionReadAction); +registerAction2(CollapseAllAgentSessionSectionsAction); registerAction2(ArchiveAgentSessionAction); registerAction2(UnarchiveAgentSessionAction); registerAction2(PinAgentSessionAction); diff --git a/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessions.ts b/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessions.ts index f01ebe74835..b8b3f9f8373 100644 --- a/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessions.ts +++ b/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessions.ts @@ -171,6 +171,8 @@ export interface IAgentSessionsControl { clearFocus(): void; hasFocusOrSelection(): boolean; + + collapseAllSections(): void; } export const agentSessionReadIndicatorForeground = registerColor( diff --git a/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsActions.ts b/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsActions.ts index c7d0360d000..b501f0a66ba 100644 --- a/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsActions.ts +++ b/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsActions.ts @@ -365,6 +365,25 @@ export class MarkAgentSessionSectionReadAction extends Action2 { } } +export class CollapseAllAgentSessionSectionsAction extends Action2 { + + constructor() { + super({ + id: 'agentSessionSection.collapseAll', + title: localize2('collapseAll', "Collapse All"), + menu: [{ + id: MenuId.AgentSessionSectionContext, + group: '2_collapse', + order: 1, + }] + }); + } + + async run(accessor: ServicesAccessor, _section: unknown, control?: IAgentSessionsControl): Promise { + control?.collapseAllSections(); + } +} + //#endregion //#region Session Actions diff --git a/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsControl.ts b/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsControl.ts index 1130ad7925e..388a65c72a0 100644 --- a/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsControl.ts +++ b/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsControl.ts @@ -421,7 +421,7 @@ export class AgentSessionsControl extends Disposable implements IAgentSessionsCo this.contextMenuService.showContextMenu({ getActions: () => Separator.join(...menu.getActions({ arg: section, shouldForwardArgs: true }).map(([, actions]) => actions)), getAnchor: () => anchor, - getActionsContext: () => section, + getActionsContext: () => this, }); menu.dispose(); @@ -509,6 +509,19 @@ export class AgentSessionsControl extends Disposable implements IAgentSessionsCo return this.agentSessionsService.model.resolve(undefined); } + collapseAllSections(): void { + if (!this.sessionsList) { + return; + } + + const model = this.agentSessionsService.model; + for (const child of this.sessionsList.getNode(model).children) { + if (isAgentSessionSection(child.element) && !child.collapsed) { + this.sessionsList.collapse(child.element); + } + } + } + async update(): Promise { return this.updateSessionsListThrottler.queue(async () => { await this.sessionsList?.updateChildren();