using System;
using System.Threading.Tasks;

namespace ClaudeDo.Ui.Services;

/// <summary>
/// Single entry point for handing a conflicting merge to the in-app 3-pane resolver.
/// Replaces the per-VM <c>RequestConflictResolution</c> Func seams that used to be
/// hand-threaded shell → details → merge-section → diff → merge-modal.
///
/// DI singleton holding the resolver entry. The holder breaks the shell↔island construction
/// cycle: islands depend on this type, the shell sets <see cref="Handler"/> after it is built.
/// </summary>
public sealed class MergeCoordinator
{
    /// Set once at composition to the shell's resolver entry. Null (headless/tests) ⇒ no-op.
    public Func<string, string, Task>? Handler { get; set; }

    public Task ResolveConflictAsync(string taskId, string targetBranch) =>
        Handler?.Invoke(taskId, targetBranch) ?? Task.CompletedTask;
}
