fix(ui): make overview modal resizable; add diff content pane
Drop outer Border wrapper in WorktreesOverviewModalView so Avalonia edge resize handles reach the window frame. Add split pane to WorktreeModalView with file tree on left and per-file unified diff on right; wire SelectedNode via SelectedItem TwoWay binding + SelectionChanged fallback; add GetFileDiffAsync to GitService. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ public sealed partial class WorktreeNodeViewModel : ViewModelBase
|
||||
public required string Name { get; init; }
|
||||
public string? Status { get; init; }
|
||||
public bool IsDirectory { get; init; }
|
||||
public string RelativePath { get; init; } = "";
|
||||
public ObservableCollection<WorktreeNodeViewModel> Children { get; } = new();
|
||||
}
|
||||
|
||||
@@ -21,6 +22,8 @@ public sealed partial class WorktreeModalViewModel : ViewModelBase
|
||||
|
||||
[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; }
|
||||
@@ -30,6 +33,29 @@ public sealed partial class WorktreeModalViewModel : ViewModelBase
|
||||
_git = git;
|
||||
}
|
||||
|
||||
partial void OnSelectedNodeChanged(WorktreeNodeViewModel? value)
|
||||
{
|
||||
_ = LoadFileDiffAsync(value);
|
||||
}
|
||||
|
||||
private async Task LoadFileDiffAsync(WorktreeNodeViewModel? node)
|
||||
{
|
||||
if (node is null || node.IsDirectory || string.IsNullOrEmpty(node.RelativePath))
|
||||
{
|
||||
SelectedFileDiff = "";
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
SelectedFileDiff = await _git.GetFileDiffAsync(WorktreePath, BaseCommit, node.RelativePath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
SelectedFileDiff = "";
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void Close() => CloseAction?.Invoke();
|
||||
|
||||
@@ -97,7 +123,8 @@ public sealed partial class WorktreeModalViewModel : ViewModelBase
|
||||
{
|
||||
Name = segments[^1],
|
||||
Status = status,
|
||||
IsDirectory = false
|
||||
IsDirectory = false,
|
||||
RelativePath = path
|
||||
};
|
||||
if (parent == null) Root.Add(leaf);
|
||||
else parent.Children.Add(leaf);
|
||||
|
||||
Reference in New Issue
Block a user