Skip to content

Commit 92d1d8d

Browse files
authored
Merge pull request #314111 from microsoft/benibenj/magnificent-lynx
Only unmaximize auxiliary side bar on explicit user action
2 parents ebfbb71 + 80a208e commit 92d1d8d

9 files changed

Lines changed: 51 additions & 15 deletions

File tree

src/vs/platform/editor/common/editor.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,18 @@ export interface IEditorOptions {
282282
*/
283283
source?: EditorOpenSource;
284284

285+
/**
286+
* Indicates whether the editor is being opened due to an explicit user
287+
* action (`true`) or automatically (`false`) as a side effect of another
288+
* action (e.g. the chat agent opening files it has edited).
289+
*
290+
* When omitted, callers should be treated as explicit. Layout logic may
291+
* use this to decide whether to react to the visibility change (for
292+
* example, by leaving the auxiliary side bar maximized when the change
293+
* was not initiated by the user).
294+
*/
295+
isExplicit?: boolean;
296+
285297
/**
286298
* An optional property to signal that certain view state should be
287299
* applied when opening the editor.

src/vs/workbench/browser/layout.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
341341
private registerLayoutListeners(): void {
342342

343343
// Restore editor if hidden and an editor is to show
344-
const showEditorIfHidden = () => {
344+
const showEditorIfHidden = (explicitUserAction?: boolean) => {
345345
if (
346346
this.isVisible(Parts.EDITOR_PART, mainWindow) || // already visible
347347
this.mainPartEditorService.visibleEditors.length === 0 // no editor to show
@@ -350,7 +350,12 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
350350
}
351351

352352
if (this.isAuxiliaryBarMaximized()) {
353-
this.toggleMaximizedAuxiliaryBar();
353+
// Do not unmaximize the auxiliary side bar when the editor was
354+
// opened automatically (e.g. by the chat agent applying edits).
355+
// Only an explicit user action should disrupt the chosen layout.
356+
if (explicitUserAction !== false) {
357+
this.toggleMaximizedAuxiliaryBar();
358+
}
354359
} else {
355360
this.toggleMaximizedPanel();
356361
}
@@ -375,10 +380,10 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
375380
this.editorGroupService.whenRestored.then(() => {
376381

377382
// Handle visible editors changing for parts visibility
378-
this._register(this.mainPartEditorService.onDidVisibleEditorsChange(() => {
383+
this._register(this.mainPartEditorService.onDidVisibleEditorsChange(e => {
379384
const handled = maybeMaximizeAuxiliaryBar();
380385
if (!handled) {
381-
showEditorIfHidden();
386+
showEditorIfHidden(e.isExplicit);
382387
}
383388
}));
384389
this._register(this.editorGroupService.mainPart.onDidActivateGroup(e => {

src/vs/workbench/browser/parts/editor/editorGroupView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
12661266

12671267
// Editor change event
12681268
if (changed) {
1269-
this._onDidActiveEditorChange.fire({ editor });
1269+
this._onDidActiveEditorChange.fire({ editor, isExplicit: options?.isExplicit });
12701270
}
12711271

12721272
// Indicate error as an event but do not bubble them up

src/vs/workbench/common/editor.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,15 @@ export interface IActiveEditorChangeEvent {
11661166
* The new active editor or `undefined` if the group is empty.
11671167
*/
11681168
editor: EditorInput | undefined;
1169+
1170+
/**
1171+
* Indicates whether the editor change is the result of an explicit
1172+
* user action (`true`) or happened automatically as a side effect
1173+
* (e.g. the chat agent opening files it has edited).
1174+
*
1175+
* When omitted, callers should treat the change as explicit.
1176+
*/
1177+
isExplicit?: boolean;
11691178
}
11701179

11711180
export interface IEditorWillMoveEvent extends IEditorIdentifier {

src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ export class ChatEditingService extends Disposable implements IChatEditingServic
256256
|| this._editorService.activeEditorPane?.input instanceof ChatEditorInput && isEqual(this._editorService.activeEditorPane.input.sessionResource, session.chatSessionResource)
257257
|| Boolean(activeUri && session.entries.get().find(entry => isEqual(activeUri, entry.modifiedURI)));
258258

259-
this._editorService.openEditor({ resource: uri, options: { inactive, preserveFocus: true, pinned: true } });
259+
this._editorService.openEditor({ resource: uri, options: { inactive, preserveFocus: true, pinned: true, isExplicit: false } });
260260
}
261261
})());
262262
};

src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ export class ChatEditingSession extends Disposable implements IChatEditingSessio
12091209
// this file does not exist yet, create it and try again
12101210
await this._bulkEditService.apply({ edits: [{ newResource: resource }] });
12111211
if (this.configurationService.getValue<boolean>('accessibility.openChatEditedFiles')) {
1212-
this._editorService.openEditor({ resource, options: { inactive: true, preserveFocus: true, pinned: true } });
1212+
this._editorService.openEditor({ resource, options: { inactive: true, preserveFocus: true, pinned: true, isExplicit: false } });
12131213
}
12141214

12151215
// Record file creation operation

src/vs/workbench/services/editor/browser/editorService.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { joinPath } from '../../../../base/common/resources.js';
1616
import { DiffEditorInput } from '../../../common/editor/diffEditorInput.js';
1717
import { SideBySideEditor as SideBySideEditorPane } from '../../../browser/parts/editor/sideBySideEditor.js';
1818
import { IEditorGroupsService, IEditorGroup, GroupsOrder, IEditorReplacement, isEditorReplacement, ICloseEditorOptions, IEditorGroupsContainer } from '../common/editorGroupsService.js';
19-
import { IUntypedEditorReplacement, IEditorService, ISaveEditorsOptions, ISaveAllEditorsOptions, IRevertAllEditorsOptions, IBaseSaveRevertAllEditorOptions, IOpenEditorsOptions, PreferredGroup, isPreferredGroup, IEditorsChangeEvent, ISaveEditorsResult } from '../common/editorService.js';
19+
import { IUntypedEditorReplacement, IEditorService, ISaveEditorsOptions, ISaveAllEditorsOptions, IRevertAllEditorsOptions, IBaseSaveRevertAllEditorOptions, IOpenEditorsOptions, PreferredGroup, isPreferredGroup, IEditorsChangeEvent, ISaveEditorsResult, IVisibleEditorsChangeEvent } from '../common/editorService.js';
2020
import { IConfigurationChangeEvent, IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
2121
import { Disposable, IDisposable, dispose, DisposableStore } from '../../../../base/common/lifecycle.js';
2222
import { coalesce, distinct } from '../../../../base/common/arrays.js';
@@ -45,7 +45,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
4545
private readonly _onDidActiveEditorChange = this._register(new Emitter<void>());
4646
readonly onDidActiveEditorChange = this._onDidActiveEditorChange.event;
4747

48-
private readonly _onDidVisibleEditorsChange = this._register(new Emitter<void>());
48+
private readonly _onDidVisibleEditorsChange = this._register(new Emitter<IVisibleEditorsChangeEvent>());
4949
readonly onDidVisibleEditorsChange = this._onDidVisibleEditorsChange.event;
5050

5151
private readonly _onDidEditorsChange = this._register(new Emitter<IEditorsChangeEvent>());
@@ -135,7 +135,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
135135
// Fire initial set of editor events if there is an active editor
136136
if (this.activeEditor) {
137137
this.doHandleActiveEditorChangeEvent();
138-
this._onDidVisibleEditorsChange.fire();
138+
this._onDidVisibleEditorsChange.fire({ isExplicit: false });
139139
}
140140
}
141141

@@ -168,9 +168,9 @@ export class EditorService extends Disposable implements EditorServiceImpl {
168168
this._onDidEditorsChange.fire({ groupId: group.id, event: e });
169169
}));
170170

171-
groupDisposables.add(group.onDidActiveEditorChange(() => {
171+
groupDisposables.add(group.onDidActiveEditorChange(e => {
172172
this.handleActiveEditorChange(group);
173-
this._onDidVisibleEditorsChange.fire();
173+
this._onDidVisibleEditorsChange.fire({ isExplicit: e.isExplicit !== false /* treat undefined as explicit */ });
174174
}));
175175

176176
groupDisposables.add(group.onWillOpenEditor(e => {

src/vs/workbench/services/editor/common/editorService.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ export interface IEditorsChangeEvent {
133133
event: IGroupModelChangeEvent;
134134
}
135135

136+
export interface IVisibleEditorsChangeEvent {
137+
138+
/**
139+
* Indicates whether the visibility change is the result of an explicit
140+
* user action (`true`) or happened automatically as a side effect
141+
* (e.g. the chat agent opening files it has edited).
142+
*/
143+
readonly isExplicit: boolean;
144+
}
145+
136146
export interface IEditorService {
137147

138148
readonly _serviceBrand: undefined;
@@ -149,7 +159,7 @@ export interface IEditorService {
149159
*
150160
* @see {@link IEditorService.visibleEditorPanes}
151161
*/
152-
readonly onDidVisibleEditorsChange: Event<void>;
162+
readonly onDidVisibleEditorsChange: Event<IVisibleEditorsChangeEvent>;
153163

154164
/**
155165
* An aggregated event for any change to any editor across

src/vs/workbench/test/browser/workbenchTestServices.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ import { CustomEditorLabelService, ICustomEditorLabelService } from '../../servi
153153
import { EditorGroupLayout, GroupDirection, GroupOrientation, GroupsArrangement, GroupsOrder, IAuxiliaryEditorPart, ICloseAllEditorsOptions, ICloseEditorOptions, ICloseEditorsFilter, IEditorDropTargetDelegate, IEditorGroup, IEditorGroupActivationEvent, IEditorGroupContextKeyProvider, IEditorGroupsContainer, IEditorGroupsService, IEditorPart, IEditorReplacement, IEditorWorkingSet, IEditorWorkingSetOptions, IFindGroupScope, IMergeGroupOptions, IModalEditorPart } from '../../services/editor/common/editorGroupsService.js';
154154
import { IEditorPaneService } from '../../services/editor/common/editorPaneService.js';
155155
import { IEditorResolverService } from '../../services/editor/common/editorResolverService.js';
156-
import { IEditorsChangeEvent, IEditorService, IRevertAllEditorsOptions, ISaveEditorsOptions, ISaveEditorsResult, PreferredGroup } from '../../services/editor/common/editorService.js';
156+
import { IEditorsChangeEvent, IEditorService, IRevertAllEditorsOptions, ISaveEditorsOptions, ISaveEditorsResult, IVisibleEditorsChangeEvent, PreferredGroup } from '../../services/editor/common/editorService.js';
157157
import { BrowserWorkbenchEnvironmentService } from '../../services/environment/browser/environmentService.js';
158158
import { IWorkbenchEnvironmentService } from '../../services/environment/common/environmentService.js';
159159
import { EnablementState, IExtensionManagementServer, IResourceExtension, IScannedExtension, IWebExtensionsScannerService, IWorkbenchExtensionEnablementService, IWorkbenchExtensionManagementService } from '../../services/extensionManagement/common/extensionManagement.js';
@@ -1050,7 +1050,7 @@ export class TestEditorService extends Disposable implements EditorServiceImpl {
10501050
declare readonly _serviceBrand: undefined;
10511051

10521052
readonly onDidActiveEditorChange: Event<void> = Event.None;
1053-
readonly onDidVisibleEditorsChange: Event<void> = Event.None;
1053+
readonly onDidVisibleEditorsChange: Event<IVisibleEditorsChangeEvent> = Event.None;
10541054
readonly onDidEditorsChange: Event<IEditorsChangeEvent> = Event.None;
10551055
readonly onWillOpenEditor: Event<IEditorWillOpenEvent> = Event.None;
10561056
readonly onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;

0 commit comments

Comments
 (0)