sessions: fix multi-select context menu to operate on all selected items#306332
sessions: fix multi-select context menu to operate on all selected items#306332
Conversation
Context menu actions in the sessions list previously only operated on the right-clicked item, ignoring other selected items. Now the context menu collects the tree selection and passes all selected sessions to actions. Changes: - sessionsList.ts: Pass selected sessions array as arg to context menu actions - sessionsViewActions.ts: Update all 7 item actions to accept ISession | ISession[] - copilotChatSessionsActions.ts: Update bridge commands to handle session arrays Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes multi-select behavior in the Agent Sessions list context menu so actions apply to all selected sessions (instead of only the right-clicked row), including Copilot-bridged menu items.
Changes:
- Update sessions list context menu to pass the full selected session set as the menu argument.
- Update session item actions (pin/archive/read/open) to accept
ISession | ISession[]and iterate over all sessions. - Update Copilot context menu bridge commands to support
ISession[]by resolving and marshalling multiple agent sessions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/vs/sessions/contrib/sessions/browser/views/sessionsViewActions.ts | Session item actions now accept single-or-array context and apply operations across the selection. |
| src/vs/sessions/contrib/sessions/browser/views/sessionsList.ts | Context menu now derives and forwards the current multi-selection (filtered to session items). |
| src/vs/sessions/contrib/copilotChatSessions/browser/copilotChatSessionsActions.ts | Copilot context menu bridge wrapper commands now handle array context and marshal multiple agent sessions. |
| } | ||
|
|
||
| const selection = this.tree.getSelection().filter((s): s is ISession => !!s && !isSessionSection(s) && !isSessionShowMore(s)); | ||
| const selectedSessions = selection.includes(element) ? selection : [element]; |
There was a problem hiding this comment.
When multi-selecting, selectedSessions uses the tree selection array as-is. That array’s order isn’t guaranteed to have the right-clicked element first, but downstream commands often treat the first item as the “primary”/clicked item. Consider ensuring element is first (e.g., [element, ...selection.filter(s => s !== element)]) or passing a structured context that preserves both the clicked item and the full selection.
| const selectedSessions = selection.includes(element) ? selection : [element]; | |
| const selectedSessions = selection.includes(element) ? [element, ...selection.filter(s => s !== element)] : [element]; |
src/vs/sessions/contrib/copilotChatSessions/browser/copilotChatSessionsActions.ts
Show resolved
Hide resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Context menu actions in the sessions list only operated on the right-clicked item, ignoring other selected items in a multi-selection.
Changes
sessionsList.tsgetSelection()and filter toISessionitemsargto context menu actionssessionsViewActions.tsISession | ISession[]and iterate over all provided sessionscopilotChatSessionsActions.tsCopilotSessionContextMenuBridgewrapper commands to handleISession[]— resolves all sessions to agent sessions and passes them in the marshalled context