Chat: group consecutive background-task notices into one collapsed chip

Two or more consecutive Claude Code task notices fold into one
task_notices row: a chip 'N background tasks' (tinted when one failed)
that opens a sheet with one compact row per task (outcome icon, summary,
outcome word), like the tools and permissions chips. A lone notice stays
one line. The server also treats Claude Code's [SYSTEM NOTIFICATION]
banner as harness text, so a bannered notification without an origin is
still a notice, never the operator's turn. The chat fixture gains
?tasks=N.
This commit is contained in:
2026-11-03 12:44:57 +00:00
parent d34185b56c
commit 1a9db0206c
10 changed files with 591 additions and 5 deletions
+1 -1
View File
@@ -116,7 +116,7 @@ Look at every PNG you cite. A capture that exits 0 is not a review.
Check a chat scroll: the full-app fixture exposes `chatScrollMetrics()` (the
open transcript's `{pixels, min, max, viewport}` as JSON;
`tool/perf/chat_scroll_probe.dart`), and `?chats=N` with `?msgs=`, `?rich=1`,
`?older=1` and `?live=N` (`tool/perf/chat_scroll_fixture.dart`) shapes the
`?older=1`, `?live=N` and `?tasks=N` (`tool/perf/chat_scroll_fixture.dart`) shape the
transcripts. `tool/capture/examples/chat-wheel-scroll.json` wheels over each
content kind and expects the offset to move:
+29 -2
View File
@@ -9,7 +9,9 @@
// `?older=1` the first page reports more history; Load older adds 20
// earlier messages;
// `?live=N` 3 s after a chat subscribes, N text deltas stream into a
// new reply, one every 60 ms.
// new reply, one every 60 ms;
// `?tasks=N` the history ends with N consecutive background-task notices
// in the server's wording (every third one failed).
import 'dart:async';
import 'package:pipelines_app/core/api_gateway.dart';
@@ -21,6 +23,28 @@ void configureChatScrollFixture(Map<String, String> params) => _params = params;
bool get _rich => _params['rich'] == '1';
bool get _older => _params['older'] == '1';
int get _live => int.tryParse(_params['live'] ?? '') ?? 0;
int get _tasks => int.tryParse(_params['tasks'] ?? '') ?? 0;
/// Background task [i]'s notice, as the server records a Claude Code task
/// notification.
JsonMap _taskNotice(String chat, int i) {
final failed = i % 3 == 2;
final summary = i.isEven
? 'Background command "Build step $i" '
'${failed ? 'failed (exit code 1)' : 'completed (exit code 0)'}'
: 'Agent "Review part $i" ${failed ? 'failed' : 'finished'}';
return {
'id': '$chat-task-$i',
'role': 'assistant',
'kind': 'notice',
'parts': [
{
'type': 'text',
'text': 'Background task ${failed ? 'failed' : 'finished'}: $summary',
},
],
};
}
/// The message count for chat [index] (`perf-chat-<index>`).
int chatScrollMessageCount(int index) {
@@ -115,7 +139,10 @@ JsonMap chatScrollHistory(String sessionId, int index, String cursor) {
};
}
return {
'messages': [for (var i = 0; i < count; i++) _message(sessionId, i)],
'messages': [
for (var i = 0; i < count; i++) _message(sessionId, i),
for (var i = 0; i < _tasks; i++) _taskNotice(sessionId, i),
],
'next_cursor': _older ? 'older' : '',
'has_more': _older,
};