Chat: draw agent follow-ups and automatic continues apart from the operator

The server now names a user turn's origin (followup, auto_continue,
auto_switch, scheduled) on chat messages, user frames and queued prompts,
from the prompt's operation id while it holds the prompt and from its own
text prefixes in history read later. Origin is a new field, so older
clients keep treating these as ordinary user turns.

The app draws an agent follow-up, auto-continue and account-switch prompt
as a quiet outlined card on the agent's side with an icon, label and the
schedule facts from the preamble; the operator's own scheduled message
keeps its bubble with a small Scheduled mark. Find searches the drawn text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 15:40:34 +00:00
parent 608b6b8edb
commit 9a6363b80e
22 changed files with 946 additions and 26 deletions
+82
View File
@@ -0,0 +1,82 @@
import 'package:pipelines_app/core/api_gateway.dart';
/// `?followups=1`: the prompts the operator did not type just now, between
/// ordinary turns: an agent's follow-up (timed and run-triggered), the
/// server's auto-continue and account switch, and the operator's own
/// scheduled message.
List<JsonMap> chatFollowupMessages(String chat) {
var minute = 0;
int at() => DateTime.utc(2026, 12, 3, 9, minute += 7).millisecondsSinceEpoch;
JsonMap user(String id, String text, [JsonMap extra = const {}]) => {
'id': '$chat-fu-$id',
'role': 'user',
'created_at': at(),
'parts': [
{'type': 'text', 'text': text},
],
...extra,
};
JsonMap reply(String id, String text) => {
'id': '$chat-fu-$id',
'role': 'assistant',
'created_at': at(),
'parts': [
{'type': 'text', 'text': text},
],
};
return [
user('q', 'Deploy the release and keep an eye on it.', {
'client': 'Laptop',
}),
reply(
'a1',
'Started run 42. I scheduled a follow-up to check it in 30 minutes.',
),
user(
'f1',
'[Follow-up you scheduled at 2026-12-03T09:14:00Z with '
'schedule_followup] Check whether run 42 finished and report the '
'deploy status.',
{
'client': 'Agent follow-up',
'operation_id': 'followup-1a2b',
'origin': 'followup',
},
),
reply('a2', 'Run 42 finished; the deploy is healthy.'),
user(
'f2',
'[Follow-up you scheduled at 2026-12-03T09:28:00Z with '
'schedule_followup, for when run 43 finishes; delivered at '
'2026-12-04T09:28:00Z at the latest] Review the canary results.'
'\n\n[Pipelines: run 43 is now succeeded; read it with pipelines '
'inspect 43.]',
{'client': 'Agent follow-up', 'origin': 'followup'},
),
reply('a3', 'You\'ve hit your 5-hour limit · resets 2pm'),
user('c1', 'Review the canary results.', {
'client': 'Pipelines (automatic)',
'operation_id': 'auto-continue-a3',
'origin': 'auto_continue',
}),
reply('a4', 'The canary results look good.'),
user(
's1',
'[Sent automatically by Pipelines] Usage ran out on ada@example.com, '
'so Pipelines switched this chat to bob@example.com. Before '
'continuing: briefly check your progress against my original '
'request and your plan.',
{
'client': 'Pipelines (automatic)',
'operation_id': 'auto-switch-a4',
'origin': 'auto_switch',
},
),
reply('a5', 'Still on track; continuing.'),
user('l1', 'Summarise the release for the team channel.', {
'client': 'Laptop',
'origin': 'scheduled',
}),
reply('a6', 'Here is the summary for the team channel.'),
];
}
+4
View File
@@ -20,9 +20,12 @@
// `?tables=1` answers carry a wrapping table, one with a long token and
// one too wide for a phone (it scrolls sideways);
// `?timestamps=1` messages carry recorded times over two calendar days.
// `?followups=1` appends agent follow-ups, auto-continue/switch prompts and
// a scheduled operator message (chat_followup_fixture.dart).
import 'dart:async';
import 'package:pipelines_app/core/api_gateway.dart';
import 'chat_followup_fixture.dart';
Map<String, String> _params = const {};
@@ -275,6 +278,7 @@ JsonMap chatScrollHistory(String sessionId, int index, String cursor) {
for (var i = 0; i < messages.length; i++)
_timed(messages[i], i, messages.length),
if (_bgwork) ..._backgroundWork(sessionId),
if (_params['followups'] == '1') ...chatFollowupMessages(sessionId),
],
'next_cursor': _older ? 'older' : '',
'has_more': _older,