sessions - allow to collapse section headers (#303228)

This commit is contained in:
Benjamin Pasero
2026-03-19 18:27:16 +01:00
committed by GitHub
parent b7ba4a7e04
commit 970e6fb2ba
4 changed files with 37 additions and 2 deletions
@@ -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);
@@ -171,6 +171,8 @@ export interface IAgentSessionsControl {
clearFocus(): void;
hasFocusOrSelection(): boolean;
collapseAllSections(): void;
}
export const agentSessionReadIndicatorForeground = registerColor(
@@ -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<void> {
control?.collapseAllSections();
}
}
//#endregion
//#region Session Actions
@@ -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<void> {
return this.updateSessionsListThrottler.queue(async () => {
await this.sessionsList?.updateChildren();