fix(worker): harden review re-run, timestamps, and queue affordance

- Clear ReviewFeedback only after a successful re-run so a failed/cancelled
  run keeps it for a manual retry.
- Clear stale StartedAt/FinishedAt when rejecting a task back to the queue.
- Only non-planning standalone tasks gate on review (guard PlanningPhase).
- Hide "send to queue" for WaitingForReview tasks so review isn't bypassed.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
mika kuns
2026-06-02 08:00:13 +02:00
parent 4684a0af76
commit 1cb5171fba
5 changed files with 37 additions and 12 deletions

View File

@@ -156,13 +156,24 @@ public sealed class QueueServiceTests : IDisposable
await service.StartAsync(cts.Token);
_waker.Wake();
await done.Task.WaitAsync(TimeSpan.FromSeconds(5));
cts.Cancel();
Assert.Contains("--resume sess-1", capturedArgs);
Assert.Equal("fix the bug", capturedPrompt);
var reloaded = await _taskRepo.GetByIdAsync(task.Id);
Assert.Null(reloaded!.ReviewFeedback);
// Feedback is cleared after the run reaches a successful terminal state (post-run),
// so poll rather than asserting on the handler-fired instant.
var deadline = DateTime.UtcNow.AddSeconds(5);
TaskEntity? reloaded;
do
{
reloaded = await new TaskRepository(_db.CreateContext()).GetByIdAsync(task.Id);
if (reloaded?.ReviewFeedback is null) break;
await Task.Delay(25);
} while (DateTime.UtcNow < deadline);
cts.Cancel();
Assert.Equal(TaskStatus.WaitingForReview, reloaded!.Status);
Assert.Null(reloaded.ReviewFeedback);
}
[Fact]