Agents: don't shadow Ctrl+N when editor area has focus#319609
Merged
benibenj merged 1 commit intoJun 2, 2026
Conversation
Introduces a workbench-wide `editorAreaFocus` context key bound by the base `EditorPart` so it is set whenever focus is inside any editor part (main, modal, or auxiliary). The Agents window's Ctrl/Cmd+N keybindings that open a new chat are now gated on the editor area not having focus, so pressing Ctrl/Cmd+N inside an editor falls through to the standard `workbench.action.files.newUntitledFile` command. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents the Agents window’s Ctrl/Cmd+N “New Chat” keybindings from overriding the standard “New Untitled File” behavior when focus is inside any editor area (main, modal, or auxiliary). It does this by introducing a workbench-wide context key (editorAreaFocus) that is true only for the active scoped context of an EditorPart.
Changes:
- Add a new workbench context key
EditorAreaFocusContext(editorAreaFocus). - Bind
editorAreaFocusonEditorPart’s scoped context key service so it’s active only when focus is within an editor part’s DOM scope. - Gate the Agents window
Ctrl/Cmd+Nbindings forworkbench.action.sessions.newChatandworkbench.action.chat.newChatwithwhen: EditorAreaFocusContext.negate()so editor-focusedCtrl/Cmd+Nfalls through toworkbench.action.files.newUntitledFile.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/common/contextkeys.ts | Introduces the new editorAreaFocus RawContextKey. |
| src/vs/workbench/browser/parts/editor/editorPart.ts | Binds editorAreaFocus to the editor part’s scoped context to reflect focus within any editor area. |
| src/vs/sessions/contrib/chat/browser/chat.contribution.ts | Gates the sessions “New Chat” action keybinding to avoid overriding editor shortcuts when editor area has focus. |
| src/vs/sessions/contrib/sessions/browser/views/sessionsViewActions.ts | Gates the workbench.action.chat.newChat Ctrl/Cmd+N rule so it won’t shadow editor-focused Ctrl/Cmd+N. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 0
benvillalobos
approved these changes
Jun 2, 2026
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.
Adds a workbench-wide
editorAreaFocuscontext key bound by the baseEditorPartso it evaluates to true whenever keyboard focus is inside any editor part (main, modal, or auxiliary).The Agents window's
Ctrl/Cmd+Nkeybindings that open a new chat (workbench.action.sessions.newChatand the reboundworkbench.action.chat.newChat) are now gated withwhen: EditorAreaFocusContext.negate(). When focus is inside an editor the keybinding falls through to the standardworkbench.action.files.newUntitledFilecommand, matching the behavior users expect from VS Code.Changes
workbench/common/contextkeys.ts: newEditorAreaFocusContext(editorAreaFocus)workbench/browser/parts/editor/editorPart.ts: bind it inhandleContextKeys()on the scoped context key service so it applies to every editor part subclasssessions/contrib/chat/browser/chat.contribution.ts: gate theNew Chatkeybinding onEditorAreaFocusContext.negate()sessions/contrib/sessions/browser/views/sessionsViewActions.ts: same gating on the second Ctrl+N keybinding rule that targetsworkbench.action.chat.newChat