Chat list: spinner and background-task badge from server activity on every row

The list applies chat_activity pushes and each row's activity by seq, so
every listed chat shows a running turn, not only the chat open here. An
idle chat with running background tasks wears a quiet badge with tooltip and
semantics "Background tasks running (N)". Older servers keep the old
behaviour. List rows that never changed carry the server's current seq so
they order after snapshots kept from an earlier server process.
This commit is contained in:
2026-11-03 19:53:52 +00:00
parent 1b98877d88
commit 45c933c176
9 changed files with 560 additions and 73 deletions
+16
View File
@@ -10,6 +10,8 @@
// that harness's account quota after a chat subscribes.
// `?colors=1` (with `?chats=N`) names the chats, stars and colours some of
// them, and keeps colours picked with chat_color;
// `?activity=1` (with `?chats=N`) lists a running chat, one with
// background tasks and idle ones;
// `?msgs=`, `?rich=1`, `?older=1`, `?live=N` vary the chat transcripts for
// scroll captures (tool/perf/chat_scroll_fixture.dart).
// `/new` in a fixture chat moves it to a fresh, empty session
@@ -32,6 +34,18 @@ int get _chats => int.tryParse(_params['chats'] ?? '') ?? 0;
bool get perfRunGraph => _params['graph'] == '1';
bool get _colors => _params['colors'] == '1';
/// `?activity=1` (with `?chats=N`): the first chat's turn is running, the
/// second is idle with two background tasks, the rest are idle, as the
/// server's `activity` row field reports them.
JsonMap? _activityFor(int i) {
if (_params['activity'] != '1') return null;
return switch (i) {
0 => {'turn_running': true, 'background_tasks': 1, 'seq': 3},
1 => {'background_tasks': 2, 'seq': 2},
_ => {'seq': 1},
};
}
/// `?colors=1`: titles, directories, stars and colours per chat index.
const _colorTitles = [
'Release notes',
@@ -58,6 +72,7 @@ JsonMap _chatRow(int i) {
if (_harness != 'opencode') 'backend': _harness,
'resume_command': _resumeCommand(id),
'native_export': _harness == 'claude',
'activity': ?_activityFor(i),
};
}
final color = _pickedColors.containsKey(id)
@@ -72,6 +87,7 @@ JsonMap _chatRow(int i) {
'updated_at': DateTime.now().millisecondsSinceEpoch - (i + 1) * 600000,
if (_colorStarred.contains(i)) 'starred': true,
'color': ?color,
'activity': ?_activityFor(i),
};
}