feat(taskstate): end no-change runs as completed and clean their worktrees
This commit is contained in:
8 files changed
+42
-15
No files matched your search
@@ -1344,8 +1344,13 @@ func (d *Daemon) cleanupTerminalTaskWorktree(ctx context.Context, task *workflow
|
||||
if latest == nil {
|
||||
return
|
||||
}
|
||||
// Statuses whose forge side is settled, so the worktree holds nothing a
|
||||
// later run needs: the PR merged, the PR was rejected, an operator refused
|
||||
// the work, or the run finished without opening a PR at all (a no-change
|
||||
// build, a triage that needed no code -- StatusCompleted). The PRNumber
|
||||
// guard keeps the worktree when a PR exists for the reconciler.
|
||||
switch latest.Status {
|
||||
case workflow.StatusMerged, workflow.StatusRejected, workflow.StatusClosedWontDo:
|
||||
case workflow.StatusMerged, workflow.StatusRejected, workflow.StatusClosedWontDo, workflow.StatusCompleted:
|
||||
if latest.PRNumber == 0 {
|
||||
if err := trees.Cleanup(task.Owner, task.Repo, task.IssueNumber); err != nil {
|
||||
d.Log.Warn("terminal worktree cleanup failed", "task", task.ID, "err", err)
|
||||
|
||||
@@ -122,6 +122,20 @@ func TestCleanupTerminalTaskWorktreeLifecycle(t *testing.T) {
|
||||
prNumber: 0,
|
||||
wantTreeExists: false,
|
||||
},
|
||||
{
|
||||
name: "root no-change completed task cleans worktree",
|
||||
taskIdentity: "",
|
||||
setupStatus: workflow.StatusCompleted,
|
||||
prNumber: 0,
|
||||
wantTreeExists: false,
|
||||
},
|
||||
{
|
||||
name: "multi-identity no-change completed task cleans identity worktree",
|
||||
taskIdentity: "winter",
|
||||
setupStatus: workflow.StatusCompleted,
|
||||
prNumber: 0,
|
||||
wantTreeExists: false,
|
||||
},
|
||||
{
|
||||
name: "parked task preserves worktree for post-mortem",
|
||||
taskIdentity: "",
|
||||
|
||||
@@ -389,10 +389,10 @@ func TestStageCommitPushClosesIssueWhenBuildNoChanges(t *testing.T) {
|
||||
} else {
|
||||
t.Log("CloseIssue called (no changes needed)")
|
||||
}
|
||||
if tc.Outcome.Status != StatusMerged {
|
||||
t.Errorf("expected Outcome=Merged, got %s", tc.Outcome.Status)
|
||||
if tc.Outcome.Status != StatusCompleted {
|
||||
t.Errorf("expected Outcome=Completed, got %s", tc.Outcome.Status)
|
||||
} else {
|
||||
t.Log("Outcome set to Merged (workflow stops)")
|
||||
t.Log("Outcome set to Completed (workflow stops)")
|
||||
}
|
||||
|
||||
if len(f.commented) != 0 {
|
||||
@@ -439,8 +439,8 @@ func TestStageCommitPushDoesNotUseSyntheticIssueForChatNoOp(t *testing.T) {
|
||||
if f.closed != 0 || len(f.commented) != 0 {
|
||||
t.Fatalf("chat no-op used synthetic issue: close=%d comments=%d", f.closed, len(f.commented))
|
||||
}
|
||||
if tc.Outcome.Status != StatusMerged {
|
||||
t.Errorf("Outcome.Status = %q, want %q", tc.Outcome.Status, StatusMerged)
|
||||
if tc.Outcome.Status != StatusCompleted {
|
||||
t.Errorf("Outcome.Status = %q, want %q", tc.Outcome.Status, StatusCompleted)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -169,13 +169,13 @@ func StageCommitPush(message func(*TaskContext) string) Stage {
|
||||
|
||||
func closeNoChangesIssue(ctx context.Context, tc *TaskContext) error {
|
||||
if !tc.Task.IsForgeBacked() {
|
||||
tc.Outcome = Outcome{Status: StatusMerged, Detail: "completed -- no changes required"}
|
||||
tc.Outcome = Outcome{Status: StatusCompleted, Detail: "completed -- no changes required"}
|
||||
return nil
|
||||
}
|
||||
if err := tc.Forge.CloseIssue(ctx, tc.Task.Owner, tc.Task.Repo, tc.Task.IssueNumber, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
tc.Outcome = Outcome{Status: StatusMerged, Detail: "completed -- no changes required"}
|
||||
tc.Outcome = Outcome{Status: StatusCompleted, Detail: "completed -- no changes required"}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ func Triage() Workflow {
|
||||
return err
|
||||
}
|
||||
}
|
||||
tc.Outcome = Outcome{Status: StatusMerged, Detail: "triaged: no code change needed -- " + captured.Reasons}
|
||||
tc.Outcome = Outcome{Status: StatusCompleted, Detail: "triaged: no code change needed -- " + captured.Reasons}
|
||||
return nil
|
||||
}
|
||||
// No fallback. The decide tool already refuses a call that
|
||||
|
||||
@@ -65,8 +65,8 @@ func TestTriageClosesWithoutCodeChange(t *testing.T) {
|
||||
if f.closed != 1 {
|
||||
t.Fatalf("CloseIssue calls = %d, want 1", f.closed)
|
||||
}
|
||||
if tc.Outcome.Status != StatusMerged {
|
||||
t.Fatalf("Outcome.Status = %q, want %q", tc.Outcome.Status, StatusMerged)
|
||||
if tc.Outcome.Status != StatusCompleted {
|
||||
t.Fatalf("Outcome.Status = %q, want %q", tc.Outcome.Status, StatusCompleted)
|
||||
}
|
||||
if tc.Task.Workflow != "" {
|
||||
t.Fatalf("Task.Workflow = %q, want unset (no requeue on the close path)", tc.Task.Workflow)
|
||||
@@ -104,8 +104,8 @@ func TestTriageClosesChatTaskWithoutForgeCall(t *testing.T) {
|
||||
if f.closed != 0 {
|
||||
t.Fatalf("CloseIssue calls = %d, want 0 for a chat-spawned (non-forge-backed) task", f.closed)
|
||||
}
|
||||
if tc.Outcome.Status != StatusMerged {
|
||||
t.Fatalf("Outcome.Status = %q, want %q", tc.Outcome.Status, StatusMerged)
|
||||
if tc.Outcome.Status != StatusCompleted {
|
||||
t.Fatalf("Outcome.Status = %q, want %q", tc.Outcome.Status, StatusCompleted)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,9 @@ import { summary } from "./state";
|
||||
const counts = computed(() => summary.value?.statuses ?? {});
|
||||
const tokensByDay = computed(() => summary.value?.tokens_by_day ?? []);
|
||||
const used = computed(() => tokensByDay.value.reduce((a, d) => a + (d.tokens || 0), 0));
|
||||
const done = computed(() => (counts.value.merged || 0) + (counts.value.pr_open || 0));
|
||||
const done = computed(
|
||||
() => (counts.value.merged || 0) + (counts.value.completed || 0) + (counts.value.pr_open || 0),
|
||||
);
|
||||
// "Needs you" is the server's grouping (attentionStatusIds), the same one the
|
||||
// Tasks page's needs_you filter reads.
|
||||
const attention = computed(() => {
|
||||
|
||||
@@ -23,8 +23,14 @@ const counts = computed(() => {
|
||||
|
||||
const total = computed(() => props.tasks.length);
|
||||
const working = computed(() => counts.value.running ?? 0);
|
||||
// Delivered counts everything whose work is out of archied's hands: merged,
|
||||
// in review, or finished with no change to make (completed, which is how a
|
||||
// no-change build and a no-code triage end).
|
||||
const delivered = computed(
|
||||
() => (counts.value.merged ?? 0) + (counts.value.pr_open ?? 0),
|
||||
() =>
|
||||
(counts.value.merged ?? 0) +
|
||||
(counts.value.completed ?? 0) +
|
||||
(counts.value.pr_open ?? 0),
|
||||
);
|
||||
|
||||
// "Needs you" is the server's grouping, not a local pair of ids: the same set
|
||||
|
||||
Reference in new issue
Block a user