import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/features/chat/ui/sessions/session_attention.dart'; void main() { test('only final turn end clears working; a background shell cannot', () { for (final status in ['started', 'streamed', 'running', 'streaming']) { final effect = chatSessionFrameEffect({ 'type': 'chat_event', 'chat_event': { 'session_id': 's', 'kind': 'step', 'step': {'status': status}, }, }); expect(effect!.running, isTrue); expect(effect.attention, isFalse); } for (final kind in ['shell', 'compaction']) { final effect = chatSessionFrameEffect({ 'type': 'chat_event', 'chat_event': { 'session_id': 's', 'kind': kind, kind: {'status': kind == 'shell' ? 'exited' : 'completed'}, }, }); expect(effect!.running, isNull); expect(effect.attention, isFalse); } final intermediate = chatSessionFrameEffect({ 'type': 'chat_event', 'chat_event': { 'session_id': 's', 'kind': 'step', 'step': {'status': 'ended', 'intermediate': true}, }, }); expect(intermediate!.running, isNull); }); test('only visible assistant reply text is unread', () { bool attention(Map event) => chatSessionFrameEffect({ 'type': 'chat_event', 'chat_event': {'session_id': 's', ...event}, })!.attention; for (final status in ['running', 'completed', 'error']) { expect( attention({ 'kind': 'tool', 'part': { 'type': 'tool', 'state': { 'status': status, 'content': [ {'type': 'text', 'text': 'out'}, ], 'error': status == 'error' ? 'failed' : null, }, }, }), isFalse, reason: 'tool $status', ); } expect(attention({'kind': 'user', 'delta': 'prompt'}), isFalse); expect(attention({'kind': 'text', 'delta': ' \n'}), isFalse); for (final messageKind in ['notice', 'agent_report']) { expect( attention({'kind': 'text', 'delta': 'x', 'message_kind': messageKind}), isFalse, ); } expect(attention({'kind': 'text', 'delta': 'answer'}), isTrue); }); }