| 1 | package main |
| 2 | |
| 3 | import "reasonix/internal/agent" |
| 4 | |
| 5 | // SessionMeta summarises one saved session for the history panel. |
| 6 | type SessionMeta struct { |
| 7 | Source *SessionSourceRef `json:"source,omitempty"` |
| 8 | Historical bool `json:"historical,omitempty"` |
| 9 | HistoricalBranch bool `json:"historicalBranch,omitempty"` |
| 10 | PreparationStatus string `json:"preparationStatus,omitempty"` |
| 11 | Path string `json:"path"` |
| 12 | SessionID string `json:"sessionId,omitempty"` |
| 13 | HostID string `json:"hostId,omitempty"` |
| 14 | Codec string `json:"codec,omitempty"` |
| 15 | Error string `json:"error,omitempty"` |
| 16 | Preview string `json:"preview"` // first user message |
| 17 | Title string `json:"title,omitempty"` // user-chosen name, when set (overrides preview) |
| 18 | Turns int `json:"turns"` |
| 19 | TurnsState string `json:"turnsState"` |
| 20 | CreatedAt int64 `json:"createdAt"` // unix milliseconds |
| 21 | LastActivityAt int64 `json:"lastActivityAt"` // unix milliseconds |
| 22 | ModTime int64 `json:"modTime"` // compatibility alias for lastActivityAt |
| 23 | DeletedAt int64 `json:"deletedAt,omitempty"` |
| 24 | Current bool `json:"current"` |
| 25 | Open bool `json:"open"` |
| 26 | Scope string `json:"scope,omitempty"` |
| 27 | WorkspaceRoot string `json:"workspaceRoot,omitempty"` |
| 28 | TopicID string `json:"topicId,omitempty"` |
| 29 | TopicTitle string `json:"topicTitle,omitempty"` |
| 30 | Kind string `json:"kind,omitempty"` // "channel" for external IM transcripts |
| 31 | Channel string `json:"channel,omitempty"` |
| 32 | ChannelLabel string `json:"channelLabel,omitempty"` |
| 33 | RemoteID string `json:"remoteId,omitempty"` |
| 34 | ChatType string `json:"chatType,omitempty"` |
| 35 | UserID string `json:"userId,omitempty"` |
| 36 | ThreadID string `json:"threadId,omitempty"` |
| 37 | SessionSource string `json:"sessionSource,omitempty"` |
| 38 | Recovered bool `json:"recovered,omitempty"` // created by conflict recovery, including an adopted/continued branch |
| 39 | RecoveryCopy bool `json:"recoveryCopy,omitempty"` // actual branch content is unchanged and covered by its parent |
| 40 | // Optional v1.24.2 lineage fields; older clients ignore them safely. |
| 41 | RecoveryGroupID string `json:"recoveryGroupId,omitempty"` |
| 42 | RecoveryRole string `json:"recoveryRole,omitempty"` // normal|covered_copy|adopted|diverged |
| 43 | RecoveryCanonical bool `json:"recoveryCanonical,omitempty"` |
| 44 | } |
| 45 | |
| 46 | func sessionMetaFromInfo(s agent.SessionInfo, title string, current, open bool, deletedAt int64, parentDir string) SessionMeta { |
| 47 | turnsState := "unknown" |
| 48 | if s.CountsKnown { |
| 49 | turnsState = "valid" |
| 50 | } |
| 51 | return SessionMeta{ |
| 52 | Path: s.Path, |
| 53 | Preview: s.Preview, |
| 54 | Title: title, |
| 55 | Turns: s.Turns, |
| 56 | TurnsState: turnsState, |
| 57 | CreatedAt: s.CreatedAt.UnixMilli(), |
| 58 | LastActivityAt: s.LastActivityAt.UnixMilli(), |
| 59 | ModTime: s.LastActivityAt.UnixMilli(), |
| 60 | DeletedAt: deletedAt, |
| 61 | Current: current, |
| 62 | Open: open, |
| 63 | Scope: s.Scope, |
| 64 | WorkspaceRoot: s.WorkspaceRoot, |
| 65 | TopicID: s.TopicID, |
| 66 | TopicTitle: s.TopicTitle, |
| 67 | Recovered: sessionInfoIsAutomaticRecovery(s), |
| 68 | RecoveryCopy: sessionInfoIsUnmodifiedRecoveryCopy(s, parentDir), |
| 69 | } |
| 70 | } |
| 71 |