Skip to content

Commit 3415626

Browse files
authored
Merge branch 'main' into add-agent-metadata-statusbar
2 parents dfc1a3a + cc07eb3 commit 3415626

File tree

6 files changed

+1091
-238
lines changed

6 files changed

+1091
-238
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
update notifications.
99
- Coder output panel enhancements: All log entries now include timestamps, and you
1010
can filter messages by log level in the panel.
11+
- Consistently use the same session for each agent. Previously,
12+
depending on how you connected, it could be possible to get two
13+
different sessions for an agent. Existing connections may still
14+
have this problem, only new connections are fixed.
1115
- Added an agent metadata monitor status bar item, so you can view your active
1216
agent metadata at a glance.
1317

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@
289289
"jsonc-parser": "^3.3.1",
290290
"memfs": "^4.17.1",
291291
"node-forge": "^1.3.1",
292-
"pretty-bytes": "^6.1.1",
293-
"proxy-agent": "^6.4.0",
292+
"pretty-bytes": "^7.0.0",
293+
"proxy-agent": "^6.5.0",
294294
"semver": "^7.7.1",
295295
"ua-parser-js": "1.0.40",
296296
"ws": "^8.18.2",
@@ -308,7 +308,7 @@
308308
"@typescript-eslint/parser": "^6.21.0",
309309
"@vscode/test-cli": "^0.0.10",
310310
"@vscode/test-electron": "^2.5.2",
311-
"@vscode/vsce": "^2.21.1",
311+
"@vscode/vsce": "^3.6.0",
312312
"bufferutil": "^4.0.9",
313313
"coder": "https://github.com/coder/coder#main",
314314
"dayjs": "^1.11.13",
@@ -323,8 +323,7 @@
323323
"nyc": "^17.1.0",
324324
"prettier": "^3.5.3",
325325
"ts-loader": "^9.5.1",
326-
"tsc-watch": "^6.2.1",
327-
"typescript": "^5.4.5",
326+
"typescript": "^5.8.3",
328327
"utf-8-validate": "^6.0.5",
329328
"vitest": "^0.34.6",
330329
"vscode-test": "^1.5.0",

src/commands.ts

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,15 @@ export class Commands {
437437
if (!baseUrl) {
438438
throw new Error("You are not logged in");
439439
}
440+
if (treeItem.primaryAgentName === undefined) {
441+
return;
442+
}
440443
await openWorkspace(
441444
baseUrl,
442445
treeItem.workspaceOwner,
443446
treeItem.workspaceName,
444-
treeItem.workspaceAgent,
445-
treeItem.workspaceFolderPath,
447+
treeItem.primaryAgentName,
448+
treeItem.primaryAgentFolderPath,
446449
true,
447450
);
448451
} else {
@@ -525,6 +528,8 @@ export class Commands {
525528
let folderPath: string | undefined;
526529
let openRecent: boolean | undefined;
527530

531+
let workspace: Workspace | undefined;
532+
528533
const baseUrl = this.restClient.getAxiosInstance().defaults.baseURL;
529534
if (!baseUrl) {
530535
throw new Error("You are not logged in");
@@ -571,7 +576,7 @@ export class Commands {
571576
});
572577
});
573578
quickPick.show();
574-
const workspace = await new Promise<Workspace | undefined>((resolve) => {
579+
workspace = await new Promise<Workspace | undefined>((resolve) => {
575580
quickPick.onDidHide(() => {
576581
resolve(undefined);
577582
});
@@ -590,20 +595,31 @@ export class Commands {
590595
}
591596
workspaceOwner = workspace.owner_name;
592597
workspaceName = workspace.name;
598+
} else {
599+
workspaceOwner = args[0] as string;
600+
workspaceName = args[1] as string;
601+
workspaceAgent = args[2] as string | undefined;
602+
folderPath = args[3] as string | undefined;
603+
openRecent = args[4] as boolean | undefined;
604+
}
605+
606+
if (!workspaceAgent) {
607+
if (workspace === undefined) {
608+
workspace = await this.restClient.getWorkspaceByOwnerAndName(
609+
workspaceOwner,
610+
workspaceName,
611+
);
612+
}
593613

594614
const agent = await this.maybeAskAgent(workspace);
595615
if (!agent) {
596616
// User declined to pick an agent.
597617
return;
598618
}
599-
folderPath = agent.expanded_directory;
619+
if (!folderPath) {
620+
folderPath = agent.expanded_directory;
621+
}
600622
workspaceAgent = agent.name;
601-
} else {
602-
workspaceOwner = args[0] as string;
603-
workspaceName = args[1] as string;
604-
workspaceAgent = args[2] as string | undefined;
605-
folderPath = args[3] as string | undefined;
606-
openRecent = args[4] as boolean | undefined;
607623
}
608624

609625
await openWorkspace(
@@ -679,7 +695,7 @@ async function openWorkspace(
679695
baseUrl: string,
680696
workspaceOwner: string,
681697
workspaceName: string,
682-
workspaceAgent: string | undefined,
698+
workspaceAgent: string,
683699
folderPath: string | undefined,
684700
openRecent: boolean | undefined,
685701
) {

src/workspacesProvider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,8 @@ export class OpenableTreeItem extends vscode.TreeItem {
379379

380380
public readonly workspaceOwner: string,
381381
public readonly workspaceName: string,
382-
public readonly workspaceAgent: string | undefined,
383-
public readonly workspaceFolderPath: string | undefined,
382+
public readonly primaryAgentName: string | undefined,
383+
public readonly primaryAgentFolderPath: string | undefined,
384384

385385
contextValue: CoderOpenableTreeItemType,
386386
) {
@@ -419,7 +419,7 @@ class AgentTreeItem extends OpenableTreeItem {
419419
}
420420
}
421421

422-
export class WorkspaceTreeItem extends OpenableTreeItem {
422+
class WorkspaceTreeItem extends OpenableTreeItem {
423423
public appStatus: {
424424
name: string;
425425
url?: string;
@@ -452,7 +452,7 @@ export class WorkspaceTreeItem extends OpenableTreeItem {
452452
: vscode.TreeItemCollapsibleState.Expanded,
453453
workspace.owner_name,
454454
workspace.name,
455-
undefined,
455+
agents[0]?.name,
456456
agents[0]?.expanded_directory,
457457
agents.length > 1
458458
? "coderWorkspaceMultipleAgents"

tsconfig.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@
1010
"strict": true,
1111
"esModuleInterop": true,
1212
"skipLibCheck": true,
13-
"forceConsistentCasingInFileNames": true
13+
"forceConsistentCasingInFileNames": true,
14+
"paths": {
15+
// axios contains both an index.d.ts and index.d.cts which apparently have
16+
// conflicting types. For some reason TypeScript is reading both and
17+
// throwing errors about AxiosInstance not being compatible with
18+
// AxiosInstance. This ensures we use only index.d.ts.
19+
"axios": ["./node_modules/axios/index.d.ts"]
20+
}
1421
},
1522
"exclude": ["node_modules"],
1623
"include": ["src/**/*"]

0 commit comments

Comments
 (0)