Files
buzz/mobile/lib/features/activity/activity_page/lists.dart
Logan Johnson 7a1910e700 feat(mobile): show contextual names in lists, Search and Pulse (#7896)
🤖
## Summary

This PR finishes the change on the remaining mobile screens. After it,
every place that names a person or agent uses a contextual name:

- The channel list, DM labels, and the new-DM picker
- The channel header and details, and the members and add-members sheets
- Huddle avatars, spotlight, and overlay
- The Activity inbox
- Search results for people and messages
- Pulse notes, agent cards, and reply previews

Screens that belong to a channel compare names against its members.
Search, Pulse, and the new-DM picker have no channel, so they compare
the identities shown together. In the example below, Search showed four
results all named "murderbot". Now the human keeps the plain name, and
baxen's three agents are labeled by owner and key suffix.

Part 3 of 3: #7894 (resolver) → #7895 (conversations) → #7896 (lists,
Search, Pulse).

### Related issue

Related to #2910. The desktop search change in #6483 addresses the same
problem in a different app.

### Testing

- Widget tests cover the Activity inbox, Search, and Pulse notes with
colliding names.
- `flutter analyze` is clean, and the full `flutter test` suite passes.
- Checked on an Android emulator against the live relay by searching for
"murderbot". The after image also shows "classy-murderbot", a new
account that was created between the two captures.

| Before | After |
| --- | --- |
| <img width="300" alt="Before: Search shows four people all named
murderbot"
src="https://github.com/user-attachments/assets/21bbcc52-fea8-4b31-ab8c-ff3ec9b32a39"
/> | <img width="300" alt="After: three results show as baxen's
murderbot with a key suffix, and the human shows as murderbot"
src="https://github.com/user-attachments/assets/d59584d9-4a35-46da-b39a-83addfad3cd2"
/> |

---------

Signed-off-by: Logan Johnson <loganj@squareup.com>
Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
2026-09-30 10:46:14 -04:00

180 lines
5.5 KiB
Dart

part of '../activity_page.dart';
/// Reminders surface for the Reminders filter — due/pending NIP-ER
/// reminders that deep-link to their target message.
class _RemindersList extends ConsumerWidget {
final ScrollController scrollController;
final void Function(Reminder reminder) onOpen;
final Future<void> Function() onRefresh;
const _RemindersList({
required this.scrollController,
required this.onOpen,
required this.onRefresh,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
final remindersAsync = ref.watch(remindersProvider);
final reminders = [
for (final r in remindersAsync.value ?? const <Reminder>[])
if (r.status == 'pending') r,
];
if (remindersAsync.isLoading && reminders.isEmpty) {
return const Center(
child: BuzzLoadingIndicator(
size: 44,
semanticLabel: 'Loading reminders',
),
);
}
if (reminders.isEmpty) {
return const _EmptySurface(
icon: LucideIcons.clock,
message: 'No reminders',
detail: 'Reminders you set will show up here.',
);
}
final now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
return BeeRefreshIndicator(
onRefresh: onRefresh,
child: ListView.builder(
controller: scrollController,
padding: _activityScrollPadding(context),
itemCount: reminders.length,
itemBuilder: (context, index) {
final reminder = reminders[index];
final due = reminder.isDue(now);
final title = reminder.note?.trim().isNotEmpty == true
? reminder.note!.trim()
: reminder.target?.preview ?? 'Reminder';
return ListTile(
key: ValueKey('reminder-row-${reminder.id}'),
leading: Icon(
due ? LucideIcons.bellRing : LucideIcons.clock,
size: 20,
color: due
? context.colors.primary
: context.colors.onSurfaceVariant,
),
title: Text(title, maxLines: 2, overflow: TextOverflow.ellipsis),
subtitle: reminder.notBefore != null
? Text(
due
? 'Due now'
: 'Due ${_inboxTimestamp(reminder.notBefore!)}',
)
: null,
onTap: () => onOpen(reminder),
);
},
),
);
}
}
/// Drafts surface for the Drafts filter — locally saved unsent composer
/// text that reopens the target composer.
class _DraftsList extends ConsumerWidget {
final List<ComposeDraft> drafts;
final ScrollController scrollController;
final Map<String, Channel> channelById;
final String? myPubkey;
final void Function(ComposeDraft draft) onOpen;
final void Function(ComposeDraft draft) onDelete;
const _DraftsList({
required this.drafts,
required this.scrollController,
required this.channelById,
required this.myPubkey,
required this.onOpen,
required this.onDelete,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
final names = ref.watch(identityNameSourcesProvider);
if (drafts.isEmpty) {
return const _EmptySurface(
icon: LucideIcons.filePen,
message: 'No drafts',
detail: 'Unsent messages you start composing will show up here.',
);
}
return ListView.builder(
controller: scrollController,
padding: _activityScrollPadding(context),
itemCount: drafts.length,
itemBuilder: (context, index) {
final draft = drafts[index];
final channel = channelById[draft.channelId];
final destination = channel == null
? 'Unavailable channel'
: channel.isDm
? resolveDmChannelDisplayLabel(
channel,
currentPubkey: myPubkey,
names: names,
)
: '#${channel.name}';
return ListTile(
key: ValueKey('draft-row-${draft.key}'),
leading: Icon(
LucideIcons.filePen,
size: 20,
color: context.colors.onSurfaceVariant,
),
title: Text(draft.text, maxLines: 2, overflow: TextOverflow.ellipsis),
subtitle: Text(
draft.threadHeadId != null ? 'Thread in $destination' : destination,
),
trailing: IconButton(
icon: const Icon(LucideIcons.trash2, size: 18),
tooltip: 'Delete draft',
onPressed: () => onDelete(draft),
),
onTap: () => onOpen(draft),
);
},
);
}
}
/// Inbox list timestamp — desktop's `formatInboxTimestamp`:
/// time today, "Yesterday", short date this year, dated otherwise.
String _inboxTimestamp(int unixSeconds, {DateTime? now}) {
final current = now ?? DateTime.now();
final date = DateTime.fromMillisecondsSinceEpoch(unixSeconds * 1000);
final today = DateTime(current.year, current.month, current.day);
final day = DateTime(date.year, date.month, date.day);
final dayDiff = today.difference(day).inDays;
if (dayDiff == 0) {
final hour = date.hour % 12 == 0 ? 12 : date.hour % 12;
final minute = date.minute.toString().padLeft(2, '0');
return '$hour:$minute ${date.hour < 12 ? 'AM' : 'PM'}';
}
if (dayDiff == 1) return 'Yesterday';
const months = [
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec',
];
final label = '${months[date.month - 1]} ${date.day}';
return date.year == current.year ? label : '$label, ${date.year}';
}