Skip to content

sessions: focus by number, reveal clipped sessions, close all - #319335

Merged
Sandeep Somavarapu (sandy081) merged 1 commit into
mainfrom
sessions/focus-reveal-close-all
Jun 1, 2026
Merged

Sandeep Somavarapu (sandy081) merged 1 commit into
mainfrom
sessions/focus-reveal-close-all

Conversation

@sandy081

Copy link
Copy Markdown
Member

What

Adds keyboard navigation and bulk close support to the Agents/sessions grid:

  • Focus session by position: Cmd/Ctrl+1..Cmd/Ctrl+9 focus the Nth session in the grid (left-to-right order). Each is also available in the Command Palette.
  • Reveal clipped sessions: When focusing a session that is partially or fully scrolled out of view (the grid overflows horizontally once sessions no longer fit), the grid now scrolls it into view via scrollIntoView.
  • Close All Sessions: New sessions.closeAllSessions command bound to Cmd/Ctrl+K Cmd/Ctrl+W (same chord as Close All Editors). The keybinding only fires while a session is focused; the command remains visible in the Command Palette.

Why

These bring familiar editor-style keyboard ergonomics (focus-by-number, close-all) to the sessions window and fix a usability issue where focusing an off-screen session left it clipped.

Notes for reviewers

  • SessionsFocusContext (sessionsFocus) was previously bound but never updated. It is now driven by a trackFocus on the content area.
  • Gotcha: the Command Palette filters by precondition/action.enabled. Opening the palette moves focus out of the sessions window, flipping sessionsFocus to false. So the focus requirement is on the keybinding when clause (evaluated at keypress, while focus is still in the session), not the precondition. The precondition is IsSessionsWindowContext only, keeping the command visible in the palette.

Co-authored-by: Copilot [email protected]

Copilot AI review requested due to automatic review settings June 1, 2026 13:44
@vs-code-engineering

vs-code-engineering Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Ladislau Szomoru (@lszomoru)

Matched files:

  • src/vs/sessions/services/sessions/browser/sessionsManagementService.ts
  • src/vs/sessions/services/sessions/common/sessionsManagement.ts
  • src/vs/sessions/services/sessions/test/browser/sessionNavigation.test.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds editor-like keyboard ergonomics to the Agents/sessions grid (focus-by-number, close-all) and improves usability by ensuring newly focused sessions are scrolled into view. It also introduces a management-layer background send option to keep the UI on the new-session view while starting a session.

Changes:

  • Adds Cmd/Ctrl+1..9 actions to focus sessions by position in the sessions grid.
  • Reveals partially clipped session views when focusing (via scrollIntoView) and wires sessionsFocus to actual focus state.
  • Introduces sessions.closeAllSessions (with Cmd/Ctrl+K Cmd/Ctrl+W when a session has focus) and adds closeAllSessions() to the sessions management service API.
Show a summary per file
File Description
src/vs/sessions/services/sessions/test/browser/sessionNavigation.test.ts Updates mock service surface to include closeAllSessions().
src/vs/sessions/services/sessions/common/sessionsManagement.ts Introduces management-layer ISendRequestOptions (incl. background) and adds closeAllSessions() to the service interface.
src/vs/sessions/services/sessions/browser/sessionsManagementService.ts Implements background send flow and closeAllSessions() in the concrete management service.
src/vs/sessions/contrib/sessions/browser/sessionsActions.ts Registers focus-by-number actions and the new “Close All Sessions” command + keybinding.
src/vs/sessions/browser/parts/sessionsPartService.ts Routes focus requests through SessionsPart.focusSession(...) (now reveals before focusing).
src/vs/sessions/browser/parts/sessionsPart.ts Tracks focus to drive sessionsFocus and reveals clipped session views before focusing.

Copilot's findings

Comments suppressed due to low confidence (4)

src/vs/sessions/services/sessions/browser/sessionsManagementService.ts:533

  • ISendRequestOptions extends provider options with management-only fields (background). Even in the non-background path, forwarding the full object means management-only fields (e.g. background: false) can leak to providers. Strip management-only fields before calling the provider APIs here as well.
			// Ask the provider to create the new chat; open its widget before sending
			const chat = await provider.createNewChat(session.sessionId, options.query);
			// Swap in a transient session whose resource is the new chat
			// resource, so the grid slot reflects the chat that is about to
			// be sent before the provider hands us the final session.

src/vs/sessions/services/sessions/browser/sessionsManagementService.ts:566

  • ISendRequestOptions now includes management-only fields like background, but sendRequest forwards the full object to the provider. Strip management-only fields before passing options through to provider.sendRequest(...).
		// Keep the sent chat as the active chat.
		this._visibility.setActiveChat(session, chat);

		const provider = this._getProvider(session);
		if (!provider) {
			throw new Error(`Sessions provider '${session.providerId}' not found`);
		}

		const updatedSession = await provider.sendRequest(session.sessionId, chat.resource, options);

src/vs/sessions/services/sessions/browser/sessionsManagementService.ts:533

  • ISendRequestOptions extends provider options with management-only fields (background). Even in the non-background path, forwarding the full object means management-only fields (e.g. background: false) can leak to providers. Strip management-only fields before calling the provider APIs here as well.
			// Ask the provider to create the new chat; open its widget before sending
			const chat = await provider.createNewChat(session.sessionId, options.query);
			// Swap in a transient session whose resource is the new chat
			// resource, so the grid slot reflects the chat that is about to
			// be sent before the provider hands us the final session.

src/vs/sessions/services/sessions/browser/sessionsManagementService.ts:566

  • ISendRequestOptions now includes management-only fields like background, but sendRequest forwards the full object to the provider. Strip management-only fields before passing options through to provider.sendRequest(...).
		// Keep the sent chat as the active chat.
		this._visibility.setActiveChat(session, chat);

		const provider = this._getProvider(session);
		if (!provider) {
			throw new Error(`Sessions provider '${session.providerId}' not found`);
		}

		const updatedSession = await provider.sendRequest(session.sessionId, chat.resource, options);
  • Files reviewed: 6/6 changed files
  • Comments generated: 5

Add keyboard navigation and bulk-close actions to the sessions grid:

- Cmd/Ctrl+1..9 focus the Nth visible session in the grid, scrolling it
  fully into view when it is clipped by the grid's horizontal overflow.
- Route focusSession through the part so revealing happens for all focus
  flows (focus active session, close session, etc.).
- Add a "Close All Sessions" command (Cmd/Ctrl+K Cmd/Ctrl+W, matching
  "Close All Editors"), keyboard-gated on session focus via a now-functional
  sessionsFocus context key.

Co-authored-by: Copilot <[email protected]>
@sandy081
Sandeep Somavarapu (sandy081) force-pushed the sessions/focus-reveal-close-all branch from 91d47ab to 3b3e246 Compare June 1, 2026 14:16
@sandy081
Sandeep Somavarapu (sandy081) merged commit c01738b into main Jun 1, 2026
25 checks passed
@sandy081
Sandeep Somavarapu (sandy081) deleted the sessions/focus-reveal-close-all branch June 1, 2026 18:14
@vs-code-engineering vs-code-engineering Bot added this to the 1.124.0 milestone Jun 1, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jul 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants