MarkByID updates the status of the task with the given 1-indexed ID. Returns false when no such task exists. Used by the @todo plugin's partial-update path when the LLM wants to flip a single status without resending the whole list. The CurrentTask cursor advances if the marked task was the current
(id int, status TaskStatus, errorMsg string)
| 341 | // The CurrentTask cursor advances if the marked task was the current |
| 342 | // one and the new status is Completed, mirroring MarkCurrentAs. |
| 343 | func (t *TaskTracker) MarkByID(id int, status TaskStatus, errorMsg string) bool { |
| 344 | t.mu.Lock() |
| 345 | defer t.mu.Unlock() |
| 346 | |
| 347 | if t.plan == nil { |
| 348 | return false |
| 349 | } |
| 350 | idx := id - 1 |
| 351 | if idx < 0 || idx >= len(t.plan.Tasks) { |
| 352 | return false |
| 353 | } |
| 354 | tk := t.plan.Tasks[idx] |
| 355 | tk.Status = status |
| 356 | tk.Attempts++ |
| 357 | switch status { |
| 358 | case TaskInProgress: |
| 359 | if tk.StartedAt.IsZero() { |
| 360 | tk.StartedAt = time.Now() |
| 361 | } |
| 362 | case TaskCompleted: |
| 363 | tk.CompletedAt = time.Now() |
| 364 | if idx == t.plan.CurrentTask { |
| 365 | t.plan.CurrentTask++ |
| 366 | } |
| 367 | case TaskFailed: |
| 368 | tk.Error = errorMsg |
| 369 | t.plan.FailureCount++ |
| 370 | if t.plan.FailureCount >= 3 { |
| 371 | t.plan.NeedsReplan = true |
| 372 | } |
| 373 | } |
| 374 | t.plan.UpdatedAt = time.Now() |
| 375 | return true |
| 376 | } |
| 377 | |
| 378 | func (t *TaskTracker) FormatProgress() string { |
| 379 | t.mu.Lock() |