From fed67992818765fe5be753cd7a034c957255c204 Mon Sep 17 00:00:00 2001 From: Benjamin Christopher Simmonds <44439583+benibenj@users.noreply.github.com> Date: Wed, 18 Mar 2026 16:36:11 +0100 Subject: [PATCH] Fix panel toggle focus in sessions window (#302862) feat - enhance panel visibility handling and focus management in workbench --- src/vs/sessions/browser/workbench.ts | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/vs/sessions/browser/workbench.ts b/src/vs/sessions/browser/workbench.ts index b94d04f64be..ca045ac8260 100644 --- a/src/vs/sessions/browser/workbench.ts +++ b/src/vs/sessions/browser/workbench.ts @@ -1123,6 +1123,8 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService { this.workbenchGrid.exitMaximizedView(); } + const panelHadFocus = !hidden || this.hasFocus(Parts.PANEL_PART); + this.partVisibility.panel = !hidden; this.mainContainer.classList.toggle(LayoutClasses.PANEL_HIDDEN, hidden); @@ -1135,15 +1137,24 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService { // If panel becomes hidden, also hide the current active pane composite if (hidden && this.paneCompositeService.getActivePaneComposite(ViewContainerLocation.Panel)) { this.paneCompositeService.hideActivePaneComposite(ViewContainerLocation.Panel); + + // Focus the chat bar when hiding the panel if it had focus + if (panelHadFocus) { + this.focusPart(Parts.CHATBAR_PART); + } } - // If panel becomes visible, show last active panel or default - if (!hidden && !this.paneCompositeService.getActivePaneComposite(ViewContainerLocation.Panel)) { - const panelToOpen = this.paneCompositeService.getLastActivePaneCompositeId(ViewContainerLocation.Panel) ?? - this.viewDescriptorService.getDefaultViewContainer(ViewContainerLocation.Panel)?.id; - if (panelToOpen) { - this.paneCompositeService.openPaneComposite(panelToOpen, ViewContainerLocation.Panel); + // If panel becomes visible, show last active panel or default and focus it + if (!hidden) { + if (!this.paneCompositeService.getActivePaneComposite(ViewContainerLocation.Panel)) { + const panelToOpen = this.paneCompositeService.getLastActivePaneCompositeId(ViewContainerLocation.Panel) ?? + this.viewDescriptorService.getDefaultViewContainer(ViewContainerLocation.Panel)?.id; + if (panelToOpen) { + this.paneCompositeService.openPaneComposite(panelToOpen, ViewContainerLocation.Panel); + } } + + this.focusPart(Parts.PANEL_PART); } }