MCPcopy Create free account
hub / github.com/diillson/chatcli / restoreSessionData

Method restoreSessionData

cli/cli_session.go:222–244  ·  view source on GitHub ↗

restoreSessionData restores history from a SessionData. Merges legacy separate histories into the unified history for backwards compatibility.

(sd *SessionData)

Source from the content-addressed store, hash-verified

220// restoreSessionData restores history from a SessionData.
221// Merges legacy separate histories into the unified history for backwards compatibility.
222func (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

Callers 1

handleLoadSessionMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected