From 817df2b437c9af902b606125188ebb6df2d4f66f Mon Sep 17 00:00:00 2001 From: Ehab Younes Date: Tue, 15 Jul 2025 19:14:15 +0300 Subject: [PATCH 1/4] Use primary agent for the remote authority when opening a workspace --- src/commands.ts | 4 ++-- src/workspacesProvider.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/commands.ts b/src/commands.ts index d6734376..6d267032 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -440,8 +440,8 @@ export class Commands { baseUrl, treeItem.workspaceOwner, treeItem.workspaceName, - treeItem.workspaceAgent, - treeItem.workspaceFolderPath, + treeItem.primaryAgentName, + treeItem.primaryAgentFolderPath, true, ); } else { diff --git a/src/workspacesProvider.ts b/src/workspacesProvider.ts index a77b31ad..b8a16fef 100644 --- a/src/workspacesProvider.ts +++ b/src/workspacesProvider.ts @@ -436,8 +436,8 @@ export class OpenableTreeItem extends vscode.TreeItem { public readonly workspaceOwner: string, public readonly workspaceName: string, - public readonly workspaceAgent: string | undefined, - public readonly workspaceFolderPath: string | undefined, + public readonly primaryAgentName: string | undefined, + public readonly primaryAgentFolderPath: string | undefined, contextValue: CoderOpenableTreeItemType, ) { @@ -476,7 +476,7 @@ class AgentTreeItem extends OpenableTreeItem { } } -export class WorkspaceTreeItem extends OpenableTreeItem { +class WorkspaceTreeItem extends OpenableTreeItem { public appStatus: { name: string; url?: string; @@ -509,7 +509,7 @@ export class WorkspaceTreeItem extends OpenableTreeItem { : vscode.TreeItemCollapsibleState.Expanded, workspace.owner_name, workspace.name, - undefined, + agents[0]?.name, agents[0]?.expanded_directory, agents.length > 1 ? "coderWorkspaceMultipleAgents" From 028b6477652b0750e05204fa0c39f633849e0a5b Mon Sep 17 00:00:00 2001 From: Ehab Younes Date: Thu, 17 Jul 2025 01:31:01 +0300 Subject: [PATCH 2/4] Make workspace agent always defined --- src/commands.ts | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/commands.ts b/src/commands.ts index 6d267032..51965be6 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -436,6 +436,9 @@ export class Commands { if (!baseUrl) { throw new Error("You are not logged in"); } + if (treeItem.primaryAgentName === undefined) { + return; + } await openWorkspace( baseUrl, treeItem.workspaceOwner, @@ -524,6 +527,8 @@ export class Commands { let folderPath: string | undefined; let openRecent: boolean | undefined; + let workspace: Workspace | undefined; + const baseUrl = this.restClient.getAxiosInstance().defaults.baseURL; if (!baseUrl) { throw new Error("You are not logged in"); @@ -570,7 +575,7 @@ export class Commands { }); }); quickPick.show(); - const workspace = await new Promise((resolve) => { + workspace = await new Promise((resolve) => { quickPick.onDidHide(() => { resolve(undefined); }); @@ -589,20 +594,31 @@ export class Commands { } workspaceOwner = workspace.owner_name; workspaceName = workspace.name; + } else { + workspaceOwner = args[0] as string; + workspaceName = args[1] as string; + workspaceAgent = args[2] as string | undefined; + folderPath = args[3] as string | undefined; + openRecent = args[4] as boolean | undefined; + } + + if (!workspaceAgent) { + if (workspace === undefined) { + workspace = await this.restClient.getWorkspaceByOwnerAndName( + workspaceOwner, + workspaceName, + ); + } const agent = await this.maybeAskAgent(workspace); if (!agent) { // User declined to pick an agent. return; } - folderPath = agent.expanded_directory; + if (!folderPath) { + folderPath = agent.expanded_directory; + } workspaceAgent = agent.name; - } else { - workspaceOwner = args[0] as string; - workspaceName = args[1] as string; - workspaceAgent = args[2] as string | undefined; - folderPath = args[3] as string | undefined; - openRecent = args[4] as boolean | undefined; } await openWorkspace( @@ -677,7 +693,7 @@ async function openWorkspace( baseUrl: string, workspaceOwner: string, workspaceName: string, - workspaceAgent: string | undefined, + workspaceAgent: string, folderPath: string | undefined, openRecent: boolean | undefined, ) { From 730ada9907a2f9abed077d744e24e0b767e40c21 Mon Sep 17 00:00:00 2001 From: Ehab Younes Date: Fri, 18 Jul 2025 20:29:42 +0300 Subject: [PATCH 3/4] Add changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f07f13fb..d1607d81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - Update `/openDevContainer` to support all dev container features when hostPath and configFile are provided. +- Fix opening a workspace restores the VS Code session (files, tabs, context) + of the selected agent. ## [v1.9.2](https://github.com/coder/vscode-coder/releases/tag/v1.9.2) 2025-06-25 From befecc0cccbd0aeaef3ad3b36908ca42325205ce Mon Sep 17 00:00:00 2001 From: Ehab Younes Date: Tue, 22 Jul 2025 21:22:28 +0300 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1607d81..bc8fe7f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and configFile are provided. - Fix opening a workspace restores the VS Code session (files, tabs, context) of the selected agent. +- Consistently use the same session for each agent. Previously, + depending on how you connected, it could be possible to get two + different sessions for an agent. Existing connections may still + have this problem, only new connections are fixed. ## [v1.9.2](https://github.com/coder/vscode-coder/releases/tag/v1.9.2) 2025-06-25 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy