fix(ui): use BorderOnly chrome; color diff +/- lines
Apply SystemDecorations=BorderOnly + ExtendClientAreaTitleBarHeightHint=-1 to WorktreesOverviewModalView and WorktreeModalView for reliable OS resize borders. Replace SelectedFileDiff SelectableTextBlock with per-line ItemsControl using WorktreeDiffLineKind coloring via DiffLineKindToBrushConverter. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,14 @@ using ClaudeDo.Data.Git;
|
||||
|
||||
namespace ClaudeDo.Ui.ViewModels.Modals;
|
||||
|
||||
public enum WorktreeDiffLineKind { Header, Hunk, Added, Removed, Context }
|
||||
|
||||
public sealed partial class WorktreeDiffLineViewModel : ViewModelBase
|
||||
{
|
||||
public required string Text { get; init; }
|
||||
public required WorktreeDiffLineKind Kind { get; init; }
|
||||
}
|
||||
|
||||
public sealed partial class WorktreeNodeViewModel : ViewModelBase
|
||||
{
|
||||
public required string Name { get; init; }
|
||||
@@ -19,11 +27,11 @@ public sealed partial class WorktreeModalViewModel : ViewModelBase
|
||||
private readonly GitService _git;
|
||||
|
||||
public ObservableCollection<WorktreeNodeViewModel> Root { get; } = new();
|
||||
public ObservableCollection<WorktreeDiffLineViewModel> SelectedFileDiffLines { get; } = new();
|
||||
|
||||
[ObservableProperty] private string _worktreePath = "";
|
||||
[ObservableProperty] private string? _baseCommit;
|
||||
[ObservableProperty] private WorktreeNodeViewModel? _selectedNode;
|
||||
[ObservableProperty] private string _selectedFileDiff = "";
|
||||
|
||||
// Set by the view (same pattern as DiffModalViewModel.CloseAction)
|
||||
public Action? CloseAction { get; set; }
|
||||
@@ -40,19 +48,33 @@ public sealed partial class WorktreeModalViewModel : ViewModelBase
|
||||
|
||||
private async Task LoadFileDiffAsync(WorktreeNodeViewModel? node)
|
||||
{
|
||||
if (node is null || node.IsDirectory || string.IsNullOrEmpty(node.RelativePath))
|
||||
{
|
||||
SelectedFileDiff = "";
|
||||
return;
|
||||
}
|
||||
SelectedFileDiffLines.Clear();
|
||||
|
||||
if (node is null || node.IsDirectory || string.IsNullOrEmpty(node.RelativePath))
|
||||
return;
|
||||
|
||||
string diff;
|
||||
try
|
||||
{
|
||||
SelectedFileDiff = await _git.GetFileDiffAsync(WorktreePath, BaseCommit, node.RelativePath);
|
||||
diff = await _git.GetFileDiffAsync(WorktreePath, BaseCommit, node.RelativePath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
SelectedFileDiff = "";
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var line in diff.Split('\n'))
|
||||
{
|
||||
var kind = line switch
|
||||
{
|
||||
_ when line.StartsWith("+++") || line.StartsWith("---") => WorktreeDiffLineKind.Header,
|
||||
_ when line.StartsWith("@@") => WorktreeDiffLineKind.Hunk,
|
||||
_ when line.StartsWith('+') => WorktreeDiffLineKind.Added,
|
||||
_ when line.StartsWith('-') => WorktreeDiffLineKind.Removed,
|
||||
_ when line.StartsWith("diff ") || line.StartsWith("index ") || line.StartsWith("\\ ") => WorktreeDiffLineKind.Header,
|
||||
_ => WorktreeDiffLineKind.Context,
|
||||
};
|
||||
SelectedFileDiffLines.Add(new WorktreeDiffLineViewModel { Text = line, Kind = kind });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user