Add pause resume and abort controls

This commit is contained in:
Mikei386
2026-06-14 22:34:22 +02:00
parent 82d00bd116
commit 656d569b27
13 changed files with 228 additions and 11 deletions
+20 -1
View File
@@ -37,7 +37,7 @@ func (q *Queue) RestoreHistory(runs []model.Run) {
q.mu.Lock()
defer q.mu.Unlock()
for _, run := range runs {
if run.Status == "queued" || run.Status == "running" {
if run.Status == "queued" || run.Status == "running" || run.Status == "paused" {
run.Status = "failed"
run.ErrorCode = "environment"
run.Message = "daemon restarted while task was active"
@@ -125,6 +125,25 @@ func (q *Queue) Cancel(id string) bool {
return false
}
func (q *Queue) SetPaused(id string, paused bool) bool {
q.mu.Lock()
defer q.mu.Unlock()
if q.active == nil || q.active.ID != id {
return false
}
expected := "running"
next := "paused"
if !paused {
expected, next = "paused", "running"
}
if q.active.Status != expected {
return false
}
q.active.Status = next
q.emitLocked()
return true
}
func (q *Queue) Stop() {
q.mu.Lock()
q.stopping = true