Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { IBaseActionViewItemOptions } from '../../../../../../base/browser/ui/ac
import { ITreeContextMenuEvent } from '../../../../../../base/browser/ui/tree/tree.js';
import { Action, IAction } from '../../../../../../base/common/actions.js';
import { coalesce } from '../../../../../../base/common/arrays.js';
import { DisposableStore } from '../../../../../../base/common/lifecycle.js';
import { Codicon } from '../../../../../../base/common/codicons.js';
import { FuzzyScore } from '../../../../../../base/common/filters.js';
import { MarshalledId } from '../../../../../../base/common/marshallingIds.js';
Expand Down Expand Up @@ -74,6 +75,7 @@ export class SessionsViewPane extends ViewPane {
private treeContainer: HTMLElement | undefined;
private messageElement?: HTMLElement;
private _isEmpty: boolean = true;
private readonly _dropdownDisposables = this._register(new DisposableStore());

constructor(
private readonly provider: IChatSessionItemProvider,
Expand Down Expand Up @@ -137,13 +139,17 @@ export class SessionsViewPane extends ViewPane {
}

private getChatSessionDropdown(defaultAction: IAction, options: IBaseActionViewItemOptions) {
// Clear previous disposables to avoid leaks when action view items are recreated
this._dropdownDisposables.clear();

const primaryAction = this.instantiationService.createInstance(MenuItemAction, {
id: defaultAction.id,
title: defaultAction.label,
icon: Codicon.plus,
}, undefined, undefined, undefined, undefined);

const menu = this.menuService.createMenu(MenuId.ChatSessionsMenu, this.scopedContextKeyService);
this._dropdownDisposables.add(menu);

const actions = menu.getActions({ shouldForwardArgs: true });
const primaryActions = getActionBarActions(
Expand Down Expand Up @@ -171,6 +177,7 @@ export class SessionsViewPane extends ViewPane {
'codicon-chevron-down',
true
);
this._dropdownDisposables.add(dropdownAction);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can dropdownAction be converted to use toAction instead? That version of IAction isn't disposable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated


const dropdownActions: IAction[] = [];

Expand Down
Loading