Show loudly in the chat list when a chat is waiting on the operator
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>
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
import '../../../core/api_gateway.dart';
|
||||
|
||||
/// One chat's live activity as the server observes it: a turn in flight and
|
||||
/// how many background tasks (shells, background commands, subagents) still
|
||||
/// run. It rides on each `chat_sessions` row as `activity` and is pushed to
|
||||
/// One chat's live activity as the server observes it: a turn in flight, how
|
||||
/// many background tasks (shells, background commands, subagents) still run,
|
||||
/// and how many approvals or questions wait on the operator. It rides on each `chat_sessions` row as `activity` and is pushed to
|
||||
/// every connection as `chat_activity` on each change. [seq] orders one
|
||||
/// chat's snapshots across the list and the pushes; the larger one is newer.
|
||||
typedef ChatListActivity = ({
|
||||
String sessionId,
|
||||
bool turnRunning,
|
||||
int backgroundTasks,
|
||||
int awaitingOperator,
|
||||
int seq,
|
||||
});
|
||||
|
||||
@@ -21,11 +22,13 @@ ChatListActivity? chatListActivityOf(Object? value, {String? sessionId}) {
|
||||
final id = sessionId ?? (named is String ? named : '');
|
||||
if (id.isEmpty) return null;
|
||||
final tasks = value['background_tasks'];
|
||||
final awaiting = value['awaiting_operator'];
|
||||
final seq = value['seq'];
|
||||
return (
|
||||
sessionId: id,
|
||||
turnRunning: value['turn_running'] == true,
|
||||
backgroundTasks: tasks is num && tasks > 0 ? tasks.toInt() : 0,
|
||||
awaitingOperator: awaiting is num && awaiting > 0 ? awaiting.toInt() : 0,
|
||||
seq: seq is num ? seq.toInt() : 0,
|
||||
);
|
||||
}
|
||||
@@ -34,6 +37,7 @@ ChatListActivity? chatListActivityOf(Object? value, {String? sessionId}) {
|
||||
JsonMap chatListActivityRowFields(ChatListActivity activity) => {
|
||||
'running': activity.turnRunning,
|
||||
'background_tasks': activity.backgroundTasks,
|
||||
'awaiting_operator': activity.awaitingOperator,
|
||||
};
|
||||
|
||||
/// Running background tasks of a list row; 0 when unknown.
|
||||
@@ -41,3 +45,10 @@ int chatSessionBackgroundTasks(JsonMap session) {
|
||||
final tasks = session['background_tasks'];
|
||||
return tasks is int && tasks > 0 ? tasks : 0;
|
||||
}
|
||||
|
||||
/// Approvals and questions a list row's chat holds unanswered; 0 when none or
|
||||
/// unknown. Above 0 the agent is blocked until the operator replies.
|
||||
int chatSessionAwaitingOperator(JsonMap session) {
|
||||
final awaiting = session['awaiting_operator'];
|
||||
return awaiting is int && awaiting > 0 ? awaiting : 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user