feat(ui): move a task to another list via drag & drop

Dragging a task row onto a user list in the Lists island now reassigns it
to that list. The task drag holds the pointer capture, so the release is
resolved geometrically (new case between the Mission Control and reorder
cases) instead of going through the Lists island's own DragDrop path,
which never sees a DragEventArgs during a task drag.

TaskRepository.MoveToListAsync reassigns the task plus every descendant
(a child must never sit in a different list than its parent) and appends
the task at the end of the target list. Guards: running tasks and tasks
holding an Active/Kept worktree are rejected to the footer error strip;
a move that changes repo asks for confirmation naming both repos.

The source repo is read from the task's own list rather than the island's
current list, which is a smart/virtual list with no working dir of its own
whenever one of those is shown.
This commit is contained in:
Mika Kuns
2026-07-29 15:10:59 +02:00
parent 4dc4fe27e3
commit 92ce7a4a77
11 changed files with 690 additions and 4 deletions
@@ -31,6 +31,9 @@ public partial class TasksIslandView : UserControl
private bool _dragArmed;
private bool _dragging;
// The list row (in the Lists island) currently highlighted as a drop target while dragging.
private ListNavItemViewModel? _hintedList;
public TasksIslandView()
{
InitializeComponent();
@@ -170,6 +173,7 @@ public partial class TasksIslandView : UserControl
{
_drag.MoveTo(this.PointToScreen(e.GetPosition(this)));
UpdateReorderHint(e, topLevel);
UpdateListDropHint(e, topLevel);
}
}
@@ -205,7 +209,17 @@ public partial class TasksIslandView : UserControl
return;
}
// 2) Released over another row in the same user list → reorder.
// 2) Released over another user list in the Lists island → move the task there.
if (DataContext is TasksIslandViewModel vmMove
&& ListItemUnder(e, topLevel) is { } targetList
&& targetList.Kind == ListKind.User
&& targetList.Id != vmMove.CurrentListId)
{
await vmMove.MoveTaskToListAsync(row, targetList);
return;
}
// 3) Released over another row in the same user list → reorder.
if (DataContext is TasksIslandViewModel vm && vm.CanReorder)
{
var targetButton = RowButtonAt(e, topLevel);
@@ -218,7 +232,7 @@ public partial class TasksIslandView : UserControl
}
}
// 3) Anywhere else → cancel; EndDrag already restored the source row.
// 4) Anywhere else → cancel; EndDrag already restored the source row.
}
private void OnPointerCaptureLost(object? sender, PointerCaptureLostEventArgs e)
@@ -229,6 +243,7 @@ public partial class TasksIslandView : UserControl
if (!_dragArmed && !_dragging) return;
if (_pressRow is not null) _pressRow.IsDragging = false;
if (DataContext is TasksIslandViewModel vm) vm.ClearDropHints();
ClearListDropHint();
_drag.End();
ResetPressState();
}
@@ -237,6 +252,7 @@ public partial class TasksIslandView : UserControl
{
if (_pressRow is not null) _pressRow.IsDragging = false;
if (DataContext is TasksIslandViewModel vm) vm.ClearDropHints();
ClearListDropHint();
_drag.End();
if (_dragging) e.Pointer.Capture(null);
ResetPressState();
@@ -295,6 +311,44 @@ public partial class TasksIslandView : UserControl
return button?.DataContext is TaskRowViewModel ? button : null;
}
// The list-row Border under the cursor (Lists island), found the same way as RowButtonAt but
// walking up to a Border with the "list-item" style class (mirrors ListsIslandView's own
// FindListItemBorder) — the task drag has the pointer captured here, so a DragEventArgs never
// reaches the Lists island's own DragDrop.DragOver/Drop handlers.
private static ListNavItemViewModel? ListItemUnder(PointerEventArgs e, TopLevel topLevel)
{
var pt = e.GetPosition((Visual)topLevel);
Visual? v = topLevel.InputHitTest(pt) as Visual;
while (v is not null)
{
if (v is Border b && b.Classes.Contains("list-item"))
return b.DataContext as ListNavItemViewModel;
v = v.GetVisualParent();
}
return null;
}
// Live drop-hint while dragging over a candidate target list row.
private void UpdateListDropHint(PointerEventArgs e, TopLevel topLevel)
{
if (DataContext is not TasksIslandViewModel vm) { ClearListDropHint(); return; }
var target = ListItemUnder(e, topLevel);
if (target is null || target.Kind != ListKind.User || target.Id == vm.CurrentListId)
target = null;
if (ReferenceEquals(_hintedList, target)) return;
if (_hintedList is not null) _hintedList.IsTaskDropTarget = false;
_hintedList = target;
if (_hintedList is not null) _hintedList.IsTaskDropTarget = true;
}
private void ClearListDropHint()
{
if (_hintedList is not null) _hintedList.IsTaskDropTarget = false;
_hintedList = null;
}
// The Mission Control view model whose window contains the release point, if any.
private static MissionControlViewModel? MissionControlUnder(PixelPoint screen)
{