Skip to content

Commit b1e281c

Browse files
committed
use built in coder cli
1 parent 68c2e04 commit b1e281c

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/commands.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { CertificateError } from "./error"
88
import { Storage } from "./storage"
99
import { AuthorityPrefix, toSafeHost } from "./util"
1010
import { OpenableTreeItem } from "./workspacesProvider"
11+
import path from "node:path"
1112

1213
export class Commands {
1314
// These will only be populated when actively connected to a workspace and are
@@ -422,8 +423,15 @@ export class Commands {
422423
vscode.commands.executeCommand("workbench.action.toggleMaximizedPanel")
423424
// If workspace_name is provided, run coder ssh before the command
424425
if (app.workspace_name) {
425-
terminal.sendText(`coder ssh ${app.workspace_name}`)
426-
// Sleep for 5 seconds
426+
let url = this.storage.getUrl()
427+
if (!url) {
428+
throw new Error("No coder url found for sidebar");
429+
}
430+
let binary = await this.storage.fetchBinary(this.restClient, toSafeHost(url))
431+
const escape = (str: string): string => `"${str.replace(/"/g, '\\"')}"`
432+
terminal.sendText(`${escape(binary)} ssh --global-config ${escape(
433+
path.dirname(this.storage.getSessionTokenPath(toSafeHost(url))),
434+
)} ${app.workspace_name}`)
427435
await new Promise((resolve) => setTimeout(resolve, 5000))
428436
terminal.sendText(app.command)
429437
} else {

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ [email protected]:
15941594

15951595
"coder@https://github.com/coder/coder#main":
15961596
version "0.0.0"
1597-
resolved "https://github.com/coder/coder#3a243c111b9abb5c38328169ff70064025bbe2fe"
1597+
resolved "https://github.com/coder/coder#2efb8088f4d923d1884fe8947dc338f9d179693b"
15981598

15991599
collapse-white-space@^1.0.2:
16001600
version "1.0.6"

0 commit comments

Comments
 (0)