enrich sessions.json with openclaw-style runtime fields

This commit is contained in:
DBT
2026-02-23 15:13:36 +00:00
parent aac3a33c26
commit 4985a934a7

View File

@@ -386,6 +386,9 @@ func (sm *SessionManager) writeOpenClawSessionsIndex() error {
"sessionId": sid, "sessionId": sid,
"sessionKey": key, "sessionKey": key,
"updatedAt": s.Updated.UnixMilli(), "updatedAt": s.Updated.UnixMilli(),
"systemSent": true,
"abortedLastRun": false,
"compactionCount": 0,
"chatType": mapKindToChatType(s.Kind), "chatType": mapKindToChatType(s.Kind),
"sessionFile": sessionFile, "sessionFile": sessionFile,
"kind": s.Kind, "kind": s.Kind,
@@ -431,6 +434,7 @@ func (sm *SessionManager) loadSessions() error {
SessionKey string `json:"sessionKey"` SessionKey string `json:"sessionKey"`
UpdatedAt int64 `json:"updatedAt"` UpdatedAt int64 `json:"updatedAt"`
Kind string `json:"kind"` Kind string `json:"kind"`
ChatType string `json:"chatType"`
} }
if err := json.Unmarshal(data, &index); err == nil { if err := json.Unmarshal(data, &index); err == nil {
for key, row := range index { for key, row := range index {
@@ -441,6 +445,8 @@ func (sm *SessionManager) loadSessions() error {
} }
if strings.TrimSpace(row.Kind) != "" { if strings.TrimSpace(row.Kind) != "" {
session.Kind = row.Kind session.Kind = row.Kind
} else if strings.TrimSpace(row.ChatType) == "direct" {
session.Kind = "main"
} }
if row.UpdatedAt > 0 { if row.UpdatedAt > 0 {
session.Updated = time.UnixMilli(row.UpdatedAt) session.Updated = time.UnixMilli(row.UpdatedAt)