(sessionID, cwd string)
| 43 | func (m *SessionManager) Create(cwd string) (*SessionController, error) { |
| 44 | id := uuid.NewString() |
| 45 | return m.createWithState(id, cwd, nil) |
| 46 | } |
| 47 | |
| 48 | func (m *SessionManager) Resume(sessionID, cwd string) (*SessionController, error) { |
| 49 | if strings.TrimSpace(sessionID) == "" { |
| 50 | return nil, errors.New("session_id is required") |
| 51 | } |
| 52 | m.mu.Lock() |
| 53 | if existing := m.sessions[sessionID]; existing != nil { |
| 54 | m.mu.Unlock() |
| 55 | return existing, nil |
| 56 | } |
| 57 | m.mu.Unlock() |
| 58 | state := m.store.LoadState(sessionID) |
| 59 | if state == nil { |
| 60 | messages := m.store.Load(sessionID) |
| 61 | if len(messages) > 0 { |
| 62 | s := agent.NewAgentState() |
| 63 | s.Messages = messages |
| 64 | state = &s |
| 65 | } |
| 66 | } |
| 67 | if state == nil { |
| 68 | return nil, fmt.Errorf("session %s not found", sessionID) |
| 69 | } |
| 70 | return m.createWithState(sessionID, cwd, state) |
| 71 | } |
no test coverage detected