restoreSessionData restores history from a SessionData. Merges legacy separate histories into the unified history for backwards compatibility.
(sd *SessionData)
| 220 | // restoreSessionData restores history from a SessionData. |
| 221 | // Merges legacy separate histories into the unified history for backwards compatibility. |
| 222 | func (cli *ChatCLI) restoreSessionData(sd *SessionData) { |
| 223 | cli.history = sd.ChatHistory |
| 224 | if cli.history == nil { |
| 225 | cli.history = make([]models.Message, 0) |
| 226 | } |
| 227 | |
| 228 | // Backwards compatibility: merge legacy separate histories if present |
| 229 | if len(sd.AgentHistory) > 0 || len(sd.CoderHistory) > 0 { |
| 230 | // Append non-system messages from legacy agent/coder histories |
| 231 | for _, msg := range sd.AgentHistory { |
| 232 | if msg.Role != "system" { |
| 233 | cli.history = append(cli.history, msg) |
| 234 | } |
| 235 | } |
| 236 | for _, msg := range sd.CoderHistory { |
| 237 | if msg.Role != "system" { |
| 238 | cli.history = append(cli.history, msg) |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | cli.checkpoints = nil |
| 244 | } |
| 245 | |
| 246 | // handleSearchSessions runs a full-text search across saved sessions and |
| 247 | // prints the matching sessions with context snippets. It reuses the existing |