Skip to content

sessions: fix multi-select context menu to operate on all selected items#306332

Merged
sandy081 merged 2 commits intomainfrom
copilot/courageous-gerbil
Mar 30, 2026
Merged

sessions: fix multi-select context menu to operate on all selected items#306332
sandy081 merged 2 commits intomainfrom
copilot/courageous-gerbil

Conversation

@sandy081
Copy link
Copy Markdown
Member

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.ts

  • Collect tree selection via getSelection() and filter to ISession items
  • Pass the full selected sessions array (or just the clicked item if not part of selection) as the arg to context menu actions

sessionsViewActions.ts

  • Update all 7 session item actions (Pin, Unpin, Archive, Unarchive, Mark Read, Mark Unread, Open in New Window) to accept ISession | ISession[] and iterate over all provided sessions

copilotChatSessionsActions.ts

  • Update CopilotSessionContextMenuBridge wrapper commands to handle ISession[] — resolves all sessions to agent sessions and passes them in the marshalled context

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>
Copilot AI review requested due to automatic review settings March 30, 2026 13:00
@vs-code-engineering vs-code-engineering bot added this to the Backlog milestone Mar 30, 2026
bpasero
bpasero previously approved these changes Mar 30, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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];
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
const selectedSessions = selection.includes(element) ? selection : [element];
const selectedSessions = selection.includes(element) ? [element, ...selection.filter(s => s !== element)] : [element];

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sandy081 sandy081 merged commit 64e73b0 into main Mar 30, 2026
18 checks passed
@sandy081 sandy081 deleted the copilot/courageous-gerbil branch March 30, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants