feat(ui): drag a task into Mission Control to queue it

This commit is contained in:
Mika Kuns
2026-06-25 22:18:10 +02:00
parent 9eb54a0d2f
commit 3b629c218f
5 changed files with 65 additions and 6 deletions

View File

@@ -15,7 +15,8 @@ namespace ClaudeDo.Ui.Views.Islands;
public partial class TasksIslandView : UserControl
{
private static readonly DataFormat<string> TaskRowFormat =
// Public so the Mission Control window can accept the same drag payload (drop-to-queue).
public static readonly DataFormat<string> TaskRowFormat =
DataFormat.CreateStringApplicationFormat("claudedo-task-row");
public TasksIslandView()

View File

@@ -6,7 +6,8 @@
xmlns:loc="using:ClaudeDo.Ui.Localization"
x:DataType="vm:MissionControlViewModel"
x:Class="ClaudeDo.Ui.Views.MissionControl.MissionControlView">
<DockPanel LastChildFill="True" Background="{DynamicResource VoidBrush}">
<DockPanel LastChildFill="True" Background="{DynamicResource VoidBrush}"
DragDrop.AllowDrop="True">
<!-- Header -->
<Border DockPanel.Dock="Top"

View File

@@ -5,6 +5,7 @@ using Avalonia.Interactivity;
using Avalonia.VisualTree;
using ClaudeDo.Ui.ViewModels;
using ClaudeDo.Ui.ViewModels.Islands;
using ClaudeDo.Ui.Views.Islands;
namespace ClaudeDo.Ui.Views.MissionControl;
@@ -23,15 +24,28 @@ public partial class MissionControlView : UserControl
private void OnPaneDragOver(object? sender, DragEventArgs e)
{
e.DragEffects = (e.DataTransfer?.Contains(PaneFormat) ?? false)
? DragDropEffects.Move
: DragDropEffects.None;
var dt = e.DataTransfer;
var accept = (dt?.Contains(PaneFormat) ?? false)
|| (dt?.Contains(TasksIslandView.TaskRowFormat) ?? false);
e.DragEffects = accept ? DragDropEffects.Move : DragDropEffects.None;
}
private void OnPaneDrop(object? sender, DragEventArgs e)
{
if (DataContext is not MissionControlViewModel vm) return;
var draggedId = e.DataTransfer?.TryGetValue(PaneFormat);
var dt = e.DataTransfer;
if (dt is null) return;
// A task dragged from the main app → queue it.
var taskId = dt.TryGetValue(TasksIslandView.TaskRowFormat);
if (!string.IsNullOrEmpty(taskId))
{
_ = vm.EnqueueTaskAsync(taskId);
return;
}
// A pane dragged within the grid → reorder.
var draggedId = dt.TryGetValue(PaneFormat);
if (string.IsNullOrEmpty(draggedId)) return;
if (e.Source is not Avalonia.Visual src) return;