feat(worker): PlanningSessionManager.DiscardAsync

This commit is contained in:
mika kuns
2026-04-23 20:58:55 +02:00
parent 84b0ba8670
commit 84e6c2d5fc
2 changed files with 29 additions and 0 deletions

View File

@@ -53,6 +53,19 @@ public sealed class PlanningSessionManager
return new PlanningSessionStartContext(taskId, list.WorkingDir, files);
}
public async Task DiscardAsync(string taskId, CancellationToken ct)
{
var ok = await _tasks.DiscardPlanningAsync(taskId, ct);
var sessionDir = Path.Combine(_rootDirectory, taskId);
if (Directory.Exists(sessionDir))
{
try { Directory.Delete(sessionDir, recursive: true); }
catch { /* best effort */ }
}
if (!ok)
throw new InvalidOperationException($"Task {taskId} was not in Planning state; nothing to discard.");
}
public async Task<PlanningSessionResumeContext> ResumeAsync(string taskId, CancellationToken ct)
{
var task = await _tasks.GetByIdAsync(taskId, ct)