@codingame/monaco-vscode-api 37.3.11 → 37.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-api",
3
- "version": "37.3.11",
3
+ "version": "37.4.0",
4
4
  "private": false,
5
5
  "description": "VSCode public API plugged on the monaco editor",
6
6
  "keywords": [],
@@ -15,13 +15,13 @@
15
15
  },
16
16
  "type": "module",
17
17
  "dependencies": {
18
- "@codingame/monaco-vscode-base-service-override": "37.3.11",
19
- "@codingame/monaco-vscode-environment-service-override": "37.3.11",
20
- "@codingame/monaco-vscode-extensions-service-override": "37.3.11",
21
- "@codingame/monaco-vscode-files-service-override": "37.3.11",
22
- "@codingame/monaco-vscode-host-service-override": "37.3.11",
23
- "@codingame/monaco-vscode-layout-service-override": "37.3.11",
24
- "@codingame/monaco-vscode-quickaccess-service-override": "37.3.11",
18
+ "@codingame/monaco-vscode-base-service-override": "37.4.0",
19
+ "@codingame/monaco-vscode-environment-service-override": "37.4.0",
20
+ "@codingame/monaco-vscode-extensions-service-override": "37.4.0",
21
+ "@codingame/monaco-vscode-files-service-override": "37.4.0",
22
+ "@codingame/monaco-vscode-host-service-override": "37.4.0",
23
+ "@codingame/monaco-vscode-layout-service-override": "37.4.0",
24
+ "@codingame/monaco-vscode-quickaccess-service-override": "37.4.0",
25
25
  "@vscode/diff": "0.0.2-7",
26
26
  "@vscode/iconv-lite-umd": "0.7.1",
27
27
  "dompurify": "3.4.15",
package/services.js CHANGED
@@ -540,10 +540,10 @@ export { IAutomationService } from './vscode/src/vs/workbench/contrib/chat/commo
540
540
  export { IAgentWorkbenchLayoutService } from './vscode/src/vs/sessions/browser/workbench.service.js';
541
541
  export { IAICustomizationItemsModel } from './vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationItemsModel.service.js';
542
542
 
543
- if (window.monacoVscodeApiBuildId != null && window.monacoVscodeApiBuildId !== "1.138.0-b83863cc-62ac-4280-864f-e513ebc4eb19") {
544
- throw new Error(`Another version of monaco-vscode-api has already been loaded. Trying to load ${"1.138.0-b83863cc-62ac-4280-864f-e513ebc4eb19"}, ${window.monacoVscodeApiBuildId} is already loaded`);
543
+ if (window.monacoVscodeApiBuildId != null && window.monacoVscodeApiBuildId !== "1.138.0-897b3e9f-e995-4307-a1f6-75656b0559fe") {
544
+ throw new Error(`Another version of monaco-vscode-api has already been loaded. Trying to load ${"1.138.0-897b3e9f-e995-4307-a1f6-75656b0559fe"}, ${window.monacoVscodeApiBuildId} is already loaded`);
545
545
  }
546
- window.monacoVscodeApiBuildId = "1.138.0-b83863cc-62ac-4280-864f-e513ebc4eb19";
546
+ window.monacoVscodeApiBuildId = "1.138.0-897b3e9f-e995-4307-a1f6-75656b0559fe";
547
547
  function registerCommands(options) {
548
548
  function asMenuId(menu) {
549
549
  switch (menu) {
@@ -121,6 +121,7 @@ export declare abstract class AHPFileSystemProvider extends Disposable implement
121
121
  * Tests can override this via the constructor parameter.
122
122
  */
123
123
  private static readonly _DEFAULT_CONNECTION_GRACE_MS;
124
+ private static readonly _DEFAULT_CONNECTION_REGISTRATION_MS;
124
125
  constructor(_connectionGraceMs?: number);
125
126
  /**
126
127
  * Register a mapping from a URI authority to a connection.
@@ -174,6 +175,7 @@ export declare abstract class AHPFileSystemProvider extends Disposable implement
174
175
  readonly read?: boolean;
175
176
  readonly write?: boolean;
176
177
  }): Promise<void>;
178
+ private _waitForAuthority;
177
179
  private _getConnection;
178
180
  /**
179
181
  * Translate a thrown error from a {@link IRemoteFilesystemConnection}
@@ -59,6 +59,9 @@ class AHPFileSystemProvider extends Disposable {
59
59
  static {
60
60
  this._DEFAULT_CONNECTION_GRACE_MS = 5000;
61
61
  }
62
+ static {
63
+ this._DEFAULT_CONNECTION_REGISTRATION_MS = 30000;
64
+ }
62
65
  constructor(_connectionGraceMs = AHPFileSystemProvider._DEFAULT_CONNECTION_GRACE_MS) {
63
66
  super();
64
67
  this._connectionGraceMs = _connectionGraceMs;
@@ -371,17 +374,39 @@ class AHPFileSystemProvider extends Disposable {
371
374
  throw this._mapError(err, FileSystemProviderErrorCode.NoPermissions);
372
375
  }
373
376
  }
374
- _getConnection(authority) {
377
+ async _waitForAuthority(authority) {
375
378
  const entry = this._authorities.get(authority);
376
- if (!entry) {
377
- return Promise.reject(createFileSystemProviderError(
378
- `No connection for authority: ${authority}`,
379
- FileSystemProviderErrorCode.Unavailable
380
- ));
379
+ if (entry) {
380
+ return entry;
381
381
  }
382
+ const store = ( new DisposableStore());
383
+ try {
384
+ return await ( new Promise((resolve, reject) => {
385
+ const unavailable = () => reject(createFileSystemProviderError(
386
+ `No connection for authority: ${authority}`,
387
+ FileSystemProviderErrorCode.Unavailable
388
+ ));
389
+ store.add(this._onDidChangeConnection.event(changedAuthority => {
390
+ if (changedAuthority === authority) {
391
+ const registered = this._authorities.get(authority);
392
+ if (registered) {
393
+ resolve(registered);
394
+ }
395
+ }
396
+ }));
397
+ store.add(
398
+ disposableTimeout(unavailable, AHPFileSystemProvider._DEFAULT_CONNECTION_REGISTRATION_MS)
399
+ );
400
+ }));
401
+ } finally {
402
+ store.dispose();
403
+ }
404
+ }
405
+ async _getConnection(authority) {
406
+ const entry = await this._waitForAuthority(authority);
382
407
  const active = entry.connections.at(-1);
383
408
  if (active) {
384
- return Promise.resolve(active);
409
+ return active;
385
410
  }
386
411
  return ( new Promise((resolve, reject) => {
387
412
  const settle = () => {
@@ -6,7 +6,7 @@ var product = {
6
6
  quality: 'stable',
7
7
  version: '1.138.0',
8
8
  commit: '7debcd0e2acdea1c52de81bf9ee1620444407dda',
9
- date: '2026-10-09T18:04:32.478Z',
9
+ date: '2026-10-12T16:44:04.262Z',
10
10
  ...(globalThis._VSCODE_PRODUCT_JSON ?? {})
11
11
  };
12
12
 
@@ -1,4 +1,4 @@
1
- import { Disposable, DisposableStore, IDisposable } from "../../base/common/lifecycle.js";
1
+ import { DisposableStore, IDisposable } from "../../base/common/lifecycle.js";
2
2
  import { Event } from "../../base/common/event.js";
3
3
  import { IDimension } from "../../base/browser/dom.js";
4
4
  import { Parts, Position, PanelAlignment, SINGLE_WINDOW_PARTS, MULTI_WINDOW_PARTS, IPartVisibilityChangeEvent } from "../../workbench/services/layout/browser/layoutService.js";
@@ -11,17 +11,22 @@ import { IInstantiationService, ServicesAccessor } from "../../platform/instanti
11
11
  import { CodeWindow } from "../../base/browser/window.js";
12
12
  import { ServiceCollection } from "../../platform/instantiation/common/serviceCollection.js";
13
13
  import { WillShutdownEvent } from "../../workbench/services/lifecycle/common/lifecycle.js";
14
- import { ILifecycleService } from "../../workbench/services/lifecycle/common/lifecycle.service.js";
15
14
  import { NotificationService } from "@codingame/monaco-vscode-notifications-service-override/vscode/vs/workbench/services/notification/common/notificationService";
16
15
  import { IEditorWillOpenEvent } from "../../workbench/common/editor.js";
17
16
  import { SessionsLayoutPolicy } from "./layoutPolicy.js";
18
17
  import { ISessionsService } from "../services/sessions/browser/sessionsService.service.js";
18
+ import { AbstractLayout } from "../../workbench/browser/abstractlayout.js";
19
19
  import { IAgentWorkbenchLayoutService } from "./workbench.service.js";
20
20
  export interface IWorkbenchOptions {
21
21
  /**
22
22
  * Extra classes to be added to the workbench container.
23
23
  */
24
24
  extraClasses?: string[];
25
+ /**
26
+ * Whether to reset the workbench parts layout on startup.
27
+ */
28
+ resetLayout?: boolean;
29
+ customEditorRestore?: (accessor: ServicesAccessor, defaultLayout: boolean) => Promise<void>;
25
30
  }
26
31
  /** Visibility of each workbench part in the Agents window layout. */
27
32
  export interface IPartVisibilityState {
@@ -89,7 +94,7 @@ export interface IDockedEditorLayout {
89
94
  getPreferredEditorPartWidth(): number | undefined;
90
95
  }
91
96
  export declare const CLOSE_MOBILE_SIDEBAR_DRAWER_COMMAND_ID = "sessions.closeMobileSidebarDrawer";
92
- export declare class Workbench extends Disposable implements IAgentWorkbenchLayoutService {
97
+ export declare class Workbench extends AbstractLayout implements IAgentWorkbenchLayoutService {
93
98
  protected readonly parent: HTMLElement;
94
99
  private readonly options;
95
100
  private readonly serviceCollection;
@@ -188,11 +193,13 @@ export declare class Workbench extends Disposable implements IAgentWorkbenchLayo
188
193
  private _sidePaneStateBeforeHide;
189
194
  private _restoreSidePaneEditorMaximizedOnShow;
190
195
  protected readonly _defaultSidePaneState: ISidePaneState;
196
+ private readonly whenReadyPromise;
197
+ protected readonly whenReady: Promise<void>;
191
198
  private readonly restoredPromise;
192
199
  readonly whenRestored: Promise<void>;
193
200
  private restored;
194
- readonly openedDefaultEditors = false;
195
201
  protected _savedPartSizes: IPartSizesState;
202
+ private initializationState;
196
203
  private static readonly _PART_VISIBILITY_KEY;
197
204
  private static readonly _PART_SIZES_KEY;
198
205
  protected editorGroupService: IEditorGroupsService;
@@ -237,6 +244,7 @@ export declare class Workbench extends Disposable implements IAgentWorkbenchLayo
237
244
  protected createNotificationsHandlers(instantiationService: IInstantiationService, notificationService: NotificationService): void;
238
245
  protected registerNotificationRowHeight(): void;
239
246
  private createPartContainer;
247
+ protected willRestoreEditors(): boolean;
240
248
  private createEditorPart;
241
249
  private createSessionsPart;
242
250
  private _restoreSessionsPartOnActivation;
@@ -244,10 +252,11 @@ export declare class Workbench extends Disposable implements IAgentWorkbenchLayo
244
252
  private _restoreMinimizedPartOnActivation;
245
253
  protected _minimumPartWidthForActivation(view: ISerializableView): number;
246
254
  private createCustomViewGridPart;
247
- protected restore(lifecycleService: ILifecycleService): void;
248
- protected restoreParts(): void;
255
+ protected restore(accessor: ServicesAccessor): void;
256
+ protected restoreParts(accessor: ServicesAccessor): void;
249
257
  private registerEditorTabHeightClass;
250
258
  initLayout(accessor: ServicesAccessor): void;
259
+ private initLayoutState;
251
260
  private areAllGroupsInMainPartEmpty;
252
261
  protected revealEditorOnOpen(e: IEditorWillOpenEvent): void;
253
262
  private handleDidCloseEditor;
@@ -4,10 +4,10 @@ import '../../workbench/browser/style.js';
4
4
  import * as style from './media/style.css';
5
5
  import * as workbench from './media/workbench.css';
6
6
  import * as phoneLayout from './media/phoneLayout.css';
7
- import { Disposable, DisposableStore, toDisposable } from '../../base/common/lifecycle.js';
7
+ import { DisposableStore, toDisposable } from '../../base/common/lifecycle.js';
8
8
  import { Emitter, setGlobalLeakWarningThreshold, Event } from '../../base/common/event.js';
9
9
  import { getActiveDocument, getWindows, getClientArea, createElement, addDisposableListener, EventType, addDisposableGenericMouseDownListener, runWhenWindowIdle, Dimension, getWindowId, getWindow, getFullscreenElement, size, getActiveElement, isAncestorUsingFlowTo } from '../../base/browser/dom.js';
10
- import { DeferredPromise, RunOnceScheduler } from '../../base/common/async.js';
10
+ import { DeferredPromise, timeout, RunOnceScheduler, Promises } from '../../base/common/async.js';
11
11
  import { isFirefox, isChrome, isSafari, onDidChangeFullscreen, isFullscreen } from '../../base/browser/browser.js';
12
12
  import { mark } from '../../base/common/performance.js';
13
13
  import { onUnexpectedError, setUnexpectedErrorHandler } from '../../base/common/errors.js';
@@ -73,6 +73,7 @@ import { ISessionsSetUpService } from './sessionsSetUpService.service.js';
73
73
  import { AGENTS_FLOATING_PANEL_GAP } from '../common/layoutConstants.js';
74
74
  import { ITelemetryService } from '../../platform/telemetry/common/telemetry.service.js';
75
75
  import { setContainerElement } from '../../base/browser/domStylesheets.js';
76
+ import { AbstractLayout } from '../../workbench/browser/abstractlayout.js';
76
77
  import { IAgentWorkbenchLayoutService } from './workbench.service.js';
77
78
  import { autorun } from '../../base/common/observableInternal/reactions/autorun.js';
78
79
  import { Orientation } from '../../base/browser/ui/sash/sash.js';
@@ -100,7 +101,7 @@ var LayoutClasses;
100
101
  LayoutClasses["PHONE_LAYOUT"] = "phone-layout";
101
102
  })(LayoutClasses || (LayoutClasses = {}));
102
103
  const CLOSE_MOBILE_SIDEBAR_DRAWER_COMMAND_ID = "sessions.closeMobileSidebarDrawer";
103
- class Workbench extends Disposable {
104
+ class Workbench extends AbstractLayout {
104
105
  get activeContainer() {
105
106
  return this.getContainerFromDocument(getActiveDocument());
106
107
  }
@@ -164,7 +165,10 @@ class Workbench extends Disposable {
164
165
  this._PART_SIZES_KEY = "workbench.sessions.partSizes";
165
166
  }
166
167
  constructor(parent, options, serviceCollection, logService) {
167
- super();
168
+ super({
169
+ resetLayout: options?.resetLayout,
170
+ customEditorRestore: options?.customEditorRestore
171
+ });
168
172
  this.parent = parent;
169
173
  this.options = options;
170
174
  this.serviceCollection = serviceCollection;
@@ -233,10 +237,11 @@ class Workbench extends Disposable {
233
237
  editor: true,
234
238
  auxiliaryBar: true
235
239
  };
240
+ this.whenReadyPromise = ( new DeferredPromise());
241
+ this.whenReady = this.whenReadyPromise.p;
236
242
  this.restoredPromise = ( new DeferredPromise());
237
243
  this.whenRestored = this.restoredPromise.p;
238
244
  this.restored = false;
239
- this.openedDefaultEditors = false;
240
245
  this._savedPartSizes = {};
241
246
  this.previousUnexpectedError = {
242
247
  message: undefined,
@@ -328,7 +333,7 @@ class Workbench extends Disposable {
328
333
  }
329
334
  this.createWorkbenchManagement(instantiationService);
330
335
  this.layout();
331
- this.restore(lifecycleService);
336
+ this.restore(accessor);
332
337
  });
333
338
  return instantiationService;
334
339
  } catch (error) {
@@ -678,6 +683,9 @@ class Workbench extends Disposable {
678
683
  part.setAttribute("role", role);
679
684
  return part;
680
685
  }
686
+ willRestoreEditors() {
687
+ return this.initializationState.editor.restoreEditors;
688
+ }
681
689
  createEditorPart() {
682
690
  const editorPartContainer = createElement("div");
683
691
  editorPartContainer.classList.add("part", "editor");
@@ -694,7 +702,7 @@ class Workbench extends Disposable {
694
702
  this._editorPartContainer = editorPartContainer;
695
703
  mark("code/willCreatePart/workbench.parts.editor");
696
704
  this.getPart(Parts.EDITOR_PART).create(editorPartContainer, {
697
- restorePreviousState: false
705
+ restorePreviousState: this.willRestoreEditors()
698
706
  });
699
707
  mark("code/didCreatePart/workbench.parts.editor");
700
708
  this.mainContainer.appendChild(editorPartContainer);
@@ -756,27 +764,45 @@ class Workbench extends Disposable {
756
764
  mark(`code/didCreatePart/${Parts.CUSTOM_VIEW_GRID_PART}`);
757
765
  this.mainContainer.appendChild(customViewGridPartContainer);
758
766
  }
759
- restore(lifecycleService) {
760
- mark("code/didStartWorkbench");
761
- performance.measure(
762
- "perf: workbench create & restore",
763
- "code/didLoadWorkbenchMain",
764
- "code/didStartWorkbench"
765
- );
766
- this.restoreParts();
767
+ restore(accessor) {
768
+ const lifecycleService = accessor.get(ILifecycleService);
769
+ try {
770
+ this.restoreParts(accessor);
771
+ } catch (error) {
772
+ onUnexpectedError(error);
773
+ }
767
774
  void this.sessionsService.restoreVisibleSessions().catch(e => {
768
775
  this.logService.error("[Workbench] restoreVisibleSessions failed", e);
769
776
  });
770
- lifecycleService.phase = LifecyclePhase.Restored;
771
- this.setRestored();
772
- const eventuallyPhaseScheduler = this._register(( new RunOnceScheduler(() => {
773
- this._register(
774
- runWhenWindowIdle(mainWindow, () => lifecycleService.phase = LifecyclePhase.Eventually, 2500)
775
- );
776
- }, 2500)));
777
- eventuallyPhaseScheduler.schedule();
777
+ this.whenReady.finally(() => Promise.race([this.whenRestored, timeout(2000)]).finally(() => {
778
+ function markDidStartWorkbench() {
779
+ mark("code/didStartWorkbench");
780
+ performance.measure(
781
+ "perf: workbench create & restore",
782
+ "code/didLoadWorkbenchMain",
783
+ "code/didStartWorkbench"
784
+ );
785
+ }
786
+ if (this.isRestored()) {
787
+ markDidStartWorkbench();
788
+ } else {
789
+ this.whenRestored.finally(() => markDidStartWorkbench());
790
+ }
791
+ lifecycleService.phase = LifecyclePhase.Restored;
792
+ const eventuallyPhaseScheduler = this._register(( new RunOnceScheduler(() => {
793
+ this._register(
794
+ runWhenWindowIdle(mainWindow, () => lifecycleService.phase = LifecyclePhase.Eventually, 2500)
795
+ );
796
+ }, 2500)));
797
+ eventuallyPhaseScheduler.schedule();
798
+ }));
778
799
  }
779
- restoreParts() {
800
+ restoreParts(accessor) {
801
+ const layoutReadyPromises = [];
802
+ const layoutRestoredPromises = [];
803
+ layoutReadyPromises.push(
804
+ this.restoreLayout(accessor, this.initializationState, layoutRestoredPromises)
805
+ );
780
806
  const partsToRestore = [{
781
807
  location: ViewContainerLocation.Sidebar,
782
808
  visible: this.partVisibility.sidebar
@@ -798,6 +824,12 @@ class Workbench extends Disposable {
798
824
  }
799
825
  }
800
826
  }
827
+ Promises.settled(layoutReadyPromises).finally(() => {
828
+ this.whenReadyPromise.complete();
829
+ Promises.settled(layoutRestoredPromises).finally(() => {
830
+ this.setRestored();
831
+ });
832
+ });
801
833
  }
802
834
  registerEditorTabHeightClass() {
803
835
  const updateCompactHeight = () => this.mainContainer.classList.toggle(
@@ -837,6 +869,10 @@ class Workbench extends Disposable {
837
869
  this.partVisibility.sessions = visDefaults.sessions;
838
870
  this.partVisibility.editor = visDefaults.editor;
839
871
  this._applyPersistedPartVisibility();
872
+ this.initLayoutState(accessor);
873
+ }
874
+ initLayoutState(accessor) {
875
+ this.initializationState = this.getInitLayoutState(accessor);
840
876
  }
841
877
  areAllGroupsInMainPartEmpty() {
842
878
  for (const group of this.editorGroupService.mainPart.groups) {
@@ -0,0 +1,146 @@
1
+ import { IDimension } from "../../base/browser/dom.js";
2
+ import { Direction, IViewSize } from "../../base/browser/ui/grid/grid.js";
3
+ import { Event } from "../../base/common/event.js";
4
+ import { Disposable, DisposableStore, IDisposable } from "../../base/common/lifecycle.js";
5
+ import { ServicesAccessor } from "../../platform/instantiation/common/instantiation.js";
6
+ import { ILayoutOffsetInfo } from "../../platform/layout/browser/layoutService.js";
7
+ import { IPath } from "../../platform/window/common/window.js";
8
+ import { IUntypedEditorInput } from "../common/editor.js";
9
+ import { EditorGroupLayout } from "../services/editor/common/editorGroupsService.js";
10
+ import { IPartVisibilityChangeEvent, MULTI_WINDOW_PARTS, PanelAlignment, Parts, Position, SINGLE_WINDOW_PARTS } from "../services/layout/browser/layoutService.js";
11
+ import { IWorkbenchLayoutService } from "../services/layout/browser/layoutService.service.js";
12
+ import { Part } from "./part.js";
13
+ export declare enum WorkbenchLayoutSettings {
14
+ AUXILIARYBAR_DEFAULT_VISIBILITY = "workbench.secondarySideBar.defaultVisibility",
15
+ AUXILIARYBAR_FORCE_MAXIMIZED = "workbench.secondarySideBar.forceMaximized",
16
+ ACTIVITY_BAR_VISIBLE = "workbench.activityBar.visible",
17
+ PANEL_POSITION = "workbench.panel.defaultLocation",
18
+ PANEL_OPENS_MAXIMIZED = "workbench.panel.opensMaximized",
19
+ ZEN_MODE_CONFIG = "zenMode",
20
+ EDITOR_CENTERED_LAYOUT_AUTO_RESIZE = "workbench.editor.centeredLayoutAutoResize",
21
+ EDITOR_RESTORE_EDITORS = "workbench.editor.restoreEditors"
22
+ }
23
+ export interface IEditorToOpen {
24
+ readonly editor: IUntypedEditorInput;
25
+ readonly viewColumn?: number;
26
+ }
27
+ export interface ILayoutInitializationState {
28
+ readonly views: {
29
+ readonly defaults: string[] | undefined;
30
+ readonly containerToRestore: {
31
+ sideBar?: string;
32
+ panel?: string;
33
+ auxiliaryBar?: string;
34
+ };
35
+ };
36
+ readonly editor: {
37
+ readonly restoreEditors: boolean;
38
+ readonly editorsToOpen: Promise<IEditorToOpen[]>;
39
+ };
40
+ readonly layout?: {
41
+ readonly editors?: EditorGroupLayout;
42
+ };
43
+ }
44
+ export interface IPathToOpen extends IPath {
45
+ readonly viewColumn?: number;
46
+ }
47
+ export interface IInitialEditorsState {
48
+ readonly filesToOpenOrCreate?: IPathToOpen[];
49
+ readonly filesToDiff?: IPathToOpen[];
50
+ readonly filesToMerge?: IPathToOpen[];
51
+ readonly layout?: EditorGroupLayout;
52
+ }
53
+ export declare abstract class AbstractLayout extends Disposable implements IWorkbenchLayoutService {
54
+ protected readonly layoutOptions?: {
55
+ resetLayout?: boolean;
56
+ customEditorRestore?: (accessor: ServicesAccessor, defaultLayout: boolean) => Promise<void>;
57
+ } | undefined;
58
+ readonly _serviceBrand: undefined;
59
+ abstract onDidChangeZenMode: Event<boolean>;
60
+ abstract onDidChangeWindowMaximized: Event<{
61
+ readonly windowId: number;
62
+ readonly maximized: boolean;
63
+ }>;
64
+ abstract onDidChangeMainEditorCenteredLayout: Event<boolean>;
65
+ abstract onDidChangePanelPosition: Event<string>;
66
+ abstract onDidChangePanelAlignment: Event<PanelAlignment>;
67
+ abstract onDidChangePartVisibility: Event<IPartVisibilityChangeEvent>;
68
+ abstract onDidChangeNotificationsVisibility: Event<boolean>;
69
+ abstract onDidChangeAuxiliaryBarMaximized: Event<void>;
70
+ abstract layout(): void;
71
+ abstract isRestored(): boolean;
72
+ abstract whenRestored: Promise<void>;
73
+ abstract hasFocus(part: Parts): boolean;
74
+ abstract isFloatingPanelsEnabled(): boolean;
75
+ abstract isModernUICompact(): boolean;
76
+ abstract focusPart(part: SINGLE_WINDOW_PARTS): void;
77
+ abstract focusPart(part: MULTI_WINDOW_PARTS, targetWindow: Window): void;
78
+ abstract focusPart(part: Parts, targetWindow: Window): void;
79
+ abstract focusPart(part: unknown, targetWindow?: unknown): void;
80
+ abstract getContainer(targetWindow: Window): HTMLElement;
81
+ abstract getContainer(targetWindow: Window, part: Parts): HTMLElement | undefined;
82
+ abstract getContainer(targetWindow: unknown, part?: unknown): HTMLElement | undefined;
83
+ abstract isVisible(part: SINGLE_WINDOW_PARTS): boolean;
84
+ abstract isVisible(part: MULTI_WINDOW_PARTS, targetWindow: Window): boolean;
85
+ abstract isVisible(part: Parts, targetWindow: Window): boolean;
86
+ abstract isVisible(part: unknown, targetWindow?: unknown): boolean;
87
+ abstract setPartHidden(hidden: boolean, part: Parts): void;
88
+ abstract isSecondarySideBarVisible(): boolean;
89
+ abstract toggleSecondarySideBar(): void;
90
+ abstract toggleMaximizedPanel(): void;
91
+ abstract isPanelMaximized(): boolean;
92
+ abstract toggleMaximizedAuxiliaryBar(): void;
93
+ abstract setAuxiliaryBarMaximized(maximized: boolean): boolean;
94
+ abstract isAuxiliaryBarMaximized(): boolean;
95
+ abstract hasMainWindowBorder(): boolean;
96
+ abstract getMainWindowBorderRadius(): string | undefined;
97
+ abstract getSideBarPosition(): Position;
98
+ abstract toggleMenuBar(): void;
99
+ abstract getPanelPosition(): Position;
100
+ abstract setPanelPosition(position: Position): void;
101
+ abstract getPanelAlignment(): PanelAlignment;
102
+ abstract setPanelAlignment(alignment: PanelAlignment): void;
103
+ abstract getMaximumEditorDimensions(container: HTMLElement): IDimension;
104
+ abstract toggleZenMode(): void;
105
+ abstract isMainEditorLayoutCentered(): boolean;
106
+ abstract centerMainEditorLayout(active: boolean): void;
107
+ abstract getSize(part: Parts): IViewSize;
108
+ abstract setSize(part: Parts, size: IViewSize): void;
109
+ abstract resizePart(part: Parts, sizeChangeWidth: number, sizeChangeHeight: number): void;
110
+ abstract registerPart(part: Part): IDisposable;
111
+ abstract isWindowMaximized(targetWindow: Window): boolean;
112
+ abstract updateWindowMaximizedState(targetWindow: Window, maximized: boolean): void;
113
+ abstract getVisibleNeighborPart(part: Parts, direction: Direction): Parts | undefined;
114
+ abstract onDidLayoutMainContainer: Event<IDimension>;
115
+ abstract onDidLayoutContainer: Event<{
116
+ readonly container: HTMLElement;
117
+ readonly dimension: IDimension;
118
+ }>;
119
+ abstract onDidLayoutActiveContainer: Event<IDimension>;
120
+ abstract onDidAddContainer: Event<{
121
+ readonly container: HTMLElement;
122
+ readonly disposables: DisposableStore;
123
+ }>;
124
+ abstract onDidChangeActiveContainer: Event<void>;
125
+ abstract mainContainerDimension: IDimension;
126
+ abstract activeContainerDimension: IDimension;
127
+ abstract mainContainer: HTMLElement;
128
+ abstract activeContainer: HTMLElement;
129
+ abstract containers: Iterable<HTMLElement>;
130
+ abstract whenContainerStylesLoaded(window: Window): Promise<void> | undefined;
131
+ abstract mainContainerOffset: ILayoutOffsetInfo;
132
+ abstract activeContainerOffset: ILayoutOffsetInfo;
133
+ abstract focus(): void;
134
+ private _openedDefaultEditors;
135
+ get openedDefaultEditors(): boolean;
136
+ constructor(layoutOptions?: {
137
+ resetLayout?: boolean;
138
+ customEditorRestore?: (accessor: ServicesAccessor, defaultLayout: boolean) => Promise<void>;
139
+ } | undefined);
140
+ protected getInitialEditorsState(accessor: ServicesAccessor): IInitialEditorsState | undefined;
141
+ protected getInitLayoutState(accessor: ServicesAccessor): ILayoutInitializationState;
142
+ private getDefaultLayoutViews;
143
+ private shouldRestoreEditors;
144
+ private resolveEditorsToOpen;
145
+ protected restoreLayout(accessor: ServicesAccessor, initialization: ILayoutInitializationState, layoutRestoredPromises: Promise<unknown>[]): Promise<void>;
146
+ }
@@ -0,0 +1,247 @@
1
+
2
+ import { coalesce } from '../../base/common/arrays.js';
3
+ import { Disposable } from '../../base/common/lifecycle.js';
4
+ import { mark } from '../../base/common/performance.js';
5
+ import { URI } from '../../base/common/uri.js';
6
+ import { IConfigurationService } from '../../platform/configuration/common/configuration.service.js';
7
+ import { IFileService } from '../../platform/files/common/files.service.js';
8
+ import { IInstantiationService } from '../../platform/instantiation/common/instantiation.js';
9
+ import { ILogService } from '../../platform/log/common/log.service.js';
10
+ import { StorageScope } from '../../platform/storage/common/storage.js';
11
+ import { IStorageService } from '../../platform/storage/common/storage.service.js';
12
+ import { isTemporaryWorkspace, WorkbenchState } from '../../platform/workspace/common/workspace.js';
13
+ import { IWorkspaceContextService } from '../../platform/workspace/common/workspace.service.js';
14
+ import { pathsToEditors, isResourceEditorInput } from '../common/editor.js';
15
+ import { GroupsOrder } from '../services/editor/common/editorGroupsService.js';
16
+ import { IEditorGroupsService } from '../services/editor/common/editorGroupsService.service.js';
17
+ import { IEditorService } from '../services/editor/common/editorService.service.js';
18
+ import { IBrowserWorkbenchEnvironmentService } from '../services/environment/browser/environmentService.service.js';
19
+
20
+ var WorkbenchLayoutSettings;
21
+ (function(WorkbenchLayoutSettings) {
22
+ WorkbenchLayoutSettings["AUXILIARYBAR_DEFAULT_VISIBILITY"] = "workbench.secondarySideBar.defaultVisibility";
23
+ WorkbenchLayoutSettings["AUXILIARYBAR_FORCE_MAXIMIZED"] = "workbench.secondarySideBar.forceMaximized";
24
+ WorkbenchLayoutSettings["ACTIVITY_BAR_VISIBLE"] = "workbench.activityBar.visible";
25
+ WorkbenchLayoutSettings["PANEL_POSITION"] = "workbench.panel.defaultLocation";
26
+ WorkbenchLayoutSettings["PANEL_OPENS_MAXIMIZED"] = "workbench.panel.opensMaximized";
27
+ WorkbenchLayoutSettings["ZEN_MODE_CONFIG"] = "zenMode";
28
+ WorkbenchLayoutSettings["EDITOR_CENTERED_LAYOUT_AUTO_RESIZE"] = "workbench.editor.centeredLayoutAutoResize";
29
+ WorkbenchLayoutSettings["EDITOR_RESTORE_EDITORS"] = "workbench.editor.restoreEditors";
30
+ })(WorkbenchLayoutSettings || (WorkbenchLayoutSettings = {}));
31
+ class AbstractLayout extends Disposable {
32
+ get openedDefaultEditors() {
33
+ return this._openedDefaultEditors;
34
+ }
35
+ constructor(layoutOptions) {
36
+ super();
37
+ this.layoutOptions = layoutOptions;
38
+ this._openedDefaultEditors = false;
39
+ }
40
+ getInitialEditorsState(accessor) {
41
+ const environmentService = accessor.get(IBrowserWorkbenchEnvironmentService);
42
+ const storageService = accessor.get(IStorageService);
43
+ const defaultLayout = environmentService.options?.defaultLayout;
44
+ if ((defaultLayout?.editors?.length || defaultLayout?.layout?.editors) && (defaultLayout.force || storageService.isNew(StorageScope.WORKSPACE))) {
45
+ this._openedDefaultEditors = true;
46
+ return {
47
+ layout: defaultLayout.layout?.editors,
48
+ filesToOpenOrCreate: defaultLayout?.editors?.map(editor => {
49
+ return {
50
+ viewColumn: editor.viewColumn,
51
+ fileUri: URI.revive(editor.uri),
52
+ openOnlyIfExists: editor.openOnlyIfExists,
53
+ options: editor.options
54
+ };
55
+ })
56
+ };
57
+ }
58
+ const {
59
+ filesToOpenOrCreate,
60
+ filesToDiff,
61
+ filesToMerge
62
+ } = environmentService;
63
+ if (filesToOpenOrCreate || filesToDiff || filesToMerge) {
64
+ return {
65
+ filesToOpenOrCreate,
66
+ filesToDiff,
67
+ filesToMerge
68
+ };
69
+ }
70
+ return undefined;
71
+ }
72
+ getInitLayoutState(accessor) {
73
+ const logService = accessor.get(ILogService);
74
+ const environmentService = accessor.get(IBrowserWorkbenchEnvironmentService);
75
+ const storageService = accessor.get(IStorageService);
76
+ const initialEditorsState = this.getInitialEditorsState(accessor);
77
+ if (initialEditorsState) {
78
+ logService.trace("Initial editor state", initialEditorsState);
79
+ }
80
+ const initialLayoutState = {
81
+ layout: {
82
+ editors: initialEditorsState?.layout
83
+ },
84
+ editor: {
85
+ restoreEditors: this.shouldRestoreEditors(accessor, initialEditorsState),
86
+ editorsToOpen: this.resolveEditorsToOpen(accessor, initialEditorsState)
87
+ },
88
+ views: {
89
+ defaults: this.getDefaultLayoutViews(environmentService, storageService),
90
+ containerToRestore: {}
91
+ }
92
+ };
93
+ return initialLayoutState;
94
+ }
95
+ getDefaultLayoutViews(environmentService, storageService) {
96
+ const defaultLayout = environmentService.options?.defaultLayout;
97
+ if (!defaultLayout) {
98
+ return undefined;
99
+ }
100
+ if (!defaultLayout.force && !storageService.isNew(StorageScope.WORKSPACE)) {
101
+ return undefined;
102
+ }
103
+ const {
104
+ views
105
+ } = defaultLayout;
106
+ if (views?.length) {
107
+ return views.map(view => view.id);
108
+ }
109
+ return undefined;
110
+ }
111
+ shouldRestoreEditors(accessor, initialEditorsState) {
112
+ const contextService = accessor.get(IWorkspaceContextService);
113
+ const configurationService = accessor.get(IConfigurationService);
114
+ if (isTemporaryWorkspace(contextService.getWorkspace())) {
115
+ return false;
116
+ }
117
+ if (configurationService.getValue(WorkbenchLayoutSettings.EDITOR_RESTORE_EDITORS) === false) {
118
+ return false;
119
+ }
120
+ const forceRestoreEditors = configurationService.getValue("window.restoreWindows") === "preserve";
121
+ return !!forceRestoreEditors || initialEditorsState === undefined;
122
+ }
123
+ async resolveEditorsToOpen(accessor, initialEditorsState) {
124
+ const fileService = accessor.get(IFileService);
125
+ const logService = accessor.get(ILogService);
126
+ const contextService = accessor.get(IWorkspaceContextService);
127
+ const configurationService = accessor.get(IConfigurationService);
128
+ const editorGroupService = accessor.get(IEditorGroupsService);
129
+ if (initialEditorsState) {
130
+ const filesToMerge = coalesce(
131
+ await pathsToEditors(initialEditorsState.filesToMerge, fileService, logService)
132
+ );
133
+ if (filesToMerge.length === 4 && isResourceEditorInput(filesToMerge[0]) && isResourceEditorInput(filesToMerge[1]) && isResourceEditorInput(filesToMerge[2]) && isResourceEditorInput(filesToMerge[3])) {
134
+ return [{
135
+ editor: {
136
+ input1: {
137
+ resource: filesToMerge[0].resource
138
+ },
139
+ input2: {
140
+ resource: filesToMerge[1].resource
141
+ },
142
+ base: {
143
+ resource: filesToMerge[2].resource
144
+ },
145
+ result: {
146
+ resource: filesToMerge[3].resource
147
+ },
148
+ options: {
149
+ pinned: true
150
+ }
151
+ }
152
+ }];
153
+ }
154
+ const filesToDiff = coalesce(
155
+ await pathsToEditors(initialEditorsState.filesToDiff, fileService, logService)
156
+ );
157
+ if (filesToDiff.length === 2) {
158
+ return [{
159
+ editor: {
160
+ original: {
161
+ resource: filesToDiff[0].resource
162
+ },
163
+ modified: {
164
+ resource: filesToDiff[1].resource
165
+ },
166
+ options: {
167
+ pinned: true
168
+ }
169
+ }
170
+ }];
171
+ }
172
+ const filesToOpenOrCreate = [];
173
+ const resolvedFilesToOpenOrCreate = await pathsToEditors(initialEditorsState.filesToOpenOrCreate, fileService, logService);
174
+ for (let i = 0; i < resolvedFilesToOpenOrCreate.length; i++) {
175
+ const resolvedFileToOpenOrCreate = resolvedFilesToOpenOrCreate[i];
176
+ if (resolvedFileToOpenOrCreate) {
177
+ filesToOpenOrCreate.push({
178
+ editor: resolvedFileToOpenOrCreate,
179
+ viewColumn: initialEditorsState.filesToOpenOrCreate?.[i].viewColumn
180
+ });
181
+ }
182
+ }
183
+ return filesToOpenOrCreate;
184
+ }
185
+ else if (contextService.getWorkbenchState() === WorkbenchState.EMPTY && configurationService.getValue("workbench.startupEditor") === "newUntitledFile") {
186
+ if (editorGroupService.hasRestorableState) {
187
+ return [];
188
+ }
189
+ return [{
190
+ editor: {
191
+ resource: undefined
192
+ }
193
+ }];
194
+ }
195
+ return [];
196
+ }
197
+ async restoreLayout(accessor, initialization, layoutRestoredPromises) {
198
+ const instantiationService = accessor.get(IInstantiationService);
199
+ const editorGroupService = accessor.get(IEditorGroupsService);
200
+ const editorService = accessor.get(IEditorService);
201
+ const logService = accessor.get(ILogService);
202
+ mark("code/willRestoreEditors");
203
+ await editorGroupService.whenReady;
204
+ mark("code/restoreEditors/editorGroupsReady");
205
+ if (initialization.layout?.editors) {
206
+ editorGroupService.mainPart.applyLayout(initialization.layout.editors);
207
+ }
208
+ const editors = await initialization.editor.editorsToOpen;
209
+ mark("code/restoreEditors/editorsToOpenResolved");
210
+ let openEditorsPromise = undefined;
211
+ if (editors.length) {
212
+ const editorGroupsInVisualOrder = editorGroupService.mainPart.getGroups(GroupsOrder.GRID_APPEARANCE);
213
+ const mapEditorsToGroup = ( new Map());
214
+ for (const editor of editors) {
215
+ const group = editorGroupsInVisualOrder[(editor.viewColumn ?? 1) - 1];
216
+ let editorsByGroup = mapEditorsToGroup.get(group.id);
217
+ if (!editorsByGroup) {
218
+ editorsByGroup = ( new Set());
219
+ mapEditorsToGroup.set(group.id, editorsByGroup);
220
+ }
221
+ editorsByGroup.add(editor.editor);
222
+ }
223
+ openEditorsPromise = Promise.all(Array.from(mapEditorsToGroup).map(async ([groupId, editors]) => {
224
+ try {
225
+ await editorService.openEditors(Array.from(editors), groupId, {
226
+ validateTrust: true
227
+ });
228
+ } catch (error) {
229
+ logService.error(error);
230
+ }
231
+ }));
232
+ }
233
+ const customEditorRestorePromise = instantiationService.invokeFunction(
234
+ this.layoutOptions?.customEditorRestore ?? (async () => {}),
235
+ !!initialization.layout?.editors
236
+ );
237
+ layoutRestoredPromises.push(Promise.all([
238
+ openEditorsPromise?.finally(() => mark("code/restoreEditors/editorsOpened")),
239
+ customEditorRestorePromise?.finally(() => mark("code/restoreEditors/customEditorsOpened")),
240
+ editorGroupService.whenRestored.finally(() => mark("code/restoreEditors/editorGroupsRestored"))
241
+ ]).finally(() => {
242
+ mark("code/didRestoreEditors");
243
+ }));
244
+ }
245
+ }
246
+
247
+ export { AbstractLayout, WorkbenchLayoutSettings };
@@ -606,9 +606,8 @@ const registry = ( Registry.as(Extensions.Configuration));
606
606
  "Controls whether editors are restored on startup. When disabled, only dirty editors will be restored from the previous session."
607
607
  )),
608
608
  "default": true,
609
- agentsWindow: {
610
- default: false,
611
- readOnly: true
609
+ "agentsWindow": {
610
+ "default": false
612
611
  }
613
612
  },
614
613
  "workbench.editor.splitInGroupLayout": {