Skip to content

Commit 95fbc18

Browse files
authored
Provide Maximized Chat View as an option for startup editor on workspace open. (fix microsoft/vscode-internalbacklog#5610) (microsoft#254874)
* Provide Maximized Chat View as an option for startup editor on workspace open. (fix microsoft/vscode-internalbacklog#5610) * refactor - move initialization of isNew property
1 parent 11c6ce5 commit 95fbc18

File tree

4 files changed

+64
-29
lines changed

4 files changed

+64
-29
lines changed

src/vs/platform/theme/electron-main/themeMainServiceImpl.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ export class ThemeMainService extends Disposable implements IThemeMainService {
345345
} else {
346346
if (auxiliaryBarDefaultVisibility === 'visible' || auxiliaryBarDefaultVisibility === 'visibleInWorkspace') {
347347
auxiliaryBarWidth = override.layoutInfo.auxiliaryBarWidth || partSplash.layoutInfo.auxiliaryBarWidth || ThemeMainService.DEFAULT_BAR_WIDTH;
348+
} else if (auxiliaryBarDefaultVisibility === 'maximized' || auxiliaryBarDefaultVisibility === 'maximizedInWorkspace') {
349+
auxiliaryBarWidth = Number.MAX_SAFE_INTEGER; // marker for a maximised auxiliary bar
348350
} else {
349351
auxiliaryBarWidth = 0;
350352
}

src/vs/workbench/browser/layout.ts

Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
419419
}
420420

421421
// Theme changes
422-
this._register(this.themeService.onDidColorThemeChange(() => this.updateWindowsBorder()));
422+
this._register(this.themeService.onDidColorThemeChange(() => this.updateWindowBorder()));
423423

424424
// Window active / focus changes
425425
this._register(this.hostService.onDidChangeFocus(focused => this.onWindowFocusChanged(focused)));
@@ -508,7 +508,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
508508
// Propagate to grid
509509
this.workbenchGrid.setViewVisible(this.titleBarPartView, shouldShowCustomTitleBar(this.configurationService, mainWindow, this.state.runtime.menuBar.toggled));
510510

511-
this.updateWindowsBorder(true);
511+
this.updateWindowBorder(true);
512512
}
513513
}
514514

@@ -518,7 +518,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
518518
this.state.runtime.activeContainerId = activeContainerId;
519519

520520
// Indicate active window border
521-
this.updateWindowsBorder();
521+
this.updateWindowBorder();
522522

523523
this._onDidChangeActiveContainer.fire();
524524
}
@@ -527,7 +527,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
527527
private onWindowFocusChanged(hasFocus: boolean): void {
528528
if (this.state.runtime.hasFocus !== hasFocus) {
529529
this.state.runtime.hasFocus = hasFocus;
530-
this.updateWindowsBorder();
530+
this.updateWindowBorder();
531531
}
532532
}
533533

@@ -582,7 +582,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
582582
this.adjustPartPositions(position, panelAlignment, panelPosition);
583583
}
584584

585-
private updateWindowsBorder(skipLayout = false) {
585+
private updateWindowBorder(skipLayout = false) {
586586
if (
587587
isWeb ||
588588
isWindows || // not working well with zooming (border often not visible)
@@ -743,7 +743,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
743743
}
744744

745745
// Window border
746-
this.updateWindowsBorder(true);
746+
this.updateWindowBorder(true);
747747
}
748748

749749
private getDefaultLayoutViews(environmentService: IBrowserWorkbenchEnvironmentService, storageService: IStorageService): string[] | undefined {
@@ -2377,7 +2377,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
23772377
this.state.runtime.maximized.delete(targetWindowId);
23782378
}
23792379

2380-
this.updateWindowsBorder();
2380+
this.updateWindowBorder();
23812381
this._onDidChangeWindowMaximized.fire({ windowId: targetWindowId, maximized });
23822382
}
23832383

@@ -2800,6 +2800,12 @@ class LayoutStateModel extends Disposable {
28002800

28012801
private readonly stateCache = new Map<string, unknown>();
28022802

2803+
private readonly isNew: {
2804+
[StorageScope.WORKSPACE]: boolean;
2805+
[StorageScope.PROFILE]: boolean;
2806+
[StorageScope.APPLICATION]: boolean;
2807+
};
2808+
28032809
constructor(
28042810
private readonly storageService: IStorageService,
28052811
private readonly configurationService: IConfigurationService,
@@ -2810,6 +2816,12 @@ class LayoutStateModel extends Disposable {
28102816
) {
28112817
super();
28122818

2819+
this.isNew = {
2820+
[StorageScope.WORKSPACE]: this.storageService.isNew(StorageScope.WORKSPACE),
2821+
[StorageScope.PROFILE]: this.storageService.isNew(StorageScope.PROFILE),
2822+
[StorageScope.APPLICATION]: this.storageService.isNew(StorageScope.APPLICATION)
2823+
};
2824+
28132825
this._register(this.configurationService.onDidChangeConfiguration(configurationChange => this.updateStateFromLegacySettings(configurationChange)));
28142826
}
28152827

@@ -2894,9 +2906,11 @@ class LayoutStateModel extends Disposable {
28942906
}
28952907

28962908
switch (this.configurationService.getValue(WorkbenchLayoutSettings.AUXILIARYBAR_DEFAULT_VISIBILITY)) {
2909+
case 'maximized':
28972910
case 'visible':
28982911
return false;
28992912
case 'visibleInWorkspace':
2913+
case 'maximizedInWorkspace':
29002914
return workbenchState === WorkbenchState.EMPTY;
29012915
default:
29022916
return true;
@@ -2945,7 +2959,7 @@ class LayoutStateModel extends Disposable {
29452959
}
29462960
});
29472961

2948-
// With experimental treatment for new users
2962+
// Auxiliary bar: With experimental treatment for new users
29492963
if (
29502964
this.storageService.isNew(StorageScope.APPLICATION) &&
29512965
this.contextService.getWorkbenchState() === WorkbenchState.EMPTY &&
@@ -2956,20 +2970,7 @@ class LayoutStateModel extends Disposable {
29562970
)
29572971
) {
29582972
if (experiment.value.experimentGroup === StartupExperimentGroup.MaximizedChat) {
2959-
this.setRuntimeValue(LayoutStateKeys.AUXILIARYBAR_LAST_NON_MAXIMIZED_VISIBILITY, {
2960-
sideBarVisible: !this.getRuntimeValue(LayoutStateKeys.SIDEBAR_HIDDEN),
2961-
panelVisible: !this.getRuntimeValue(LayoutStateKeys.PANEL_HIDDEN),
2962-
editorVisible: !this.getRuntimeValue(LayoutStateKeys.EDITOR_HIDDEN),
2963-
auxiliaryBarVisible: !this.getRuntimeValue(LayoutStateKeys.AUXILIARYBAR_HIDDEN)
2964-
});
2965-
2966-
this.setRuntimeValue(LayoutStateKeys.SIDEBAR_HIDDEN, true);
2967-
this.setRuntimeValue(LayoutStateKeys.PANEL_HIDDEN, true);
2968-
this.setRuntimeValue(LayoutStateKeys.EDITOR_HIDDEN, true);
2969-
this.setRuntimeValue(LayoutStateKeys.AUXILIARYBAR_HIDDEN, false);
2970-
2971-
this.setRuntimeValue(LayoutStateKeys.AUXILIARYBAR_LAST_NON_MAXIMIZED_SIZE, this.getInitializationValue(LayoutStateKeys.AUXILIARYBAR_SIZE));
2972-
this.setRuntimeValue(LayoutStateKeys.AUXILIARYBAR_WAS_LAST_MAXIMIZED, true);
2973+
this.applyAuxiliaryBarMaximizedOverride();
29732974
} else if (
29742975
experiment.value.experimentGroup === StartupExperimentGroup.SplitEmptyEditorChat ||
29752976
experiment.value.experimentGroup === StartupExperimentGroup.SplitWelcomeChat
@@ -2980,6 +2981,17 @@ class LayoutStateModel extends Disposable {
29802981
}
29812982
}
29822983

2984+
// Auxiliary bar: Based on setting for new workspaces
2985+
else if (this.isNew[StorageScope.WORKSPACE]) {
2986+
const defaultAuxiliaryBarVisibility = this.configurationService.getValue(WorkbenchLayoutSettings.AUXILIARYBAR_DEFAULT_VISIBILITY);
2987+
if (
2988+
defaultAuxiliaryBarVisibility === 'maximized' ||
2989+
(defaultAuxiliaryBarVisibility === 'maximizedInWorkspace' && this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY)
2990+
) {
2991+
this.applyAuxiliaryBarMaximizedOverride();
2992+
}
2993+
}
2994+
29832995
// Both editor and panel should not be hidden on startup unless auxiliary bar is maximized
29842996
if (
29852997
this.getRuntimeValue(LayoutStateKeys.PANEL_HIDDEN) &&
@@ -2990,6 +3002,23 @@ class LayoutStateModel extends Disposable {
29903002
}
29913003
}
29923004

3005+
private applyAuxiliaryBarMaximizedOverride(): void {
3006+
this.setRuntimeValue(LayoutStateKeys.AUXILIARYBAR_LAST_NON_MAXIMIZED_VISIBILITY, {
3007+
sideBarVisible: !this.getRuntimeValue(LayoutStateKeys.SIDEBAR_HIDDEN),
3008+
panelVisible: !this.getRuntimeValue(LayoutStateKeys.PANEL_HIDDEN),
3009+
editorVisible: !this.getRuntimeValue(LayoutStateKeys.EDITOR_HIDDEN),
3010+
auxiliaryBarVisible: !this.getRuntimeValue(LayoutStateKeys.AUXILIARYBAR_HIDDEN)
3011+
});
3012+
3013+
this.setRuntimeValue(LayoutStateKeys.SIDEBAR_HIDDEN, true);
3014+
this.setRuntimeValue(LayoutStateKeys.PANEL_HIDDEN, true);
3015+
this.setRuntimeValue(LayoutStateKeys.EDITOR_HIDDEN, true);
3016+
this.setRuntimeValue(LayoutStateKeys.AUXILIARYBAR_HIDDEN, false);
3017+
3018+
this.setRuntimeValue(LayoutStateKeys.AUXILIARYBAR_LAST_NON_MAXIMIZED_SIZE, this.getInitializationValue(LayoutStateKeys.AUXILIARYBAR_SIZE));
3019+
this.setRuntimeValue(LayoutStateKeys.AUXILIARYBAR_WAS_LAST_MAXIMIZED, true);
3020+
}
3021+
29933022
save(workspace: boolean, global: boolean): void {
29943023
let key: keyof typeof LayoutStateKeys;
29953024

@@ -3071,13 +3100,15 @@ class LayoutStateModel extends Disposable {
30713100
}
30723101

30733102
private loadKeyFromStorage<T extends StorageKeyType>(key: WorkbenchLayoutStateKey<T>): T | undefined {
3074-
let value: any = this.storageService.get(`${LayoutStateModel.STORAGE_PREFIX}${key.name}`, key.scope);
3103+
const value = this.storageService.get(`${LayoutStateModel.STORAGE_PREFIX}${key.name}`, key.scope);
30753104

30763105
if (value !== undefined) {
3106+
this.isNew[key.scope] = false; // remember that we had previous state for this scope
3107+
30773108
switch (typeof key.defaultValue) {
3078-
case 'boolean': value = value === 'true'; break;
3079-
case 'number': value = parseInt(value); break;
3080-
case 'object': value = JSON.parse(value); break;
3109+
case 'boolean': return (value === 'true') as T;
3110+
case 'number': return parseInt(value) as T;
3111+
case 'object': return JSON.parse(value) as T;
30813112
}
30823113
}
30833114

src/vs/workbench/browser/workbench.contribution.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,14 +536,16 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
536536
},
537537
'workbench.secondarySideBar.defaultVisibility': {
538538
'type': 'string',
539-
'enum': ['hidden', 'visibleInWorkspace', 'visible'],
539+
'enum': ['hidden', 'visibleInWorkspace', 'visible', 'maximizedInWorkspace', 'maximized'],
540540
'default': 'hidden',
541541
'tags': ['onExp'],
542542
'description': localize('secondarySideBarDefaultVisibility', "Controls the default visibility of the secondary side bar in workspaces or empty windows opened for the first time."),
543543
'enumDescriptions': [
544544
localize('workbench.secondarySideBar.defaultVisibility.hidden', "The secondary side bar is hidden by default."),
545545
localize('workbench.secondarySideBar.defaultVisibility.visibleInWorkspace', "The secondary side bar is visible by default if a workspace is opened."),
546-
localize('workbench.secondarySideBar.defaultVisibility.visible', "The secondary side bar is visible by default.")
546+
localize('workbench.secondarySideBar.defaultVisibility.visible', "The secondary side bar is visible by default."),
547+
localize('workbench.secondarySideBar.defaultVisibility.maximizedInWorkspace', "The secondary side bar is visible and maximized by default if a workspace is opened."),
548+
localize('workbench.secondarySideBar.defaultVisibility.maximized', "The secondary side bar is visible and maximized by default.")
547549
]
548550
},
549551
'workbench.secondarySideBar.showLabels': {

src/vs/workbench/contrib/chat/browser/actions/chatActions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ registerAction2(class ToggleDefaultVisibilityAction extends Action2 {
11311131
async run(accessor: ServicesAccessor) {
11321132
const configurationService = accessor.get(IConfigurationService);
11331133

1134-
const currentValue = configurationService.getValue<'hidden' | 'visibleInWorkspace' | 'visible'>('workbench.secondarySideBar.defaultVisibility');
1134+
const currentValue = configurationService.getValue<'hidden' | unknown>('workbench.secondarySideBar.defaultVisibility');
11351135
configurationService.updateValue('workbench.secondarySideBar.defaultVisibility', currentValue !== 'hidden' ? 'hidden' : 'visible');
11361136
}
11371137
});

0 commit comments

Comments
 (0)