4c82a9637e
The server's chat activity now counts each session's unanswered approvals and questions (awaiting_operator) and pushes it to every connection when it changes. A waiting chat's list row pulses in the error colour with a solid bar on its leading edge, its avatar wears a ringing bell in place of the spinner, and its state line leads with a bold "Waiting for you". Reduced motion holds the pulse and the bell still. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
138 lines
4.1 KiB
Dart
138 lines
4.1 KiB
Dart
import '../../../../core/servers/server_context.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
/// State uses neutral text and shapes; the chat's chosen color stays identity.
|
|
Color chatStateForeground(BuildContext context) =>
|
|
Theme.of(context).colorScheme.onSurface;
|
|
|
|
Color chatMetadataForeground(BuildContext context) =>
|
|
Theme.of(context).colorScheme.onSurfaceVariant;
|
|
|
|
class ChatSessionStateLine extends StatelessWidget {
|
|
const ChatSessionStateLine({
|
|
super.key,
|
|
required this.active,
|
|
required this.visible,
|
|
required this.running,
|
|
required this.backgroundTasks,
|
|
required this.unread,
|
|
this.awaitingOperator = 0,
|
|
});
|
|
final bool active, visible, running, unread;
|
|
final int backgroundTasks;
|
|
final int awaitingOperator;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final entries = <(IconData, String)>[
|
|
if (active)
|
|
(Icons.radio_button_checked, 'Active')
|
|
else if (visible)
|
|
(Icons.visibility_outlined, 'Visible'),
|
|
if (running) (Icons.play_circle_outline, 'Working'),
|
|
if (backgroundTasks > 0)
|
|
(Icons.pending_actions, '$backgroundTasks background'),
|
|
if (unread) (Icons.mark_chat_unread_outlined, 'New'),
|
|
];
|
|
final error = Theme.of(context).colorScheme.error;
|
|
return Wrap(
|
|
spacing: 10,
|
|
runSpacing: 4,
|
|
children: [
|
|
if (awaitingOperator > 0)
|
|
Row(
|
|
key: const Key('chat-row-awaiting-label'),
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(Icons.notifications_active, size: 16, color: error),
|
|
const SizedBox(width: 4),
|
|
Flexible(
|
|
child: Text(
|
|
awaitingOperator == 1
|
|
? 'Waiting for you'
|
|
: 'Waiting for you ($awaitingOperator)',
|
|
style: TextStyle(color: error, fontWeight: FontWeight.w800),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
for (final (icon, label) in entries)
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(icon, size: 14, color: chatStateForeground(context)),
|
|
const SizedBox(width: 4),
|
|
Flexible(
|
|
child: Text(
|
|
label,
|
|
style: TextStyle(color: chatStateForeground(context)),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
class ChatSessionSubtitle extends StatelessWidget {
|
|
const ChatSessionSubtitle({
|
|
super.key,
|
|
required this.metadata,
|
|
this.machineName,
|
|
required this.closed,
|
|
required this.active,
|
|
required this.visible,
|
|
required this.running,
|
|
required this.backgroundTasks,
|
|
required this.unread,
|
|
this.awaitingOperator = 0,
|
|
});
|
|
final String metadata;
|
|
final String? machineName;
|
|
final bool closed, active, visible, running, unread;
|
|
final int awaitingOperator;
|
|
final int backgroundTasks;
|
|
@override
|
|
Widget build(BuildContext context) => Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text.rich(
|
|
TextSpan(
|
|
children: [
|
|
if (closed)
|
|
const TextSpan(
|
|
text: 'Closed',
|
|
style: TextStyle(fontWeight: FontWeight.w600),
|
|
),
|
|
if (closed && metadata.isNotEmpty) const TextSpan(text: ' · '),
|
|
TextSpan(
|
|
text: machineName == null
|
|
? ServerContext.metadata(context, metadata)
|
|
: '$machineName${metadata.isEmpty ? '' : ' · $metadata'}',
|
|
),
|
|
],
|
|
),
|
|
style: TextStyle(color: chatMetadataForeground(context)),
|
|
),
|
|
if (active ||
|
|
visible ||
|
|
running ||
|
|
backgroundTasks > 0 ||
|
|
unread ||
|
|
awaitingOperator > 0)
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 4),
|
|
child: ChatSessionStateLine(
|
|
active: active,
|
|
visible: visible,
|
|
running: running,
|
|
backgroundTasks: backgroundTasks,
|
|
unread: unread,
|
|
awaitingOperator: awaitingOperator,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|