efaa0d9fca
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>
61 lines
1.9 KiB
Dart
61 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../core/api_gateway.dart';
|
|
import '../domain/chat_colors.dart';
|
|
import '../domain/chat_list_activity.dart';
|
|
import '../domain/chat_sessions.dart';
|
|
import '../ui/sessions/chat_color_palette.dart';
|
|
import '../ui/sessions/session_row_content.dart';
|
|
|
|
/// One open chat as the chat stack shows it: the pane that holds it and the
|
|
/// chat's latest list row (its title, colour, harness and live state).
|
|
@immutable
|
|
class ChatStackEntry {
|
|
const ChatStackEntry({
|
|
required this.paneId,
|
|
required this.session,
|
|
this.current = false,
|
|
this.group,
|
|
});
|
|
|
|
final String paneId;
|
|
final JsonMap session;
|
|
|
|
/// Whether this is the chat on screen.
|
|
final bool current;
|
|
|
|
/// The chat stack group it is in, or null.
|
|
final String? group;
|
|
|
|
String get sessionId => '${session['id'] ?? ''}';
|
|
String get title => chatSessionTitle(session);
|
|
|
|
bool get _closed => session['closed_at'] != null || session['closed'] == true;
|
|
|
|
/// Unanswered approvals and questions: the agent is blocked on the
|
|
/// operator.
|
|
int get awaitingOperator =>
|
|
_closed ? 0 : chatSessionAwaitingOperator(session);
|
|
bool get running => session['running'] == true;
|
|
|
|
/// The chat's colour as the list draws it, or null for none.
|
|
Color? color(BuildContext context) =>
|
|
chatColorShade(context, chatSessionColor(session));
|
|
}
|
|
|
|
/// [entry]'s list avatar; with [cues] it keeps the list's corner badge
|
|
/// (waiting on the operator, working, background tasks).
|
|
Widget chatStackAvatar(ChatStackEntry entry, {bool cues = true}) =>
|
|
ChatSessionAvatar(
|
|
session: entry.session,
|
|
awaitingOperator: cues ? entry.awaitingOperator : 0,
|
|
running: cues && entry.running,
|
|
backgroundTasks: cues && !entry.running
|
|
? chatSessionBackgroundTasks(entry.session)
|
|
: 0,
|
|
selected: entry.current,
|
|
);
|
|
|
|
/// The collapsed stack's spoken name: "Chats, 5 open".
|
|
String chatStackLabel(int count) => 'Chats, $count open';
|