Merge main (Compact design) into Glass

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 23:22:56 +00:00
93 changed files with 4110 additions and 313 deletions
@@ -0,0 +1,78 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/data/chat_repository.dart';
import 'package:pipelines_app/features/chat/speech/speech.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_controller.dart';
import '../../speech/fake_speech_engine.dart';
import 'chat_test_harness.dart';
import 'fake_chat_gateway.dart';
JsonMap _row(String id, {bool closed = false}) => {
'id': id,
'title': id,
'directory': '/w',
if (closed) 'closed_at': '2026-12-03T10:00:00Z',
};
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
late FakeChatGateway gateway;
late ChatSessionsController controller;
late SpeechController speech;
setUp(() async {
speech = installFakeSpeech(FakeSpeechEngine());
gateway = FakeChatGateway()
..sessionsReply = {
'chat_sessions': [_row('s1'), _row('s2')],
}
..actionHandler = (_, _) async => const {};
controller = ChatSessionsController(
ChatRepository(gateway),
localStore: MemoryChatSessionLocalStore(),
);
addTearDown(controller.dispose);
await controller.refresh();
await speech.read(speechMessageId('s1', 'r1'), ['Hello.']);
expect(speech.state, SpeechState.speaking);
});
test('closing the reading chat stops it', () async {
await controller.close('s1');
await pumpEventQueue();
expect(speech.state, SpeechState.idle);
});
test('closing another chat keeps reading', () async {
await controller.close('s2');
await pumpEventQueue();
expect(speech.state, SpeechState.speaking);
});
test('a chat closed on another device stops it on the next read', () async {
gateway.sessionsReply = {
'chat_sessions': [_row('s1', closed: true), _row('s2')],
};
await controller.refresh();
await pumpEventQueue();
expect(speech.state, SpeechState.idle);
});
test('a deleted chat stops it; a failed read does not', () async {
gateway.sessionsHandler = () async => throw StateError('offline');
await controller.refresh();
await pumpEventQueue();
expect(speech.state, SpeechState.speaking);
gateway
..sessionsHandler = null
..sessionsReply = {
'chat_sessions': [_row('s2')],
};
await controller.refresh();
await pumpEventQueue();
expect(speech.state, SpeechState.idle);
});
}
@@ -0,0 +1,104 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/speech/speech.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_awaiting.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_compact_avatar.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_row_content.dart';
import '../../speech/fake_speech_engine.dart';
const _speaking = Key('chat-row-speaking');
Widget _avatars({bool reduceMotion = false}) => MaterialApp(
home: MediaQuery(
data: MediaQueryData(disableAnimations: reduceMotion),
child: const Scaffold(
body: Column(
children: [
ChatSessionAvatar(
key: Key('one'),
session: {'id': 's1', 'title': 'One'},
running: true,
awaitingOperator: 2,
),
ChatSessionAvatar(
key: Key('two'),
session: {'id': 's2', 'title': 'Two'},
),
ChatCompactAvatar(
key: Key('two-compact'),
sessionId: 's2',
title: 'Two',
color: Colors.blue,
active: false,
visible: false,
running: false,
backgroundTasks: 0,
unread: false,
),
],
),
),
),
);
Finder _badgeOf(String avatar) => find.descendant(
of: find.byKey(Key(avatar)),
matching: find.byKey(_speaking),
);
Future<void> _read(WidgetTester tester, SpeechController speech, String chat) =>
tester.runAsync(() => speech.read(speechMessageId(chat, 'r1'), ['Hi.']));
void main() {
testWidgets('the reading chat wears the speaking badge, and it moves', (
tester,
) async {
final speech = installFakeSpeech(FakeSpeechEngine());
await tester.pumpWidget(_avatars());
expect(find.byKey(_speaking), findsNothing);
await _read(tester, speech, 's1');
await tester.pump();
expect(_badgeOf('one'), findsOneWidget);
expect(_badgeOf('two'), findsNothing);
expect(_badgeOf('two-compact'), findsNothing);
// Speaking outranks the operator wait and the running spinner.
expect(find.byKey(const Key('chat-row-working')), findsNothing);
expect(find.byType(ChatAwaitingBadge), findsNothing);
await _read(tester, speech, 's2');
await tester.pump();
expect(_badgeOf('one'), findsNothing);
expect(_badgeOf('two'), findsOneWidget);
expect(_badgeOf('two-compact'), findsOneWidget);
expect(find.byKey(const Key('chat-speaking-wave')), findsNWidgets(2));
await tester.runAsync(speech.stop);
await tester.pump();
expect(find.byKey(_speaking), findsNothing);
});
testWidgets('a Settings voice sample marks no chat', (tester) async {
final speech = installFakeSpeech(FakeSpeechEngine());
await tester.pumpWidget(_avatars());
await tester.runAsync(speech.sample);
await tester.pump();
expect(speech.state, SpeechState.speaking);
expect(find.byKey(_speaking), findsNothing);
});
testWidgets('reduced motion shows a still speaker', (tester) async {
final speech = installFakeSpeech(FakeSpeechEngine());
await tester.pumpWidget(_avatars(reduceMotion: true));
// The first chat's spinner gives way to the speaking badge.
await _read(tester, speech, 's1');
await tester.pump();
expect(_badgeOf('one'), findsOneWidget);
expect(find.byKey(const Key('chat-speaking-still')), findsOneWidget);
expect(find.byKey(const Key('chat-speaking-wave')), findsNothing);
// Nothing ticks: settling finishes with the badge still shown.
await tester.pumpAndSettle();
expect(_badgeOf('one'), findsOneWidget);
});
}