Let workflows merge or discard their own tasks

This commit is contained in:
Ian Gulliver
2026-10-22 16:46:57 -07:00
parent b2cb15dd2a
commit efa1513568
13 changed files with 489 additions and 398 deletions
+40
View File
@@ -143,6 +143,46 @@ func (m *Manager) cancelReadyTool(l *live) mcp.Tool {
}
}
func (m *Manager) selfClose(c store.SelfClose) {
ctx := context.Background()
err := m.approveSelfClose(ctx, c)
if err != nil {
action := "merge"
if c.Ready == "discard" {
action = "discard"
}
slog.Error("workflow self close", "task", c.TaskID, "ready", c.Ready, "err", err)
m.fileError(ctx, c.TaskID, fmt.Sprintf("The workflow lets this task %[1]s itself, but byre couldn't %[1]s it: %[2]v. Do it by hand.", action, err))
return
}
slog.Info("workflow self close", "task", c.TaskID, "ready", c.Ready)
}
func (m *Manager) approveSelfClose(ctx context.Context, c store.SelfClose) error {
task, project, err := m.activeTask(ctx, c.TaskID)
if err != nil {
return err
}
taken, err := m.store.TakeReady(ctx, c.TaskID, c.Ready)
if err != nil || !taken {
return err
}
if c.Ready == "discard" {
_, err = m.Discard(ctx, task, "byre")
return err
}
user, err := m.store.GetUser(ctx, c.By)
if err != nil {
return err
}
if c.Ready == "continue" {
_, err = m.MergeToMain(ctx, task, project, user, task.MergeTitle)
return err
}
_, err = m.Merge(ctx, task, project, user, task.MergeTitle)
return err
}
func (m *Manager) promptReady(p store.ReadyPrompt) {
ctx := context.Background()
err := m.sendReadyPrompt(ctx, p)