mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-08 18:57:33 +08:00
enrich sessions.json with openclaw-style runtime fields
This commit is contained in:
@@ -383,12 +383,15 @@ func (sm *SessionManager) writeOpenClawSessionsIndex() error {
|
|||||||
sid = deriveSessionID(key)
|
sid = deriveSessionID(key)
|
||||||
}
|
}
|
||||||
entry := map[string]interface{}{
|
entry := map[string]interface{}{
|
||||||
"sessionId": sid,
|
"sessionId": sid,
|
||||||
"sessionKey": key,
|
"sessionKey": key,
|
||||||
"updatedAt": s.Updated.UnixMilli(),
|
"updatedAt": s.Updated.UnixMilli(),
|
||||||
"chatType": mapKindToChatType(s.Kind),
|
"systemSent": true,
|
||||||
"sessionFile": sessionFile,
|
"abortedLastRun": false,
|
||||||
"kind": s.Kind,
|
"compactionCount": 0,
|
||||||
|
"chatType": mapKindToChatType(s.Kind),
|
||||||
|
"sessionFile": sessionFile,
|
||||||
|
"kind": s.Kind,
|
||||||
}
|
}
|
||||||
s.mu.RUnlock()
|
s.mu.RUnlock()
|
||||||
index[key] = entry
|
index[key] = entry
|
||||||
@@ -427,10 +430,11 @@ func (sm *SessionManager) loadSessions() error {
|
|||||||
indexPath := filepath.Join(sm.storage, "sessions.json")
|
indexPath := filepath.Join(sm.storage, "sessions.json")
|
||||||
if data, err := os.ReadFile(indexPath); err == nil {
|
if data, err := os.ReadFile(indexPath); err == nil {
|
||||||
var index map[string]struct {
|
var index map[string]struct {
|
||||||
SessionID string `json:"sessionId"`
|
SessionID string `json:"sessionId"`
|
||||||
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user