Chat: fold activity-only rows between messages into one summary line

Tool-only turns, thinking-only turns and background-task notices that sit
between two content rows become one collapsible activity_group row, e.g.
"Ran 7 commands · used 9 tools · 8 background tasks finished · 1 failed",
the failure count in the error colour and never ellipsized. Expanding it
shows the folded rows as they render on their own. A run's task notices
fold into one chip at the newest notice; a notice whose id recurs later is
counted only at its latest position.

Grouping is a pure domain step (groupChatActivity) applied last in the
thread view's row pipeline; group rows list every member id so ChatRowKeys
keeps their identity, unchanged runs return the identical group object, and
the transcript anchor accepts a group's agent-turn ids. The scroll fixture
gains ?bgwork=1 for the shape.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 10:58:25 +00:00
parent 33874005c4
commit 22866ec0ce
10 changed files with 963 additions and 13 deletions
@@ -1,4 +1,5 @@
import '../../../core/api_gateway.dart';
import '../domain/chat_activity_groups.dart';
/// Where an opened transcript is split into its older and newer halves.
///
@@ -49,10 +50,17 @@ int chatTranscriptAnchorIndex(List<JsonMap> rows, String? anchor) {
return -1;
}
/// The stored message ids of one user or assistant row. Cards, activity lines
/// and the pending-response shell carry none and can never be an anchor.
/// The stored message ids of one user or assistant row, or of the agent turns
/// an activity group folds. Cards, notices, activity lines and the
/// pending-response shell carry none and can never be an anchor.
List<String> _messageIds(JsonMap row) {
final kind = row['kind'];
if (kind == chatActivityGroupKind) {
return [
for (final id in chatActivityGroupTurnIds(row))
if (id.trim().isNotEmpty) id.trim(),
];
}
if (kind == 'assistant') {
final listed = row['messageIds'];
if (listed is! List) return const [];