diff --git a/build/gulpfile.vscode.ts b/build/gulpfile.vscode.ts index ea4f88df500..dc7c5462436 100644 --- a/build/gulpfile.vscode.ts +++ b/build/gulpfile.vscode.ts @@ -384,8 +384,6 @@ function packageTask(platform: string, arch: string, sourceFolderName: string, d const telemetry = gulp.src('.build/telemetry/**', { base: '.build/telemetry', dot: true }); - const workbenchModes = gulp.src('resources/workbenchModes/**', { base: '.', dot: true }); - const jsFilter = util.filter(data => !data.isDirectory() && /\.js$/.test(data.path)); const root = path.resolve(path.join(import.meta.dirname, '..')); const productionDependencies = getProductionDependencies(root); @@ -420,7 +418,6 @@ function packageTask(platform: string, arch: string, sourceFolderName: string, d license, api, telemetry, - workbenchModes, sources, deps ); diff --git a/resources/workbenchModes/agent-sessions.code-workbench-mode b/resources/workbenchModes/agent-sessions.code-workbench-mode deleted file mode 100644 index f7e3b6b4c9d..00000000000 --- a/resources/workbenchModes/agent-sessions.code-workbench-mode +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "Agent Sessions", - "settings": { - "chat.agentsControl.clickBehavior": "focus", - "chat.agentsControl.enabled": true, - "chat.agent.maxRequests": 1000, - "chat.restoreLastPanelSession": true, - "chat.unifiedAgentsBar.enabled": true, - "diffEditor.renderSideBySide": false, - "diffEditor.hideUnchangedRegions.enabled": true, - "files.autoSave": "afterDelay", - "github.copilot.chat.claudeCode.enabled": true, - "github.copilot.chat.languageContext.typescript.enabled": true, - "inlineChat.affordance": "editor", - "inlineChat.renderMode": "hover", - "workbench.activityBar.location": "top", - "workbench.editor.restoreEditors": false, - "workbench.editor.showTabs": "single", - "workbench.sideBar.location": "right", - "workbench.statusBar.visible": false, - "workbench.secondarySideBar.forceMaximized": true, - "workbench.secondarySideBar.defaultVisibility": "maximized", - "workbench.startupEditor": "none", - "workbench.tips.enabled": false, - "workbench.layoutControl.type": "toggles", - "workbench.activityBar.autoHide": true - } -} diff --git a/src/vs/editor/standalone/browser/standaloneServices.ts b/src/vs/editor/standalone/browser/standaloneServices.ts index 7fda56bbc64..90c8c11a1f8 100644 --- a/src/vs/editor/standalone/browser/standaloneServices.ts +++ b/src/vs/editor/standalone/browser/standaloneServices.ts @@ -222,7 +222,6 @@ class StandaloneEnvironmentService implements IEnvironmentService { readonly keyboardLayoutResource: URI = URI.from({ scheme: 'monaco', authority: 'keyboardLayoutResource' }); readonly argvResource: URI = URI.from({ scheme: 'monaco', authority: 'argvResource' }); readonly untitledWorkspacesHome: URI = URI.from({ scheme: 'monaco', authority: 'untitledWorkspacesHome' }); - readonly builtinWorkbenchModesHome: URI = URI.from({ scheme: 'monaco', authority: 'builtinWorkbenchModesHome' }); readonly workspaceStorageHome: URI = URI.from({ scheme: 'monaco', authority: 'workspaceStorageHome' }); readonly localHistoryHome: URI = URI.from({ scheme: 'monaco', authority: 'localHistoryHome' }); readonly cacheHome: URI = URI.from({ scheme: 'monaco', authority: 'cacheHome' }); diff --git a/src/vs/platform/environment/common/environment.ts b/src/vs/platform/environment/common/environment.ts index 9084b17736b..137a08dab33 100644 --- a/src/vs/platform/environment/common/environment.ts +++ b/src/vs/platform/environment/common/environment.ts @@ -58,7 +58,6 @@ export interface IEnvironmentService { workspaceStorageHome: URI; localHistoryHome: URI; cacheHome: URI; - builtinWorkbenchModesHome: URI; // --- settings sync userDataSyncHome: URI; diff --git a/src/vs/platform/environment/common/environmentService.ts b/src/vs/platform/environment/common/environmentService.ts index 6d2fdd83a75..c6869a109f1 100644 --- a/src/vs/platform/environment/common/environmentService.ts +++ b/src/vs/platform/environment/common/environmentService.ts @@ -107,9 +107,6 @@ export abstract class AbstractNativeEnvironmentService implements INativeEnviron @memoize get untitledWorkspacesHome(): URI { return URI.file(join(this.userDataPath, 'Workspaces')); } - @memoize - get builtinWorkbenchModesHome(): URI { return joinPath(URI.file(this.appRoot), 'resources', 'workbenchModes'); } - @memoize get builtinExtensionsPath(): string { const cliBuiltinExtensionsDir = this.args['builtin-extensions-dir']; diff --git a/src/vs/workbench/browser/contextkeys.ts b/src/vs/workbench/browser/contextkeys.ts index 4be91f9e5fb..366e5759558 100644 --- a/src/vs/workbench/browser/contextkeys.ts +++ b/src/vs/workbench/browser/contextkeys.ts @@ -6,7 +6,7 @@ import { Disposable } from '../../base/common/lifecycle.js'; import { IContextKeyService, IContextKey, setConstant as setConstantContextKey } from '../../platform/contextkey/common/contextkey.js'; import { IsMacContext, IsLinuxContext, IsWindowsContext, IsWebContext, IsMacNativeContext, IsDevelopmentContext, IsIOSContext, ProductQualityContext, IsMobileContext } from '../../platform/contextkey/common/contextkeys.js'; -import { SplitEditorsVertically, InEditorZenModeContext, AuxiliaryBarVisibleContext, SideBarVisibleContext, PanelAlignmentContext, PanelMaximizedContext, PanelVisibleContext, EmbedderIdentifierContext, EditorTabsVisibleContext, IsMainEditorCenteredLayoutContext, MainEditorAreaVisibleContext, DirtyWorkingCopiesContext, EmptyWorkspaceSupportContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, IsMainWindowFullscreenContext, OpenFolderWorkspaceSupportContext, RemoteNameContext, VirtualWorkspaceContext, WorkbenchStateContext, WorkspaceFolderCountContext, PanelPositionContext, TemporaryWorkspaceContext, TitleBarVisibleContext, TitleBarStyleContext, IsAuxiliaryWindowFocusedContext, ActiveEditorGroupEmptyContext, ActiveEditorGroupIndexContext, ActiveEditorGroupLastContext, ActiveEditorGroupLockedContext, MultipleEditorGroupsContext, EditorsVisibleContext, AuxiliaryBarMaximizedContext, InAutomationContext, IsAgentSessionsWorkspaceContext, WorkbenchModeContext } from '../common/contextkeys.js'; +import { SplitEditorsVertically, InEditorZenModeContext, AuxiliaryBarVisibleContext, SideBarVisibleContext, PanelAlignmentContext, PanelMaximizedContext, PanelVisibleContext, EmbedderIdentifierContext, EditorTabsVisibleContext, IsMainEditorCenteredLayoutContext, MainEditorAreaVisibleContext, DirtyWorkingCopiesContext, EmptyWorkspaceSupportContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, IsMainWindowFullscreenContext, OpenFolderWorkspaceSupportContext, RemoteNameContext, VirtualWorkspaceContext, WorkbenchStateContext, WorkspaceFolderCountContext, PanelPositionContext, TemporaryWorkspaceContext, TitleBarVisibleContext, TitleBarStyleContext, IsAuxiliaryWindowFocusedContext, ActiveEditorGroupEmptyContext, ActiveEditorGroupIndexContext, ActiveEditorGroupLastContext, ActiveEditorGroupLockedContext, MultipleEditorGroupsContext, EditorsVisibleContext, AuxiliaryBarMaximizedContext, InAutomationContext, IsAgentSessionsWorkspaceContext } from '../common/contextkeys.js'; import { preferredSideBySideGroupDirection, GroupDirection, IEditorGroupsService } from '../services/editor/common/editorGroupsService.js'; import { IConfigurationService } from '../../platform/configuration/common/configuration.js'; import { IWorkbenchEnvironmentService } from '../services/environment/common/environmentService.js'; @@ -23,7 +23,6 @@ import { getTitleBarStyle } from '../../platform/window/common/window.js'; import { mainWindow } from '../../base/browser/window.js'; import { isFullscreen, onDidChangeFullscreen } from '../../base/browser/browser.js'; import { IEditorService } from '../services/editor/common/editorService.js'; -import { IWorkbenchModeService } from '../services/layout/common/workbenchModeService.js'; export class WorkbenchContextKeysHandler extends Disposable { @@ -49,7 +48,6 @@ export class WorkbenchContextKeysHandler extends Disposable { private virtualWorkspaceContext: IContextKey; private temporaryWorkspaceContext: IContextKey; private isAgentSessionsWorkspaceContext: IContextKey; - private workbenchModeContext: IContextKey; private inAutomationContext: IContextKey; private inZenModeContext: IContextKey; @@ -79,7 +77,6 @@ export class WorkbenchContextKeysHandler extends Disposable { @IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService, @IPaneCompositePartService private readonly paneCompositeService: IPaneCompositePartService, @IWorkingCopyService private readonly workingCopyService: IWorkingCopyService, - @IWorkbenchModeService private readonly workbenchModeService: IWorkbenchModeService, ) { super(); @@ -99,8 +96,6 @@ export class WorkbenchContextKeysHandler extends Disposable { this.temporaryWorkspaceContext = TemporaryWorkspaceContext.bindTo(this.contextKeyService); this.isAgentSessionsWorkspaceContext = IsAgentSessionsWorkspaceContext.bindTo(this.contextKeyService); this.isAgentSessionsWorkspaceContext.set(!!this.contextService.getWorkspace().isAgentSessionsWorkspace); - this.workbenchModeContext = WorkbenchModeContext.bindTo(this.contextKeyService); - this.workbenchModeContext.set(this.workbenchModeService.workbenchMode ?? ''); this.updateWorkspaceContextKeys(); // Capabilities @@ -232,8 +227,6 @@ export class WorkbenchContextKeysHandler extends Disposable { this.updateWorkspaceContextKeys(); })); - this._register(this.workbenchModeService.onDidChangeWorkbenchMode(mode => this.workbenchModeContext.set(mode ?? ''))); - this._register(this.configurationService.onDidChangeConfiguration(e => { if (e.affectsConfiguration('workbench.editor.openSideBySideDirection')) { this.updateSplitEditorsVerticallyContext(); diff --git a/src/vs/workbench/browser/web.main.ts b/src/vs/workbench/browser/web.main.ts index b9a2f073d8f..fce64b1f337 100644 --- a/src/vs/workbench/browser/web.main.ts +++ b/src/vs/workbench/browser/web.main.ts @@ -98,8 +98,6 @@ import { INotificationService, Severity } from '../../platform/notification/comm import { IDefaultAccountService } from '../../platform/defaultAccount/common/defaultAccount.js'; import { DefaultAccountService } from '../services/accounts/browser/defaultAccount.js'; import { AccountPolicyService } from '../services/policies/common/accountPolicyService.js'; -import { WorkbenchModeService } from '../services/layout/browser/workbenchModeService.js'; -import { IWorkbenchModeService } from '../services/layout/common/workbenchModeService.js'; export class BrowserMain extends Disposable { @@ -389,15 +387,6 @@ export class BrowserMain extends Disposable { // // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // Layout Mode - const workbenchModeService: WorkbenchModeService = this._register(new WorkbenchModeService(configurationService, fileService, environmentService, uriIdentityService, logService, storageService)); - serviceCollection.set(IWorkbenchModeService, workbenchModeService); - try { - await workbenchModeService.initialize(); - } catch (error) { - logService.error('Error while initializing workbench mode service', error); - } - // Workspace Trust Service const workspaceTrustEnablementService = new WorkspaceTrustEnablementService(configurationService, environmentService); serviceCollection.set(IWorkspaceTrustEnablementService, workspaceTrustEnablementService); diff --git a/src/vs/workbench/common/contextkeys.ts b/src/vs/workbench/common/contextkeys.ts index 20b3b1f804d..fad039e7689 100644 --- a/src/vs/workbench/common/contextkeys.ts +++ b/src/vs/workbench/common/contextkeys.ts @@ -35,8 +35,6 @@ export const TemporaryWorkspaceContext = new RawContextKey('temporaryWo export const IsAgentSessionsWorkspaceContext = new RawContextKey('isAgentSessionsWorkspace', false, localize('isAgentSessionsWorkspace', "Whether the current workspace is the agent sessions workspace.")); -export const WorkbenchModeContext = new RawContextKey('workbenchMode', '', localize('workbenchMode', "The current workbench mode.")); - export const HasWebFileSystemAccess = new RawContextKey('hasWebFileSystemAccess', false, true); // Support for FileSystemAccess web APIs (https://wicg.github.io/file-system-access) export const EmbedderIdentifierContext = new RawContextKey('embedderIdentifier', undefined, localize('embedderIdentifier', 'The identifier of the embedder according to the product service, if one is defined')); diff --git a/src/vs/workbench/contrib/chat/electron-browser/agentSessions/agentSessionsActions.ts b/src/vs/workbench/contrib/chat/electron-browser/agentSessions/agentSessionsActions.ts index 274ca60b475..4e8021f5899 100644 --- a/src/vs/workbench/contrib/chat/electron-browser/agentSessions/agentSessionsActions.ts +++ b/src/vs/workbench/contrib/chat/electron-browser/agentSessions/agentSessionsActions.ts @@ -11,16 +11,14 @@ import { INativeEnvironmentService } from '../../../../../platform/environment/c import { IFileService } from '../../../../../platform/files/common/files.js'; import { INativeHostService } from '../../../../../platform/native/common/native.js'; import { ChatEntitlementContextKeys } from '../../../../services/chat/common/chatEntitlementService.js'; -import { IWorkbenchModeService } from '../../../../services/layout/common/workbenchModeService.js'; -import { IsAgentSessionsWorkspaceContext, WorkbenchModeContext } from '../../../../common/contextkeys.js'; import { CHAT_CATEGORY } from '../../browser/actions/chatActions.js'; import { ProductQualityContext } from '../../../../../platform/contextkey/common/contextkeys.js'; -export class OpenAgentSessionsWindowAction extends Action2 { +export class OpenSessionsWindowAction extends Action2 { constructor() { super({ - id: 'workbench.action.openAgentSessionsWindow', - title: localize2('openAgentSessionsWindow', "Open Agent Sessions Window"), + id: 'workbench.action.openSessionsWindow', + title: localize2('openSessionsWindow', "Open Sessions Window"), category: CHAT_CATEGORY, precondition: ContextKeyExpr.and(ProductQualityContext.notEqualsTo('stable'), ChatEntitlementContextKeys.Setup.hidden.negate()), f1: true, @@ -47,47 +45,3 @@ export class OpenAgentSessionsWindowAction extends Action2 { await nativeHostService.openWindow([{ workspaceUri }], { forceNewWindow: true }); } } - -export class SwitchToAgentSessionsModeAction extends Action2 { - constructor() { - super({ - id: 'workbench.action.switchToAgentSessionsMode', - title: localize2('switchToAgentSessionsMode', "Switch to Agent Sessions Mode"), - category: CHAT_CATEGORY, - precondition: ContextKeyExpr.and( - ProductQualityContext.notEqualsTo('stable'), - ChatEntitlementContextKeys.Setup.hidden.negate(), - IsAgentSessionsWorkspaceContext.toNegated(), - WorkbenchModeContext.notEqualsTo('agent-sessions') - ), - f1: true, - }); - } - - async run(accessor: ServicesAccessor) { - const workbenchModeService = accessor.get(IWorkbenchModeService); - await workbenchModeService.setWorkbenchMode('agent-sessions'); - } -} - -export class SwitchToNormalModeAction extends Action2 { - constructor() { - super({ - id: 'workbench.action.switchToNormalMode', - title: localize2('switchToNormalMode', "Switch to Default Mode"), - category: CHAT_CATEGORY, - precondition: ContextKeyExpr.and( - ProductQualityContext.notEqualsTo('stable'), - ChatEntitlementContextKeys.Setup.hidden.negate(), - IsAgentSessionsWorkspaceContext.toNegated(), - WorkbenchModeContext.notEqualsTo('') - ), - f1: true, - }); - } - - async run(accessor: ServicesAccessor) { - const workbenchModeService = accessor.get(IWorkbenchModeService); - await workbenchModeService.setWorkbenchMode(undefined); - } -} diff --git a/src/vs/workbench/contrib/chat/electron-browser/chat.contribution.ts b/src/vs/workbench/contrib/chat/electron-browser/chat.contribution.ts index 3abfc386a4c..8ea0d40a484 100644 --- a/src/vs/workbench/contrib/chat/electron-browser/chat.contribution.ts +++ b/src/vs/workbench/contrib/chat/electron-browser/chat.contribution.ts @@ -35,7 +35,7 @@ import { registerChatDeveloperActions } from './actions/chatDeveloperActions.js' import { registerChatExportZipAction } from './actions/chatExportZip.js'; import { HoldToVoiceChatInChatViewAction, InlineVoiceChatAction, KeywordActivationContribution, QuickVoiceChatAction, ReadChatResponseAloud, StartVoiceChatAction, StopListeningAction, StopListeningAndSubmitAction, StopReadAloud, StopReadChatItemAloud, VoiceChatInChatViewAction } from './actions/voiceChatActions.js'; import { NativeBuiltinToolsContribution } from './builtInTools/tools.js'; -import { OpenAgentSessionsWindowAction, SwitchToAgentSessionsModeAction, SwitchToNormalModeAction } from './agentSessions/agentSessionsActions.js'; +import { OpenSessionsWindowAction } from './agentSessions/agentSessionsActions.js'; class ChatCommandLineHandler extends Disposable { @@ -194,9 +194,7 @@ class ChatLifecycleHandler extends Disposable { } } -registerAction2(OpenAgentSessionsWindowAction); -registerAction2(SwitchToAgentSessionsModeAction); -registerAction2(SwitchToNormalModeAction); +registerAction2(OpenSessionsWindowAction); registerAction2(StartVoiceChatAction); registerAction2(VoiceChatInChatViewAction); diff --git a/src/vs/workbench/electron-browser/desktop.main.ts b/src/vs/workbench/electron-browser/desktop.main.ts index b4399ffbe70..30c2d80d574 100644 --- a/src/vs/workbench/electron-browser/desktop.main.ts +++ b/src/vs/workbench/electron-browser/desktop.main.ts @@ -65,8 +65,6 @@ import { IDefaultAccountService } from '../../platform/defaultAccount/common/def import { DefaultAccountService } from '../services/accounts/browser/defaultAccount.js'; import { AccountPolicyService } from '../services/policies/common/accountPolicyService.js'; import { MultiplexPolicyService } from '../services/policies/common/multiplexPolicyService.js'; -import { WorkbenchModeService } from '../services/layout/browser/workbenchModeService.js'; -import { IWorkbenchModeService } from '../services/layout/common/workbenchModeService.js'; export class DesktopMain extends Disposable { @@ -324,16 +322,6 @@ export class DesktopMain extends Disposable { }) ]); - // Workbench Mode - const workbenchModeService: WorkbenchModeService = this._register(new WorkbenchModeService(configurationService, fileService, environmentService, uriIdentityService, logService, storageService)); - serviceCollection.set(IWorkbenchModeService, workbenchModeService); - - try { - await workbenchModeService.initialize(); - } catch (error) { - logService.error('Error while initializing workbench mode service', error); - } - // Workspace Trust Service const workspaceTrustEnablementService = new WorkspaceTrustEnablementService(configurationService, environmentService); serviceCollection.set(IWorkspaceTrustEnablementService, workspaceTrustEnablementService); diff --git a/src/vs/workbench/services/environment/browser/environmentService.ts b/src/vs/workbench/services/environment/browser/environmentService.ts index 880ce418f10..ec1a621d29e 100644 --- a/src/vs/workbench/services/environment/browser/environmentService.ts +++ b/src/vs/workbench/services/environment/browser/environmentService.ts @@ -138,9 +138,6 @@ export class BrowserWorkbenchEnvironmentService implements IBrowserWorkbenchEnvi @memoize get untitledWorkspacesHome(): URI { return joinPath(this.userRoamingDataHome, 'Workspaces'); } - @memoize - get builtinWorkbenchModesHome(): URI { return joinPath(this.userRoamingDataHome, 'builtinWorkbenchModes'); } - @memoize get serviceMachineIdResource(): URI { return joinPath(this.userRoamingDataHome, 'machineid'); } diff --git a/src/vs/workbench/services/layout/browser/workbenchModeService.ts b/src/vs/workbench/services/layout/browser/workbenchModeService.ts deleted file mode 100644 index e80ab6c958f..00000000000 --- a/src/vs/workbench/services/layout/browser/workbenchModeService.ts +++ /dev/null @@ -1,167 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { Emitter, Event } from '../../../../base/common/event.js'; -import { Disposable, DisposableStore } from '../../../../base/common/lifecycle.js'; -import { IFileService } from '../../../../platform/files/common/files.js'; -import { IEnvironmentService } from '../../../../platform/environment/common/environment.js'; -import { IWorkbenchModeConfiguration, IWorkbenchModeService } from '../common/workbenchModeService.js'; -import { ILogService } from '../../../../platform/log/common/log.js'; -import { URI } from '../../../../base/common/uri.js'; -import { IUriIdentityService } from '../../../../platform/uriIdentity/common/uriIdentity.js'; -import { parse } from '../../../../base/common/json.js'; -import { IWorkspaceContextService } from '../../../../platform/workspace/common/workspace.js'; -import { Registry } from '../../../../platform/registry/common/platform.js'; -import { Extensions, IConfigurationDefaults, IConfigurationRegistry } from '../../../../platform/configuration/common/configurationRegistry.js'; -import { IStringDictionary } from '../../../../base/common/collections.js'; -import { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js'; - -export class WorkbenchModeService extends Disposable implements IWorkbenchModeService { - - declare readonly _serviceBrand: undefined; - - private static readonly WORKBENCH_MODE_STORAGE_KEY = 'workbench.mode'; - - private _workbenchMode: string | undefined; - get workbenchMode(): string | undefined { return this._workbenchMode; } - - private readonly _onDidChangeWorkbenchMode = this._register(new Emitter()); - readonly onDidChangeWorkbenchMode: Event = this._onDidChangeWorkbenchMode.event; - - private readonly workbenchModeFileWatcherDiposables = this._register(new DisposableStore()); - private readonly configurationRegistry = Registry.as(Extensions.Configuration); - private configurationDefaults: IConfigurationDefaults | undefined; - - constructor( - @IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService, - @IFileService private readonly fileService: IFileService, - @IEnvironmentService private readonly environmentService: IEnvironmentService, - @IUriIdentityService private readonly uriIdentityService: IUriIdentityService, - @ILogService private readonly logService: ILogService, - @IStorageService private readonly storageService: IStorageService - ) { - super(); - this._workbenchMode = this.workspaceContextService.getWorkspace().isAgentSessionsWorkspace - ? 'agent-sessions' - : this.storageService.get(WorkbenchModeService.WORKBENCH_MODE_STORAGE_KEY, StorageScope.WORKSPACE); - this.watchCurrentModeFile(); - } - - async initialize(): Promise { - return this.updateWorkbenchModeConfiguration(); - } - - private async updateWorkbenchModeConfiguration(): Promise { - const workbenchModeConfiguration = this._workbenchMode ? await this.getWorkbenchModeConfiguration(this._workbenchMode) : undefined; - this.updateConfigurationDefaults(workbenchModeConfiguration?.settings); - } - - private updateConfigurationDefaults(configurationDefaults: IStringDictionary | undefined): void { - if (this.configurationDefaults) { - this.configurationRegistry.deregisterDefaultConfigurations([this.configurationDefaults]); - } - if (configurationDefaults) { - this.configurationDefaults = { overrides: configurationDefaults, donotCache: true }; - this.configurationRegistry.registerDefaultConfigurations([this.configurationDefaults]); - } else { - this.configurationDefaults = undefined; - } - } - - private watchCurrentModeFile(): void { - if (!this._workbenchMode) { - this.workbenchModeFileWatcherDiposables.clear(); - return; - } - - const workbenchModeFileUri = this.getWorkbenchModeFileUri(this._workbenchMode); - if (!workbenchModeFileUri) { - this.workbenchModeFileWatcherDiposables.clear(); - return; - } - - this.workbenchModeFileWatcherDiposables.add(this.fileService.watch(workbenchModeFileUri)); - this.workbenchModeFileWatcherDiposables.add(this.fileService.onDidFilesChange(e => { - if (e.affects(workbenchModeFileUri)) { - this.updateWorkbenchModeConfiguration(); - this._onDidChangeWorkbenchMode.fire(this._workbenchMode); - } - })); - } - - private getWorkbenchModeFileUri(layoutId: string): URI { - return this.uriIdentityService.extUri.joinPath(this.environmentService.builtinWorkbenchModesHome, `${layoutId}.code-workbench-mode`); - } - - async getWorkbenchModeConfiguration(id: string): Promise { - const resource = this.getWorkbenchModeFileUri(id); - return this.resolveWorkbenchModeConfiguration(resource); - } - - async getWorkbenchModeConfigurations(): Promise { - const result: IWorkbenchModeConfiguration[] = []; - const workbenchModesFolder = this.environmentService.builtinWorkbenchModesHome; - try { - const stat = await this.fileService.resolve(workbenchModesFolder); - if (!stat.children?.length) { - return result; - } - for (const child of stat.children) { - if (child.isDirectory) { - continue; - } - const workbenchModeConfiguration = await this.resolveWorkbenchModeConfiguration(child.resource); - if (workbenchModeConfiguration) { - result.push(workbenchModeConfiguration); - } - } - } catch (error) { - this.logService.error(`Error while reading workbench mode files from ${workbenchModesFolder.toString()}`, error); - } - return result; - } - - private async resolveWorkbenchModeConfiguration(workbenchConfigurationModeFile: URI): Promise { - if (this.uriIdentityService.extUri.extname(workbenchConfigurationModeFile) !== '.code-workbench-mode') { - return undefined; - } - try { - const content = (await this.fileService.readFile(workbenchConfigurationModeFile)).value.toString(); - const name = this.uriIdentityService.extUri.basename(workbenchConfigurationModeFile); - const workbenchModeConfiguration: IWorkbenchModeConfiguration = { - id: name.substring(0, name.length - '.code-workbench-mode'.length), - ...parse(content) - }; - return workbenchModeConfiguration; - } catch (error) { - this.logService.error(`Error while reading workbench mode file from ${workbenchConfigurationModeFile.toString()}`, error); - return undefined; - } - } - - async setWorkbenchMode(modeId: string | undefined): Promise { - if (this.workspaceContextService.getWorkspace().isAgentSessionsWorkspace) { - throw new Error('Cannot set workbench mode in an agent sessions workspace'); - } - - if (this._workbenchMode === modeId) { - return; - } - - this.updateWorkbenchMode(modeId); - await this.updateWorkbenchModeConfiguration(); - this.watchCurrentModeFile(); - this._onDidChangeWorkbenchMode.fire(modeId); - } - - private updateWorkbenchMode(modeId: string | undefined): void { - this._workbenchMode = modeId; - if (modeId === undefined) { - this.storageService.remove(WorkbenchModeService.WORKBENCH_MODE_STORAGE_KEY, StorageScope.WORKSPACE); - } else { - this.storageService.store(WorkbenchModeService.WORKBENCH_MODE_STORAGE_KEY, modeId, StorageScope.WORKSPACE, StorageTarget.MACHINE); - } - } -} diff --git a/src/vs/workbench/services/layout/common/workbenchModeService.ts b/src/vs/workbench/services/layout/common/workbenchModeService.ts deleted file mode 100644 index 87b5530d99d..00000000000 --- a/src/vs/workbench/services/layout/common/workbenchModeService.ts +++ /dev/null @@ -1,65 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { Event } from '../../../../base/common/event.js'; -import { IStringDictionary } from '../../../../base/common/collections.js'; -import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js'; - -export const IWorkbenchModeService = createDecorator('workbenchModeService'); - -export interface IWorkbenchModeConfiguration { - readonly id: string; - readonly name: string; - readonly settings: IStringDictionary; -} - -export interface IWorkbenchModeService { - readonly _serviceBrand: undefined; - - /** - * The currently active workbench mode id, or undefined if using default settings - */ - readonly workbenchMode: string | undefined; - - /** - * Event fired when the workbench mode changes - */ - readonly onDidChangeWorkbenchMode: Event; - - /** - * Resolve a workbench mode by its id - * @param id The id of the workbench mode to resolve - */ - getWorkbenchModeConfiguration(id: string): Promise; - - /** - * Get all workbench modes - */ - getWorkbenchModeConfigurations(): Promise; - - /** - * Set the active workbench mode. Pass undefined to clear the mode and return to defaults. - */ - setWorkbenchMode(workbenchMode: string | undefined): Promise; -} - -export class DefaultWorkbenchModeService implements IWorkbenchModeService { - - readonly _serviceBrand: undefined; - readonly workbenchMode: string | undefined = undefined; - readonly onDidChangeWorkbenchMode: Event = Event.None; - - getWorkbenchModeConfiguration(_id: string): Promise { - return Promise.resolve(undefined); - } - - getWorkbenchModeConfigurations(): Promise { - return Promise.resolve([]); - } - - setWorkbenchMode(_workbenchMode: string | undefined): Promise { - return Promise.resolve(); - } -}