Skip to content

Agents sessions context menus leak transient Action instances #330628

Description

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

  1. Run a Code OSS development build with disposable leak tracking enabled.
  2. Open the Agents Window.
  3. Open a sessions-list context menu, such as by right-clicking a session row, group header, or empty list area.
  4. 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.

Metadata

Metadata

Labels

freeze-slow-crash-leakVS Code crashing, performance, freeze and memory leak issues

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions