feat(queue): warn when the base branch has uncommitted changes

Queuing (update_task_status, batch_update_task_status) and run_task_now
now surface a non-blocking baseDirty warning (separate modified/untracked
counts) when the list's working dir has uncommitted changes at enqueue
time, since a new worktree forks from the commit tip and silently misses
them. BaseDirtyChecker caches per working dir for a few seconds so a
batch queue over many tasks in one list only shells out to git once. The
UI surfaces the same warning via the footer error strip on queue actions.
This commit is contained in:
mika kuns
2026-08-10 14:30:33 +02:00
parent 6a2a19cc9e
commit d3155e6868
23 changed files with 481 additions and 32 deletions
+15 -1
View File
@@ -1,6 +1,7 @@
using ClaudeDo.Data;
using ClaudeDo.Data.Models;
using ClaudeDo.Data.Repositories;
using ClaudeDo.Worker.Git;
using ClaudeDo.Worker.Hub;
using ClaudeDo.Worker.Planning;
using ClaudeDo.Worker.Queue;
@@ -17,6 +18,7 @@ public sealed class TaskStateService : ITaskStateService
private readonly PlanningChainCoordinator _chain;
private readonly RunCancellationRegistry _runCancels;
private readonly Func<IActiveMergeState> _mergeState;
private readonly IBaseDirtyChecker _baseDirtyChecker;
private readonly ILogger<TaskStateService> _logger;
public TaskStateService(
@@ -26,6 +28,7 @@ public sealed class TaskStateService : ITaskStateService
PlanningChainCoordinator chain,
RunCancellationRegistry runCancels,
Func<IActiveMergeState> mergeState,
IBaseDirtyChecker baseDirtyChecker,
ILogger<TaskStateService> logger)
{
_dbFactory = dbFactory;
@@ -34,6 +37,7 @@ public sealed class TaskStateService : ITaskStateService
_chain = chain;
_runCancels = runCancels;
_mergeState = mergeState;
_baseDirtyChecker = baseDirtyChecker;
_logger = logger;
}
@@ -56,7 +60,17 @@ public sealed class TaskStateService : ITaskStateService
_waker.Wake();
await _broadcaster.TaskUpdated(taskId);
return new TransitionResult(true, null);
// Heads-up only: a worktree forks from the commit tip (WorktreeManager.ResolveBaseCommitAsync),
// not the working tree, so uncommitted changes sitting in the list's repo right now are
// invisible to this (and every other) queued task. Never blocks the transition above.
var workingDir = await ctx.Tasks.AsNoTracking()
.Where(t => t.Id == taskId)
.Select(t => t.List.WorkingDir)
.FirstOrDefaultAsync(ct);
var baseDirty = await _baseDirtyChecker.CheckAsync(workingDir, ct);
return new TransitionResult(true, null, baseDirty);
}
public async Task<TransitionResult> StartRunningAsync(string taskId, DateTime startedAt, CancellationToken ct)