From ab2937bef3682cb1f09f47e2ec864f1c294f2f77 Mon Sep 17 00:00:00 2001 From: kyuz0 Date: Tue, 1 Dec 2026 18:51:39 +0000 Subject: [PATCH] Keep live workspace folders when initialization overtakes the cache --- patches/local-storage.diff | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/patches/local-storage.diff b/patches/local-storage.diff index 1056f7630c04..31ce6c4ead26 100644 --- a/patches/local-storage.diff +++ b/patches/local-storage.diff @@ -11,8 +11,10 @@ IndexedDB and does not appear nearly as easy to redirect to disk. To test change settings from the UI and on disk while making sure they appear on the other side. -This patch also resolves a bug where a global value for workspace initialization -is used in a non async-safe way. +When opening a remote workspace for the first time, the server can finish reading +its workspace file after the browser creates an empty cached workspace but before +it assigns that workspace. Use the loaded configuration at assignment so Explorer +shows the folders listed in the file. Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts =================================================================== @@ -79,15 +81,24 @@ Index: code-server/lib/vscode/src/vs/workbench/services/configuration/browser/co }); })); -@@ -574,6 +576,12 @@ export class WorkspaceService extends Di +@@ -535,6 +537,10 @@ export class WorkspaceService extends Di + + private async createMultiFolderWorkspace(workspaceIdentifier: IWorkspaceIdentifier): Promise { + await this.workspaceConfiguration.initialize({ id: workspaceIdentifier.id, configPath: workspaceIdentifier.configPath }, this.isWorkspaceTrusted); ++ return this.workspaceFromConfiguration(workspaceIdentifier); ++ } ++ ++ private workspaceFromConfiguration(workspaceIdentifier: IWorkspaceIdentifier): Workspace { + const workspaceConfigPath = workspaceIdentifier.configPath; + const workspaceFolders = toWorkspaceFolders(this.workspaceConfiguration.getFolders(), workspaceConfigPath, this.uriIdentityService.extUri); + const workspaceId = workspaceIdentifier.id; +@@ -574,6 +580,10 @@ export class WorkspaceService extends Di previousFolders = this.workspace.folders; this.workspace.update(workspace); } else { -+ // It is possible for the configuration to become initialized in between -+ // when the workspace was created and this function was called, so check -+ // the configuration again now. -+ if (!workspace.initialized && this.workspaceConfiguration.initialized) { -+ workspace.initialized = true; ++ // The live configuration may have replaced the cache after this workspace was created. ++ if (!workspace.initialized && workspace.configuration && this.workspaceConfiguration.initialized) { ++ workspace = this.workspaceFromConfiguration({ id: workspace.id, configPath: workspace.configuration }); + } this.workspace = workspace; }