Wire TasksIslandViewModel to TaskUpdated/WorktreeUpdated/TaskMessage worker events so rows refresh without a full reload; add ForegroundHelper to permit wt.exe to take foreground on planning launch; misc UI polish on lists, task rows and settings modal. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
108 lines
3.8 KiB
C#
108 lines
3.8 KiB
C#
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 async void OnOpenPlanningSessionClick(object? sender, RoutedEventArgs e)
|
|
{
|
|
if (DataContext is TaskRowViewModel row && FindTasksVm() is { } vm)
|
|
await vm.OpenPlanningSessionCommand.ExecuteAsync(row);
|
|
}
|
|
|
|
private async void OnResumePlanningSessionClick(object? sender, RoutedEventArgs e)
|
|
{
|
|
if (DataContext is TaskRowViewModel row && FindTasksVm() is { } vm)
|
|
await vm.ResumePlanningSessionCommand.ExecuteAsync(row);
|
|
}
|
|
|
|
private async void OnDiscardPlanningSessionClick(object? sender, RoutedEventArgs e)
|
|
{
|
|
if (DataContext is TaskRowViewModel row && FindTasksVm() is { } vm)
|
|
await vm.DiscardPlanningSessionCommand.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);
|
|
RenderTransform = new TranslateTransform(0, 8);
|
|
Opacity = 0;
|
|
var anim = new Avalonia.Animation.Animation
|
|
{
|
|
Duration = TimeSpan.FromMilliseconds(300),
|
|
Easing = new CubicEaseOut(),
|
|
Children =
|
|
{
|
|
new KeyFrame { Cue = new Cue(0), Setters = { new Setter(OpacityProperty, 0d) } },
|
|
new KeyFrame { Cue = new Cue(1), Setters = { new Setter(OpacityProperty, 1d) } },
|
|
}
|
|
};
|
|
await anim.RunAsync(this);
|
|
Opacity = 1;
|
|
RenderTransform = null;
|
|
}
|
|
}
|