Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
}),
);

let shouldShowSshOutput = false;
// Since the "onResolveRemoteAuthority:ssh-remote" activation event exists
// in package.json we're able to perform actions before the authority is
// resolved by the remote SSH extension.
Expand All @@ -370,6 +371,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
);
if (details) {
ctx.subscriptions.push(details);
shouldShowSshOutput = details.startedWorkspace;
// Authenticate the plugin client which is used in the sidebar to display
// workspaces belonging to this deployment.
client.setHost(details.url);
Expand Down Expand Up @@ -460,9 +462,27 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
}
}
}

if (shouldShowSshOutput) {
showSshOutput();
}
Comment on lines +466 to +468
Copy link
Collaborator Author

@EhabY EhabY Oct 17, 2025

Choose a reason for hiding this comment

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

I'm aiming for a less intrusive UX by only showing the Output: Remote SSH channel when a workspace starts (i.e., when the startup script runs). However, since the channel logs activity during (normal) connection as well, we could always show it to help catch issues sooner. The caveat is that we can't automatically hide the output channel once a connection succeeds.

What would be the best UX approach here?

  • Show the output only after a workspace startup (current approach)
  • Show it always when connecting to a remote SSH (whether it's a startup or not).

Copy link
Collaborator Author

@EhabY EhabY Oct 17, 2025

Choose a reason for hiding this comment

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

I'm now leaning more towards the latter because those logs can be useful still even if this part is faster than the startup script part

Copy link
Member

Choose a reason for hiding this comment

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

If we could hide it after connecting I think it might make sense but as a user I feel like I might be annoyed if I have to keep closing the window every time I connect (but I am not a VS Code user so I could be wrong). Do we have users asking for this?

If we just want users to be aware something is happening, the progress notifications should cover that, but maybe we need to show more detail in the notification? Although, that is on the remote SSH extension side and not something we can change. 🤔

Copy link
Collaborator Author

@EhabY EhabY Oct 21, 2025

Choose a reason for hiding this comment

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

Do we have users asking for this?

This scenario was encountered by @dannykopping where their workspace seemed like it was stuck but it was just executing the startup script and working normally. Seeing the logs just shows that things are moving I suppose while the progress notification doesn't tell us if things are ACTUALLY working (can't tell if it's stuck).

I can keep it as is where we just show the output logs when we start the workspace, that way it's less annoying but might not show the output in some cases.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense. Actually, I was thinking at this stage we handed off to the remote extension and had no more control, but we do actually still control this part right? We start the workspace before handing off, I think? What if we updated the notification with the last line from the log? Or would that look janky? Maybe even just adding a "open build log" button would do the trick.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hahaha I went through the same exact confusion so I understand

Copy link
Member

Choose a reason for hiding this comment

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

On the one hand, it feels surprising the build watch endpoint does not also wait for startup scripts, on the other hand it does make sense, I suppose they are distinct steps.

Thinking out loud, maybe we could check if the agent has any blocking startup scripts (start_blocks_login I think) and then pop up the remote SSH log window if so.

The best long-term fix I suppose would be to actually follow and print the startup script logs, like with the /api/v2/workspaceagents/$id/logs?follow=true endpoint (watchWorkspaceAgentLogs in coder/coder's api.ts). But I think this endpoint stays open indefinitely. We would need some new endpoint specifically for the startup scripts I think.

Copy link
Member

Choose a reason for hiding this comment

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

Wait actually, I think the workspace status does tell us if the startup scripts finished? I vaguely remember doing this in the Jetbrains plugin now that I think about it.

Yeah there are lifecycle states to tell us if the scripts are done: https://github.com/coder/jetbrains-coder/blob/51d1d57bc80e8173b6603a8c4c39b8ffc0e6cbde/src/main/kotlin/com/coder/gateway/models/WorkspaceAndAgentStatus.kt#L31

We could combine that with watching logs

Copy link
Collaborator Author

@EhabY EhabY Oct 22, 2025

Choose a reason for hiding this comment

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

Ooooh that could be nice, watching the logs and showing a similar terminal to the Build Log one is very clear. But how do we know that the startup script finished executing besides just polling getWorkspace, extracting the agents and checking if the lifecycle is not starting?

Copy link
Member

@code-asher code-asher Oct 22, 2025

Choose a reason for hiding this comment

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

Polling is how we did it in Gateway but we could also use watchWorkspace I believe (I think we already use it, but would need some refactoring).

}

async function showTreeViewSearch(id: string): Promise<void> {
await vscode.commands.executeCommand(`${id}.focus`);
await vscode.commands.executeCommand("list.find");
}

function showSshOutput(): void {
for (const command of [
"opensshremotes.showLog",
"windsurf-remote-openssh.showLog",
]) {
/**
* We must not await this command because
* 1) it may not exist
* 2) it might cause the Remote SSH extension to be loaded synchronously
*/
void vscode.commands.executeCommand(command);
}
}
4 changes: 4 additions & 0 deletions src/remote/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { computeSSHProperties, sshSupportsSetEnv } from "./sshSupport";
export interface RemoteDetails extends vscode.Disposable {
url: string;
token: string;
startedWorkspace: boolean;
}

export class Remote {
Expand Down Expand Up @@ -415,6 +416,7 @@ export class Remote {
}
}

let startedWorkspace = false;
const disposables: vscode.Disposable[] = [];
try {
// Register before connection so the label still displays!
Expand Down Expand Up @@ -442,6 +444,7 @@ export class Remote {
await this.closeRemote();
return;
}
startedWorkspace = true;
workspace = updatedWorkspace;
}
this.commands.workspace = workspace;
Expand Down Expand Up @@ -681,6 +684,7 @@ export class Remote {
return {
url: baseUrlRaw,
token,
startedWorkspace,
dispose: () => {
disposables.forEach((d) => d.dispose());
},
Expand Down