feat(tasks): offer Mark as Idle for cancelled tasks

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
mika kuns
2026-10-02 10:31:51 +02:00
co-authored by Claude Sonnet 5.5
parent d8f78056c1
commit 3fab4016f7
5 changed files with 42 additions and 3 deletions
+7 -3
View File
@@ -677,10 +677,14 @@ public sealed class WorkerHub : Microsoft.AspNetCore.SignalR.Hub
throw new HubException("Cannot change the status of a running task. Cancel it first.");
// Queueing goes through the gated transition so draft subtasks can't be queued;
// Idle goes through ResetToIdleAsync so StartedAt/FinishedAt/Result are cleared;
// other statuses keep the unconditional "set status freely" affordance.
var result = parsed == TaskStatus.Queued
? await _state.EnqueueAsync(taskId, Context.ConnectionAborted)
: await _state.ForceSetStatusAsync(taskId, parsed, Context.ConnectionAborted);
var result = parsed switch
{
TaskStatus.Queued => await _state.EnqueueAsync(taskId, Context.ConnectionAborted),
TaskStatus.Idle => await _state.ResetToIdleAsync(taskId, Context.ConnectionAborted),
_ => await _state.ForceSetStatusAsync(taskId, parsed, Context.ConnectionAborted),
};
if (!result.Ok) throw new HubException(result.Reason ?? "set status failed");
return new SetTaskStatusResultDto(
result.BaseDirty is { } w ? new BaseDirtyWarningDto(w.ModifiedCount, w.UntrackedCount) : null);