Skip to content

impl: enhanced workflow for network disruptions #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 25, 2025

Conversation

fioan89
Copy link
Collaborator

@fioan89 fioan89 commented Jul 23, 2025

Currently, when the network connection drops, the Coder TBX plugin resets itself, redirects users to the authentication page, and terminates active SSH sessions to remote IDEs. This disrupts the user experience, forcing users to manually reconnect once the network is restored. Additionally, since the SSH session to the remote IDE is lost, the JBClient is unable to re-establish a connection with the remote backend.

This PR aims to improve that experience by adopting a behavior similar to the SSH plugin. Instead of clearing the list of workspaces or dropping existing SSH sessions during a network outage, we retain them. Once the network is restored, the plugin will automatically reinitialize the HTTP client and regenerate the SSH configuration—only if the number of workspaces has changed during the disconnection—without requiring user intervention.

Additionally we also add support for remembering SSH connections that were not manually disconnected by the user. This allows the plugin to automatically restore those connections on the next startup enabling remote IDEs that remained open to reconnect once the SSH link is re-established.

fioan89 added 2 commits July 23, 2025 23:45
Currently, when the network connection drops, the Coder TBX plugin resets itself, redirects users to the authentication page, and terminates active SSH sessions to remote IDEs. This disrupts the user experience, forcing users to manually reconnect once the network is restored. Additionally, since the SSH session to the remote IDE is lost, the JBClient is unable to re-establish a connection with the remote backend.

This PR aims to improve that experience by adopting a behavior similar to the SSH plugin. Instead of clearing the list of workspaces or dropping existing SSH sessions during a network outage, we retain them. Once the network is restored, the plugin will automatically reinitialize the HTTP client and regenerate the SSH configuration—only if the number of workspaces has changed during the disconnection—without requiring user intervention.
Adds support for remembering SSH connections that were not manually disconnected by the user.
This allows the plugin to automatically restore those connections on the next startup
enabling remote IDEs that remained open to reconnect once the SSH link is re-established.
@fioan89 fioan89 requested review from matifali and f0ssel July 23, 2025 22:07
Comment on lines +211 to +214
if (isManual) {
// if the user manually disconnects the ssh connection we should not connect automatically
context.settingsStore.updateAutoConnect(this.id, false)
}
Copy link
Member

Choose a reason for hiding this comment

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

Why this choice? If the user manually disconnects and then connects again, we should still try to resume the last active connection if possible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If you take a look at beforeConnection we set auto-connect to true. In other words:

  • user connects the ssh, and then TBX is closed -> at the next restart we automatically reconnect.
  • user connects to the ssh, manually disconnects and then TBX is closed -> at the next restart we no longer reconnect automatically because the user made a conscious choice to disconnect.
  • user connects to the ssh, manually disconnects, then reconnects again the ssh session, and then TBX is closed -> at the next restart we automatically reconnect.

Copy link
Member

@matifali matifali left a comment

Choose a reason for hiding this comment

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

I have a few questions and suggestions.

@matifali
Copy link
Member

Tested on macOS with both Coder Desktop and without, and the connection seems to recover gracefully. I noticed some delay (5-10s) in showing Connecting in Toolbox after seeing Connecting in IDE first.

@fioan89 fioan89 marked this pull request as ready for review July 24, 2025 21:28
@fioan89
Copy link
Collaborator Author

fioan89 commented Jul 24, 2025

Tested on macOS with both Coder Desktop and without, and the connection seems to recover gracefully. I noticed some delay (5-10s) in showing Connecting in Toolbox after seeing Connecting in IDE first.

This looks like it is under JetBrains control. I can reproduce the same thing with the SSH plugin. The "Connecting" is a state from from JetBrains.

@fioan89 fioan89 requested a review from matifali July 24, 2025 21:31
Copy link
Member

@matifali matifali left a comment

Choose a reason for hiding this comment

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

Thanks. I tested and it works as expected.

fioan89 added 2 commits July 25, 2025 01:21
Auto connect will now happen everytime at start up if there is a url and token available.
Reason for the major change: major changes in how we handle network disruptions
@fioan89 fioan89 merged commit 296e311 into main Jul 25, 2025
6 checks passed
@fioan89 fioan89 deleted the impl-improved-workflow-after-network-goes-down branch July 25, 2025 13:47
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.

2 participants