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
This commit is contained in:
Levi Neely 2026-04-21 18:28:54 +02:00
parent 24e4209a95
commit ac0970c5b2
1 changed files with 17 additions and 1 deletions

View File

@ -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()