From ac0970c5b2c6f28864654c8023ee05caa0498c99 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Tue, 21 Apr 2026 18:28:54 +0200 Subject: [PATCH] store: add SessionStore.SessionFileStore to match BatchStore.JobStore pattern - SessionStore now owns construction of its child SessionFileStore - Add SaveTranscript to SessionStoreConfig - Server delegates to SessionStore instead of assembling the child --- pkg/store/session.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pkg/store/session.go b/pkg/store/session.go index 2339b34..5658be0 100644 --- a/pkg/store/session.go +++ b/pkg/store/session.go @@ -87,7 +87,8 @@ type SessionStoreConfig struct { MkdirAll func(string, os.FileMode) error // OnRename is called after a session is renamed in the map, // for protocol-level fixups (e.g. fid path rewriting). - OnRename func(oldID, newID string) + OnRename func(oldID, newID string) + SaveTranscript func([]byte) error } // SessionStore implements Store for session management. @@ -191,6 +192,21 @@ func (s *SessionStore) Session(id string) *Session { return s.sessions[id] } +// SessionFileStore returns a SessionFileStore for the given session ID. +func (s *SessionStore) SessionFileStore(id string) (*SessionFileStore, bool) { + sess := s.Session(id) + if sess == nil { + return nil, false + } + return NewSessionFileStore( + sess, + s.cfg.Log, + func() { s.KillSession(id) }, + func(newID string) error { return s.Rename(id, newID) }, + s.cfg.SaveTranscript, + ), true +} + // InterruptAll interrupts every active session. func (s *SessionStore) InterruptAll() { s.mu.RLock()