diff --git a/CHANGELOG.md b/CHANGELOG.md index 80371d86..c32ffad0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ update notifications. - Coder output panel enhancements: All log entries now include timestamps, and you can filter messages by log level in the panel. +- 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 diff --git a/src/commands.ts b/src/commands.ts index 7485c0b2..3a6fafb4 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -437,12 +437,15 @@ export class Commands { if (!baseUrl) { throw new Error("You are not logged in"); } + if (treeItem.primaryAgentName === undefined) { + return; + } await openWorkspace( baseUrl, treeItem.workspaceOwner, treeItem.workspaceName, - treeItem.workspaceAgent, - treeItem.workspaceFolderPath, + treeItem.primaryAgentName, + treeItem.primaryAgentFolderPath, true, ); } else { @@ -525,6 +528,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"); @@ -571,7 +576,7 @@ export class Commands { }); }); quickPick.show(); - const workspace = await new Promise((resolve) => { + workspace = await new Promise((resolve) => { quickPick.onDidHide(() => { resolve(undefined); }); @@ -590,20 +595,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( @@ -679,7 +695,7 @@ async function openWorkspace( baseUrl: string, workspaceOwner: string, workspaceName: string, - workspaceAgent: string | undefined, + workspaceAgent: string, folderPath: string | undefined, openRecent: boolean | undefined, ) { diff --git a/src/workspacesProvider.ts b/src/workspacesProvider.ts index 64b74e7d..59915e58 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" 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