From b1cbb9ca7cfbc6f01c42afab69a52b68c4930f4b Mon Sep 17 00:00:00 2001 From: Ollie Agent Date: Sat, 1 Aug 2026 20:35:02 +0200 Subject: [PATCH] session/fs: handle empty sessions during persistence persistSession: check sess.Core.Agent() != nil before saving. silently skip sessions with no agent instead of logging 'no active session' error on shutdown. SaveSession: return nil (no-op) when there are no agents, rather than returning an error that gets logged. --- fs/session/persist.go | 3 ++- session/session.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/session/persist.go b/fs/session/persist.go index 5c022e0..3c2d7ca 100644 --- a/fs/session/persist.go +++ b/fs/session/persist.go @@ -134,7 +134,8 @@ func persistSession(rs *rootState, id string) { if !ok { return } - if sess.Core == nil { + if sess.Core == nil || sess.Core.Agent() == nil { + // Empty session — no agent to persist. Silently skip. return } dir := activeSessionsDir(rs) diff --git a/session/session.go b/session/session.go index 72c239b..0a6a300 100644 --- a/session/session.go +++ b/session/session.go @@ -346,9 +346,10 @@ func (a *Session) flushSave() { } // SaveSession writes the current session state to the given path. +// Returns nil if there is no agent (empty session). func (a *Session) SaveSession(path string) error { if ag := a.Agent(); ag != nil { return ag.SaveFull(path, a.id, a.CWD(), a.remote) } - return fmt.Errorf("no agent in session") + return nil }