Commit c885a7cc7c

c885a7cc7c393b7c6fc02024fba1e8c013a6ae1d

parent: 85830f9609

Unregistered key

Ulyssa <git@ulyssa.dev> · 2026-10-07 01:39 UTC
committer: <noreply@github.com>

Add "Muted" and "Calmed" labels for rooms with adjusted notification settings (#787)

Layout: unified · split

config.full.toml +1
@@ -36,6 +36,7 @@ reaction_display = true
3636reaction_shortcode_display = false
3737read_receipt_display = true
3838read_receipt_send = true
39room_labels = ["membership", "muted", "tags"]
3940request_timeout = 10000
4041sync_delay_ms = 1000
4142typing_notice_display = true
docs/iamb.1 +3 −1
@@ -242,7 +242,9 @@ Note that
242242.Dq mentions
243243and
244244.Dq keywords
245are aliases for the same behaviour.
245are aliases for the same behaviour, and the room will be labeled
246.Dq Calmed
247in room lists.
246248.It Sy ":room notify unset"
247249Unset any room-level notification configuration.
248250.It Sy ":room notify show"
docs/iamb.5 +21
@@ -284,6 +284,27 @@ A message must be sent to the room before marking it read.
284284Defines whether or not read confirmations are displayed.
285285.It Sy request_timeout
286286Defines the maximum time per request in seconds.
287.It Sy room_labels
288Defines which kinds of labels to put next to room names and what order to show the information in.
289This defaults to
290.Sy ["unread",\ "membership",\ "tags",\ "muted",\ "type"] .
291The possible values and the information shown are:
292.Bl -tag -width Ds
293.It Sy membership
294Show whether you're not currently a room member, such as when you're invited to a room.
295.It Sy muted
296Show
297.Dq Muted
298and
299.Dq Calmed
300if the room doesn't notify for all new messages.
301.It Sy tags
302Show if the room has been tagged, such as a Favorite or Low Priority room.
303.It Sy type
304Show if this is a regular room, a DM or a space when the current window shows multiple kinds.
305.It Sy unread
306Show if a non-muted, non-calmed room has unread messages or mentions.
307.El
287308.It Sy send_on_enter
288309If
289310.Sy true
src/base.rs +20
@@ -1290,6 +1290,21 @@ impl DisplayNameStore {
12901290 }
12911291}
12921292
1293bitflags::bitflags! {
1294 /// Additional information about a room.
1295 #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
1296 pub struct RoomInfoFlags: u32 {
1297 /// No flags specified.
1298 const NONE = 0b00000000;
1299
1300 /// All notifications for this room have been muted.
1301 const MUTED = 0b00000001;
1302
1303 /// Non-mention/keyword notifications for this room have been muted.
1304 const CALMED = 0b00000010;
1305 }
1306}
1307
12931308/// Information about room's the user's joined.
12941309pub struct RoomInfo {
12951310 /// The display name for this room.
@@ -1298,6 +1313,8 @@ pub struct RoomInfo {
12981313 /// The tags placed on this room.
12991314 pub tags: Option<Tags>,
13001315
1316 pub flags: RoomInfoFlags,
1317
13011318 /// A map of event IDs to where they are stored in this struct.
13021319 pub keys: HashMap<OwnedEventId, EventLocation>,
13031320 pub echo_keys: HashMap<OwnedTransactionId, EchoLocation>,
@@ -1360,6 +1377,7 @@ impl Default for RoomInfo {
13601377 name: Default::default(),
13611378 tags: Default::default(),
13621379 keys: Default::default(),
1380 flags: Default::default(),
13631381 echo_keys: Default::default(),
13641382 event_receipts: Default::default(),
13651383 user_receipts: Default::default(),
@@ -2560,6 +2578,7 @@ impl ChatStore {
25602578 name: String,
25612579 tags: Option<Tags>,
25622580 aliases: Vec<OwnedRoomAliasId>,
2581 flags: RoomInfoFlags,
25632582 ) {
25642583 for alias in aliases {
25652584 self.aliases.insert(alias, room_id.clone());
@@ -2567,6 +2586,7 @@ impl ChatStore {
25672586
25682587 let info = self.rooms.get_or_default(room_id);
25692588 info.name = name.into();
2589 info.flags = flags;
25702590 info.tags = tags;
25712591 }
25722592}
src/config/mod.rs +31
@@ -69,6 +69,14 @@ const DEFAULT_SPACE_SORT: [SortColumn<SortFieldSpace>; 3] = [
6969 SortColumn(SortFieldSpace::SpaceOrder, SortOrder::Ascending),
7070];
7171
72const DEFAULT_ROOM_LABELS: [RoomLabel; 5] = [
73 RoomLabel::Unread,
74 RoomLabel::Membership,
75 RoomLabel::Tags,
76 RoomLabel::Muted,
77 RoomLabel::Type,
78];
79
7280const DEFAULT_ENABLE_TITLE: bool = true;
7381const DEFAULT_REQ_TIMEOUT: u64 = 120;
7482const DEFAULT_SYNC_FREQUENCY: u64 = 250;
@@ -462,6 +470,18 @@ impl Visitor<'_> for EncryptionIndicatorLocationVisitor {
462470 }
463471}
464472
473/// Types of room labels to display in room lists.
474#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
475#[serde(rename_all = "kebab-case")]
476#[repr(u8)]
477pub enum RoomLabel {
478 Membership,
479 Muted,
480 Tags,
481 Type,
482 Unread,
483}
484
465485#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)]
466486#[serde(rename_all = "lowercase")]
467487pub enum UserDisplayStyle {
@@ -844,6 +864,7 @@ pub struct TunableValues {
844864 pub read_receipt_send: bool,
845865 pub read_receipt_trigger: ReadReceiptTrigger,
846866 pub read_receipt_display: bool,
867 pub room_labels: Vec<RoomLabel>,
847868 pub request_timeout: u64,
848869 pub sort: SortValues,
849870 pub state_event_display: bool,
@@ -904,6 +925,7 @@ pub struct Tunables {
904925 pub read_receipt_send: Option<bool>,
905926 pub read_receipt_trigger: Option<ReadReceiptTrigger>,
906927 pub read_receipt_display: Option<bool>,
928 pub room_labels: Option<Vec<RoomLabel>>,
907929 pub request_timeout: Option<u64>,
908930 pub state_event_display: Option<bool>,
909931 pub sync_delay_ms: Option<u64>,
@@ -961,6 +983,7 @@ impl Tunables {
961983 read_receipt_send: self.read_receipt_send.or(other.read_receipt_send),
962984 read_receipt_trigger: self.read_receipt_trigger.or(other.read_receipt_trigger),
963985 read_receipt_display: self.read_receipt_display.or(other.read_receipt_display),
986 room_labels: self.room_labels.or(other.room_labels),
964987 request_timeout: self.request_timeout.or(other.request_timeout),
965988 state_event_display: self.state_event_display.or(other.state_event_display),
966989 sync_delay_ms: self.sync_delay_ms.or(other.sync_delay_ms),
@@ -1009,6 +1032,7 @@ impl Tunables {
10091032 read_receipt_send: self.read_receipt_send.unwrap_or(true),
10101033 read_receipt_trigger: self.read_receipt_trigger.unwrap_or_default(),
10111034 read_receipt_display: self.read_receipt_display.unwrap_or(true),
1035 room_labels: self.room_labels.unwrap_or_else(|| DEFAULT_ROOM_LABELS.to_vec()),
10121036 request_timeout: self.request_timeout.unwrap_or(DEFAULT_REQ_TIMEOUT),
10131037 state_event_display: self.state_event_display.unwrap_or(true),
10141038 sync_delay_ms: self.sync_delay_ms.unwrap_or(DEFAULT_SYNC_FREQUENCY),
@@ -1996,6 +2020,13 @@ mod tests {
19962020 assert!(serde_json::from_str::<NotifyVia>(r#""""#).is_err());
19972021 }
19982022
2023 #[test]
2024 fn test_parse_room_labels() {
2025 assert_eq!(RoomLabel::Membership, serde_json::from_str(r#""membership""#).unwrap());
2026 assert_eq!(RoomLabel::Tags, serde_json::from_str(r#""tags""#).unwrap());
2027 assert_eq!(RoomLabel::Type, serde_json::from_str(r#""type""#).unwrap());
2028 }
2029
19992030 #[test]
20002031 fn test_parse_cursor_shape() {
20012032 assert_eq!(CursorShape::Auto, CursorShape::default());
src/prelude.rs +1
@@ -89,6 +89,7 @@ pub use crate::base::{
8989 RoomAction,
9090 RoomFocus,
9191 RoomInfo,
92 RoomInfoFlags,
9293 SendAction,
9394 SpaceAction,
9495 TimelineAction,
src/tests.rs +1
@@ -167,6 +167,7 @@ pub fn mock_tunables() -> TunableValues {
167167 read_receipt_send: true,
168168 read_receipt_trigger: Default::default(),
169169 read_receipt_display: true,
170 room_labels: Default::default(),
170171 request_timeout: 120,
171172 sort: SortOverrides::default().values(),
172173 state_event_display: true,
src/windows/mod.rs +67 −41
@@ -31,6 +31,7 @@ use crate::base::{
3131 SpaceInfo,
3232 UnreadInfo,
3333};
34use crate::config::RoomLabel;
3435use crate::config::theme::ThemeRoomsValues;
3536use crate::prelude::*;
3637use crate::resolve_mxid;
@@ -129,34 +130,6 @@ fn room_name_from_preview(preview: &RoomPreview) -> Cow<'_, str> {
129130 format!("Empty Room (was {name})").into()
130131}
131132
132fn name_and_labels<'a>(
133 name: &'a str,
134 unread: &UnreadInfo,
135 room_membership: MatrixRoomState,
136 name_style: Style,
137 tags_style: Style,
138) -> (Span<'a>, Vec<Vec<Span<'static>>>) {
139 let name = Span::styled(name, name_style);
140
141 let mut labels = vec![];
142
143 match room_membership {
144 MatrixRoomState::Joined => {},
145 MatrixRoomState::Left => labels.push(vec![Span::styled("Unjoined", tags_style)]),
146 MatrixRoomState::Banned => labels.push(vec![Span::styled("Banned", tags_style)]),
147 MatrixRoomState::Knocked => labels.push(vec![Span::styled("Knocked", tags_style)]),
148 MatrixRoomState::Invited => labels.push(vec![Span::styled("Invited", tags_style)]),
149 }
150
151 if unread.unread_mentions > 0 {
152 labels.push(vec![Span::styled("Unread Mention", tags_style)]);
153 } else if unread.is_unread() {
154 labels.push(vec![Span::styled("Unread", tags_style)]);
155 }
156
157 (name, labels)
158}
159
160133/// Sort `Some` to be less than `None` so that list items with values come before those without.
161134#[inline]
162135fn some_cmp<T, F>(a: Option<T>, b: Option<T>, f: F) -> Ordering
@@ -1390,6 +1363,7 @@ pub struct GenericRoomItem {
13901363 tags: Option<Tags>,
13911364 section: Option<ListSectionHeader>,
13921365 membership: MatrixRoomState,
1366 room_flags: RoomInfoFlags,
13931367 unread: UnreadInfo,
13941368 room_type_show: bool,
13951369 room_type: RoomType,
@@ -1407,6 +1381,7 @@ impl GenericRoomItem {
14071381 let name = info.name.clone().unwrap_or_default();
14081382 let alias = room.canonical_alias();
14091383 let mut unread = info.unreads(room);
1384 let room_flags = info.flags;
14101385 let tags = info.tags.clone();
14111386
14121387 if room.is_space() &&
@@ -1434,6 +1409,7 @@ impl GenericRoomItem {
14341409 tags,
14351410 unread,
14361411 membership: room.state(),
1412 room_flags,
14371413 room_type,
14381414 room_type_show: true,
14391415 section: None,
@@ -1459,6 +1435,7 @@ impl GenericRoomItem {
14591435 alias: preview.canonical_alias.clone(),
14601436 tags: None,
14611437 membership,
1438 room_flags: RoomInfoFlags::NONE,
14621439 unread: Default::default(),
14631440 room_type,
14641441 room_type_show: true,
@@ -1474,6 +1451,64 @@ impl GenericRoomItem {
14741451 fn set_section<T: SortedSection>(&mut self, fields: &[SortColumn<T>]) {
14751452 self.section = ListSectionHeader::for_room(self, fields);
14761453 }
1454
1455 /// Generate the list of labels to show for this room.
1456 fn name_and_labels<'a>(
1457 &'a self,
1458 name_style: Style,
1459 tags_style: Style,
1460 order: &[RoomLabel],
1461 ) -> (Span<'a>, Vec<Vec<Span<'a>>>) {
1462 let name = Span::styled(&self.name, name_style);
1463
1464 let mut labels = vec![];
1465
1466 for label in order {
1467 match label {
1468 RoomLabel::Membership => {
1469 let label = match self.membership {
1470 MatrixRoomState::Joined => None,
1471 MatrixRoomState::Left => Some("Unjoined"),
1472 MatrixRoomState::Banned => Some("Banned"),
1473 MatrixRoomState::Knocked => Some("Knocked"),
1474 MatrixRoomState::Invited => Some("Invited"),
1475 };
1476
1477 if let Some(label) = label {
1478 labels.push(vec![Span::styled(label, tags_style)]);
1479 }
1480 },
1481 RoomLabel::Unread => {
1482 if self.unread.unread_mentions > 0 {
1483 labels.push(vec![Span::styled("Unread Mention", tags_style)]);
1484 } else if self.unread.is_unread() {
1485 labels.push(vec![Span::styled("Unread", tags_style)]);
1486 }
1487 },
1488 RoomLabel::Muted => {
1489 if self.room_flags.contains(RoomInfoFlags::MUTED) {
1490 labels.push(vec![Span::styled("Muted", tags_style)]);
1491 } else if self.room_flags.contains(RoomInfoFlags::CALMED) {
1492 labels.push(vec![Span::styled("Calmed", tags_style)]);
1493 }
1494 },
1495 RoomLabel::Type => {
1496 if self.room_type_show &&
1497 let Some(label) = self.room_type.text()
1498 {
1499 labels.push(vec![Span::styled(label, tags_style)]);
1500 }
1501 },
1502 RoomLabel::Tags => {
1503 if let Some(tags) = &self.tags {
1504 labels.extend(tags.keys().map(|t| tag_to_span(t, tags_style)));
1505 }
1506 },
1507 }
1508 }
1509
1510 (name, labels)
1511 }
14771512}
14781513
14791514impl RoomLikeItem for GenericRoomItem {
@@ -1534,25 +1569,15 @@ impl ListItem<IambInfo> for GenericRoomItem {
15341569 store: &mut ProgramStore,
15351570 ) -> Text<'_> {
15361571 let theme = &store.application.settings.theme;
1572 let order = store.application.settings.tunables.room_labels.as_slice();
15371573
15381574 let (unreads, name_style, tags_style) = unreads_and_style(&self.unread, &theme.rooms);
15391575 let name_style = selected_style(selected, name_style);
1540 let tags_style = selected_style(selected, tags_style);
1576 let tags_style = if selected { name_style } else { tags_style };
15411577
1542 let (name, mut labels) =
1543 name_and_labels(&self.name, &self.unread, self.membership, name_style, tags_style);
1578 let (name, labels) = self.name_and_labels(name_style, tags_style, order);
15441579 let mut spans = vec![unreads, name];
15451580
1546 if let Some(label) = self.room_type.text() &&
1547 self.room_type_show
1548 {
1549 labels.push(vec![Span::styled(label, tags_style)]);
1550 }
1551
1552 if let Some(tags) = &self.tags {
1553 labels.extend(tags.keys().map(|t| tag_to_span(t, tags_style)));
1554 }
1555
15561581 append_tags(labels, &mut spans, tags_style);
15571582 Text::from(Line::from(spans))
15581583 }
@@ -1904,6 +1929,7 @@ mod tests {
19041929 tags: None,
19051930 membership: MatrixRoomState::Joined,
19061931 unread: UnreadInfo::default(),
1932 room_flags: RoomInfoFlags::NONE,
19071933 room_type_show: true,
19081934 room_type: RoomType::Room,
19091935 section: None,
src/worker.rs +12 −3
@@ -16,6 +16,7 @@ use matrix_sdk::deserialized_responses::RawSyncOrStrippedState;
1616use matrix_sdk::deserialized_responses::{TimelineEvent, TimelineEventKind};
1717use matrix_sdk::encryption::{BackupDownloadStrategy, EncryptionSettings};
1818use matrix_sdk::event_handler::Ctx;
19use matrix_sdk::notification_settings::RoomNotificationMode;
1920use matrix_sdk::room::RoomMember;
2021use matrix_sdk::ruma::OwnedRoomAliasId;
2122use matrix_sdk::ruma::api::client::filter::{
@@ -749,8 +750,16 @@ async fn refresh_rooms(client: &Client, store: &AsyncProgramStore, first_sync: b
749750 let mut aliases = room.alt_aliases();
750751 aliases.extend(room.canonical_alias());
751752
753 let mut flags = RoomInfoFlags::NONE;
754
755 match room.notification_mode().await {
756 Some(RoomNotificationMode::MentionsAndKeywordsOnly) => flags |= RoomInfoFlags::CALMED,
757 Some(RoomNotificationMode::Mute) => flags |= RoomInfoFlags::MUTED,
758 _ => (),
759 }
760
752761 pinned.push((room.room_id().to_owned(), room.pinned_event_ids().unwrap_or_default()));
753 names_and_tags.push((room.room_id().to_owned(), name, tags, aliases));
762 names_and_tags.push((room.room_id().to_owned(), name, tags, aliases, flags));
754763
755764 if room.is_direct().await.unwrap_or_default() {
756765 dms.push(room);
@@ -766,8 +775,8 @@ async fn refresh_rooms(client: &Client, store: &AsyncProgramStore, first_sync: b
766775 locked.application.sync_info.rooms = rooms;
767776 locked.application.sync_info.dms = dms;
768777
769 for (room_id, name, tags, aliases) in names_and_tags {
770 locked.application.set_room_info(room_id, name, tags, aliases);
778 for (room_id, name, tags, aliases, flags) in names_and_tags {
779 locked.application.set_room_info(room_id, name, tags, aliases, flags);
771780 }
772781
773782 for (room_id, pinned_events) in pinned {