refactor(ui): scope "Let Claude handle it" to a single list

This commit is contained in:
Mika Kuns
2026-07-27 15:02:50 +02:00
parent e3bacc3143
commit 40eb979924
7 changed files with 21 additions and 62 deletions
@@ -100,18 +100,6 @@ public sealed partial class ListsIslandViewModel : ViewModelBase, IDisposable
LetClaudeHandleRequested?.Invoke(new MergeHelperRequest(rawId, ids));
}
[RelayCommand]
private async Task LetClaudeHandleAllAsync()
{
if (Dialogs is null || _services is null) return;
var vm = _services.GetRequiredService<MergeHelperSelectionModalViewModel>();
vm.Configure(null, null);
await vm.LoadAsync();
var ids = await Dialogs.ShowMergeHelperSelectionAsync(vm);
if (ids is { Count: > 0 })
LetClaudeHandleRequested?.Invoke(new MergeHelperRequest(null, ids));
}
[RelayCommand]
private void OpenInExplorer(ListNavItemViewModel? row)
{
@@ -14,7 +14,6 @@ public sealed partial class MergeHelperTaskRowViewModel : ViewModelBase
public required string Id { get; init; }
public required string Title { get; init; }
public required string StatusText { get; init; }
public required string ListName { get; init; }
[ObservableProperty] private bool _isSelected;
}
@@ -27,12 +26,11 @@ public sealed partial class MergeHelperTaskRowViewModel : ViewModelBase
public sealed partial class MergeHelperSelectionModalViewModel : ViewModelBase
{
private readonly IDbContextFactory<ClaudeDoDbContext> _dbFactory;
private string? _listId;
private string _listId = "";
public ObservableCollection<MergeHelperTaskRowViewModel> Tasks { get; } = new();
[ObservableProperty] private string _scopeLabel = "";
[ObservableProperty] private bool _isGlobal;
public bool HasTasks => Tasks.Count > 0;
public bool CanConfirm => Tasks.Any(t => t.IsSelected);
@@ -43,13 +41,10 @@ public sealed partial class MergeHelperSelectionModalViewModel : ViewModelBase
public MergeHelperSelectionModalViewModel(IDbContextFactory<ClaudeDoDbContext> dbFactory)
=> _dbFactory = dbFactory;
public void Configure(string? listId, string? listName)
public void Configure(string listId, string listName)
{
_listId = listId;
IsGlobal = listId is null;
ScopeLabel = listId is null
? Loc.T("modals.mergeHelper.scopeAll")
: Loc.T("modals.mergeHelper.scopeList", listName ?? "");
ScopeLabel = Loc.T("modals.mergeHelper.scopeList", listName);
}
public async Task LoadAsync(CancellationToken ct = default)
@@ -58,14 +53,11 @@ public sealed partial class MergeHelperSelectionModalViewModel : ViewModelBase
Tasks.Clear();
await using var ctx = await _dbFactory.CreateDbContextAsync(ct);
var query = ctx.Tasks.AsNoTracking()
.Where(t => t.Status != TaskStatus.Done && t.Status != TaskStatus.Cancelled);
if (_listId is not null)
query = query.Where(t => t.ListId == _listId);
var candidates = await query
var candidates = await ctx.Tasks.AsNoTracking()
.Where(t => t.Status != TaskStatus.Done && t.Status != TaskStatus.Cancelled)
.Where(t => t.ListId == _listId)
.OrderBy(t => t.SortOrder).ThenBy(t => t.CreatedAt)
.Select(t => new { t.Id, t.Title, t.Status, ListName = t.List.Name })
.Select(t => new { t.Id, t.Title, t.Status })
.ToListAsync(ct);
foreach (var c in candidates)
@@ -75,7 +67,6 @@ public sealed partial class MergeHelperSelectionModalViewModel : ViewModelBase
Id = c.Id,
Title = c.Title,
StatusText = c.Status.ToString(),
ListName = c.ListName,
IsSelected = IsTickedByDefault(c.Status),
};
row.PropertyChanged += OnRowChanged;
@@ -181,8 +181,8 @@
</ItemsControl.ItemTemplate>
</ItemsControl>
<!-- New list + import + merge-helper row -->
<Grid ColumnDefinitions="*,Auto,Auto" Margin="0,4,0,0">
<!-- New list + import row -->
<Grid ColumnDefinitions="*,Auto" Margin="0,4,0,0">
<Button Grid.Column="0" Classes="new-list-btn"
Command="{Binding CreateListCommand}">
<StackPanel Orientation="Horizontal" Spacing="6">
@@ -203,13 +203,6 @@
Width="14" Height="14"
Foreground="{DynamicResource TextMuteBrush}"/>
</Button>
<Button Grid.Column="2" Classes="icon-btn" Margin="6,0,0,0"
Command="{Binding LetClaudeHandleAllCommand}"
ToolTip.Tip="{loc:Tr lists.letClaudeAllTip}">
<PathIcon Data="{StaticResource Icon.Broom}"
Width="14" Height="14"
Foreground="{DynamicResource TextMuteBrush}"/>
</Button>
</Grid>
</StackPanel>
@@ -38,12 +38,10 @@
</Grid>
<!-- Column headers -->
<Grid DockPanel.Dock="Top" ColumnDefinitions="32,*,120,120" Margin="20,0,20,4"
<Grid DockPanel.Dock="Top" ColumnDefinitions="32,*,120" Margin="20,0,20,4"
IsVisible="{Binding HasTasks}">
<TextBlock Grid.Column="1" Classes="eyebrow" Text="{loc:Tr modals.mergeHelper.columnTask}"/>
<TextBlock Grid.Column="2" Classes="eyebrow" Text="{loc:Tr modals.mergeHelper.columnStatus}"/>
<TextBlock Grid.Column="3" Classes="eyebrow" Text="{loc:Tr modals.mergeHelper.columnList}"
IsVisible="{Binding IsGlobal}"/>
</Grid>
<ScrollViewer Padding="20,2,20,8">
@@ -54,7 +52,7 @@
<ItemsControl ItemsSource="{Binding Tasks}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="vm:MergeHelperTaskRowViewModel">
<Grid ColumnDefinitions="32,*,120,120" Margin="0,1">
<Grid ColumnDefinitions="32,*,120" Margin="0,1">
<CheckBox Grid.Column="0" MinWidth="0"
IsChecked="{Binding IsSelected, Mode=TwoWay}"
VerticalAlignment="Center"/>
@@ -65,10 +63,6 @@
HorizontalAlignment="Left" VerticalAlignment="Center">
<TextBlock Text="{Binding StatusText}"/>
</Border>
<TextBlock Classes="meta" Grid.Column="3" Text="{Binding ListName}"
VerticalAlignment="Center" Margin="8,0,0,0"
TextTrimming="CharacterEllipsis"
IsVisible="{Binding $parent[Window].((vm:MergeHelperSelectionModalViewModel)DataContext).IsGlobal}"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>