diff --git a/session/session.go b/session/session.go index be472e9..d4171fe 100644 --- a/session/session.go +++ b/session/session.go @@ -39,6 +39,7 @@ type Session struct { prevPrompt []byte // last submitted prompt; overwritten on each new submission peers map[string]bool // peer session IDs (bidirectional links) remote string // SSH target for remote execution (empty = local) + mount *mountState // non-nil for remote sessions that need a local mount // Cached model list (expensive API call; refreshed every 24h). modelsMu sync.Mutex @@ -847,6 +848,9 @@ func (s *Manager) Shutdown() { if sess != nil { sess.Cancel() sess.Core.Close() + if sess.mount != nil { + teardownMount(sess.mount) + } s.cfg.Log.Info("shutdown session %s", id) } } @@ -860,6 +864,9 @@ func (s *Manager) KillSession(id string) { if sess != nil { sess.Cancel() sess.Core.Close() + if sess.mount != nil { + teardownMount(sess.mount) + } s.removePersistedSession(id) s.cfg.Log.Info("killed session %s", id) if s.cfg.OnSessionKilled != nil { @@ -1046,6 +1053,15 @@ func (s *Manager) CreateSession(args []string) (string, error) { sessPtr = sess sess.remote = remoteTarget + // For remote sessions, the mount isn't managed by a local execute.Server + // (which doesn't exist). Start it directly so $OLLIE is available for + // local prompt resolution. + if remoteTarget != "" && !s.cfg.NoMount { + ms := &mountState{envExtra: make(map[string]string)} + startMount(ms, uname) + sess.mount = ms + } + s.mu.Lock() sess.uname = uname s.sessions[sessID] = sess