From f01d41c78427b8f7b2d3651a02500a05ed3e69ae Mon Sep 17 00:00:00 2001 From: Josh Spicer <23246594+joshspicer@users.noreply.github.com> Date: Tue, 10 Mar 2026 13:29:24 -0700 Subject: [PATCH] Keep Chat customizations section selected while active (#300528) Keep active customization section selected Ensure the left sections list re-applies selection/focus for the active section when the list selection is cleared, so the active view remains persistently selected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../aiCustomizationManagementEditor.ts | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationManagementEditor.ts b/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationManagementEditor.ts index 82cfd7a06ad..8235c4644bb 100644 --- a/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationManagementEditor.ts +++ b/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationManagementEditor.ts @@ -362,17 +362,14 @@ export class AICustomizationManagementEditor extends EditorPane { )); this.sectionsList.splice(0, this.sectionsList.length, this.sections); - - // Select the saved section - const selectedIndex = this.sections.findIndex(s => s.id === this.selectedSection); - if (selectedIndex >= 0) { - this.sectionsList.setSelection([selectedIndex]); - } + this.ensureSectionsListReflectsActiveSection(); this.editorDisposables.add(this.sectionsList.onDidChangeSelection(e => { - if (e.elements.length > 0) { - this.selectSection(e.elements[0].id); + if (e.elements.length === 0) { + this.ensureSectionsListReflectsActiveSection(); + return; } + this.selectSection(e.elements[0].id); })); // Folder picker (sessions window only) @@ -539,6 +536,7 @@ export class AICustomizationManagementEditor extends EditorPane { private selectSection(section: AICustomizationManagementSection): void { if (this.selectedSection === section) { + this.ensureSectionsListReflectsActiveSection(section); return; } @@ -565,6 +563,29 @@ export class AICustomizationManagementEditor extends EditorPane { if (this.isPromptsSection(section)) { void this.listWidget.setSection(section); } + + this.ensureSectionsListReflectsActiveSection(section); + } + + private ensureSectionsListReflectsActiveSection(section: AICustomizationManagementSection = this.selectedSection): void { + if (!this.sectionsList) { + return; + } + + const index = this.sections.findIndex(s => s.id === section); + if (index < 0) { + return; + } + + const selection = this.sectionsList.getSelection(); + if (selection.length !== 1 || selection[0] !== index) { + this.sectionsList.setSelection([index]); + } + + const focus = this.sectionsList.getFocus(); + if (focus.length !== 1 || focus[0] !== index) { + this.sectionsList.setFocus([index]); + } } private updateContentVisibility(): void { @@ -758,8 +779,7 @@ export class AICustomizationManagementEditor extends EditorPane { if (this.isPromptsSection(sectionId)) { void this.listWidget.setSection(sectionId); } - this.sectionsList.setFocus([index]); - this.sectionsList.setSelection([index]); + this.ensureSectionsListReflectsActiveSection(sectionId); } }