fix(merge): pass the stash consent to the conflict resolver so it opens on a dirty target

The resolver restarts the merge via StartConflictMerge, which had no autostash.
After a stash-retry approve reported 'conflict', the restart hit the same dirty
target, got 'dirty_target' and the resolver silently never opened. Thread the
consent through the hub, client, coordinator and resolver; surface a refusal in
the footer instead of dropping it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
mika kuns
2026-10-02 17:25:52 +02:00
co-authored by Claude Sonnet 5.5
parent ff7197c410
commit feb0afa33a
16 changed files with 173 additions and 20 deletions
@@ -60,7 +60,7 @@ public class DetailsIslandConflictSeamTests : IDisposable
string? capturedTarget = null;
var coordinator = new MergeCoordinator
{
Handler = (tid, target) =>
Handler = (tid, target, _) =>
{
capturedTaskId = tid;
capturedTarget = target;
@@ -77,4 +77,35 @@ public class DetailsIslandConflictSeamTests : IDisposable
Assert.Equal(taskId, capturedTaskId);
Assert.Equal("main", capturedTarget);
}
/// <summary>Models the worker: a dirty target refuses the merge unless the caller consented to the stash.</summary>
private sealed class DirtyTargetConflictWorkerClient : StubWorkerClient
{
public override bool IsConnected => true;
public override Task<MergeResultDto?> ApproveReviewAsync(string taskId, string targetBranch, bool autostash = false) =>
Task.FromResult<MergeResultDto?>(autostash
? new MergeResultDto("conflict", new[] { "a.cs" }, null)
: new MergeResultDto("dirty_target", Array.Empty<string>(), "target working tree has uncommitted changes"));
}
[Fact]
public async Task ApproveReview_StashRetryEndsInConflict_HandsTheStashConsentToTheResolver()
{
// Regression: the resolver restarts the merge itself; without the consent it hit the same
// dirty target, got "dirty_target" and silently never opened.
bool? capturedAutostash = null;
var coordinator = new MergeCoordinator
{
Handler = (_, _, autostash) => { capturedAutostash = autostash; return Task.CompletedTask; },
};
var vm = BuildVm(new DirtyTargetConflictWorkerClient(), coordinator);
vm.Dialogs = new RecordingDialogService { ConfirmResult = true };
vm.Bind(new TaskRowViewModel { Id = "task-dirty-1", Status = TaskStatus.WaitingForReview });
vm.Merge.SelectedMergeTarget = "main";
await vm.ApproveReviewCommand.ExecuteAsync(null);
Assert.True(capturedAutostash);
}
}