diff --git a/src/ClaudeDo.Ui/ViewModels/Conflicts/ConflictModels.cs b/src/ClaudeDo.Ui/ViewModels/Conflicts/ConflictModels.cs new file mode 100644 index 0000000..16c538a --- /dev/null +++ b/src/ClaudeDo.Ui/ViewModels/Conflicts/ConflictModels.cs @@ -0,0 +1,49 @@ +using System.Collections.Generic; +using System.Linq; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; + +namespace ClaudeDo.Ui.ViewModels.Conflicts; + +public sealed partial class ConflictHunk : ObservableObject +{ + public string Ours { get; } + public string Theirs { get; } + public string? Base { get; } + + [ObservableProperty] private string? _resolution; + + public bool IsResolved => Resolution is not null; + + public ConflictHunk(string ours, string theirs, string? @base) + { + Ours = ours; + Theirs = theirs; + Base = @base; + } + + partial void OnResolutionChanged(string? value) => OnPropertyChanged(nameof(IsResolved)); + + [RelayCommand] private void AcceptCurrent() => Resolution = Ours; + [RelayCommand] private void AcceptIncoming() => Resolution = Theirs; + [RelayCommand] private void AcceptBoth() => Resolution = Ours + Theirs; + [RelayCommand] private void EditManually() => Resolution ??= Ours; +} + +public sealed class ConflictFile +{ + public string Path { get; } + public IReadOnlyList Hunks { get; } + + public ConflictFile(string path, IReadOnlyList hunks) + { + Path = path; + Hunks = hunks; + } + + public bool AllHunksResolved => Hunks.Count > 0 && Hunks.All(h => h.IsResolved); + + /// Merged file content: concatenation of each hunk's resolution + /// (single whole-file hunk today; concatenation stays correct for multi-hunk later). + public string ComposeResolvedContent() => string.Concat(Hunks.Select(h => h.Resolution)); +}