Skip to content

Conversation

@leonhausdorf
Copy link
Collaborator

Summary

This PR implements configurable SSH connection timeouts and enhanced error classification to improve user experience when connecting to remote hosts. The changes address common pain points where the UI would hang on unreachable hosts and users recieved cryptic error messages that were difficult to diagnose.

Motivation

The current SSH implementation had several usability issues:

  1. SSH connections used hardcoded timeouts, causing the interface to appear frozen when connecting to unreachable hosts.
  2. Generic error messages like "connection failed" provided no actionable information for users
  3. Network environments vary, but timeout values were fixed
  4. Users couldn't easily distinguish between network issues, authentication problems, or host key mismatches

Changes Made

With this update a new ConnectionConfig struct was introduced with configurable timeouts. SSH errors are now Context-aware with descritptions that provide actionable suggestions. The enhancement leaves functions unchanged but added the *WithConfig variant to not introduce breaking changes.

Error Classification

  • Timeout errors: "Connection timed out (host may be unreachable or firewall blocking)"
  • Connection refused: "Connection refused (SSH daemon may not be running or wrong port)"
  • Authentication failures: "Authentication failed (check SSH keys or credentials)"
  • Host key issues: "Host key verification failed (run 'keymaster trust-host' to accept)

Integration Points

  • All existing ssh.Dial calls now use configurable timeouts
  • Error classification applied on connection failures
  • Deployer struct extended to store configuration for future use

Testing

  • Unit tests provide a 100% coverage of new timeout and error classification functions
  • Edge case testing for nil errors, various error message formats and boundary conditions
  • Integration for timeout configuration properly applied to SSH connections

Test results:

$ go test ./internal/deploy
  ok      github.com/toeirei/keymaster/internal/deploy    0.476s

Additional notes

Love those QoL enhancements

@ToeiRei ToeiRei merged commit 03595f4 into ToeiRei:main Sep 29, 2025
1 check passed
@ToeiRei
Copy link
Owner

ToeiRei commented Sep 29, 2025

Love, love me do - beatles.

@leonhausdorf leonhausdorf added this to the v1.4 milestone Sep 29, 2025
@leonhausdorf leonhausdorf added enhancement New feature or request tui Everything related to our Text User Interface component labels Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request tui Everything related to our Text User Interface component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants