feat: implement local terminal support with shell configuration and UI integration

This commit is contained in:
Andy Dixon
2026-05-21 13:13:06 +01:00
parent 3ff04feb92
commit a7cf28b404
21 changed files with 626 additions and 3 deletions
+42
View File
@@ -24,6 +24,7 @@ import (
"github.com/andydixon/nexus/internal/audit"
"github.com/andydixon/nexus/internal/exportimport"
"github.com/andydixon/nexus/internal/localshell"
"github.com/andydixon/nexus/internal/models"
"github.com/andydixon/nexus/internal/preferences"
"github.com/andydixon/nexus/internal/secrets"
@@ -369,6 +370,24 @@ func (s *Service) ConnectQuick(profile models.Profile) (models.SessionInfo, erro
return *info, nil
}
// ConnectLocal opens a local shell session using the configured (or default) shell.
func (s *Service) ConnectLocal() (models.SessionInfo, error) {
shell := ""
if s.prefs != nil {
prefs := s.prefs.Get()
shell = prefs.LocalShell
}
sessionID, err := s.sessions.ConnectLocal(shell)
if err != nil {
return models.SessionInfo{}, err
}
info := s.sessions.GetSessionInfo(sessionID)
if info == nil {
return models.SessionInfo{}, fmt.Errorf("session created but info not found")
}
return *info, nil
}
// DisconnectSession closes a session by ID.
func (s *Service) DisconnectSession(sessionID string) error {
return s.sessions.Disconnect(sessionID)
@@ -923,6 +942,29 @@ func (s *Service) GetVNCWebSocketURL(sessionID string) (string, error) {
return s.sessions.GetVNCWebSocketURL(sessionID)
}
// ---------------------------------------------------------------------------
// Local shell
// ---------------------------------------------------------------------------
// GetDefaultShell returns the system's default shell path.
func (s *Service) GetDefaultShell() string {
return localshell.DefaultShell()
}
// BrowseForShell opens a file dialog to select a shell binary.
func (s *Service) BrowseForShell() (string, error) {
if s.ctx == nil {
return "", fmt.Errorf("application context not set")
}
path, err := wailsRuntime.OpenFileDialog(s.ctx, wailsRuntime.OpenDialogOptions{
Title: "Select Shell Binary",
})
if err != nil {
return "", fmt.Errorf("file dialog failed: %w", err)
}
return path, nil
}
// ---------------------------------------------------------------------------
// Port forwarding
// ---------------------------------------------------------------------------