Send watched-pane-free signal only when something waits on the human

This commit is contained in:
Ian Gulliver
2026-10-22 21:34:12 -07:00
parent 0233e2c310
commit 73519bf4dd
3 changed files with 44 additions and 2 deletions
+9
View File
@@ -552,6 +552,15 @@ func (s *Store) ActiveTasks(ctx context.Context) ([]api.Task, error) {
return s.queryTasks(ctx, `SELECT `+taskColumns+` FROM tasks WHERE status = ? ORDER BY created_at`, string(api.TaskStatusActive))
}
func (s *Store) ErrorUnanswered(ctx context.Context, taskID string) (bool, error) {
unanswered := false
err := s.db.QueryRowContext(ctx, `
SELECT coalesce(max(CASE WHEN kind != 'user.message' THEN seq END), 0) > coalesce(max(CASE WHEN kind = 'user.message' THEN seq END), 0)
FROM events WHERE task_id = ? AND kind IN ('session.error', 'session.rate_limited', 'user.message')
`, taskID).Scan(&unanswered)
return unanswered, err
}
func (s *Store) ActiveSubtasks(ctx context.Context, parentID string) ([]api.Task, error) {
return s.queryTasks(ctx, `SELECT `+taskColumns+` FROM tasks WHERE parent_task_id = ? AND status = ? ORDER BY created_at`, parentID, string(api.TaskStatusActive))
}