sessions: fix chat keyboard shortcuts in the agents window - #324404
Open
yashjeswani63 wants to merge 7 commits into
Open
sessions: fix chat keyboard shortcuts in the agents window#324404yashjeswani63 wants to merge 7 commits into
yashjeswani63 wants to merge 7 commits into
Conversation
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @sandy081Matched files:
@lszomoruMatched files:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes chat keyboard shortcuts in the Agents window (multi-chat sessions) so that chords like Cmd/Ctrl+T, Cmd/Ctrl+Shift+T, Cmd/Ctrl+Shift+O, and Cmd/Ctrl+Shift+[/] are scoped to the Agents window and only fire when there is something to act on, otherwise falling back cleanly to session-level or global commands. It introduces a new sessionHasClosedChats context key and refines the when conditions and runtime checks of the relevant actions.
Changes:
- Added
SessionHasClosedChatsContextcontext key and wired it intosetActiveSessionContextKeys, gatingReopenLastClosedChatActionon it. - Simplified
AddChatToSessionAction's keybindingwhenand moved the multiple-chats/archived checks intorun()as a no-op; gatedShowChatsPickerActiononSessionHasMultipleCommittedChatsContext. - Added
Ctrl/Cmd+Shift+[/]as secondary keybindings for session navigation on Windows/Linux (matching the existing mac bindings), and added a new context-key unit test.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/vs/sessions/common/contextkeys.ts |
Declares the new SessionHasClosedChatsContext raw context key. |
src/vs/sessions/services/sessions/common/sessionContextKeys.ts |
Binds and sets hasClosedChats from the active session's closedChats. |
src/vs/sessions/contrib/sessions/browser/sessionsActions.ts |
Scopes Add/Reopen/Go-to-Chat actions with context keys and runtime no-op checks. |
src/vs/sessions/contrib/sessions/browser/views/sessionsViewActions.ts |
Adds Ctrl/Cmd+Shift+[/] secondary session-navigation bindings on non-mac. |
src/vs/sessions/services/sessions/test/browser/sessionContextKeys.test.ts |
New unit test asserting closed/open chat context keys; the makeSession stub does not conform to ISession. |
Comment on lines
+41
to
+62
| function makeSession(id: string, chats: IChat[]): ISession { | ||
| return { | ||
| sessionId: id, | ||
| resource: URI.parse(`test:///session/${id}`), | ||
| providerId: 'test-provider', | ||
| sessionType: 'test-type', | ||
| icon: { id: 'test-icon' }, | ||
| createdAt: new Date(), | ||
| workspace: constObservable(undefined), | ||
| isQuickChat: constObservable(false), | ||
| title: constObservable(id), | ||
| status: constObservable(SessionStatus.Completed), | ||
| isArchived: constObservable(false), | ||
| isRead: constObservable(true), | ||
| capabilities: constObservable({ supportsMultipleChats: true }), | ||
| chats: constObservable(chats), | ||
| mainChat: constObservable(chats[0]), | ||
| changesets: constObservable([]), | ||
| changes: constObservable([]), | ||
| workingSet: constObservable(undefined), | ||
| }; | ||
| } |
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Chat Keyboard Shortcuts in the Agents Window (Multi-Chat)
Fixes #324363
This PR fixes issues with chat tab management, navigation shortcuts, and context-dependent fallbacks inside multi-chat/Agents window sessions.
Summary
Keyboard shortcuts for managing and navigating chats in an active multi-chat session are now scoped to the Agents window and only fire when there is something to act on. Otherwise, they fall back to the existing session-level or global commands cleanly:
Reopen Last Closed Chat (
Cmd/Ctrl+Shift+T):sessionHasClosedChatscontext key which tracks whether there is a closed chat available to reopen.ReopenLastClosedChatActionto only fire whensessionHasClosedChatsis true. If there are no closed chats, it falls back to the editor's default reopen command (reopenClosedEditor).Add Chat (
Cmd/Ctrl+T):whencondition of theAddChatToSessionActionkeybinding to focus purely on active, created sessions.run()method so that pressingCtrl+Tin those cases is intercepted and results in a no-op ("does nothing"), instead of falling back to the global symbol finder.Go to Chat Picker (
Cmd/Ctrl+Shift+O):ShowChatsPickerActionkeybinding on thesessionHasMultipleCommittedChatscontext key so it correctly falls back to "Go to Symbol in Editor" when a single chat is focused.Previous/Next Chat (
Cmd/Ctrl+Shift+[/]):KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.BracketLeft/BracketRightsecondary keybindings on Windows and Linux toNavigatePreviousSessionActionandNavigateNextSessionAction. If the session has only a single chat tab, these shortcuts now correctly fall back to session-level navigation on all platforms.Proposed Changes
Sessions
contextkeys.ts
SessionHasClosedChatsContextcontext key.sessionContextKeys.ts
SessionHasClosedChatsContextto the context key service.setActiveSessionContextKeysto dynamically sethasClosedChatsto true if the active session has closed chats.sessionsActions.ts
AddChatToSessionAction(Cmd/Ctrl+T),ReopenLastClosedChatAction(Cmd/Ctrl+Shift+T), andShowChatsPickerAction(Cmd/Ctrl+Shift+O) with the appropriate context key conditions and runtime checks to handle no-ops and clean fallbacks.sessionsViewActions.ts
Verification
Automated Tests
src/vs/sessions/services/sessions/test/browser/sessionContextKeys.test.tsto assert that context keys correctly reflect open and closed chat states.