Add scheduled tasks with a Project tab section and lead tools

This commit is contained in:
Ian Gulliver
2026-10-21 15:15:20 -07:00
parent 4b4763779d
commit f445e1cac3
21 changed files with 1689 additions and 347 deletions
+16 -3
View File
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log/slog"
"time"
)
const abandonedMergeText = "The Merge turn ended unfinished (interrupted, failed to start, or with no final message), so byre didn't squash or push the task. Merge again to retry."
@@ -17,21 +18,29 @@ func (m *Manager) poke() {
func (m *Manager) coordinate() {
started := map[string]bool{}
timer := time.NewTimer(time.Hour)
timer.Stop()
for {
select {
case <-m.watchStop:
return
case <-m.pokes:
m.coordinatePass(context.Background(), started)
case <-timer.C:
}
next := m.coordinatePass(context.Background(), started)
timer.Stop()
if next != nil {
timer.Reset(time.Until(*next))
}
}
}
func (m *Manager) coordinatePass(ctx context.Context, started map[string]bool) {
func (m *Manager) coordinatePass(ctx context.Context, started map[string]bool) *time.Time {
work, err := m.store.Coordinate(ctx)
if err != nil {
slog.Error("coordinate", "err", err)
return
retry := time.Now().Add(time.Minute)
return &retry
}
for _, id := range work.AbandonedMerges {
slog.Info("merge turn ended unfinished", "task", id)
@@ -84,9 +93,13 @@ func (m *Manager) coordinatePass(ctx context.Context, started map[string]bool) {
for _, p := range work.ReadyPrompts {
once("ready:"+p.TaskID, func() { m.promptReady(p) })
}
for _, sc := range work.DueSchedules {
once(fmt.Sprintf("schedule:%s:%d", sc.Id, sc.NextRun.UnixNano()), func() { m.runSchedule(sc) })
}
for key := range started {
if !current[key] {
delete(started, key)
}
}
return work.NextSchedule
}