diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f55972573..7c9478d739 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,33 @@ from published versions since it shows up in the VS Code extension changelog tab and is confusing to users. Add it back between releases if needed. --> +## Unreleased + +### Added + +- A Workspaces panel is now the Coder Remote sidebar, replacing the legacy My + Workspaces, Shared Workspaces, and All Workspaces tree views. From one place + you can: + - Switch between your workspaces, workspaces shared with you, and, for + owners, all workspaces. + - Search the listed workspaces by name, owner, or template with `Ctrl+F` + (`Cmd+F` on macOS). + - See at a glance whether each workspace and agent is healthy, and which + workspaces have a Coder Agents chat. + - Expand a workspace to see its agents, dev containers, app statuses, and + agent metadata. + - Start, stop, restart, update, and delete workspaces without leaving the + editor. You're asked to confirm before deleting a workspace or + interrupting the one you're connected to. + - Open a workspace or a specific agent, or go to its dashboard, sharing, or + settings page. + - Ping, run a speed test, or collect a support bundle for a specific agent. + - Keep working from the last results if your deployment can't be reached. +- To switch back to the legacy tree views, choose **Switch to Legacy Tree + Views** from the panel's **...** menu, or set `coder.workspacesPanel.enabled` + to `false`. No reload is needed, and **Switch to Workspaces Panel** switches + back. + ## [v1.18.1](https://github.com/coder/vscode-coder/releases/tag/v1.18.1) 2026-11-18 ### Security diff --git a/package.json b/package.json index a003faf418..60a894ea33 100644 --- a/package.json +++ b/package.json @@ -194,6 +194,12 @@ "default": false, "scope": "application" }, + "coder.workspacesPanel.enabled": { + "markdownDescription": "Show workspaces in the Coder sidebar as a single panel where you can filter, check status, and start, stop, or update them. Disable to use the legacy My Workspaces, Shared Workspaces, and All Workspaces tree views instead.", + "type": "boolean", + "default": true, + "scope": "application" + }, "coder.sshFlags": { "markdownDescription": "Additional flags to pass to the `coder ssh` command when establishing SSH connections. Enter each flag as a separate array item; values are passed verbatim and in order. See the [CLI ssh reference](https://coder.com/docs/reference/cli/ssh) for available flags.\n\nNote: `--network-info-dir` and `--ssh-host-prefix` are ignored (managed internally). Prefer `#coder.proxyLogDirectory#` over `--log-dir`/`-l` for full functionality.", "type": "array", @@ -334,22 +340,25 @@ "id": "coderTasks", "title": "Coder Tasks (Deprecated)", "icon": "media/tasks-logo.svg" - }, - { - "id": "coderExperimentalWorkspaces", - "title": "Coder Workspaces", - "icon": "media/shorthand-logo.svg" } ] }, "views": { "coder": [ + { + "type": "webview", + "id": "coder.workspacesPanel", + "name": "Workspaces", + "icon": "media/logo-white.svg", + "when": "config.coder.workspacesPanel.enabled" + }, { "id": "myWorkspaces", "name": "My Workspaces", "visibility": "visible", "icon": "media/logo-white.svg", - "initialSize": 2 + "initialSize": 2, + "when": "!config.coder.workspacesPanel.enabled" }, { "id": "sharedWorkspaces", @@ -357,7 +366,7 @@ "visibility": "visible", "icon": "media/logo-white.svg", "initialSize": 1, - "when": "coder.authenticated" + "when": "!config.coder.workspacesPanel.enabled && coder.authenticated" }, { "id": "allWorkspaces", @@ -365,7 +374,7 @@ "visibility": "visible", "icon": "media/logo-white.svg", "initialSize": 1, - "when": "coder.authenticated && coder.isOwner" + "when": "!config.coder.workspacesPanel.enabled && coder.authenticated && coder.isOwner" } ], "coderTasks": [ @@ -382,15 +391,6 @@ "icon": "media/tasks-logo.svg", "when": "coder.authenticated && coder.tasksSupported" } - ], - "coderExperimentalWorkspaces": [ - { - "type": "webview", - "id": "coder.workspacesPanel", - "name": "Coder Workspaces", - "icon": "media/shorthand-logo.svg", - "when": "coder.workspacesPanelEnabled" - } ] }, "viewsWelcome": [ @@ -469,12 +469,6 @@ "title": "Update Workspace", "category": "Coder" }, - { - "command": "coder.refreshWorkspaces", - "title": "Refresh Workspace", - "category": "Coder", - "icon": "$(refresh)" - }, { "command": "coder.speedTest", "title": "Speed Test Workspace", @@ -561,6 +555,16 @@ "category": "Coder", "icon": "$(search)" }, + { + "command": "coder.workspaces.showPanel", + "title": "Switch to Workspaces Panel", + "category": "Coder" + }, + { + "command": "coder.workspaces.showTreeViews", + "title": "Switch to Legacy Tree Views", + "category": "Coder" + }, { "command": "coder.applyRecommendedSettings", "title": "Apply Recommended SSH Settings", @@ -642,10 +646,6 @@ "command": "coder.workspace.update", "when": "coder.workspace.updatable" }, - { - "command": "coder.refreshWorkspaces", - "when": "coder.authenticated" - }, { "command": "coder.viewLogs", "when": "true" @@ -699,12 +699,20 @@ }, { "command": "coder.workspaces.refresh", - "when": "false" + "when": "coder.authenticated" }, { "command": "coder.workspaces.search", "when": "false" }, + { + "command": "coder.workspaces.showPanel", + "when": "!config.coder.workspacesPanel.enabled" + }, + { + "command": "coder.workspaces.showTreeViews", + "when": "config.coder.workspacesPanel.enabled" + }, { "command": "coder.applyRecommendedSettings" } @@ -725,6 +733,16 @@ "group": "deployment@1", "when": "coder.authenticated && (view == myWorkspaces || view == coder.workspacesPanel)" }, + { + "command": "coder.workspaces.showPanel", + "group": "view@1", + "when": "view == myWorkspaces" + }, + { + "command": "coder.workspaces.showTreeViews", + "group": "view@1", + "when": "view == coder.workspacesPanel" + }, { "command": "coder.login", "when": "!coder.authenticated && (view == myWorkspaces || view == coder.workspacesPanel)" @@ -734,21 +752,11 @@ "when": "coder.authenticated && (view == myWorkspaces || view == coder.workspacesPanel)", "group": "navigation@1" }, - { - "command": "coder.refreshWorkspaces", - "when": "coder.authenticated && view == myWorkspaces", - "group": "navigation@2" - }, { "command": "coder.searchMyWorkspaces", "when": "coder.authenticated && view == myWorkspaces", "group": "navigation@3" }, - { - "command": "coder.refreshWorkspaces", - "when": "coder.authenticated && view == sharedWorkspaces", - "group": "navigation@2" - }, { "command": "coder.searchSharedWorkspaces", "when": "coder.authenticated && view == sharedWorkspaces", @@ -766,8 +774,8 @@ }, { "command": "coder.workspaces.refresh", - "when": "coder.authenticated && view == coder.workspacesPanel", - "group": "navigation@1" + "when": "coder.authenticated && (view == myWorkspaces || view == sharedWorkspaces || view == allWorkspaces || view == coder.workspacesPanel)", + "group": "navigation@2" }, { "command": "coder.workspaces.search", diff --git a/packages/workspaces/README.md b/packages/workspaces/README.md index e45eadbfc8..c8cce52c98 100644 --- a/packages/workspaces/README.md +++ b/packages/workspaces/README.md @@ -2,21 +2,8 @@ This package contains the Workspaces webview panel for the Coder VS Code extension. -## Enabling the Feature - -The workspaces panel is controlled by the `coder.experimental.workspacesPanel` configuration setting. - -To enable via settings.json: - -1. Open your VS Code settings.json (Cmd/Ctrl + Shift + P → "Preferences: Open User Settings (JSON)") -2. Add the following: - -```json -{ - "coder.experimental.workspacesPanel": true -} -``` - -3. Reload VS Code - -The **Coder Workspaces** activity bar icon opens the **Coder Workspaces** view when the setting is enabled. +The panel is the default view in the **Coder Remote** sidebar. Setting +`coder.workspacesPanel.enabled` to `false` shows the My Workspaces, Shared +Workspaces, and All Workspaces tree views instead. The sidebar shows either the +panel or the tree views, never both, and switches as soon as the setting +changes. diff --git a/src/extension.ts b/src/extension.ts index c63f7afb96..3cef29c3d2 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -34,9 +34,12 @@ import { WorkspacesPanelProvider } from "./webviews/workspaces/workspacesPanelPr import { WorkspaceStore } from "./webviews/workspaces/workspaceStore"; import { WorkspaceProvider } from "./workspace/workspacesProvider"; +import type { WorkspaceFilter } from "@repo/shared"; + const MY_WORKSPACES_TREE_ID = "myWorkspaces"; const SHARED_WORKSPACES_TREE_ID = "sharedWorkspaces"; const ALL_WORKSPACES_TREE_ID = "allWorkspaces"; +const WORKSPACES_PANEL_SETTING = "coder.workspacesPanel.enabled"; export async function activate(ctx: vscode.ExtensionContext): Promise { const serviceContainer = new ServiceContainer(ctx); @@ -174,30 +177,6 @@ async function doActivate( ); ctx.subscriptions.push(announcementManager); - const myWorkspacesProvider = new WorkspaceProvider( - "mine", - client, - output, - deploymentManager.session, - ); - ctx.subscriptions.push(myWorkspacesProvider); - - const allWorkspacesProvider = new WorkspaceProvider( - "all", - client, - output, - deploymentManager.session, - ); - ctx.subscriptions.push(allWorkspacesProvider); - - const sharedWorkspacesProvider = new WorkspaceProvider( - "shared", - client, - output, - deploymentManager.session, - ); - ctx.subscriptions.push(sharedWorkspacesProvider); - // The deprecated Tasks panel only shows on deployments old enough to // still support it, which requires fetching the deployment version. const updateTasksSupported = async () => { @@ -223,31 +202,6 @@ async function doActivate( }), ); - // createTreeView, unlike registerTreeDataProvider, gives us the tree view API - // (so we can see when it is visible) but otherwise they have the same effect. - const registerWorkspaceTreeView = ( - viewId: string, - provider: WorkspaceProvider, - ) => { - const tree = vscode.window.createTreeView(viewId, { - treeDataProvider: provider, - }); - ctx.subscriptions.push(tree); - provider.setVisibility(tree.visible); - tree.onDidChangeVisibility( - (event) => provider.setVisibility(event.visible), - undefined, - ctx.subscriptions, - ); - }; - - registerWorkspaceTreeView(MY_WORKSPACES_TREE_ID, myWorkspacesProvider); - registerWorkspaceTreeView( - SHARED_WORKSPACES_TREE_ID, - sharedWorkspacesProvider, - ); - registerWorkspaceTreeView(ALL_WORKSPACES_TREE_ID, allWorkspacesProvider); - // Register globally available commands. Many of these have visibility // controlled by contexts, see `when` in the package.json. const commands = new Commands(serviceContainer, client, deploymentManager); @@ -286,53 +240,99 @@ async function doActivate( ), ); - const workspacesPanelEnabled = vscode.workspace - .getConfiguration("coder") - .get("experimental.workspacesPanel", false); - - contextManager.set("coder.workspacesPanelEnabled", workspacesPanelEnabled); - - const workspaceStore = workspacesPanelEnabled - ? new WorkspaceStore(client, output, deploymentManager.session) - : undefined; + // The `when` clauses show either the workspaces panel or the tree views, as + // the setting picks. Both stay registered and only fetch while visible. + const workspaceStore = new WorkspaceStore( + client, + output, + deploymentManager.session, + ); // Until the stored session is checked, signed out means "not known yet". const markSessionRestored = () => { contextManager.set("coder.loaded", true); - void workspaceStore?.markSessionRestored(); + void workspaceStore.markSessionRestored(); }; - - if (workspaceStore) { - const workspacesPanelProvider = new WorkspacesPanelProvider( - ctx.extensionUri, - workspaceStore, + const workspacesPanelProvider = new WorkspacesPanelProvider( + ctx.extensionUri, + workspaceStore, + commands, + new WorkspaceActionRunner( + client, + deploymentManager.session, commands, - new WorkspaceActionRunner( - client, - deploymentManager.session, - commands, - telemetryService, - output, - ), + telemetryService, output, - ); + ), + output, + ); - commandManager.register("coder.workspaces.refresh", () => - workspacesPanelProvider.refresh(), - ); - commandManager.register("coder.workspaces.search", () => - workspacesPanelProvider.showSearch(), - ); + ctx.subscriptions.push( + workspaceStore, + workspacesPanelProvider, + vscode.window.registerWebviewViewProvider( + WorkspacesPanelProvider.viewType, + workspacesPanelProvider, + { webviewOptions: { retainContextWhenHidden: true } }, + ), + ); + // createTreeView, unlike registerTreeDataProvider, gives us the tree view API + // (so we can see when it is visible) but otherwise they have the same effect. + const createWorkspaceTree = (viewId: string, filter: WorkspaceFilter) => { + const provider = new WorkspaceProvider( + filter, + client, + output, + deploymentManager.session, + ); + const tree = vscode.window.createTreeView(viewId, { + treeDataProvider: provider, + }); + provider.setVisibility(tree.visible); ctx.subscriptions.push( - workspaceStore, - workspacesPanelProvider, - vscode.window.registerWebviewViewProvider( - WorkspacesPanelProvider.viewType, - workspacesPanelProvider, - { webviewOptions: { retainContextWhenHidden: true } }, + provider, + tree, + tree.onDidChangeVisibility((event) => + provider.setVisibility(event.visible), ), ); - } + return provider; + }; + const workspaceTrees = [ + createWorkspaceTree(MY_WORKSPACES_TREE_ID, "mine"), + createWorkspaceTree(SHARED_WORKSPACES_TREE_ID, "shared"), + createWorkspaceTree(ALL_WORKSPACES_TREE_ID, "all"), + ]; + + commandManager.register("coder.workspaces.search", () => + workspacesPanelProvider.showSearch(), + ); + commandManager.register("coder.workspaces.showPanel", () => + vscode.workspace + .getConfiguration() + .update( + WORKSPACES_PANEL_SETTING, + true, + vscode.ConfigurationTarget.Global, + ), + ); + commandManager.register("coder.workspaces.showTreeViews", () => + vscode.workspace + .getConfiguration() + .update( + WORKSPACES_PANEL_SETTING, + false, + vscode.ConfigurationTarget.Global, + ), + ); + + // Hidden views skip the refresh and list again when shown. + commandManager.register("coder.workspaces.refresh", async () => { + await Promise.all([ + workspacesPanelProvider.refresh(), + ...workspaceTrees.map((tree) => tree.fetchAndRefresh()), + ]); + }); ctx.subscriptions.push( registerUriHandler({ @@ -377,11 +377,6 @@ async function doActivate( "coder.navigateToWorkspaceSettings", commands.navigateToWorkspaceSettings.bind(commands), ); - commandManager.register("coder.refreshWorkspaces", () => { - void myWorkspacesProvider.fetchAndRefresh(); - void sharedWorkspacesProvider.fetchAndRefresh(); - void allWorkspacesProvider.fetchAndRefresh(); - }); commandManager.register("coder.viewLogs", commands.viewLogs.bind(commands)); commandManager.register( "coder.openSshConfig", diff --git a/src/supportBundle/settings.ts b/src/supportBundle/settings.ts index d13d6b6fc4..9a543997e8 100644 --- a/src/supportBundle/settings.ts +++ b/src/supportBundle/settings.ts @@ -38,6 +38,7 @@ const COLLECTED_SETTINGS: readonly string[] = [ "coder.tlsCertFile", "coder.tlsKeyFile", "coder.useKeyring", + "coder.workspacesPanel.enabled", "remote.SSH.connectTimeout", "remote.SSH.logLevel", "remote.SSH.reconnectionGraceTime", diff --git a/src/vscode/commandManager.ts b/src/vscode/commandManager.ts index 68e4fe3069..a83a87a66b 100644 --- a/src/vscode/commandManager.ts +++ b/src/vscode/commandManager.ts @@ -22,7 +22,6 @@ export const CODER_COMMAND_IDS = [ "coder.createWorkspace", "coder.navigateToWorkspace", "coder.navigateToWorkspaceSettings", - "coder.refreshWorkspaces", "coder.viewLogs", "coder.openSshConfig", "coder.exportTelemetry", @@ -42,6 +41,8 @@ export const CODER_COMMAND_IDS = [ "coder.tasks.refresh", "coder.workspaces.refresh", "coder.workspaces.search", + "coder.workspaces.showPanel", + "coder.workspaces.showTreeViews", ] as const; export type CoderCommandId = (typeof CODER_COMMAND_IDS)[number]; diff --git a/src/vscode/contextManager.ts b/src/vscode/contextManager.ts index 368272c4a5..c8ab30ad41 100644 --- a/src/vscode/contextManager.ts +++ b/src/vscode/contextManager.ts @@ -7,7 +7,6 @@ const CONTEXT_DEFAULTS = { "coder.tasksSupported": false, "coder.workspace.connected": false, "coder.workspace.updatable": false, - "coder.workspacesPanelEnabled": false, } as const; type CoderContext = keyof typeof CONTEXT_DEFAULTS; diff --git a/src/webviews/workspaces/workspacesPanelProvider.ts b/src/webviews/workspaces/workspacesPanelProvider.ts index 5f5dd079c3..6b87937d5d 100644 --- a/src/webviews/workspaces/workspacesPanelProvider.ts +++ b/src/webviews/workspaces/workspacesPanelProvider.ts @@ -155,8 +155,14 @@ export class WorkspacesPanelProvider this.syncVisibility(); } - /** List again, reporting a failure since the user asked for it. */ + /** + * List again, reporting a failure since the user asked for it. A hidden + * panel does nothing: it lists when shown, and its last status may be stale. + */ public async refresh(): Promise { + if (!this.view?.visible) { + return; + } await this.store.refresh(); const { status } = this.store.state; if (status.kind === "failed") { diff --git a/test/unit/vscode/commandManager.test.ts b/test/unit/vscode/commandManager.test.ts index 74ce8af8e4..a3b7629e7c 100644 --- a/test/unit/vscode/commandManager.test.ts +++ b/test/unit/vscode/commandManager.test.ts @@ -58,8 +58,8 @@ describe("CommandManager", () => { const { manager } = makeHarness(); const handler = vi.fn((a: number, b: number) => a + b); - manager.register("coder.refreshWorkspaces", handler); - const result = await getRegisteredCallback("coder.refreshWorkspaces")( + manager.register("coder.workspaces.refresh", handler); + const result = await getRegisteredCallback("coder.workspaces.refresh")( 2, 3, ); @@ -83,15 +83,15 @@ describe("CommandManager", () => { describe("telemetry", () => { it("emits one command.invoked event with success and a numeric durationMs on success", async () => { const { manager, sink } = makeHarness(); - manager.register("coder.refreshWorkspaces", () => "ok"); + manager.register("coder.workspaces.refresh", () => "ok"); - await getRegisteredCallback("coder.refreshWorkspaces")(); + await getRegisteredCallback("coder.workspaces.refresh")(); expect(sink.events).toHaveLength(1); expect(sink.events[0]).toMatchObject({ eventName: "command.invoked", properties: { - command_id: "coder.refreshWorkspaces", + command_id: "coder.workspaces.refresh", result: "success", }, }); diff --git a/test/unit/webviews/workspaces/workspacesPanelProvider.test.ts b/test/unit/webviews/workspaces/workspacesPanelProvider.test.ts index 133c3710b1..377a21dbf8 100644 --- a/test/unit/webviews/workspaces/workspacesPanelProvider.test.ts +++ b/test/unit/webviews/workspaces/workspacesPanelProvider.test.ts @@ -269,6 +269,18 @@ describe("WorkspacesPanelProvider", () => { ); }); + it("does not report an earlier failure when refreshed while hidden", async () => { + const h = setup(); + h.client.getWorkspaces.mockRejectedValueOnce(new Error("offline")); + h.hooks.setVisible(true); + await h.store.settled; + h.hooks.setVisible(false); + + await h.provider.refresh(); + expect(vscode.window.showErrorMessage).not.toHaveBeenCalled(); + expect(h.client.getWorkspaces).toHaveBeenCalledOnce(); + }); + interface OpenCase { name: string; params: OpenWorkspaceParams;