Match mobile mention chips to desktop styling (#9706)

Mobile mentions now use the desktop chip treatment: neutral rounded
pills for other identities, the chat accent for mentions of the viewer,
and a contrasting inset fill inside outgoing messages. This applies to
message bodies and compact previews, while preserving profile taps and
resolving self-highlights by public key.

The change reuses the existing chat palette and keeps it stable across
parent rebuilds, so unchanged messages retain their parsed Markdown.
Mention routing and composer behavior are unchanged.

Validation: `just mobile-check mobile-test` passed (5,118 Flutter tests,
71 skipped, plus 27 crypto-package tests). Coverage includes light/dark
themes, 2× text, profile taps, live identity switching, outgoing
contrast, and Markdown reuse; removing self-highlighting makes the
regression fail. A signed iOS build was installed and checked on a
physical device, then approved for PR preparation.

### Snapshots

Actual Flutter component renders with synthetic identities and the
bundled app font. Each shows received/own messages, compact previews,
and enlarged text.

| Light | Dark |
| --- | --- |
| ![Light mention
chips](https://github.com/user-attachments/assets/54cd45ae-0196-4244-837c-2858e1768f11)
| ![Dark mention
chips](https://github.com/user-attachments/assets/b72be61f-c919-4a9d-8941-9d417e1309ba)
|

buzz-review-completed

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
This commit is contained in:
klopez4212
2026-11-19 18:31:32 +00:00
committed by GitHub
parent 98e2b7cbbc
commit 1ac0b1dad1
6 changed files with 172 additions and 24 deletions

View File

@@ -1,8 +1,10 @@
import 'message_reply_drag_target.dart';
import 'package:buzz/shared/widgets/feedback_snackbar.dart';
import 'dart:async';
import 'dart:convert';
import '../../shared/widgets/ios_media_carousel.dart';
import '../../shared/widgets/message_attachment_corners.dart';
@@ -232,7 +234,13 @@ class MessageContent extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final markdownTheme = GptMarkdownTheme.of(context);
final chatColors = ChatColors.of(context);
final resolvedChatColors = ChatColors.of(context);
// The fallback palette is newly allocated; keep the nested theme stable so
// unchanged messages do not reparse their Markdown on parent rebuilds.
final chatColors = useMemoized(() => resolvedChatColors, [
resolvedChatColors.outgoing,
resolvedChatColors.foreground,
]);
final ownTextColor = chatColors.foreground;
// Own-bubble links share the bubble ink; markdown marks them by underline.
final linkColor = ownMessage ? ownTextColor : context.colors.tertiary;
@@ -396,6 +404,7 @@ class MessageContent extends HookConsumerWidget {
}, [markdownContent, mentionPresentationKey]);
final inlinePatterns = _useMessageInlinePatterns(
ownBubble: bubble && ownMessage,
content: content,
finalContent: finalContent,
mentionNames: resolvedMentionNames,
@@ -554,6 +563,10 @@ class MessageContent extends HookConsumerWidget {
),
child: Theme(
data: Theme.of(context).copyWith(
extensions: [
...Theme.of(context).extensions.values,
chatColors,
],
colorScheme: context.colors.copyWith(
primary: linkColor,
),

View File

@@ -1,6 +1,7 @@
part of '../message_content.dart';
List<InlinePattern> _useMessageInlinePatterns({
required bool ownBubble,
required String content,
required String finalContent,
required Map<String, String> mentionNames,
@@ -51,6 +52,7 @@ List<InlinePattern> _useMessageInlinePatterns({
return useMemoized(
() => [
_MentionMd(
ownBubble: ownBubble,
mentionNames: inputs.mentionNames,
mentionLabels: inputs.mentionLabels,
bindings: inputs.bindings,
@@ -71,7 +73,7 @@ List<InlinePattern> _useMessageInlinePatterns({
onChannelTap: channelTap,
).pattern,
],
[inputs],
[inputs, ownBubble],
);
}

View File

@@ -1,6 +1,7 @@
part of '../message_content.dart';
class _MentionMd {
final bool ownBubble;
final Map<String, Set<String>> bindings;
final Map<String, String> displayLabels;
final Map<String, String> mentionNames;
@@ -15,6 +16,7 @@ class _MentionMd {
_MentionMd({
required this.bindings,
required this.ownBubble,
required this.displayLabels,
required this.mentionNames,
required this.mentionLabels,
@@ -58,6 +60,8 @@ class _MentionMd {
);
final pill = MessageMentionPill(
label: visibleLabel,
pubkey: pubkey,
ownBubble: ownBubble,
semanticsLabel: fullLabel,
isAgent: isAgent,
textStyle: style,

View File

@@ -91,6 +91,7 @@ class MessagePreview extends HookConsumerWidget {
baseline: TextBaseline.alphabetic,
child: MessageMentionPill(
label: label,
pubkey: pubkey,
semanticsLabel: semanticsLabel,
isAgent: agents.contains(pubkey),
textStyle: style,

View File

@@ -1,10 +1,13 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../../shared/relay/relay_provider.dart';
import '../../shared/widgets/buzz_agent_icon.dart';
import '../../shared/theme/theme.dart';
/// The inline identity label shared by chat mentions and channel actions.
class MessageMentionPill extends StatelessWidget {
class MessageMentionPill extends ConsumerWidget {
/// Visible contextual identity name.
final String label;
@@ -14,6 +17,12 @@ class MessageMentionPill extends StatelessWidget {
/// Whether to use the desktop robot icon instead of the @ prefix.
final bool isAgent;
/// Resolved identity; unresolved names never receive the self highlight.
final String? pubkey;
/// Whether the chip sits inside the viewer’s colored message bubble.
final bool ownBubble;
/// Typography inherited from the surrounding message.
final TextStyle? textStyle;
@@ -24,38 +33,60 @@ class MessageMentionPill extends StatelessWidget {
this.semanticsLabel,
required this.isAgent,
this.textStyle,
this.pubkey,
this.ownBubble = false,
});
@override
Widget build(BuildContext context) {
Widget build(BuildContext context, WidgetRef ref) {
final viewer = pubkey == null ? null : ref.watch(myPubkeyProvider);
final isSelf =
viewer != null && pubkey?.toLowerCase() == viewer.toLowerCase();
final chat = ChatColors.of(context);
final ink = ownBubble || isSelf
? chat.foreground
: context.colors.onSurface;
final fill = ownBubble
? chatCodeTint(chat.foreground, 0.18)
: isSelf
? chat.outgoing
: (context.colors.brightness == Brightness.dark
? Colors.white.withValues(alpha: 0.16)
: Colors.black.withValues(alpha: 0.10));
final style =
(textStyle ?? context.textTheme.bodyMedium)?.copyWith(
color: context.colors.primary,
color: ink,
fontWeight: FontWeight.w500,
height: 1,
) ??
TextStyle(
color: context.colors.primary,
fontWeight: FontWeight.w500,
height: 1,
);
TextStyle(color: ink, fontWeight: FontWeight.w500, height: 1);
final fontSize = style.fontSize ?? 16;
return Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if (isAgent)
BuzzAgentIcon(size: fontSize, color: context.colors.primary)
else
Transform.translate(
offset: const Offset(0, -Grid.quarter),
child: Text('@', style: style),
return Container(
padding: const EdgeInsets.symmetric(
horizontal: Grid.quarter * 1.5,
vertical: Grid.quarter,
),
decoration: BoxDecoration(
color: fill,
borderRadius: BorderRadius.circular(Radii.full),
),
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if (isAgent)
BuzzAgentIcon(size: fontSize, color: ink)
else
Transform.translate(
offset: const Offset(0, -Grid.quarter),
child: Text('@', style: style),
),
Flexible(
child: Text(label, style: style, semanticsLabel: semanticsLabel),
),
Flexible(
child: Text(label, style: style, semanticsLabel: semanticsLabel),
),
],
],
),
);
}
}

View File

@@ -0,0 +1,97 @@
import 'package:buzz/features/channels/message_content.dart';
import 'package:buzz/features/channels/message_mention_pill.dart';
import 'package:buzz/shared/relay/relay.dart';
import 'package:buzz/shared/theme/theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
void main() {
testWidgets(
'mentions follow identity, bubble, and appearance while staying tappable',
(tester) async {
final container = ProviderContainer(
overrides: [myPubkeyProvider.overrideWithValue('alice')],
);
addTearDown(container.dispose);
String? tapped;
const names = {'alice': 'Alice', 'bob': 'Bob'};
for (final brightness in Brightness.values) {
for (final own in [false, true]) {
final theme = mobileAppearanceTheme(brightness, '#c0a2f1');
final chat = theme.extension<ChatColors>()!;
await tester.pumpWidget(
UncontrolledProviderScope(
container: container,
child: MaterialApp(
theme: theme,
home: Scaffold(
body: MediaQuery(
data: const MediaQueryData(
size: Size(800, 600),
textScaler: TextScaler.linear(2),
),
child: AppMarkdownTheme(
child: SizedBox(
width: 320,
child: MessageContent(
content: 'Hello @Alice and @Bob',
mentionNames: names,
bubble: true,
ownMessage: own,
onMentionTap: (key) => tapped = key,
),
),
),
),
),
),
),
);
await tester.pumpAndSettle();
Color fill(String label) {
final pill = find.ancestor(
of: find.text(label),
matching: find.byType(MessageMentionPill),
);
final box = tester.widget<Container>(
find.descendant(of: pill, matching: find.byType(Container)).first,
);
return (box.decoration! as BoxDecoration).color!;
}
expect(
fill('Alice'),
own ? chatCodeTint(chat.foreground, .18) : chat.outgoing,
);
expect(
fill('Bob'),
own
? chatCodeTint(chat.foreground, .18)
: (brightness == Brightness.dark
? Colors.white.withValues(alpha: .16)
: Colors.black.withValues(alpha: .10)),
);
tapped = null;
await tester.tap(find.text('Bob'));
expect(tapped, 'bob');
expect(tester.takeException(), isNull);
// Switching identity updates already-parsed spans, without new content.
container.updateOverrides([
myPubkeyProvider.overrideWithValue('bob'),
]);
await tester.pump();
if (!own) {
expect(fill('Bob'), chat.outgoing);
expect(fill('Alice'), isNot(chat.outgoing));
}
container.updateOverrides([
myPubkeyProvider.overrideWithValue('alice'),
]);
await tester.pump();
}
}
},
);
}