diff --git a/src/ClaudeDo.App/Program.cs b/src/ClaudeDo.App/Program.cs index 8c0e831..f9c32e6 100644 --- a/src/ClaudeDo.App/Program.cs +++ b/src/ClaudeDo.App/Program.cs @@ -95,6 +95,7 @@ sealed class Program // ViewModels sc.AddTransient(); + sc.AddTransient>(sp => () => sp.GetRequiredService()); sc.AddTransient(); sc.AddTransient>(sp => () => sp.GetRequiredService()); sc.AddSingleton(); diff --git a/src/ClaudeDo.Ui/ViewModels/Modals/WorktreesOverviewModalViewModel.cs b/src/ClaudeDo.Ui/ViewModels/Modals/WorktreesOverviewModalViewModel.cs index b9b416b..4554ed4 100644 --- a/src/ClaudeDo.Ui/ViewModels/Modals/WorktreesOverviewModalViewModel.cs +++ b/src/ClaudeDo.Ui/ViewModels/Modals/WorktreesOverviewModalViewModel.cs @@ -24,6 +24,7 @@ public sealed partial class WorktreeOverviewRowViewModel : ViewModelBase [ObservableProperty] private string? _diffStat; [ObservableProperty] private DateTime _createdAt; [ObservableProperty] private bool _pathExistsOnDisk; + [ObservableProperty] private bool _isSelected; public string AgeText => FormatAge(DateTime.UtcNow - CreatedAt); public bool IsActive => State == WorktreeState.Active; @@ -48,24 +49,34 @@ public sealed partial class WorktreesGroupViewModel : ViewModelBase public sealed partial class WorktreesOverviewModalViewModel : ViewModelBase { private readonly WorkerClient _worker; + private readonly Func _diffVmFactory; [ObservableProperty] private string? _listIdFilter; [ObservableProperty] private string _title = "Worktrees"; [ObservableProperty] private bool _isGlobal; [ObservableProperty] private bool _isBusy; [ObservableProperty] private string? _statusMessage; + [ObservableProperty] private WorktreeOverviewRowViewModel? _selectedRow; public ObservableCollection Rows { get; } = new(); public ObservableCollection Groups { get; } = new(); public Action? CloseAction { get; set; } - public Action? ShowDiffAction { get; set; } + public Action? ShowDiffAction { get; set; } public Action? JumpToTaskAction { get; set; } public Func>? ConfirmAction { get; set; } - public WorktreesOverviewModalViewModel(WorkerClient worker) + public WorktreesOverviewModalViewModel(WorkerClient worker, Func diffVmFactory) { _worker = worker; + _diffVmFactory = diffVmFactory; + } + + public void SelectRow(WorktreeOverviewRowViewModel row) + { + if (SelectedRow is not null) SelectedRow.IsSelected = false; + SelectedRow = row; + row.IsSelected = true; } public void Configure(string? listId, string? listName) @@ -136,7 +147,9 @@ public sealed partial class WorktreesOverviewModalViewModel : ViewModelBase private void ShowDiff(WorktreeOverviewRowViewModel? row) { if (row is null) return; - ShowDiffAction?.Invoke(row); + var diffVm = _diffVmFactory(); + diffVm.WorktreePath = row.Path; + ShowDiffAction?.Invoke(diffVm); } [RelayCommand] diff --git a/src/ClaudeDo.Ui/Views/Islands/ListsIslandView.axaml.cs b/src/ClaudeDo.Ui/Views/Islands/ListsIslandView.axaml.cs index 5a18926..832bf1e 100644 --- a/src/ClaudeDo.Ui/Views/Islands/ListsIslandView.axaml.cs +++ b/src/ClaudeDo.Ui/Views/Islands/ListsIslandView.axaml.cs @@ -38,7 +38,15 @@ public partial class ListsIslandView : UserControl if (item is not null) v.SelectedList = item; } }; - // TODO: ShowDiffAction and ConfirmAction not wired in v1 + modal.ShowDiffAction = diffVm => + { + var top2 = TopLevel.GetTopLevel(this) as Window; + if (top2 is null) return; + var dlg = new WorktreeModalView { DataContext = diffVm }; + diffVm.CloseAction = () => dlg.Close(); + _ = diffVm.LoadAsync(); + _ = dlg.ShowDialog(top2); + }; var top = TopLevel.GetTopLevel(this) as Window; if (top is null) window.Show(); else await window.ShowDialog(top); diff --git a/src/ClaudeDo.Ui/Views/MainWindow.axaml.cs b/src/ClaudeDo.Ui/Views/MainWindow.axaml.cs index 5221497..d8fb811 100644 --- a/src/ClaudeDo.Ui/Views/MainWindow.axaml.cs +++ b/src/ClaudeDo.Ui/Views/MainWindow.axaml.cs @@ -3,6 +3,7 @@ using Avalonia.Controls; using Avalonia.Input; using ClaudeDo.Ui.ViewModels; using ClaudeDo.Ui.ViewModels.Islands; +using ClaudeDo.Ui.ViewModels.Modals; using ClaudeDo.Ui.Views.Modals; using ClaudeDo.Ui.Views.Planning; @@ -45,7 +46,13 @@ public partial class MainWindow : Window if (item is not null && s.Lists is not null) s.Lists.SelectedList = item; } }; - // TODO: ShowDiffAction and ConfirmAction not wired in v1 + modal.ShowDiffAction = diffVm => + { + var diffDlg = new WorktreeModalView { DataContext = diffVm }; + diffVm.CloseAction = () => diffDlg.Close(); + _ = diffVm.LoadAsync(); + _ = diffDlg.ShowDialog(this); + }; await dlg.ShowDialog(this); }; } diff --git a/src/ClaudeDo.Ui/Views/Modals/WorktreesOverviewModalView.axaml b/src/ClaudeDo.Ui/Views/Modals/WorktreesOverviewModalView.axaml index 4521bb4..7352ac8 100644 --- a/src/ClaudeDo.Ui/Views/Modals/WorktreesOverviewModalView.axaml +++ b/src/ClaudeDo.Ui/Views/Modals/WorktreesOverviewModalView.axaml @@ -7,11 +7,16 @@ Title="{Binding Title}" Width="900" Height="560" MinWidth="640" MinHeight="360" WindowStartupLocation="CenterOwner" - Background="{DynamicResource VoidBrush}"> + Background="{DynamicResource VoidBrush}" + SystemDecorations="None" + ExtendClientAreaToDecorationsHint="True"> + - + + + - - -