From e55367af67dda317f92cd63829b00fd65249fcc4 Mon Sep 17 00:00:00 2001 From: mika kuns Date: Wed, 20 May 2026 11:24:51 +0200 Subject: [PATCH] fix(ui): wire details-island buttons and drop dead handlers - Bind star button to ToggleStarCommand; wrap header and subtask done-check ellipses in buttons (ToggleDone / ToggleSubtaskDone). - Wire AgentStrip copy-path button to clipboard handler. - Remove dead Notes/PromptInput/ApproveMerge/ShowWorktreeModal code with no UI bindings. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../Islands/DetailsIslandViewModel.cs | 96 +++++++++---------- .../Views/Islands/AgentStripView.axaml | 1 + .../Views/Islands/AgentStripView.axaml.cs | 11 +++ .../Views/Islands/DetailsIslandView.axaml | 37 ++++--- .../Views/Islands/DetailsIslandView.axaml.cs | 14 --- 5 files changed, 80 insertions(+), 79 deletions(-) diff --git a/src/ClaudeDo.Ui/ViewModels/Islands/DetailsIslandViewModel.cs b/src/ClaudeDo.Ui/ViewModels/Islands/DetailsIslandViewModel.cs index 24fd6fb..4426cd6 100644 --- a/src/ClaudeDo.Ui/ViewModels/Islands/DetailsIslandViewModel.cs +++ b/src/ClaudeDo.Ui/ViewModels/Islands/DetailsIslandViewModel.cs @@ -31,8 +31,6 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase [ObservableProperty] private string _editableDescription = ""; [ObservableProperty] private bool _isEditingDescription; [ObservableProperty] private bool _isDescriptionExpanded = true; - [ObservableProperty] private string _notes = ""; - [ObservableProperty] private string _promptInput = ""; public bool IsDescriptionEditorVisible => IsDescriptionExpanded && IsEditingDescription; public bool IsDescriptionPreviewVisible => IsDescriptionExpanded && !IsEditingDescription; @@ -175,10 +173,7 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase // Set by the view so OpenDiffCommand can show the modal as a dialog public Func? ShowDiffModal { get; set; } - // Set by the view so OpenWorktreeCommand can show the modal as a dialog - public Func? ShowWorktreeModal { get; set; } - - // Set by the view so ApproveMergeCommand can show the modal as a dialog + // Set by the view so OpenDiff can pass through merge requests from the diff modal public Func? ShowMergeModal { get; set; } // Set by the view so DeleteTaskCommand can prompt yes/no before deleting @@ -223,7 +218,6 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase DequeueCommand.NotifyCanExecuteChanged(); ResetAndRetryCommand.NotifyCanExecuteChanged(); ContinueCommand.NotifyCanExecuteChanged(); - ApproveMergeCommand.NotifyCanExecuteChanged(); } }; @@ -427,7 +421,6 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase _subscribedTaskId = null; EditableTitle = ""; EditableDescription = ""; - Notes = ""; Model = null; WorktreePath = null; WorktreeStateLabel = null; @@ -473,7 +466,6 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase _suppressDescSave = true; try { EditableDescription = entity.Description ?? ""; } finally { _suppressDescSave = false; } - Notes = entity.Notes ?? ""; Model = entity.Model; WorktreePath = entity.Worktree?.Path; WorktreeBaseCommit = entity.Worktree?.BaseCommit; @@ -737,29 +729,55 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase { OpenDiffCommand.NotifyCanExecuteChanged(); OpenWorktreeCommand.NotifyCanExecuteChanged(); - ApproveMergeCommand.NotifyCanExecuteChanged(); - } - - partial void OnWorktreeStateLabelChanged(string? value) - { - ApproveMergeCommand.NotifyCanExecuteChanged(); - } - - [RelayCommand] - private async System.Threading.Tasks.Task SendPromptAsync() - { - if (string.IsNullOrWhiteSpace(PromptInput) || Task == null) return; - Log.Add(new LogLineViewModel { Kind = LogKind.Msg, Text = $"[you] {PromptInput}" }); - // TODO: WorkerClient has no SendPromptAsync — no matching hub method found. - // When the worker gains a "SendPrompt" hub method, call: - // await _worker.SendPromptAsync(Task.Id, PromptInput); - PromptInput = ""; - await System.Threading.Tasks.Task.CompletedTask; } [RelayCommand] private void CloseDetails() => CloseDetail?.Invoke(); + [RelayCommand] + private async System.Threading.Tasks.Task ToggleStarAsync() + { + if (Task is null) return; + Task.IsStarred = !Task.IsStarred; + await using var ctx = _dbFactory.CreateDbContext(); + var repo = new TaskRepository(ctx); + var entity = await repo.GetByIdAsync(Task.Id); + if (entity is null) return; + entity.IsStarred = Task.IsStarred; + await repo.UpdateAsync(entity); + } + + [RelayCommand] + private async System.Threading.Tasks.Task ToggleDoneAsync() + { + if (Task is null) return; + Task.Done = !Task.Done; + await using var ctx = _dbFactory.CreateDbContext(); + var repo = new TaskRepository(ctx); + var entity = await repo.GetByIdAsync(Task.Id); + if (entity is null) return; + entity.Status = Task.Done + ? ClaudeDo.Data.Models.TaskStatus.Done + : ClaudeDo.Data.Models.TaskStatus.Idle; + Task.Status = entity.Status; + AgentStatusLabel = entity.Status.ToString(); + await repo.UpdateAsync(entity); + } + + [RelayCommand] + private async System.Threading.Tasks.Task ToggleSubtaskDoneAsync(SubtaskRowViewModel? row) + { + if (row is null) return; + row.Done = !row.Done; + await using var ctx = _dbFactory.CreateDbContext(); + var repo = new SubtaskRepository(ctx); + var subs = await repo.GetByTaskIdAsync(Task?.Id ?? ""); + var entity = subs.FirstOrDefault(s => s.Id == row.Id); + if (entity is null) return; + entity.Completed = row.Done; + await repo.UpdateAsync(entity); + } + [RelayCommand] private async System.Threading.Tasks.Task DeleteTaskAsync() { @@ -813,30 +831,6 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase NewSubtaskTitle = ""; } - [RelayCommand] - private async System.Threading.Tasks.Task SaveNotesAsync() - { - if (Task == null) return; - await using var ctx = _dbFactory.CreateDbContext(); - var repo = new TaskRepository(ctx); - var entity = await repo.GetByIdAsync(Task.Id); - if (entity == null) return; - entity.Notes = Notes; - await repo.UpdateAsync(entity); - } - - [RelayCommand(CanExecute = nameof(CanMerge))] - private async System.Threading.Tasks.Task ApproveMergeAsync() - { - if (Task == null || ShowMergeModal == null) return; - var vm = _services.GetRequiredService(); - await vm.InitializeAsync(Task.Id, Task.Title); - await ShowMergeModal(vm); - } - - private bool CanMerge() => - Task != null && _worker.IsConnected && WorktreePath != null && WorktreeStateLabel == "Active"; - [RelayCommand] private async System.Threading.Tasks.Task StopAsync() { diff --git a/src/ClaudeDo.Ui/Views/Islands/AgentStripView.axaml b/src/ClaudeDo.Ui/Views/Islands/AgentStripView.axaml index 8951e3c..0ab3b8a 100644 --- a/src/ClaudeDo.Ui/Views/Islands/AgentStripView.axaml +++ b/src/ClaudeDo.Ui/Views/Islands/AgentStripView.axaml @@ -81,6 +81,7 @@ diff --git a/src/ClaudeDo.Ui/Views/Islands/AgentStripView.axaml.cs b/src/ClaudeDo.Ui/Views/Islands/AgentStripView.axaml.cs index 84ef7b3..018221f 100644 --- a/src/ClaudeDo.Ui/Views/Islands/AgentStripView.axaml.cs +++ b/src/ClaudeDo.Ui/Views/Islands/AgentStripView.axaml.cs @@ -1,8 +1,19 @@ using Avalonia.Controls; +using Avalonia.Input.Platform; +using Avalonia.Interactivity; +using ClaudeDo.Ui.ViewModels.Islands; namespace ClaudeDo.Ui.Views.Islands; public partial class AgentStripView : UserControl { public AgentStripView() { InitializeComponent(); } + + private async void OnCopyWorktreePathClick(object? sender, RoutedEventArgs e) + { + if (DataContext is not DetailsIslandViewModel vm) return; + var clipboard = TopLevel.GetTopLevel(this)?.Clipboard; + if (clipboard is null || string.IsNullOrEmpty(vm.WorktreePath)) return; + await clipboard.SetTextAsync(vm.WorktreePath); + } } diff --git a/src/ClaudeDo.Ui/Views/Islands/DetailsIslandView.axaml b/src/ClaudeDo.Ui/Views/Islands/DetailsIslandView.axaml index 85ffb92..ebfaaf5 100644 --- a/src/ClaudeDo.Ui/Views/Islands/DetailsIslandView.axaml +++ b/src/ClaudeDo.Ui/Views/Islands/DetailsIslandView.axaml @@ -38,13 +38,16 @@ - + @@ -176,13 +181,17 @@ - + - { - var owner = TopLevel.GetTopLevel(this) as Window; - if (owner == null) return; - var modal = new WorktreeModalView { DataContext = worktreeVm }; - await modal.ShowDialog(owner); - }; - vm.ShowMergeModal = async (mergeVm) => { var owner = TopLevel.GetTopLevel(this) as Window; @@ -143,12 +135,6 @@ public partial class DetailsIslandView : UserControl return await tcs.Task; } - private void NotesLostFocus(object? sender, RoutedEventArgs e) - { - if (DataContext is DetailsIslandViewModel vm) - vm.SaveNotesCommand.Execute(null); - } - private async void OnCopyDescriptionClick(object? sender, RoutedEventArgs e) { if (DataContext is not DetailsIslandViewModel vm) return;