Agents app: keybindings to switch between sessions (Ctrl+1..9)#310994
Agents app: keybindings to switch between sessions (Ctrl+1..9)#310994
Conversation
Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/d75b30ac-58ce-49b7-b32f-c6b4e7794f31 Co-authored-by: ulugbekna <16353531+ulugbekna@users.noreply.github.com>
|
@copilot Cmd+N is used for focusing various views in vscode, so I think it should use Ctrl regardless of OS |
Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/2772740d-836f-4dc1-be18-54d0968c9c3d Co-authored-by: ulugbekna <16353531+ulugbekna@users.noreply.github.com>
|
@copilot it doesn't work because another command is being invoked: |
Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/c80fda2c-9e56-4a5b-83e6-13a387874ed8 Co-authored-by: ulugbekna <16353531+ulugbekna@users.noreply.github.com>
... The conflict is with |
There was a problem hiding this comment.
Pull request overview
Adds session-switching keybindings (Ctrl+1..9) to the Agents (sessions) window to quickly open the Nth/last visible session, mirroring common “tab index” navigation patterns while being gated to the sessions window context.
Changes:
- Added
getVisibleSessions(): readonly ISession[]toISessionsList/SessionsList, capturing a “visible sessions” list duringupdate(). - Registered
sessionsViewPane.openSessionAtIndexplus Ctrl+1..9 keybindings that resolve the activeSessionsViewand open the corresponding session viaISessionsManagementService.
Show a summary per file
| File | Description |
|---|---|
| src/vs/sessions/contrib/sessions/browser/views/sessionsViewActions.ts | Registers command + keybindings and dispatches to openSession(...) based on visible-session index. |
| src/vs/sessions/contrib/sessions/browser/views/sessionsList.ts | Introduces getVisibleSessions() and tracks “visible” sessions during list updates. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 2
| const children: IObjectTreeElement<SessionListItem>[] = []; | ||
| const visibleSessions: ISession[] = []; | ||
|
|
There was a problem hiding this comment.
getVisibleSessions() is populated from the section/session data before it’s applied to the tree, so it can include sessions that aren’t actually visible in the UI (e.g. sessions inside collapsed sections, or sessions hidden by the tree’s Find-widget filtering). This will make Ctrl+1..9 open “invisible” sessions and misalign indices with what the user sees.
Consider deriving the visible session list from the tree model after setChildren() (e.g. traverse this.tree.getNode() in render order and collect only nodes where node.visible is true and the element is an ISession, skipping section/show-more nodes).
| } | ||
|
|
||
| getVisibleSessions(): readonly ISession[] { | ||
| return this._visibleSessions; |
There was a problem hiding this comment.
This new getVisibleSessions() API is now used to drive keyboard navigation (Ctrl+1..9). Since there are already tests covering other logic exported from this file, it would be good to add coverage for getVisibleSessions()—especially cases like workspace-group capping ("show more"), collapsed sections, and Find-widget filtering—to ensure index-to-session mapping matches the UI.
| return this._visibleSessions; | |
| const sessions = new Set(this.sessions); | |
| const visibleSessions: ISession[] = []; | |
| const collectVisibleSessions = (node: ITreeNode<SessionListItem, FuzzyScore | undefined>): void => { | |
| if (sessions.has(node.element as ISession)) { | |
| visibleSessions.push(node.element as ISession); | |
| } | |
| if (node.collapsed) { | |
| return; | |
| } | |
| for (const child of node.children) { | |
| collectVisibleSessions(child); | |
| } | |
| }; | |
| const root = this.tree.getNode(); | |
| for (const child of root.children) { | |
| collectVisibleSessions(child); | |
| } | |
| return visibleSessions; |
Adds
Ctrl+1..Ctrl+9to switch between sessions in the Agents window, mirroring the familiar tab-switching pattern.Ctrl+1..Ctrl+8open the Nth visible sessionCtrl+9opens the last visible session (Chrome/Slack convention)Ctrlon all platforms (including macOS) to avoid conflicting withCmd+Nview-focus shortcuts in VS CodeIsSessionsWindowContextso regular VS Code shortcuts are unaffectedChanges
sessionsList.ts: addedgetVisibleSessions(): readonly ISession[]toISessionsList/SessionsList. The visible list (in display order, after filters/sorting/grouping; excludes items hidden behind workspace-group "show more" capping) is captured duringupdate().sessionsViewActions.ts: registeredsessionsViewPane.openSessionAtIndexplus 9 keybinding rules. Handler resolves the activeSessionsView, indexes intogetVisibleSessions(), and callsISessionsManagementService.openSession(). The keybinding weight isWorkbenchContrib + 1so it overrides the built-inworkbench.action.openEditorAtIndexNwhich also bindsCtrl+Non macOS.