Skip to content

Commit a90fd3e

Browse files
committed
Add URI handler for one-click open
1 parent ef3759d commit a90fd3e

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"description": "Open any workspace with a single click.",
66
"repository": "https://github.com/coder/vscode-coder",
77
"preview": true,
8-
"version": "0.0.3",
8+
"version": "0.0.4",
99
"engines": {
1010
"vscode": "^1.73.0"
1111
},

src/extension.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,28 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
2424
})
2525

2626
vscode.window.registerUriHandler({
27-
handleUri: (uri) => {
27+
handleUri: async (uri) => {
2828
const params = new URLSearchParams(uri.query)
2929
if (uri.path === "/open") {
3030
const owner = params.get("owner")
31-
const name = params.get("name")
32-
vscode.commands.executeCommand("coder.open", owner, name)
31+
const workspace = params.get("workspace")
32+
const agent = params.get("agent")
33+
if (!owner) {
34+
throw new Error("owner must be specified as a query parameter")
35+
}
36+
if (!workspace) {
37+
throw new Error("workspace must be specified as a query parameter")
38+
}
39+
40+
const url = params.get("url")
41+
const token = params.get("token")
42+
if (url) {
43+
await storage.setURL(url)
44+
}
45+
if (token) {
46+
await storage.setSessionToken(token)
47+
}
48+
vscode.commands.executeCommand("coder.open", owner, workspace, agent)
3349
}
3450
},
3551
})

0 commit comments

Comments
 (0)