feat(ui): add queueing and scheduling from task row context menu
- Right-click on a task row exposes Send to queue / Remove from queue and Schedule for... / Clear schedule actions. - New virtual:queued list in the sidebar with live count. - Sidebar counts are now computed (open per list, running, queued, review) and refreshed on task- and worker-side events. - Sending a task to the queue wakes the worker so it starts immediately.
This commit is contained in:
@@ -19,11 +19,22 @@
|
||||
Margin="0"
|
||||
Classes.selected="{Binding IsSelected}"
|
||||
Classes.done="{Binding Done}">
|
||||
<Grid ColumnDefinitions="4,32,*,32" Margin="6,8,10,8">
|
||||
|
||||
<!-- Left accent bar (visible when selected) -->
|
||||
<Border Grid.Column="0" Classes="task-row-accent"
|
||||
IsVisible="{Binding IsSelected}"/>
|
||||
<Border.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="Send to queue"
|
||||
IsVisible="{Binding !IsQueued}"
|
||||
Click="OnSendToQueueClick"/>
|
||||
<MenuItem Header="Remove from queue"
|
||||
IsVisible="{Binding IsQueued}"
|
||||
Click="OnRemoveFromQueueClick"/>
|
||||
<Separator/>
|
||||
<MenuItem Header="Schedule for..." Click="OnScheduleForClick"/>
|
||||
<MenuItem Header="Clear schedule"
|
||||
IsVisible="{Binding HasSchedule}"
|
||||
Click="OnClearScheduleClick"/>
|
||||
</ContextMenu>
|
||||
</Border.ContextMenu>
|
||||
<Grid ColumnDefinitions="0,32,*,32" Margin="6,8,10,8">
|
||||
|
||||
<!-- Done toggle -->
|
||||
<Button Grid.Column="1" Classes="flat" VerticalAlignment="Top"
|
||||
@@ -53,6 +64,15 @@
|
||||
<TextBlock Text="{Binding Status}"/>
|
||||
</Border>
|
||||
|
||||
<!-- Dequeue button (only when Queued) -->
|
||||
<Button Classes="icon-btn dequeue-btn"
|
||||
IsVisible="{Binding IsQueued}"
|
||||
ToolTip.Tip="Remove from queue"
|
||||
Command="{Binding $parent[ItemsControl].((vm:TasksIslandViewModel)DataContext).RemoveFromQueueCommand}"
|
||||
CommandParameter="{Binding}">
|
||||
<PathIcon Width="10" Height="10" Data="{StaticResource Icon.X}"/>
|
||||
</Button>
|
||||
|
||||
<!-- List chip with dot -->
|
||||
<Border Classes="chip chip-list">
|
||||
<StackPanel Orientation="Horizontal" Spacing="5" VerticalAlignment="Center">
|
||||
@@ -129,5 +149,45 @@
|
||||
<Border Height="2" VerticalAlignment="Center" Margin="4,0"
|
||||
Background="{DynamicResource MossBrush}" CornerRadius="1"/>
|
||||
</Grid>
|
||||
|
||||
<!-- Hidden schedule anchor (its Flyout is shown from the context menu) -->
|
||||
<Button Grid.Row="1" x:Name="ScheduleAnchor"
|
||||
Width="1" Height="1" Opacity="0"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||
IsHitTestVisible="False" Focusable="False">
|
||||
<Button.Flyout>
|
||||
<Flyout Placement="Bottom" ShowMode="Standard">
|
||||
<Border Background="{DynamicResource Surface2Brush}"
|
||||
BorderBrush="{DynamicResource BorderBrush}"
|
||||
BorderThickness="1" CornerRadius="10"
|
||||
Padding="16" Width="300">
|
||||
<StackPanel Spacing="12">
|
||||
<TextBlock Text="Schedule task"
|
||||
FontWeight="SemiBold" FontSize="13"
|
||||
Foreground="{DynamicResource TextBrush}"/>
|
||||
|
||||
<StackPanel Spacing="6">
|
||||
<TextBlock Text="DATE" FontSize="10" Opacity="0.6"
|
||||
Foreground="{DynamicResource TextDimBrush}"/>
|
||||
<DatePicker x:Name="ScheduleDate" HorizontalAlignment="Stretch"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Spacing="6">
|
||||
<TextBlock Text="TIME" FontSize="10" Opacity="0.6"
|
||||
Foreground="{DynamicResource TextDimBrush}"/>
|
||||
<TimePicker x:Name="ScheduleTime" ClockIdentifier="24HourClock"
|
||||
HorizontalAlignment="Stretch"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Spacing="8"
|
||||
HorizontalAlignment="Right" Margin="0,4,0,0">
|
||||
<Button Content="Cancel" Click="OnScheduleCancelClick" MinWidth="76"/>
|
||||
<Button Content="Schedule" Classes="accent" Click="OnScheduleSetClick" MinWidth="76"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Flyout>
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -1,16 +1,72 @@
|
||||
using System.Linq;
|
||||
using Avalonia;
|
||||
using Avalonia.Animation;
|
||||
using Avalonia.Animation.Easings;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Styling;
|
||||
using Avalonia.VisualTree;
|
||||
using ClaudeDo.Ui.ViewModels.Islands;
|
||||
|
||||
namespace ClaudeDo.Ui.Views.Islands;
|
||||
|
||||
public partial class TaskRowView : UserControl
|
||||
{
|
||||
private TaskRowViewModel? _pendingScheduleRow;
|
||||
|
||||
public TaskRowView() { InitializeComponent(); }
|
||||
|
||||
private TasksIslandViewModel? FindTasksVm() =>
|
||||
this.GetVisualAncestors().OfType<ItemsControl>()
|
||||
.Select(ic => ic.DataContext).OfType<TasksIslandViewModel>().FirstOrDefault();
|
||||
|
||||
private async void OnSendToQueueClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is TaskRowViewModel row && FindTasksVm() is { } vm)
|
||||
await vm.SendToQueueCommand.ExecuteAsync(row);
|
||||
}
|
||||
|
||||
private async void OnRemoveFromQueueClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is TaskRowViewModel row && FindTasksVm() is { } vm)
|
||||
await vm.RemoveFromQueueCommand.ExecuteAsync(row);
|
||||
}
|
||||
|
||||
private async void OnClearScheduleClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is TaskRowViewModel row && FindTasksVm() is { } vm)
|
||||
await vm.ClearScheduleCommand.ExecuteAsync(row);
|
||||
}
|
||||
|
||||
private void OnScheduleForClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is not TaskRowViewModel row) return;
|
||||
_pendingScheduleRow = row;
|
||||
var seed = row.ScheduledFor ?? DateTime.Now.AddHours(1);
|
||||
ScheduleDate.SelectedDate = new DateTimeOffset(seed.Date, TimeSpan.Zero);
|
||||
ScheduleTime.SelectedTime = seed.TimeOfDay;
|
||||
ScheduleAnchor.Flyout?.ShowAt(ScheduleAnchor);
|
||||
}
|
||||
|
||||
private async void OnScheduleSetClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
ScheduleAnchor.Flyout?.Hide();
|
||||
if (_pendingScheduleRow is null || ScheduleDate.SelectedDate is null) return;
|
||||
var date = ScheduleDate.SelectedDate.Value.Date;
|
||||
var time = ScheduleTime.SelectedTime ?? TimeSpan.FromHours(9);
|
||||
var when = date + time;
|
||||
if (FindTasksVm() is { } tvm)
|
||||
await tvm.SetScheduledForAsync(_pendingScheduleRow, when);
|
||||
_pendingScheduleRow = null;
|
||||
}
|
||||
|
||||
private void OnScheduleCancelClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
ScheduleAnchor.Flyout?.Hide();
|
||||
_pendingScheduleRow = null;
|
||||
}
|
||||
|
||||
protected override async void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
||||
{
|
||||
base.OnAttachedToVisualTree(e);
|
||||
|
||||
Reference in New Issue
Block a user