Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions mobile/lib/features/channels/me/me_chat_assistant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,25 +106,25 @@ useMeChatAssistant(
}
}
// The owner's inventory name outranks the agent's self-published profile.
final names = watchMeAssistantNames(
ref,
agents,
saved: [selected, pending?.agent],
);
// Only Solo reads these names; other chats must not watch every profile.
final names = enabled
? watchMeAssistantNames(ref, agents, saved: [selected, pending?.agent])
: null;
// A known agent outside the inventory, such as an archived one, is labeled
// against the live agents so it never reads as a live namesake.
bool named(String pubkey) =>
agents.any((agent) => agent.pubkey == pubkey) ||
ref.read(userCacheProvider)[pubkey]?.displayName?.trim().isNotEmpty ==
true;
names != null &&
(agents.any((agent) => agent.pubkey == pubkey) ||
ref.read(userCacheProvider)[pubkey]?.displayName?.trim().isNotEmpty ==
true);
final name = selected != null && named(selected)
? names.labelFor(selected)
? names!.labelFor(selected)
: profile?.displayName;
final avatarInitial = name?.trim().isNotEmpty == true
? name!.trim()[0].toUpperCase()
: profile?.initial ?? '?';
String agentName(String pubkey) {
if (named(pubkey)) return names.labelFor(pubkey);
if (named(pubkey)) return names!.labelFor(pubkey);
return pubkey.length > 12
? '${pubkey.substring(0, 8)}…${pubkey.substring(pubkey.length - 4)}'
: pubkey;
Expand Down
18 changes: 18 additions & 0 deletions mobile/test/features/channels/channel_detail_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5033,8 +5033,10 @@ void main() {
_testChannel,
otherChannel,
]);
final profiles = _FakeUserCacheNotifier({});
await tester.pumpWidget(
_buildTestable(
userCacheNotifier: profiles,
messages: [
for (var i = 0; i < 5; i++)
_textMsg(
Expand Down Expand Up @@ -5062,6 +5064,22 @@ void main() {
await tester.pumpAndSettle();

expect(rebuilt.whereType<MessageContent>(), isEmpty);

// A profile learned in another surface must not rebuild this ordinary
// channel: the Solo naming hook is disabled here.
rebuilt.clear();
profiles.replace(
UserProfile(pubkey: 'f' * 64, displayName: 'Unrelated profile'),
);
await tester.pumpAndSettle();
expect(
rebuilt.where(
(widget) =>
widget.runtimeType.toString() == '_ResolvedChannelDetailPage',
),
isEmpty,
reason: 'an unrelated profile must not rebuild the open channel page',
);
});

testWidgets('clears the composer inset when membership is revoked', (
Expand Down
Loading