From 31420574db2c5902de8c554a5a3da87794b3edb5 Mon Sep 17 00:00:00 2001 From: Mika Kuns Date: Wed, 22 Apr 2026 11:03:37 +0200 Subject: [PATCH] feat(ui): show status messages and real diff-stats in DiffModal - Count additions/deletions per file as lines are parsed. - Surface load failures and empty-diff states via StatusMessage. - Pass the worktree base commit so diffs render against the branch base, not just the working-tree HEAD. --- .../Islands/DetailsIslandViewModel.cs | 1 + .../ViewModels/Modals/DiffModalViewModel.cs | 22 ++++++++++++++----- .../Views/Modals/DiffModalView.axaml | 19 +++++++++++----- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/ClaudeDo.Ui/ViewModels/Islands/DetailsIslandViewModel.cs b/src/ClaudeDo.Ui/ViewModels/Islands/DetailsIslandViewModel.cs index 7277f72..646b10b 100644 --- a/src/ClaudeDo.Ui/ViewModels/Islands/DetailsIslandViewModel.cs +++ b/src/ClaudeDo.Ui/ViewModels/Islands/DetailsIslandViewModel.cs @@ -262,6 +262,7 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase Notes = entity.Notes ?? ""; Model = entity.Model; WorktreePath = entity.Worktree?.Path; + WorktreeBaseCommit = entity.Worktree?.BaseCommit; WorktreeStateLabel = entity.Worktree?.State.ToString(); BranchLine = entity.Worktree is { } w ? $"{w.BranchName} \u2190 main" : null; AgentStatusLabel = entity.Status.ToString(); diff --git a/src/ClaudeDo.Ui/ViewModels/Modals/DiffModalViewModel.cs b/src/ClaudeDo.Ui/ViewModels/Modals/DiffModalViewModel.cs index c1fd1a1..6476da5 100644 --- a/src/ClaudeDo.Ui/ViewModels/Modals/DiffModalViewModel.cs +++ b/src/ClaudeDo.Ui/ViewModels/Modals/DiffModalViewModel.cs @@ -31,8 +31,8 @@ public sealed class DiffLineViewModel public sealed class DiffFileViewModel { public required string Path { get; init; } - public int Additions { get; init; } - public int Deletions { get; init; } + public int Additions { get; set; } + public int Deletions { get; set; } public ObservableCollection Lines { get; } = new(); } @@ -50,6 +50,7 @@ public sealed partial class DiffModalViewModel : ViewModelBase public ObservableCollection Files { get; } = new(); [ObservableProperty] private DiffFileViewModel? _selectedFile; + [ObservableProperty] private string? _statusMessage; // Injected action to close the owning Window public Action? CloseAction { get; set; } @@ -79,6 +80,7 @@ public sealed partial class DiffModalViewModel : ViewModelBase public async Task LoadAsync(CancellationToken ct = default) { Files.Clear(); + StatusMessage = null; string raw; try @@ -87,9 +89,17 @@ public sealed partial class DiffModalViewModel : ViewModelBase ? await _git.GetBranchDiffAsync(WorktreePath, BaseRef, ct) : await _git.GetDiffAsync(WorktreePath, ct); } - catch { return; } + catch (Exception ex) + { + StatusMessage = $"Failed to load diff: {ex.Message}"; + return; + } - if (string.IsNullOrWhiteSpace(raw)) return; + if (string.IsNullOrWhiteSpace(raw)) + { + StatusMessage = "No changes to show."; + return; + } // Parse unified diff — state machine over lines DiffFileViewModel? current = null; @@ -134,7 +144,7 @@ public sealed partial class DiffModalViewModel : ViewModelBase NewNo = newLine++, Text = line.Length > 1 ? line[1..] : "", }); - // Count additions on the file VM + current.Additions++; } else if (line.StartsWith('-')) { @@ -144,6 +154,7 @@ public sealed partial class DiffModalViewModel : ViewModelBase OldNo = oldLine++, Text = line.Length > 1 ? line[1..] : "", }); + current.Deletions++; } else if (line.StartsWith(' ')) { @@ -158,6 +169,7 @@ public sealed partial class DiffModalViewModel : ViewModelBase } SelectedFile = Files.Count > 0 ? Files[0] : null; + if (Files.Count == 0) StatusMessage = "No changes to show."; } private static void ParseHunkHeader(string header, out int oldStart, out int newStart) diff --git a/src/ClaudeDo.Ui/Views/Modals/DiffModalView.axaml b/src/ClaudeDo.Ui/Views/Modals/DiffModalView.axaml index 6a2c96d..1d4b76f 100644 --- a/src/ClaudeDo.Ui/Views/Modals/DiffModalView.axaml +++ b/src/ClaudeDo.Ui/Views/Modals/DiffModalView.axaml @@ -96,7 +96,7 @@ FontFamily="{StaticResource MonoFamily}" FontSize="11" Foreground="{StaticResource TextDimBrush}" - TextTrimming="LeadingEllipsis"/> + TextTrimming="PrefixCharacterEllipsis"/> - + + + @@ -166,7 +172,8 @@ - + +