Skip to content

Add speedtest command#864

Draft
yazan-abu-obaideh wants to merge 2 commits intocoder:mainfrom
yazan-abu-obaideh:feat-750
Draft

Add speedtest command#864
yazan-abu-obaideh wants to merge 2 commits intocoder:mainfrom
yazan-abu-obaideh:feat-750

Conversation

@yazan-abu-obaideh
Copy link
Copy Markdown

@yazan-abu-obaideh yazan-abu-obaideh commented Mar 27, 2026

Closes #750

Copy link
Copy Markdown
Collaborator

@EhabY EhabY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing to this repo, appreciated ♥️

Also make sure to run format/lint:fix (I think the pipeline would fail now)

/**
* Build CLI auth flags for execFile (no shell escaping).
*/
function authArgs(auth: CliAuth): string[] {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure that this function exists elsewhere already, getGlobalFlags in the cli settings

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make this a JS file and run it using node so it's cross-platform

const featureSet = featureSetForVersion(version);
const configDir = this.pathResolver.getGlobalConfigDir(safeHost);
const configs = vscode.workspace.getConfiguration();
const auth = resolveCliAuth(configs, featureSet, baseUrl, configDir);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we only pass the auth but not the global flags which might break if users have proxy rules or headers. See openAppStatus and how it uses getGlobalFlags

const configDir = this.pathResolver.getGlobalConfigDir(safeHost);
const configs = vscode.workspace.getConfiguration();
const auth = resolveCliAuth(configs, featureSet, baseUrl, configDir);
const workspaceName = createWorkspaceIdentifier(this.workspace!);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid these kinds of null assertions (I thought we had a rule for that actually 🤔). Also might make sense to capture this.workspace in a variable in case it changes during one of the await operations (and would make the null assertion unnecessary as well)


/**
* Run a speed test against the specified workspace and return the JSON output.
* Throw if unable to execute the binary or parse the output.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This here does not parse the output so this is inaccurate

Comment on lines +181 to +186
const doc = await vscode.workspace.openTextDocument({
content: stdout,
language: "json",
});
await vscode.window.showTextDocument(doc);
} catch (error) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO I think we should show a save dialog instead of opening an untitled window.

We can show the save dialog then an info dialog that confirms it's been saved with a button to open the file in the editor

Comment on lines +159 to +164
await withProgress(
{
location: vscode.ProgressLocation.Notification,
title: "Running speed test...",
},
async () => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we pass the cancellation token to the CLI here? Also possibly use the -t argument and mention that in the title: https://coder.com/docs/reference/cli/speedtest#-t---time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add command to run a coder speedtest against a workspace

2 participants