Skip to content

Commit 172e5ba

Browse files
klopez4212Terp
andcommitted
fix(mobile): show thread typing for every agent DM
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Signed-off-by: kenny lopez <[email protected]>
1 parent 40d919f commit 172e5ba

2 files changed

Lines changed: 21 additions & 43 deletions

File tree

‎mobile/lib/features/channels/channel_detail_page.dart‎

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
2020

2121
import '../../shared/emoji/emoji_burst.dart';
2222
import '../../shared/me/me_sync.dart';
23-
import '../../shared/me/default_agent.dart';
2423
import '../../shared/me/me_search_placement.dart';
2524
import 'me/me_assistant_picker.dart';
2625
import 'me/me_chat_assistant.dart';
@@ -372,33 +371,6 @@ class _ResolvedChannelDetailPage extends HookConsumerWidget {
372371
.toSet()
373372
.length;
374373
final isOneToOneDm = resolvedChannel.isDm && participantCount == 2;
375-
// Bestie's direct conversation surfaces its work even when the reply
376-
// is threaded. Other ordinary channels keep thread activity in the thread.
377-
final defaultAgent = ref.watch(defaultAgentProvider);
378-
final defaultAgentKey = defaultAgent.isLoading || defaultAgent.hasError
379-
? null
380-
: defaultAgent.value;
381-
final showsDefaultAgentThreads =
382-
defaultAgentKey != null &&
383-
isActiveDirectConversation(
384-
resolvedChannel,
385-
null,
386-
currentPubkey,
387-
defaultAgentKey,
388-
);
389-
final typingEntries = ref
390-
.watch(
391-
visibleTypingProvider(
392-
channel.id,
393-
selfPubkey: currentPubkey,
394-
include: (e) =>
395-
personalChat ||
396-
e.threadHeadId == null ||
397-
(showsDefaultAgentThreads &&
398-
e.pubkey.toLowerCase() == defaultAgentKey.toLowerCase()),
399-
),
400-
)
401-
.entries;
402374
final memberProfilesPreload = useMemoized(
403375
() => _preloadMembers(
404376
ref,
@@ -470,6 +442,21 @@ class _ResolvedChannelDetailPage extends HookConsumerWidget {
470442
channelBotPubkeys:
471443
channelBotPubkeysState.asData?.value ?? const <String>{},
472444
);
445+
// Agent work is visible in every DM, even when its response is threaded.
446+
// Ordinary channels keep thread activity inside the thread view.
447+
final typingEntries = ref
448+
.watch(
449+
visibleTypingProvider(
450+
channel.id,
451+
selfPubkey: currentPubkey,
452+
include: (e) =>
453+
personalChat ||
454+
e.threadHeadId == null ||
455+
(resolvedChannel.isDm &&
456+
agentPubkeys.contains(e.pubkey.toLowerCase())),
457+
),
458+
)
459+
.entries;
473460
useEffect(() {
474461
if (sessionStatus != SessionStatus.connected ||
475462
identitySubscriptionPubkeys.isEmpty) {

‎mobile/test/features/channels/channel_detail_page_test.dart‎

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:buzz/shared/me/default_agent.dart';
21
import 'package:buzz/features/channels/compose_bar.dart';
32
import 'package:buzz/features/channels/send_message_provider.dart';
43
import 'package:buzz/features/channels/agent_reply_handoff.dart';
@@ -242,7 +241,6 @@ Widget _buildTestable({
242241
bool darkTheme = false,
243242
String? chatColor,
244243
bool personalChat = false,
245-
String? defaultAgent,
246244
required List<NostrEvent> messages,
247245
PresenceCacheNotifier? presenceCache,
248246
List<TypingEntry> typing = const [],
@@ -306,7 +304,6 @@ Widget _buildTestable({
306304
return ProviderScope(
307305
retry: providerRetry ?? (disableRetries ? (_, _) => null : null),
308306
overrides: [
309-
defaultAgentProvider.overrideWith((ref) => Stream.value(defaultAgent)),
310307
if (sender != null) sendMessageProvider.overrideWithValue(sender),
311308
if (soloSender != null) ...[
312309
meSendMessageProvider.overrideWithValue(soloSender),
@@ -11124,17 +11121,11 @@ void main() {
1112411121
});
1112511122

1112611123
for (final scenario in [
11127-
(personal: true, dm: false, agent: 'alice', group: false, visible: true),
11128-
(
11129-
personal: false,
11130-
dm: false,
11131-
agent: 'alice',
11132-
group: false,
11133-
visible: false,
11134-
),
11135-
(personal: false, dm: true, agent: 'alice', group: false, visible: true),
11136-
(personal: false, dm: true, agent: 'bob', group: false, visible: false),
11137-
(personal: false, dm: true, agent: 'alice', group: true, visible: false),
11124+
(personal: true, dm: false, agent: true, group: false, visible: true),
11125+
(personal: false, dm: false, agent: true, group: false, visible: false),
11126+
(personal: false, dm: true, agent: true, group: false, visible: true),
11127+
(personal: false, dm: true, agent: false, group: false, visible: false),
11128+
(personal: false, dm: true, agent: true, group: true, visible: true),
1113811129
]) {
1113911130
testWidgets('reply-scoped typing follows conversation scope: $scenario', (
1114011131
tester,
@@ -11143,7 +11134,7 @@ void main() {
1114311134
await tester.pumpWidget(
1114411135
_buildTestable(
1114511136
personalChat: scenario.personal,
11146-
defaultAgent: scenario.agent,
11137+
knownAgentPubkeys: scenario.agent ? {'alice'} : <String>{},
1114711138
channel: scenario.dm
1114811139
? Channel(
1114911140
id: _channelId,

0 commit comments

Comments
 (0)