feat(ssh): cancellable connection attempts#66
Open
BungeeDEV wants to merge 1 commit into
Open
Conversation
Let the user abort an in-flight SSH/SFTP connection from the connecting
dialog instead of waiting for the handshake to time out.
Backend:
- SshManager tracks in-flight attempts by a frontend-supplied attempt_id
in a `pending_connects` map. connect / connect_no_pty race establish +
PTY-open against a CancellationToken; on cancel the future is dropped
mid-await so partial handles tear down and nothing is inserted into
`sessions` (no ghost session).
- New ssh_cancel_connect command + SshError::Cancelled ("cancelled").
- attempt_id threaded through ssh_connect / connect_saved_host /
connect_saved_host_no_pty; pf_start_tunnel passes None.
Frontend:
- HostsDashboard generates an attempt_id per connect/explore/recent flow,
exposes a cancel() that calls ssh_cancel_connect and disconnects if the
session settled in the race window.
- ConnectionDialog shows a Cancel button while connecting; Escape cancels
during connect and closes in the error state.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds support for cancelling in-progress SSH connection attempts from the frontend, improving the user experience when connecting to SSH hosts. The changes introduce a new cancellation mechanism on both the backend (Rust) and frontend (React/TypeScript), allowing users to abort SSH handshakes cleanly and avoid ghost sessions or lingering handles. Additionally, the UI now provides a Cancel button during connection attempts, and Escape key handling is improved for cancelling or closing dialogs.
SSH Connection Cancellation Support
Backend (Rust):
ssh_cancel_connectTauri command and corresponding handler inSshManager, allowing the frontend to abort an in-flight SSH connection attempt via a frontend-suppliedattempt_id. The backend races the handshake against a cancellation token, ensuring no ghost sessions are left on cancellation. [1] [2] [3] [4] [5] [6] [7]attempt_idparameter, wiring it through to the manager for cancellation support. [1] [2] [3] [4] [5]SshError::Cancelledvariant to signal when a connection attempt was cancelled, and updated serialization for error reporting. [1] [2]Frontend (React/TypeScript):
ConnectionDialogcomponent to support anonCancelcallback, display a Cancel button while connecting, and use Escape to cancel or close as appropriate. [1] [2]HostsDashboardto generate a uniqueattemptIdper connect attempt, provide a cancel function that calls the backend cancel command, and clean up UI state and backend sessions if cancelled. [1] [2] [3] [4] [5] [6] [7]These changes ensure that users can abort SSH connection attempts responsively, and the backend will not leave any partial or ghost sessions if a connection is cancelled.