Drag chats from the list onto panes

On desktop a chat dragged from the list or compact rail onto a tiled
pane replaces that pane's chat when dropped in its centre, or opens in a
split right of or below it when dropped on that edge; an open chat moves
without duplicating and a floating chat docks.
This commit is contained in:
2026-11-13 12:45:42 +00:00
parent df0614e2f7
commit cb49aeef34
15 changed files with 313 additions and 30 deletions
@@ -82,6 +82,38 @@ class ChatCompactSidebar extends StatelessWidget {
final color =
chatColorShade(context, chatSessionColor(row)) ??
Theme.of(context).colorScheme.primary;
final button = _button(
context,
details,
ExcludeSemantics(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ChatCompactAvatar(
title: title,
color: color,
active: selected,
visible: visible,
running: running,
backgroundTasks: backgroundTasks,
unread: unread,
),
if (machineName case final name?)
Text(
name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.labelSmall,
),
],
),
),
() {
unawaited(controller.markOpened(row));
onOpen(row);
},
selected: selected,
);
return ChatVisibilityMarker(
sessionId: id,
color: color,
@@ -92,37 +124,26 @@ class ChatCompactSidebar extends StatelessWidget {
? Duration.zero
: const Duration(milliseconds: 200),
color: selected ? Colors.transparent : color.withValues(alpha: .07),
child: _button(
context,
details,
ExcludeSemantics(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ChatCompactAvatar(
title: title,
color: color,
active: selected,
visible: visible,
running: running,
backgroundTasks: backgroundTasks,
unread: unread,
),
if (machineName case final name?)
Text(
name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.labelSmall,
),
],
child: LongPressDraggable<JsonMap>(
data: row,
feedback: Material(
elevation: 4,
borderRadius: BorderRadius.circular(20),
child: Chip(
avatar: ChatCompactAvatar(
title: title,
color: color,
active: false,
visible: false,
running: running,
backgroundTasks: backgroundTasks,
unread: unread,
),
label: Text(title),
),
),
() {
unawaited(controller.markOpened(row));
onOpen(row);
},
selected: selected,
childWhenDragging: Opacity(opacity: .35, child: button),
child: button,
),
),
);
@@ -33,6 +33,7 @@ class ChatSessionsBody extends StatelessWidget {
required this.error,
required this.onOpen,
this.onOpenBeside,
this.draggable = false,
this.onOpenBelow,
this.onFloat,
this.paneMenu,
@@ -65,6 +66,7 @@ class ChatSessionsBody extends StatelessWidget {
final String? error;
final ValueChanged<JsonMap> onOpen;
final ValueChanged<JsonMap>? onOpenBeside;
final bool draggable;
final ValueChanged<JsonMap>? onOpenBelow;
final ValueChanged<JsonMap>? onFloat;
final SessionPaneMenu? paneMenu;
@@ -104,6 +106,7 @@ class ChatSessionsBody extends StatelessWidget {
duplicateTitles: duplicateTitles,
onOpen: onOpen,
onOpenBeside: onOpenBeside,
draggable: draggable,
onOpenBelow: onOpenBelow,
onFloat: onFloat,
paneMenu: paneMenu,
@@ -33,6 +33,7 @@ class ChatSessionsScreen extends StatefulWidget {
required this.gateway,
required this.onOpen,
this.onOpenBeside,
this.draggable = false,
this.onOpenBelow,
this.onFloat,
this.paneMenu,
@@ -52,6 +53,7 @@ class ChatSessionsScreen extends StatefulWidget {
/// Optional split-pane actions; absent when the host cannot offer a split.
final ValueChanged<JsonMap>? onOpenBeside;
final bool draggable;
final ValueChanged<JsonMap>? onOpenBelow;
/// Floats the chat in a window over the app; absent when it cannot.
@@ -333,6 +335,7 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
onOpenBeside: widget.onOpenBeside == null
? null
: _openBeside,
draggable: widget.draggable,
onOpenBelow: widget.onOpenBelow == null
? null
: _openBelow,
@@ -88,6 +88,7 @@ SessionListItem chatSessionRowItem(
required Set<String> duplicateTitles,
required bool Function(JsonMap) isUnseen,
required ValueChanged<JsonMap> onOpen,
bool draggable = false,
ValueChanged<JsonMap>? onOpenBeside,
ValueChanged<JsonMap>? onOpenBelow,
ValueChanged<JsonMap>? onFloat,
@@ -112,6 +113,7 @@ SessionListItem chatSessionRowItem(
unseen: isUnseen(session),
divider: divider,
onOpen: onOpen,
draggable: draggable,
onOpenBeside: onOpenBeside,
onOpenBelow: onOpenBelow,
onFloat: onFloat,
@@ -14,6 +14,7 @@ class MaterialSessionList extends StatelessWidget {
required this.emptyMessage,
required this.duplicateTitles,
required this.onOpen,
this.draggable = false,
this.onOpenBeside,
this.onOpenBelow,
this.onFloat,
@@ -42,6 +43,7 @@ class MaterialSessionList extends StatelessWidget {
final String? emptyMessage;
final Set<String> duplicateTitles;
final ValueChanged<JsonMap> onOpen;
final bool draggable;
final ValueChanged<JsonMap>? onOpenBeside;
final ValueChanged<JsonMap>? onOpenBelow;
final ValueChanged<JsonMap>? onFloat;
@@ -117,6 +119,7 @@ class MaterialSessionList extends StatelessWidget {
duplicateTitles: duplicateTitles,
isUnseen: isUnseen,
onOpen: onOpen,
draggable: draggable,
onOpenBeside: onOpenBeside,
onOpenBelow: onOpenBelow,
onFloat: onFloat,
@@ -44,12 +44,14 @@ class ChatSessionRow extends StatelessWidget {
this.duplicateTitles = const {},
this.onLongPress,
this.selectionOnly = false,
this.draggable = false,
});
final JsonMap session;
/// A choosing surface keeps the normal row content but offers only opening.
final bool selectionOnly;
final bool draggable;
final ValueChanged<JsonMap> onOpen;
final ValueChanged<JsonMap>? onOpenBeside;
final ValueChanged<JsonMap>? onOpenBelow;
@@ -78,7 +80,24 @@ class ChatSessionRow extends StatelessWidget {
color: tint == null ? background : Color.alphaBlend(tint, background),
marker: marker,
markerWidth: visible ? (selected ? 10 : 3) : 0,
child: _marked(context, id, marker, accent),
child: draggable
? LongPressDraggable<JsonMap>(
data: session,
feedback: Material(
elevation: 4,
borderRadius: BorderRadius.circular(20),
child: Chip(
avatar: ChatSessionAvatar(session: session),
label: Text(chatSessionTitle(session)),
),
),
childWhenDragging: Opacity(
opacity: .35,
child: _marked(context, id, marker, accent),
),
child: _marked(context, id, marker, accent),
)
: _marked(context, id, marker, accent),
);
}
@@ -21,6 +21,7 @@ Widget memoChatSessionRow({
required bool unseen,
required bool divider,
required ValueChanged<JsonMap> onOpen,
bool draggable = false,
ValueChanged<JsonMap>? onOpenBeside,
ValueChanged<JsonMap>? onOpenBelow,
ValueChanged<JsonMap>? onFloat,
@@ -43,6 +44,7 @@ Widget memoChatSessionRow({
unseen,
divider,
onOpen,
draggable,
onOpenBeside,
onOpenBelow,
onFloat,
@@ -63,6 +65,7 @@ Widget memoChatSessionRow({
unseen: unseen,
divider: divider,
onOpen: onOpen,
draggable: draggable,
onOpenBeside: onOpenBeside,
onOpenBelow: onOpenBelow,
onFloat: onFloat,