Skip to content

Commit 0407d72

Browse files
feat: set 'vscode_connection' as build reason on workspace start (#550)
Co-authored-by: Ethan <39577870+ethanndickson@users.noreply.github.com>
1 parent 22d24da commit 0407d72

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/api.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import * as vscode from "vscode";
1212
import * as ws from "ws";
1313
import { errToStr } from "./api-helper";
1414
import { CertificateError } from "./error";
15+
import { FeatureSet } from "./featureSet";
1516
import { getHeaderArgs } from "./headers";
1617
import { getProxyForUrl } from "./proxy";
1718
import { Storage } from "./storage";
@@ -174,6 +175,7 @@ export async function startWorkspaceIfStoppedOrFailed(
174175
binPath: string,
175176
workspace: Workspace,
176177
writeEmitter: vscode.EventEmitter<string>,
178+
featureSet: FeatureSet,
177179
): Promise<Workspace> {
178180
// Before we start a workspace, we make an initial request to check it's not already started
179181
const updatedWorkspace = await restClient.getWorkspace(workspace.id);
@@ -191,6 +193,10 @@ export async function startWorkspaceIfStoppedOrFailed(
191193
"--yes",
192194
workspace.owner_name + "/" + workspace.name,
193195
];
196+
if (featureSet.buildReason) {
197+
startArgs.push(...["--reason", "vscode_connection"]);
198+
}
199+
194200
const startProcess = spawn(binPath, startArgs);
195201

196202
startProcess.stdout.on("data", (data: Buffer) => {

src/featureSet.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export type FeatureSet = {
44
vscodessh: boolean;
55
proxyLogDirectory: boolean;
66
wildcardSSH: boolean;
7+
buildReason: boolean;
78
};
89

910
/**
@@ -29,5 +30,10 @@ export function featureSetForVersion(
2930
wildcardSSH:
3031
(version ? version.compare("2.19.0") : -1) >= 0 ||
3132
version?.prerelease[0] === "devel",
33+
34+
// The --reason flag was added to `coder start` in 2.25.0
35+
buildReason:
36+
(version?.compare("2.25.0") || 0) >= 0 ||
37+
version?.prerelease[0] === "devel",
3238
};
3339
}

src/remote.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export class Remote {
6868
workspace: Workspace,
6969
label: string,
7070
binPath: string,
71+
featureSet: FeatureSet,
7172
): Promise<Workspace | undefined> {
7273
const workspaceName = `${workspace.owner_name}/${workspace.name}`;
7374

@@ -136,6 +137,7 @@ export class Remote {
136137
binPath,
137138
workspace,
138139
writeEmitter,
140+
featureSet,
139141
);
140142
break;
141143
case "failed":
@@ -153,6 +155,7 @@ export class Remote {
153155
binPath,
154156
workspace,
155157
writeEmitter,
158+
featureSet,
156159
);
157160
break;
158161
}
@@ -383,6 +386,7 @@ export class Remote {
383386
workspace,
384387
parts.label,
385388
binaryPath,
389+
featureSet,
386390
);
387391
if (!updatedWorkspace) {
388392
// User declined to start the workspace.

0 commit comments

Comments
 (0)
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