Files
buzz/mobile/test/features/channels/reply_summary_link_test.dart
klopez4212 3f03aa0450 fix(mobile): restore ordinary DM behavior for Bestie (#8987)
Mobile Bestie used a special flat timeline that hid reply threads. It
now opens the normal DM screen, matching desktop’s pinned Bestie
(block/buzz-app#1935), with existing threads, reply actions, and
top-level sending in the same conversation.

Thread-scoped agent typing in DMs stays beneath its originating message.
Working avatars and mobile’s bouncing dots share a compact neutral
container, matching desktop’s subtle activity control. The elbow is
visible from the start, with the working container already at the final
thread-footer position. For a single-agent reply, the same avatar stays
mounted while the container and dots fade out over 200 ms, the avatar
slides into its summary position, and the reply count fades/scales in
from 95%. The elbow stays fixed. Reduced motion switches immediately.
The avatar-to-dots gap is 4 points. Reply text uses its natural line
height so its glyphs center on the avatar and elbow rather than drawing
at the top of the footer. Multi-participant summaries retain their
grouped layout. The accessible View thread action, reaction placement,
and final reply-footer position are preserved.

Validation:
- The final commit (`c6fef5d80`) passed full analysis, 4,220 Flutter
tests (40 skipped), 4 push-configuration tests, and 27 crypto tests.
- Container alignment checks pass in both directions, including avatar
continuity, intermediate fade and final geometry, reduced motion, and
thread actions. Glyph-box alignment is checked against the avatar
center. An additional regression covers a reply arriving before typing
stops and work restarting mid-transition.
- Updated DM journeys cover opening Bestie, existing threads, threaded
and top-level sending, swipe-to-reply, and absence of duplicate main-row
thread typing.
- Installed the final product source (`c6fef5d80`) in place on Pixel 10
and iPhone Air previews. The iPhone uses a release-mode preview so it
launches from the home screen; saved Kenny Lopez / Starry Night
conversation verified after install. Pixel retains Testing Agent
Sessions. The pending/midpoint/completed handoff was rendered in widget
checks, and the corrected reply-label alignment was verified on the
Pixel against the same messages before and after; human acceptance of
this final animation remains pending.
- Mandatory push hooks passed, including file-size and branch checks. A
rendered widget preview verifies the container and elbow; live
acceptance remains pending.

Self-review found no blockers in the changed paths. Review status is
preserved.

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-11-03 18:16:14 +00:00

191 lines
7.5 KiB
Dart

import 'package:buzz/features/channels/reply_summary_link.dart';
import 'package:buzz/features/channels/small_avatar.dart';
import 'package:buzz/features/channels/timeline_message.dart';
import 'package:buzz/shared/profile/user_cache_provider.dart';
import 'package:buzz/shared/profile/user_profile.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import '../../helpers/widget_helpers.dart';
void main() {
for (final mirrored in [false, true]) {
for (final reducedMotion in [false, true]) {
testWidgets(
'thread footer morphs working content while keeping the thread elbow fixed: mirrored=$mirrored reduced=$reducedMotion',
(tester) async {
final complete = ValueNotifier(false);
addTearDown(complete.dispose);
var opened = 0;
await tester.pumpWidget(
WidgetHelpers.testable(
disableAnimations: reducedMotion,
overrides: [userCacheProvider.overrideWith(_Profiles.new)],
child: SizedBox(
key: const ValueKey('lane'),
width: 400,
child: Align(
alignment: mirrored ? Alignment.topRight : Alignment.topLeft,
child: ValueListenableBuilder(
valueListenable: complete,
builder: (context, done, _) => ReplySummaryLink(
mirrored: mirrored,
summary: done
? const ThreadSummary(
threadHeadId: 'root',
replyCount: 1,
participantPubkeys: ['agent'],
)
: null,
working: done ? const [] : const ['agent'],
workingNames: done ? const [] : const ['Agent'],
onTap: () => opened++,
),
),
),
),
),
);
await tester.pump();
final lane = tester.getRect(find.byKey(const ValueKey('lane')));
expect(
tester.getCenter(find.byType(SmallAvatar)).dy,
closeTo(tester.getCenter(find.byType(ReplySummaryLink)).dy, 0.1),
);
final pending = mirrored
? tester
.getRect(
find.byKey(const ValueKey('thread-working-container')),
)
.right
: tester
.getRect(
find.byKey(const ValueKey('thread-working-container')),
)
.left;
expect(
pending,
closeTo(mirrored ? lane.right - 32 : lane.left + 32, 0.1),
);
expect(
find.bySemanticsLabel('View thread: Agent is working'),
findsOneWidget,
);
await tester.tap(find.byType(ReplySummaryLink));
expect(opened, 1);
final avatarElement = tester.element(find.byType(SmallAvatar));
final avatarBefore = tester.getTopLeft(find.byType(SmallAvatar)).dx;
complete.value = true;
await tester.pump();
double endPosition() => mirrored
? tester.getRect(find.text('1 reply')).right
: tester.getRect(find.byType(SmallAvatar)).left;
final start = endPosition();
expect(tester.element(find.byType(SmallAvatar)), same(avatarElement));
if (!reducedMotion) {
expect(
tester.getTopLeft(find.byType(SmallAvatar)).dx,
closeTo(avatarBefore, 0.1),
);
}
await tester.pump(const Duration(milliseconds: 100));
final middle = tester.getTopLeft(find.byType(SmallAvatar)).dx;
final background =
tester
.widget<DecoratedBox>(
find.byKey(const ValueKey('thread-working-container')),
)
.decoration
as BoxDecoration;
expect(background.color!.a, reducedMotion ? 0 : closeTo(0.5, 0.1));
await tester.pump(const Duration(milliseconds: 150));
final end = endPosition();
final paragraph = tester.renderObject<RenderParagraph>(
find.text('1 reply'),
);
final glyphBox = paragraph
.getBoxesForSelection(
const TextSelection(baseOffset: 0, extentOffset: 7),
)
.first
.toRect();
expect(
paragraph.localToGlobal(glyphBox.center).dy,
closeTo(tester.getCenter(find.byType(SmallAvatar)).dy, 1),
);
expect(
end,
closeTo(mirrored ? lane.right - 32 : lane.left + 32, 0.1),
);
if (reducedMotion) {
expect(start, closeTo(end, 0.1));
} else {
expect(
(tester.getTopLeft(find.byType(SmallAvatar)).dx - middle).abs(),
greaterThan(0.1),
);
}
expect(tester.element(find.byType(SmallAvatar)), same(avatarElement));
expect(
find.byKey(const ValueKey('thread-working-dots')),
findsNothing,
);
expect(find.bySemanticsLabel('View thread: 1 reply'), findsOneWidget);
await tester.tap(find.byType(ReplySummaryLink));
expect(opened, 2);
expect(tester.takeException(), isNull);
},
);
}
}
testWidgets(
'reply arriving before typing ends keeps its count and can resume work',
(tester) async {
Widget view({required bool working, required bool replied}) =>
WidgetHelpers.testable(
overrides: [userCacheProvider.overrideWith(_Profiles.new)],
child: Align(
alignment: Alignment.topRight,
child: ReplySummaryLink(
mirrored: true,
summary: replied
? const ThreadSummary(
threadHeadId: 'root',
replyCount: 1,
participantPubkeys: ['agent'],
)
: null,
working: working ? const ['agent'] : const [],
onTap: () {},
),
),
);
await tester.pumpWidget(view(working: true, replied: false));
final avatar = tester.element(find.byType(SmallAvatar));
await tester.pumpWidget(view(working: true, replied: true));
expect(find.text('1 reply'), findsOneWidget);
expect(find.byKey(const ValueKey('thread-working-dots')), findsOneWidget);
await tester.pumpWidget(view(working: false, replied: true));
await tester.pump(const Duration(milliseconds: 100));
await tester.pumpWidget(view(working: true, replied: true));
await tester.pump(const Duration(milliseconds: 250));
expect(tester.element(find.byType(SmallAvatar)), same(avatar));
expect(find.text('1 reply'), findsOneWidget);
expect(find.byKey(const ValueKey('thread-working-dots')), findsOneWidget);
await tester.pumpWidget(view(working: false, replied: true));
await tester.pump(const Duration(milliseconds: 250));
expect(find.byKey(const ValueKey('thread-working-dots')), findsNothing);
expect(tester.takeException(), isNull);
},
);
}
class _Profiles extends UserCacheNotifier {
@override
Map<String, UserProfile> build() => const {
'agent': UserProfile(pubkey: 'agent', displayName: 'Agent'),
};
}