Skip to content

fix(desktop): populate last_message_at in channel browser#951

Merged
wpfleger96 merged 1 commit into
mainfrom
duncan/populate-last-message-at
Jun 10, 2026
Merged

fix(desktop): populate last_message_at in channel browser#951
wpfleger96 merged 1 commit into
mainfrom
duncan/populate-last-message-at

Conversation

@wpfleger96

Copy link
Copy Markdown
Collaborator

The "Browse Channels" pane shows "No activity" for every channel because get_channels never populated the last_message_at field on ChannelInfo. The rendering path (formatRelativeTime) already handles the field correctly — it just never had data.

Changes

Add a batched relay query after the existing member-count back-fill in get_channels (desktop/src-tauri/src/commands/channels.rs). For each browse-pane channel, sends a per-channel filter:

{"kinds": [9, 40002], "#h": ["<channel-id>"], "limit": 1}

All filters go in one /query POST — the relay loops per-filter, so each returns that channel's newest event with no cross-channel crowding. Per channel, takes MAX(created_at) and assigns to last_message_at.

Key decisions:

  • Per-channel single-#h filters — avoids the multi-value #h SQL-pushdown trap where a global limit truncates quieter channels.
  • Kinds [9, 40002] — includes KIND_STREAM_MESSAGE_V2 so v2-only channels don't show false "No activity". Excludes edits (40003), system messages (40099), and forum kinds (45001/45003).
  • No since bound — channels quiet for weeks show "Active 3w ago" rather than misleading "No activity".
  • No frontend changesformatRelativeTime(channel.lastMessageAt) already renders correctly on non-null values; the DTO bridge and TypeScript types already wire the field through.

Also bumps timestamp_to_iso in nostr_convert.rs to pub(crate) visibility (was private, already existed).

Files changed

  • desktop/src-tauri/src/commands/channels.rs — recency query + assignment
  • desktop/src-tauri/src/nostr_convert.rs — visibility bump on timestamp_to_iso

The browse-channels pane showed 'No activity' for every channel because
get_channels never back-filled last_message_at after constructing
ChannelInfo from metadata events (the relay doesn't emit the kind:40901
summary sidecar that channel_info_from_event would parse it from).

Add a batched relay query using per-channel filters — one filter per
channel with a single #h value and limit:1 — to fetch the most recent
kind:9 (stream message) or kind:40002 (v2 stream message) event per
channel. Per-channel filters ensure the relay can push the query to its
indexed channel_id column; multi-value #h would fall back to a global
scan and silently drop quieter channels under the limit cap.

No since bound on the recency query so channels quiet for weeks still
show 'Active 3w ago' rather than misleading 'No activity'.

Co-authored-by: Will Pfleger <wpfleger@squareup.com>
Signed-off-by: Will Pfleger <wpfleger@squareup.com>
@wpfleger96 wpfleger96 requested a review from a team as a code owner June 10, 2026 18:45
@wpfleger96 wpfleger96 enabled auto-merge (squash) June 10, 2026 19:01
@wpfleger96 wpfleger96 merged commit b792aa4 into main Jun 10, 2026
13 checks passed
@wpfleger96 wpfleger96 deleted the duncan/populate-last-message-at branch June 10, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants