chore(claude-do): Return confirmation payload from delete_task and cancel_task
delete_task (and likely cancel_task) return no output on success. Silent success is indistinguishable from a no-op, so callers can't verify the action took effect.
Fix: return a small confirmation object, e.g. { deleted: true, id } / { cancelled: true, id }. Indicate not-found vs deleted distinctly.
ClaudeDo-Task: 97a87ebb-0d87-4ee0-800c-aa1a0b3a06c5
This commit is contained in:
@@ -10,6 +10,8 @@ using TaskStatus = ClaudeDo.Data.Models.TaskStatus;
|
||||
namespace ClaudeDo.Worker.External;
|
||||
|
||||
public sealed record TaskListDto(string Id, string Name, string? WorkingDir);
|
||||
public sealed record DeleteTaskResult(bool Deleted, string Id);
|
||||
public sealed record CancelTaskResult(bool Cancelled, string Id);
|
||||
|
||||
public sealed record TaskDto(
|
||||
string Id,
|
||||
@@ -206,16 +208,16 @@ public sealed class ExternalMcpService
|
||||
await _broadcaster.TaskUpdated(taskId);
|
||||
}
|
||||
|
||||
[McpServerTool, Description("Cancel a running task. Returns true if the task was running and cancellation was requested.")]
|
||||
public async Task<bool> CancelTask(string taskId, CancellationToken cancellationToken)
|
||||
[McpServerTool, Description("Cancel a running task. Returns { cancelled: true, id } if the task was running and cancellation was requested; cancelled is false if the task was not running.")]
|
||||
public async Task<CancelTaskResult> CancelTask(string taskId, CancellationToken cancellationToken)
|
||||
{
|
||||
var cancelled = _queue.CancelTask(taskId);
|
||||
if (cancelled) await _broadcaster.TaskUpdated(taskId);
|
||||
return cancelled;
|
||||
return new CancelTaskResult(cancelled, taskId);
|
||||
}
|
||||
|
||||
[McpServerTool, Description("Delete a task. Refuses if the task is currently Running — cancel it first.")]
|
||||
public async Task DeleteTask(string taskId, CancellationToken cancellationToken)
|
||||
[McpServerTool, Description("Delete a task. Returns { deleted: true, id } on success. Throws if the task is not found or is currently Running — cancel it first.")]
|
||||
public async Task<DeleteTaskResult> DeleteTask(string taskId, CancellationToken cancellationToken)
|
||||
{
|
||||
var task = await _tasks.GetByIdAsync(taskId, cancellationToken)
|
||||
?? throw new InvalidOperationException($"Task {taskId} not found.");
|
||||
@@ -224,6 +226,7 @@ public sealed class ExternalMcpService
|
||||
|
||||
await _tasks.DeleteAsync(taskId, cancellationToken);
|
||||
await _broadcaster.TaskUpdated(taskId);
|
||||
return new DeleteTaskResult(true, taskId);
|
||||
}
|
||||
|
||||
private static TaskDto ToDto(TaskEntity t) => new(
|
||||
|
||||
Reference in New Issue
Block a user