mirror of
https://github.com/block/buzz.git
synced 2026-11-13 12:51:34 +00:00
fix(mobile): show the owner's agent name in the Solo chat header
The existing-chat header and pending-change label preferred the agent's self-published profile name over the owner's 30177 inventory name. Prefer the directory name and keep the profile for the avatar. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tom Brow <tomb@block.xyz>
This commit is contained in:
@@ -89,16 +89,17 @@ useMeChatAssistant(
|
||||
? ref.watch(userCacheProvider)[selected] ??
|
||||
ref.read(userCacheProvider.notifier).get(selected)
|
||||
: null;
|
||||
// The owner's inventory name outranks the agent's self-published profile.
|
||||
final name =
|
||||
profile?.displayName ??
|
||||
agents
|
||||
.where((agent) => agent.pubkey == selected)
|
||||
.firstOrNull
|
||||
?.displayName;
|
||||
?.displayName ??
|
||||
profile?.displayName;
|
||||
String agentName(String pubkey) {
|
||||
final names = [
|
||||
ref.read(userCacheProvider)[pubkey]?.displayName,
|
||||
agents.where((a) => a.pubkey == pubkey).firstOrNull?.displayName,
|
||||
ref.read(userCacheProvider)[pubkey]?.displayName,
|
||||
];
|
||||
return names
|
||||
.whereType<String>()
|
||||
|
||||
@@ -22,8 +22,9 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
class _Profiles extends UserCacheNotifier {
|
||||
@override
|
||||
Map<String, UserProfile> build() => {
|
||||
'a': const UserProfile(pubkey: 'a', displayName: 'Alpha'),
|
||||
'b': const UserProfile(pubkey: 'b', displayName: 'Beta'),
|
||||
// Self-published names differ so tests prove the owner's name wins.
|
||||
'a': const UserProfile(pubkey: 'a', displayName: 'Confusable Alpha'),
|
||||
'b': const UserProfile(pubkey: 'b', displayName: 'Confusable Beta'),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ import 'package:flutter/services.dart';
|
||||
import 'package:nostr/nostr.dart' as nostr;
|
||||
import 'package:buzz/shared/relay/relay.dart';
|
||||
import 'package:buzz/shared/me/me_assistants.dart';
|
||||
import 'package:buzz/shared/mentions/agent_identity_provider.dart';
|
||||
import 'package:buzz/shared/profile/user_cache_provider.dart';
|
||||
import 'package:buzz/shared/profile/user_profile.dart';
|
||||
import 'package:buzz/shared/theme/buzz_icons.dart';
|
||||
import 'package:buzz/shared/widgets/frosted_app_bar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -328,8 +331,11 @@ void main() {
|
||||
channelsProvider.overrideWith(FakeChannels.new),
|
||||
meAssistantsProvider.overrideWith((ref) async {
|
||||
directoryLoads++;
|
||||
return [];
|
||||
return const [
|
||||
AgentDirectoryEntry(pubkey: 'agent', displayName: 'Owner Name'),
|
||||
];
|
||||
}),
|
||||
userCacheProvider.overrideWith(_ConfusableProfiles.new),
|
||||
],
|
||||
child: MaterialApp(theme: AppTheme.light(), home: const MePage()),
|
||||
),
|
||||
@@ -347,7 +353,14 @@ void main() {
|
||||
final args = calls.single.arguments as Map;
|
||||
expect(args['title'], 'New chat');
|
||||
expect(args['placeholder'], 'Chat name');
|
||||
expect(args['assistants'], isEmpty);
|
||||
expect(args['assistants'], [
|
||||
{
|
||||
'id': 'agent',
|
||||
'name': 'Owner Name',
|
||||
'artworkScale': '1',
|
||||
'avatarUrl': '',
|
||||
},
|
||||
]);
|
||||
expect(args['projects'], [
|
||||
{'id': 'mobile', 'name': 'Mobile app'},
|
||||
]);
|
||||
@@ -471,3 +484,10 @@ void main() {
|
||||
expect(find.text('A place to work with your agents'), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
class _ConfusableProfiles extends UserCacheNotifier {
|
||||
@override
|
||||
Map<String, UserProfile> build() => {
|
||||
'agent': const UserProfile(pubkey: 'agent', displayName: 'Confusable Name'),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user