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>
This commit is contained in:
Josh Spicer
2026-03-10 13:29:24 -07:00
committed by GitHub
parent 9a1fe573bb
commit f01d41c784

View File

@@ -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);
}
}