fix(app): chat turns are content-sized bubbles without role labels, as the web

This commit is contained in:
2026-10-23 15:43:07 +01:00
parent 702bf8559d
commit c46a46ee14
3 changed files with 51 additions and 42 deletions
@@ -66,16 +66,15 @@ void main() {
await tester.pumpWidget(_host(_userRow(), scale: 2));
await tester.pumpAndSettle();
expect(find.text('User'), findsOneWidget);
// Side and colour say who spoke; the role is a semantics label only.
expect(find.text('User'), findsNothing);
expect(find.bySemanticsLabel('User message'), findsOneWidget);
expect(find.text('Ada phone'), findsOneWidget);
expect(find.text(' Keep this exact\nline two '), findsOneWidget);
expect(find.text('plan.md'), findsOneWidget);
expect(find.text('report.csv'), findsOneWidget);
final role = tester.widget<Text>(find.text('User'));
final theme = Theme.of(tester.element(find.byType(ChatMessageView)));
expect(theme.brightness, Brightness.dark);
expect(role.style?.color, theme.colorScheme.onSurfaceVariant);
expect(role.style?.color?.computeLuminance(), greaterThan(0.4));
expect(tester.takeException(), isNull);
});
@@ -86,14 +85,12 @@ void main() {
await tester.pumpWidget(_host(_userRow(), cupertino: true, scale: 2));
await tester.pumpAndSettle();
expect(find.text('User'), findsOneWidget);
expect(find.text('User'), findsNothing);
expect(find.text(' Keep this exact\nline two '), findsOneWidget);
expect(find.text('plan.md'), findsOneWidget);
expect(find.text('report.csv'), findsOneWidget);
final context = tester.element(find.byType(ChatMessageView));
expect(CupertinoTheme.of(context).brightness, Brightness.dark);
final role = tester.widget<Text>(find.text('User'));
expect(role.style?.color?.computeLuminance(), greaterThan(0.4));
expect(tester.takeException(), isNull);
},
);
@@ -120,7 +117,8 @@ void main() {
await tester.pumpWidget(_host(row, scale: 2));
await tester.pumpAndSettle();
expect(find.text('Assistant'), findsOneWidget);
expect(find.text('Assistant'), findsNothing);
expect(find.bySemanticsLabel('Assistant message'), findsOneWidget);
expect(find.text('private reasoning'), findsNothing);
expect(find.textContaining('"command": "ls"'), findsNothing);
expect(find.textContaining('"payload": 7'), findsNothing);
@@ -318,4 +316,21 @@ void main() {
expect(find.text('Rendered **markdown**'), findsOneWidget);
expect(find.text('**markdown**'), findsNothing);
});
testWidgets('a short user turn is a right-aligned bubble, not a full row', (
tester,
) async {
_phone(tester);
await tester.pumpWidget(_host(_userRow()));
await tester.pumpAndSettle();
final row = tester.getRect(find.byType(ChatMessageView));
final bubble = tester.getRect(
find.ancestor(
of: find.text('Ada phone'),
matching: find.byType(Material),
).first,
);
expect(bubble.width, lessThanOrEqualTo(row.width * 0.85 + 0.5));
expect(bubble.right, closeTo(row.right, 1));
});
}
@@ -27,13 +27,7 @@ void main() {
),
),
);
final label = tester.widget<Text>(find.text('User'));
expect(
label.style!.fontWeight,
Theme.of(
tester.element(find.byType(ChatMessageView)),
).textTheme.labelLarge!.fontWeight,
);
expect(find.text('User'), findsNothing);
expect(find.text('Recorded user text'), findsOneWidget);
await tester.tap(find.text('Unrecognised part: future-content'));
await tester.pumpAndSettle();