Chat: the transcript ends at the composer's top; the colour wash starts at the bar's top edge

This commit is contained in:
2026-11-03 12:27:53 +00:00
parent d34185b56c
commit 777c444529
7 changed files with 144 additions and 55 deletions
@@ -157,15 +157,26 @@ void main() {
final pane = tester.getRect(
find.byKey(const ValueKey('chat-detail-pane')),
);
// The wash starts at the very top of the pane, the bar's top edge,
// over the bar's scrim, and carries on below the bar to fade out.
expect(washRect.top, pane.top);
expect(washRect.height, lessThan(pane.height / 4));
final box = tester.widget<DecoratedBox>(
find.byKey(const Key('chat-color-wash')),
);
final gradient =
(box.decoration as BoxDecoration).gradient! as LinearGradient;
expect(gradient.colors.first.a, lessThanOrEqualTo(0.25));
expect(gradient.colors.last.a, 0);
final bar = tester.getRect(find.byKey(const Key('chat-thread-header')));
expect(bar.top, pane.top);
expect(washRect.bottom, bar.bottom);
final below = find.byKey(const Key('chat-color-wash-below'));
expect(tester.getRect(below).top, bar.bottom);
expect(tester.getRect(below).bottom, lessThan(pane.height / 4));
LinearGradient gradientOf(Finder finder) =>
(tester.widget<DecoratedBox>(finder).decoration as BoxDecoration)
.gradient!
as LinearGradient;
final top = gradientOf(find.byKey(const Key('chat-color-wash')));
final rest = gradientOf(below);
expect(top.colors.first.a, greaterThan(0.15));
expect(top.colors.first.a, lessThanOrEqualTo(0.25));
// One continuous fade across the two parts.
expect(rest.colors.first.a, closeTo(top.colors.last.a, 1e-6));
expect(rest.colors.last.a, 0);
// A plain chat has none.
await _ctrl(tester, LogicalKeyboardKey.digit3);
@@ -66,7 +66,7 @@ void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host composer floats as glass with the transcript behind', (
testWidgets('$host transcript viewport ends at the composer top', (
tester,
) async {
_size(tester, const Size(560, 800));
@@ -74,30 +74,41 @@ void main() {
final pill = find.byKey(const Key('chat-composer-pill'));
expect(tester.widget(pill), isA<GlassPill>());
// The transcript fills the page: it runs under the composer.
final list = tester.getRect(find.byKey(const ValueKey('chat-thread-s')));
final composer = tester.getRect(pill);
expect(list.bottom, 800);
expect(composer.bottom, lessThanOrEqualTo(800));
expect(composer.top, greaterThan(list.top));
expect(list.bottom, greaterThanOrEqualTo(composer.bottom));
Rect list() =>
tester.getRect(find.byKey(const ValueKey('chat-thread-s')));
Rect composer() => tester.getRect(find.byKey(const Key('chat-composer')));
// Nothing renders behind the composer: the viewport stops at its top.
expect(list().bottom, composer().top);
expect(composer().bottom, lessThanOrEqualTo(800));
expect(tester.getRect(pill).top, greaterThanOrEqualTo(list().bottom));
// Following the end, the last message rests fully above the composer.
final last = tester.getRect(
find.text('Message number 29 of the transcript.'),
);
expect(last.bottom, lessThanOrEqualTo(composer.top));
final last = find.text('Message number 29 of the transcript.');
expect(tester.getRect(last).bottom, lessThanOrEqualTo(composer().top));
// Scrolling back up passes history behind the floating composer.
// A multi-line draft grows the composer; the viewport shrinks with it
// and the newest message stays in view above it.
final oneLine = composer().top;
await tester.enterText(
find.byKey(const Key('chat-composer-field')),
List.generate(6, (index) => 'Draft line $index').join('\n'),
);
await tester.pumpAndSettle();
expect(composer().top, lessThan(oneLine));
expect(list().bottom, composer().top);
expect(tester.getRect(last).bottom, lessThanOrEqualTo(composer().top));
// Scrolling back up moves history down inside the shortened viewport.
final rested = tester.getRect(last).top;
await tester.drag(
find.byKey(const ValueKey('chat-thread-s')),
const Offset(0, 120),
);
await tester.pumpAndSettle();
final behind = find.text('Message number 29 of the transcript.');
if (behind.evaluate().isNotEmpty) {
expect(tester.getRect(behind).top, greaterThan(last.top));
if (last.evaluate().isNotEmpty) {
expect(tester.getRect(last).top, greaterThan(rested));
}
expect(list().bottom, composer().top);
expect(tester.takeException(), isNull);
});