Skip to content

Add speedtest command#864

Open
yazan-abu-obaideh wants to merge 1 commit intocoder:mainfrom
yazan-abu-obaideh:feat-750
Open

Add speedtest command#864
yazan-abu-obaideh wants to merge 1 commit 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)

@yazan-abu-obaideh
Copy link
Copy Markdown
Author

@EhabY happy to contribute 😉

(should pass now 🙏)

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.

Love the tests! I think we'll have to await Asher's response for the UX but the rest are smaller issues!

Comment on lines +152 to +158
if (isWindows()) {
await fs.writeFile(echoArgsBin, `@node "${scriptPath}" %*\r\n`);
} else {
const content = await fs.readFile(scriptPath, "utf8");
await fs.writeFile(echoArgsBin, `#!/usr/bin/env node\n${content}`);
await fs.chmod(echoArgsBin, "755");
}
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.

Do we need this? Can't we execute the JS file the same way?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not if we want to use 'execFile', which takes the binPath. Is it worth it for testing convenience? 🤔

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.

Fair enough, I think your solution makes sense. We can add the shebang to the JS file so on non-Windows we just copy the file as is but on Windows we prepend but honestly could go either way

Add speed test command + tests. Runs the speedtest command through the Coder Cli and opens a json for the user to view.
@EhabY EhabY marked this pull request as ready for review April 5, 2026 19:13
Comment on lines +126 to +128
if (!this.onAuthRequired) {
return false;
}
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 already guard on this so I would throw here instead

Comment on lines +218 to +220

if (!result.ok) {
if (!result.cancelled) {
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.

Nit: flatten this out like:

if(result.cancelled) {
    return
}
if (result.ok) {
...
} else {
...
}

if (!result.cancelled) {
this.logger.error("Speed test failed", result.error);
vscode.window.showErrorMessage(
`Speed test failed: ${result.error instanceof Error ? result.error.message : String(result.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.

We already have toError from errorUtils.ts

binPath: string,
globalFlags: string[],
workspaceName: string,
options: { signal?: AbortSignal; duration?: string },
Copy link
Copy Markdown
Collaborator

@EhabY EhabY Apr 5, 2026

Choose a reason for hiding this comment

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

I don't love mixing two different kinds of options, one for args and one for the execution itself 🤔

Actually maybe inline this, it's very similar to the one in commands#openAppStatus. If we want to separate it out for testability then maybe we use a separate file for this? Something like core/cliExec.ts? (we'd move the version to it)

Comment on lines +196 to +198
const baseUrl = this.requireExtensionBaseUrl();
const safeHost = toSafeHost(baseUrl);
const binary = await this.cliManager.fetchBinary(this.extensionClient);
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 should use the this.remoteWorkspaceClient since users can be connected to a deployment that is different than the one logged in from the sidebar!

content: result.value,
language: "json",
});
vscode.window.showTextDocument(doc);
Copy link
Copy Markdown
Collaborator

@EhabY EhabY Apr 5, 2026

Choose a reason for hiding this comment

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

Let's await this one for consistency actually

Comment on lines +185 to +187
return /^\d+[smh]$/.test(v.trim())
? null
: "Enter a duration like 5s, 10s, or 1m";
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.

The issue here is that this will always be incomplete, this basically accepts ANY Go duration string like 1m30s, maybe we just fail for invalid input?

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

3 participants