Description
Opening a context menu in the Agents Window sessions list can produce [LEAKED DISPOSABLE] warnings for transient Action instances.
The first observed warning points to SessionsList.getCreateGroupAction, but the same context-menu code path creates several other Action instances with no owner.
Reproduction steps
- Run a Code OSS development build with disposable leak tracking enabled.
- Open the Agents Window.
- Open a sessions-list context menu, such as by right-clicking a session row, group header, or empty list area.
- Dismiss the menu and allow or force garbage collection.
Expected behavior
All context-menu actions are either non-disposable values or are disposed when the menu closes.
Actual behavior
The disposable tracker reports an Action that was garbage-collected without being disposed:
[LEAKED DISPOSABLE] Error: CREATED via:
at GCBasedDisposableTracker.trackDisposable (...)
at trackDisposable (...)
at new Disposable (...)
at new Action (...)
at SessionsList.getCreateGroupAction (.../sessionsList.js:2250:12)
at SessionsList.getGroupSessionActions (.../sessionsList.js:2229:23)
at Object.getActions (.../sessionsList.js:2211:35)
at ContextMenuHandler.showContextMenu (...)
at ContextMenuService.showContextMenu (...)
at SessionsList.onContextMenu (...)
Root cause
Confirmed: Action extends Disposable, while SessionsList creates short-lived actions inside context-menu delegates without registering or disposing them.
Affected code is in src/vs/sessions/contrib/sessions/browser/views/sessionsList.ts, including:
getCreateGroupAction
- Add/Move to Group submenu actions
- Remove from Group
- Rename Group
- Delete Group
- Extension-command wrapper actions created in
onContextMenu
The issue is present at commit cbec6fc64b5adf3dcba6abb102f0a05772f2e878.
Possible implementation direction
These actions do not need mutable state or change events. Replace the transient new Action(...) instances with the lighter-weight, non-disposable toAction(...) helper. Alternatively, explicitly own all created actions in a menu-scoped DisposableStore and dispose it from onHide.
Add coverage that opens and closes each sessions-list context-menu variant under disposable leak tracking.
Description
Opening a context menu in the Agents Window sessions list can produce
[LEAKED DISPOSABLE]warnings for transientActioninstances.The first observed warning points to
SessionsList.getCreateGroupAction, but the same context-menu code path creates several otherActioninstances with no owner.Reproduction steps
Expected behavior
All context-menu actions are either non-disposable values or are disposed when the menu closes.
Actual behavior
The disposable tracker reports an
Actionthat was garbage-collected without being disposed:Root cause
Confirmed:
ActionextendsDisposable, whileSessionsListcreates short-lived actions inside context-menu delegates without registering or disposing them.Affected code is in
src/vs/sessions/contrib/sessions/browser/views/sessionsList.ts, including:getCreateGroupActiononContextMenuThe issue is present at commit
cbec6fc64b5adf3dcba6abb102f0a05772f2e878.Possible implementation direction
These actions do not need mutable state or change events. Replace the transient
new Action(...)instances with the lighter-weight, non-disposabletoAction(...)helper. Alternatively, explicitly own all created actions in a menu-scopedDisposableStoreand dispose it fromonHide.Add coverage that opens and closes each sessions-list context-menu variant under disposable leak tracking.