Skip to content

Allow for transient workspaces that go away after restart or window reload #119695

@alyssajotice

Description

@alyssajotice

Version: 1.55.0-insider (user setup)
Commit: 111a6ce
Date: 2021-03-18T05:14:49.087Z
Electron: 11.3.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Windows_NT x64 10.0.19042

Possibly related to #110982

I have been working on finding a way to leave a Live Share session upon a user reload. Our current strategy, based on the discussion in #110982 was to delete the Live Share workspace files during deactivate. I have built out this approach but after the workspace has been deleted, VS Code has a workspace open with the title Visual Studio Live Share (Workspace). I made the following test extension to demonstrate the behavior we are seeing. Can you explain why this behavior is happening? Is there a way to close the current workspace during the reloading process to achieve our desired behavior?

Steps to Reproduce:

  1. Run the attached extension
  2. Open the folder C:\Users\UserProfile\AppData\Local\Temp\vsliveshare
  3. From the extension development host, join a Live Share session
  4. Observe the workspace be added to the vsliveshare folder
  5. From the command palette, run the command Delete temp workspace files upon reload
  6. Reload the window
  7. Observe workspace folder being deleted via the logs and the vsliveshare folder

Expected Behavior: VS Code will go back to being in a fresh state with no workspaces open
Actual Behavior: VS Code has the deleted workspace open and is in a bad state

extension.ts

import * as vscode from 'vscode';
import * as path from 'path';
import * as os from 'os';
import * as fs from 'fs';

export var shouldDeleteUponReload: boolean;

export function activate(context: vscode.ExtensionContext) {
	console.log('Congratulations, your extension "delete-workspace" is now active!');
	let disposable = vscode.commands.registerCommand('delete-workspace.shouldDeleteUponReload', () => {
		shouldDeleteUponReload = true;
	});
	context.subscriptions.push(disposable);
}

export async function deactivate() {
	const LIVESHARE_WORKSPACE_TEMP_DIR = path.join(os.tmpdir(), 'vsliveshare');
	console.log(shouldDeleteUponReload);
	if (shouldDeleteUponReload) {
		await fs.readdir(LIVESHARE_WORKSPACE_TEMP_DIR, (err, files) => {
			files.forEach(file => {
				let dir = LIVESHARE_WORKSPACE_TEMP_DIR + '\\' + file;
				fs.rmdir(dir, { recursive: true }, (err) =>{ console.log(err?.message); });
				console.log("Removed: " + dir);
			});
		});
	}
}

delete-workspace.zip

cc @bpasero

Metadata

Metadata

Assignees

Labels

feature-requestRequest for new features or functionalityon-release-notesIssue/pull request mentioned in release noteson-testplanworkbench-multirootMulti-root (multiple folders) issues

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions