feat(#2569): matrix producer — sweep_unread pushes per-room todos instead of direct wakes

This commit is contained in:
damocles 2026-07-19 01:40:32 +02:00 committed by mara
commit 711e0ece2a
4 changed files with 125 additions and 71 deletions

View file

@ -901,6 +901,21 @@ pub fn unread_count(client: &Client) -> DaemonResponse {
/// mind if latency becomes a concern.
#[must_use]
pub async fn collect_unread(client: &Client) -> Vec<crate::protocol::RoomUnread> {
collect_unread_with_ids(client)
.await
.into_iter()
.map(|(_, ru)| ru)
.collect()
}
/// Like [`collect_unread`] but pairs each entry with its `OwnedRoomId`.
/// The todo producer (loose-ends v2, #2569) needs the room id as the
/// per-room upsert/dedup key, which the claude-facing `RoomUnread`
/// payload intentionally doesn't carry.
#[must_use]
pub async fn collect_unread_with_ids(
client: &Client,
) -> Vec<(matrix_sdk::ruma::OwnedRoomId, crate::protocol::RoomUnread)> {
use crate::protocol::RoomUnread;
let mut result = Vec::new();
for room in client.joined_rooms() {
@ -915,12 +930,15 @@ pub async fn collect_unread(client: &Client) -> Vec<crate::protocol::RoomUnread>
} else {
(None, None)
};
result.push(RoomUnread {
label,
count,
last_body,
last_sender,
});
result.push((
room.room_id().to_owned(),
RoomUnread {
label,
count,
last_body,
last_sender,
},
));
}
result
}