mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-30 11:07:29 +08:00
task lifecycle + heartbeat resilience: preserve archived done tasks and reset heartbeat session on pairing-loop errors
This commit is contained in:
@@ -1029,6 +1029,7 @@ func (e *Engine) persistStateLocked() {
|
||||
existingMap[it.ID] = it
|
||||
}
|
||||
items := make([]TaskItem, 0, len(e.state))
|
||||
built := map[string]struct{}{}
|
||||
for _, st := range e.state {
|
||||
status := "todo"
|
||||
switch st.Status {
|
||||
@@ -1056,6 +1057,7 @@ func (e *Engine) persistStateLocked() {
|
||||
if strings.TrimSpace(source) == "" {
|
||||
source = "memory_todo"
|
||||
}
|
||||
built[st.ID] = struct{}{}
|
||||
items = append(items, TaskItem{
|
||||
ID: st.ID,
|
||||
ParentTaskID: prev.ParentTaskID,
|
||||
@@ -1076,6 +1078,18 @@ func (e *Engine) persistStateLocked() {
|
||||
UpdatedAt: nowRFC3339(),
|
||||
})
|
||||
}
|
||||
for _, old := range existing {
|
||||
if old.ID == "" {
|
||||
continue
|
||||
}
|
||||
if _, ok := built[old.ID]; ok {
|
||||
continue
|
||||
}
|
||||
st := strings.ToLower(strings.TrimSpace(old.Status))
|
||||
if st == "done" || st == "canceled" || st == "paused" {
|
||||
items = append(items, old)
|
||||
}
|
||||
}
|
||||
_ = e.taskStore.Save(items)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user