Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(issues): honor Don't start yet when an issue's blockers have ended (#11502)

pseudoyu2101833fb88a
diff --git a/server/internal/handler/issue_blocker_test.go b/server/internal/handler/issue_blocker_test.go
index d1688f4189..737098d748 100644
--- a/server/internal/handler/issue_blocker_test.go
+++ b/server/internal/handler/issue_blocker_test.go
@@ -358,3 +358,55 @@ func TestIssueBlockerGuestSeesOnlyItsProjectsReferences(t *testing.T) {
t.Fatalf("member lost blockers: %+v", got)
}
}
+
+// "Don't start yet" on the write that makes a released issue startable is an
+// answer to that release: the dependency rule must not start the run anyway.
+func TestIssueBlockerReleaseHonorsSuppressedRun(t *testing.T) {
+ agent := seededReadyAgentID(t)
+ svc := service.IssueWakeupService{Tasks: testHandler.TaskService}
+ tick := func() {
+ t.Helper()
+ if err := svc.TickWorkspaces(context.Background(), parseUUID(testWorkspaceID)); err != nil {
+ t.Fatal(err)
+ }
+ }
+ writes := map[string]func(id string, updates map[string]any){
+ "single": func(id string, updates map[string]any) {
+ updateIssueForTest(t, id, updates).Want(http.StatusOK)
+ },
+ "batch": func(id string, updates map[string]any) {
+ testutil.Call(t, testHandler.BatchUpdateIssues, newRequest("POST", "/api/issues/batch-update?workspace_id="+testWorkspaceID, map[string]any{
+ "issue_ids": []string{id}, "updates": updates,
+ })).Want(http.StatusOK)
+ },
+ }
+ for name, write := range writes {
+ t.Run(name, func(t *testing.T) {
+ prerequisite := blockerTestIssue(t, map[string]any{"status": "todo"})
+ issue := blockerTestIssue(t, map[string]any{"status": "backlog", "assignee_type": "agent", "assignee_id": agent, "blocked_by": []string{prerequisite.ID}})
+ runs := func() int {
+ return dbfx.Count(t, "SELECT count(*) FROM agent_task_queue WHERE issue_id=$1", issue.ID)
+ }
+ updateIssueForTest(t, prerequisite.ID, map[string]any{"status": "done"}).Want(http.StatusOK)
+ tick()
+ write(issue.ID, map[string]any{"status": "todo", "suppress_run": true})
+ tick()
+ if n := runs(); n != 0 {
+ t.Fatalf("suppressed promotion started %d runs", n)
+ }
+ // Later moves between active statuses are not a new release.
+ updateIssueForTest(t, issue.ID, map[string]any{"status": "in_progress"}).Want(http.StatusOK)
+ tick()
+ if n := runs(); n != 0 {
+ t.Fatalf("status move after a suppressed promotion started %d runs", n)
+ }
+ // A new wait is delivered as usual.
+ updateIssueForTest(t, prerequisite.ID, map[string]any{"status": "todo"}).Want(http.StatusOK)
+ updateIssueForTest(t, prerequisite.ID, map[string]any{"status": "done"}).Want(http.StatusOK)
+ tick()
+ if n := runs(); n != 1 {
+ t.Fatalf("new wait started %d runs, want 1", n)
+ }
+ })
+ }
+}
diff --git a/server/internal/handler/issue_trigger.go b/server/internal/handler/issue_trigger.go
index 64400ebc51..ec30e31dfd 100644
--- a/server/internal/handler/issue_trigger.go
+++ b/server/internal/handler/issue_trigger.go
@@ -126,6 +126,11 @@ func (h *Handler) resolveIssueRun(r *http.Request, issue db.Issue, trigger servi
switch {
case willRun && suppressRun:
status, reason = DispatchDeferred, ReasonDeferred
+ // Otherwise the dependency rule starts on its next pass the run this
+ // write declined.
+ if err := h.Queries.DismissIssueBlockerRelease(r.Context(), issue.ID); err != nil {
+ slog.Warn("dismiss blocker release failed", "issue_id", uuidToString(issue.ID), "error", err)
+ }
case willRun:
status, reason = h.dispatchIssueRun(r.Context(), issue, trigger, actorType, actorID, handoffNote)
case trigger.DeclineReason != "":
diff --git a/server/pkg/db/generated/issue_blocker.sql.go b/server/pkg/db/generated/issue_blocker.sql.go
index 20d940db71..c3812c2b2e 100644
--- a/server/pkg/db/generated/issue_blocker.sql.go
+++ b/server/pkg/db/generated/issue_blocker.sql.go
@@ -60,6 +60,28 @@ func (q *Queries) AddIssueBlocker(ctx context.Context, arg AddIssueBlockerParams
return err
}
+const dismissIssueBlockerRelease = `-- name: DismissIssueBlockerRelease :exec
+WITH dismissed AS (
+ UPDATE issue_wakeup w
+ SET condition_state='ready',next_fire_at=NULL,updated_at=clock_timestamp()
+ FROM issue i
+ WHERE i.id=$1 AND w.issue_id=i.id AND w.workspace_id=i.workspace_id
+ AND w.system_rule='blockers_done' AND w.enabled
+ AND i.status<>'backlog' AND i.triage_state IS NULL
+ AND NOT issue_has_open_blockers(i.workspace_id,i.id)
+ RETURNING w.id,w.revision
+)
+UPDATE issue_wakeup_receipt r SET processed_at=clock_timestamp()
+FROM dismissed d WHERE r.wakeup_id=d.id AND r.revision=d.revision AND r.processed_at IS NULL
+`
+
+// The write that made the issue startable declined its run, which answers the
+// pending release. A later wait resets condition_state and releases again.
+func (q *Queries) DismissIssueBlockerRelease(ctx context.Context, issueID pgtype.UUID) error {
+ _, err := q.db.Exec(ctx, dismissIssueBlockerRelease, issueID)
+ return err
+}
+
const getIssueRunAdmission = `-- name: GetIssueRunAdmission :one
SELECT triage_state,issue_has_open_blockers(workspace_id,id)::boolean AS blocked
FROM issue WHERE id = $1
diff --git a/server/pkg/db/queries/issue_blocker.sql b/server/pkg/db/queries/issue_blocker.sql
index 5c04dedfef..32fdc45801 100644
--- a/server/pkg/db/queries/issue_blocker.sql
+++ b/server/pkg/db/queries/issue_blocker.sql
@@ -54,3 +54,19 @@ WITH acknowledged AS (
)
UPDATE issue_wakeup_receipt r SET processed_at=clock_timestamp(),task_id=sqlc.arg('task_id')
FROM acknowledged a WHERE r.wakeup_id=a.id AND r.revision=a.revision AND r.processed_at IS NULL;
+
+-- name: DismissIssueBlockerRelease :exec
+-- The write that made the issue startable declined its run, which answers the
+-- pending release. A later wait resets condition_state and releases again.
+WITH dismissed AS (
+ UPDATE issue_wakeup w
+ SET condition_state='ready',next_fire_at=NULL,updated_at=clock_timestamp()
+ FROM issue i
+ WHERE i.id=sqlc.arg('issue_id') AND w.issue_id=i.id AND w.workspace_id=i.workspace_id
+ AND w.system_rule='blockers_done' AND w.enabled
+ AND i.status<>'backlog' AND i.triage_state IS NULL
+ AND NOT issue_has_open_blockers(i.workspace_id,i.id)
+ RETURNING w.id,w.revision
+)
+UPDATE issue_wakeup_receipt r SET processed_at=clock_timestamp()
+FROM dismissed d WHERE r.wakeup_id=d.id AND r.revision=d.revision AND r.processed_at IS NULL;