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, }); final String paneId; final JsonMap session; /// Whether this is the chat on screen. final bool current; 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';