Keep chat controls readable and expose labeled app navigation

This commit is contained in:
2026-11-07 20:46:02 +00:00
parent 68c0ad3caa
commit 4bbbe01633
20 changed files with 582 additions and 159 deletions
@@ -41,62 +41,69 @@ void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host header keeps back, title pill and model on one row', (
tester,
) async {
_useNarrowText(tester);
final semantics = tester.ensureSemantics();
final gateway = FakeChatGateway();
addTearDown(gateway.close);
gateway.history = (_) async => chatPage(const []);
gateway.subscribe = () async => const {};
var backed = 0;
testWidgets(
'$host narrow header keeps native back/title and readable model',
(tester) async {
_useNarrowText(tester);
final semantics = tester.ensureSemantics();
final gateway = FakeChatGateway();
addTearDown(gateway.close);
gateway.history = (_) async => chatPage(const []);
gateway.subscribe = () async => const {};
var backed = 0;
await tester.pumpWidget(
_host(
ChatThreadView(
gateway: gateway,
sessionId: 's',
title: _title,
session: _session,
onBack: () => backed++,
await tester.pumpWidget(
_host(
ChatThreadView(
gateway: gateway,
sessionId: 's',
title: _title,
session: _session,
onBack: () => backed++,
),
cupertino: cupertino,
),
cupertino: cupertino,
),
);
await tester.pumpAndSettle();
);
await tester.pumpAndSettle();
final title = find.text(_title);
final model = find.byKey(const Key('chat-model'));
final info = find.byKey(const Key('chat-info'));
final back = find.byKey(const Key('chat-back'));
expect(title, findsOneWidget);
expect(model, findsOneWidget);
expect(info, findsOneWidget);
expect(back, findsOneWidget);
expect(tester.takeException(), isNull);
// Back is the platform's own control, as on every other page.
expect(
find.descendant(of: back, matching: findNativeBack()),
findsOneWidget,
);
final title = find.text(_title);
final model = find.byKey(const Key('chat-model'));
final info = find.byKey(const Key('chat-info'));
final back = find.byKey(const Key('chat-back'));
expect(title, findsOneWidget);
expect(model, findsOneWidget);
expect(info, findsOneWidget);
expect(back, findsOneWidget);
expect(tester.takeException(), isNull);
// Back is the platform's own control, as on every other page.
expect(
find.descendant(of: back, matching: findNativeBack()),
findsOneWidget,
);
// One floating row of separate pieces: the round Back, the title pill
// (which is the information control and holds the title), then the
// model in the trailing pill.
double centerY(Finder finder) => tester.getCenter(finder).dy;
expect((centerY(back) - centerY(info)).abs(), lessThan(16));
expect((centerY(model) - centerY(info)).abs(), lessThan(16));
expect(find.descendant(of: info, matching: title), findsOneWidget);
double right(Finder finder) => tester.getTopRight(finder).dx;
expect(right(back), lessThanOrEqualTo(tester.getTopLeft(info).dx));
expect(right(info), lessThanOrEqualTo(tester.getTopLeft(model).dx));
// One floating row of separate pieces: the round Back, the title pill
// (which is the information control and holds the title), then the
// model in the trailing pill.
double centerY(Finder finder) => tester.getCenter(finder).dy;
expect((centerY(back) - centerY(info)).abs(), lessThan(16));
expect(
tester.getTopLeft(model).dy,
greaterThanOrEqualTo(tester.getBottomLeft(info).dy),
);
expect(find.descendant(of: info, matching: title), findsOneWidget);
double right(Finder finder) => tester.getTopRight(finder).dx;
expect(right(back), lessThanOrEqualTo(tester.getTopLeft(info).dx));
expect(
find.textContaining('an-extremely-long-recorded-model-id'),
findsOneWidget,
);
await tester.tap(back);
await tester.pump();
expect(backed, 1);
semantics.dispose();
});
await tester.tap(back);
await tester.pump();
expect(backed, 1);
semantics.dispose();
},
);
}
for (final cupertino in [false, true]) {
@@ -151,10 +158,17 @@ void main() {
final actions = find.byKey(const Key('chat-actions-island'));
expect(selectors, findsOneWidget);
expect(actions, findsOneWidget);
expect(
tester.getTopRight(selectors).dx,
lessThan(tester.getTopLeft(actions).dx),
);
if (width >= 800) {
expect(
tester.getTopRight(selectors).dx,
lessThan(tester.getTopLeft(actions).dx),
);
} else {
expect(
tester.getTopLeft(selectors).dy,
greaterThanOrEqualTo(tester.getBottomLeft(actions).dy),
);
}
expect(find.byKey(const Key('chat-next')), findsNothing);
expect(find.text('Next chat'), findsNothing);
expect(find.byKey(const Key('chat-model')), findsOneWidget);