From 9b5db8746bded9dfdfd5cf7cbf96c890258daaaf Mon Sep 17 00:00:00 2001 From: Osvaldo Ortega Date: Mon, 30 Mar 2026 14:03:04 -0700 Subject: [PATCH] Do not steal focus from quick picks during startup Guard focus calls in NewChatViewPane and SessionsWelcomeOverlay by checking IQuickInputService.currentQuickInput before focusing. This prevents the sessions welcome page from closing an already open quick pick (e.g. Open Recent) and stealing focus to the chat input box. Fixes microsoft/vscode#294505 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../contrib/welcome/browser/welcome.contribution.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/vs/sessions/contrib/welcome/browser/welcome.contribution.ts b/src/vs/sessions/contrib/welcome/browser/welcome.contribution.ts index 29634287b09..bdf5cb8a0e4 100644 --- a/src/vs/sessions/contrib/welcome/browser/welcome.contribution.ts +++ b/src/vs/sessions/contrib/welcome/browser/welcome.contribution.ts @@ -27,6 +27,7 @@ import { Categories } from '../../../../platform/action/common/actionCommonCateg import { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js'; import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js'; import { IWorkbenchEnvironmentService } from '../../../../workbench/services/environment/common/environmentService.js'; +import { IQuickInputService } from '../../../../platform/quickinput/common/quickInput.js'; const WELCOME_COMPLETE_KEY = 'workbench.agentsession.welcomeComplete'; @@ -40,6 +41,7 @@ class SessionsWelcomeOverlay extends Disposable { @ICommandService private readonly commandService: ICommandService, @IExtensionService private readonly extensionService: IExtensionService, @ILogService private readonly logService: ILogService, + @IQuickInputService private readonly quickInputService: IQuickInputService, ) { super(); @@ -71,8 +73,11 @@ class SessionsWelcomeOverlay extends Disposable { this._register(actionButton.onDidClick(() => this._runSetup(actionButton, spinnerContainer, errorContainer))); - // Focus the button so the overlay traps keyboard input - actionButton.focus(); + // Focus the button so the overlay traps keyboard input, + // but only if no quick input is currently visible. + if (!this.quickInputService.currentQuickInput) { + actionButton.focus(); + } } private async _runSetup(button: Button, spinner: HTMLElement, error: HTMLElement): Promise {