Chat stack: groups of open chats, synced with the open-chat set

A chat dropped onto the middle of another makes a named group (asked at
once, "Group N" by default); onto a group it joins, a group dropped onto
a chat takes it in, groups merge. The top level shows each group as a
small pile with its name and count; a tap opens it in place under a
header that leads back (also the scrim, Back and Escape). In a group,
dropping a chat on the header leaves the group; a group of one
dissolves. The close button ungroups a dropped group with Undo. Rename,
Ungroup, Close all (with Undo), Move to group and Remove from group are
in the group menu and as semantic actions.

Each open-chat entry carries its group name (protocol field "group",
omitted when ungrouped; older clients ignore it), stored and pushed by
the server like the order; names are trimmed, printable, at most 80
characters. Needs a server restart to keep groups.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 22:18:44 +00:00
parent 130c1e6708
commit efaa0d9fca
30 changed files with 2399 additions and 308 deletions
@@ -22,7 +22,13 @@ const double kChatStackLabelGap = 10;
/// through each other, and its rim separates them. A raised design drops a
/// short shadow; a flat one casts none, and its avatar frames itself.
class ChatStackDisc extends StatelessWidget {
const ChatStackDisc({super.key, required this.child, this.ring, this.lift});
const ChatStackDisc({
super.key,
required this.child,
this.ring,
this.lift,
this.liftRing,
});
final Widget child;
@@ -33,6 +39,9 @@ class ChatStackDisc extends StatelessWidget {
/// design a frame in the primary colour.
final Animation<double>? lift;
/// A drop target's ring colour, worn as [lift] runs.
final Color? liftRing;
@override
Widget build(BuildContext context) {
final tokens = AppDesignTokens.of(context);
@@ -59,7 +68,7 @@ class ChatStackDisc extends StatelessWidget {
child: chatStackLifted(
lift,
rest,
chatStackRaised(rest, tokens, scheme),
chatStackRaised(rest, tokens, scheme, ring: liftRing),
child: SizedBox.square(
dimension: kChatStackDisc,
child: Center(
@@ -117,17 +126,24 @@ List<BoxShadow> chatStackLiftShadows(ColorScheme scheme) => [
];
/// [rest] as a dragged item wears it: the lifted shadow, or under a flat
/// design (which casts none) a frame in the primary colour.
/// design (which casts none) a frame in the primary colour. With [ring] (a
/// drop target) every design gets a ring in that colour.
ShapeDecoration chatStackRaised(
ShapeDecoration rest,
AppDesignTokens tokens,
ColorScheme scheme,
) {
ColorScheme scheme, {
Color? ring,
}) {
final shape = rest.shape;
final side = ring != null
? BorderSide(color: ring, width: 2)
: tokens.flat
? BorderSide(color: scheme.primary, width: 1.5)
: null;
return ShapeDecoration(
color: rest.color,
shape: tokens.flat && shape is OutlinedBorder
? shape.copyWith(side: BorderSide(color: scheme.primary, width: 1.5))
shape: side != null && shape is OutlinedBorder
? shape.copyWith(side: side)
: shape,
shadows: tokens.flat ? null : chatStackLiftShadows(scheme),
);
@@ -156,9 +172,21 @@ class ChatStackLabel extends StatelessWidget {
this.color,
this.emphasized = false,
this.lift,
this.liftRing,
this.detail,
this.trailing,
});
final String text;
/// A muted note after the text (a group's chat count).
final String? detail;
/// A small control at the end (the group header's menu).
final Widget? trailing;
/// A drop target's ring colour, worn as [lift] runs.
final Color? liftRing;
final Color? color;
final bool emphasized;
@@ -188,15 +216,42 @@ class ChatStackLabel extends StatelessWidget {
return chatStackLifted(
lift,
rest,
chatStackRaised(rest, tokens, scheme),
chatStackRaised(rest, tokens, scheme, ring: liftRing),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
child: Text(
text,
maxLines: 1,
overflow: TextOverflow.ellipsis,
softWrap: false,
style: style,
padding: EdgeInsetsDirectional.only(
start: 12,
end: trailing == null ? 12 : 2,
top: 6,
bottom: 6,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: Text(
text,
maxLines: 1,
overflow: TextOverflow.ellipsis,
softWrap: false,
style: style,
),
),
if (detail case final detail?) ...[
const SizedBox(width: 6),
Text(
detail,
maxLines: 1,
style: style.copyWith(
color: scheme.onSurfaceVariant,
fontWeight: FontWeight.w500,
),
),
],
if (trailing case final trailing?) ...[
const SizedBox(width: 2),
trailing,
],
],
),
),
);