Commit 1c1b9f92c0

1c1b9f92c037087f044551ad0626ab7ee366ead2

parent: 1934ca1f41

Unregistered key

Ulyssa <git@ulyssa.dev> · 2026-08-16 00:19 UTC
committer: <noreply@github.com>

Support configuring when read marker updates are triggered (#641)

Layout: unified · split

docs/iamb.5 +19
@@ -229,6 +229,25 @@ Defines whether or not reactions should be shown.
229Defines whether or not reactions should be shown as their respective shortcode. 229Defines whether or not reactions should be shown as their respective shortcode.
230.It Sy read_receipt_send 230.It Sy read_receipt_send
231Defines whether or not public read confirmations are sent. 231Defines whether or not public read confirmations are sent.
232.It Sy read_receipt_trigger
233Defines under what conditions threads and rooms are marked read.
234Possible values are:
235.Bl -tag -width Ds
236.It Sy focused
237The room or thread must be focused and scrolled to the last message.
238This is the default value.
239.It Sy visible
240The room or thread must be on screen and scrolled to the last message.
241.It Sy scrollback
242Some portion of the scrollback for the room or thread must be on screen, but
243the room does not need to be scrolled to the last message.
244.It Sy message
245A message must be sent to the room before marking it read.
246.It Sy disabled
247Rooms and threads do not get their read markers updated, and the room
248will remain marked unread until manually cleared or another device updates
249the read marker.
250.El
232.It Sy read_receipt_display 251.It Sy read_receipt_display
233Defines whether or not read confirmations are displayed. 252Defines whether or not read confirmations are displayed.
234.It Sy request_timeout 253.It Sy request_timeout
src/base.rs +3 −4
@@ -93,13 +93,12 @@ use modalkit::{
93 prelude::{CommandType, WordStyle}, 93 prelude::{CommandType, WordStyle},
94}; 94};
95 95
96use crate::config::ImagePreviewProtocolValues;
97use crate::notifications::NotificationHandle;
98use crate::preview::{source_from_event, PreviewManager};
99use crate::{ 96use crate::{
97 config::{ApplicationSettings, ImagePreviewProtocolValues},
100 message::{Message, MessageEvent, MessageKey, MessageTimeStamp, Messages}, 98 message::{Message, MessageEvent, MessageKey, MessageTimeStamp, Messages},
99 notifications::NotificationHandle,
100 preview::{source_from_event, PreviewManager},
101 worker::Requester, 101 worker::Requester,
102 ApplicationSettings,
103}; 102};
104 103
105/// The set of characters used in different Matrix IDs. 104/// The set of characters used in different Matrix IDs.
src/config.rs +40
@@ -347,6 +347,42 @@ where
347 } 347 }
348} 348}
349 349
350#[derive(Copy, Clone, Debug, Default, Deserialize, Eq, PartialEq)]
351#[serde(rename_all = "kebab-case")]
352#[repr(u8)]
353pub enum ReadReceiptTrigger {
354 /// Update read receipts for a room when a window for it is focused, and it is scrolled to the
355 /// last message.
356 #[default]
357 Focused,
358 /// Update read receipts for a room when a window for it is visible, and it is scrolled to the
359 /// last message.
360 Visible,
361 /// Update read receipts for a room whenever some portion of its scrollback is rendered.
362 Scrollback,
363 /// Update read receipts for a room once the user sends a message to it.
364 Message,
365 /// Never update read receipts.
366 Disabled,
367}
368
369impl ReadReceiptTrigger {
370 /// Whether to update read receipts when a room is being rendered.
371 pub fn on_render(&self, last_visible: bool, room_focused: bool) -> bool {
372 match self {
373 Self::Disabled => false,
374 Self::Scrollback => true,
375 Self::Focused => last_visible && room_focused,
376 Self::Visible => last_visible,
377 Self::Message => false,
378 }
379 }
380
381 pub fn on_message(&self) -> bool {
382 matches!(self, Self::Message)
383 }
384}
385
350#[derive(Copy, Clone, Debug, Default, Deserialize, Eq, PartialEq)] 386#[derive(Copy, Clone, Debug, Default, Deserialize, Eq, PartialEq)]
351#[serde(rename_all = "kebab-case")] 387#[serde(rename_all = "kebab-case")]
352#[repr(u8)] 388#[repr(u8)]
@@ -763,6 +799,7 @@ pub struct TunableValues {
763 pub reaction_display: bool, 799 pub reaction_display: bool,
764 pub reaction_shortcode_display: bool, 800 pub reaction_shortcode_display: bool,
765 pub read_receipt_send: bool, 801 pub read_receipt_send: bool,
802 pub read_receipt_trigger: ReadReceiptTrigger,
766 pub read_receipt_display: bool, 803 pub read_receipt_display: bool,
767 pub request_timeout: u64, 804 pub request_timeout: u64,
768 pub sort: SortValues, 805 pub sort: SortValues,
@@ -812,6 +849,7 @@ pub struct Tunables {
812 pub reaction_display: Option<bool>, 849 pub reaction_display: Option<bool>,
813 pub reaction_shortcode_display: Option<bool>, 850 pub reaction_shortcode_display: Option<bool>,
814 pub read_receipt_send: Option<bool>, 851 pub read_receipt_send: Option<bool>,
852 pub read_receipt_trigger: Option<ReadReceiptTrigger>,
815 pub read_receipt_display: Option<bool>, 853 pub read_receipt_display: Option<bool>,
816 pub request_timeout: Option<u64>, 854 pub request_timeout: Option<u64>,
817 pub state_event_display: Option<bool>, 855 pub state_event_display: Option<bool>,
@@ -855,6 +893,7 @@ impl Tunables {
855 .reaction_shortcode_display 893 .reaction_shortcode_display
856 .or(other.reaction_shortcode_display), 894 .or(other.reaction_shortcode_display),
857 read_receipt_send: self.read_receipt_send.or(other.read_receipt_send), 895 read_receipt_send: self.read_receipt_send.or(other.read_receipt_send),
896 read_receipt_trigger: self.read_receipt_trigger.or(other.read_receipt_trigger),
858 read_receipt_display: self.read_receipt_display.or(other.read_receipt_display), 897 read_receipt_display: self.read_receipt_display.or(other.read_receipt_display),
859 request_timeout: self.request_timeout.or(other.request_timeout), 898 request_timeout: self.request_timeout.or(other.request_timeout),
860 state_event_display: self.state_event_display.or(other.state_event_display), 899 state_event_display: self.state_event_display.or(other.state_event_display),
@@ -892,6 +931,7 @@ impl Tunables {
892 reaction_display: self.reaction_display.unwrap_or(true), 931 reaction_display: self.reaction_display.unwrap_or(true),
893 reaction_shortcode_display: self.reaction_shortcode_display.unwrap_or(false), 932 reaction_shortcode_display: self.reaction_shortcode_display.unwrap_or(false),
894 read_receipt_send: self.read_receipt_send.unwrap_or(true), 933 read_receipt_send: self.read_receipt_send.unwrap_or(true),
934 read_receipt_trigger: self.read_receipt_trigger.unwrap_or_default(),
895 read_receipt_display: self.read_receipt_display.unwrap_or(true), 935 read_receipt_display: self.read_receipt_display.unwrap_or(true),
896 request_timeout: self.request_timeout.unwrap_or(DEFAULT_REQ_TIMEOUT), 936 request_timeout: self.request_timeout.unwrap_or(DEFAULT_REQ_TIMEOUT),
897 state_event_display: self.state_event_display.unwrap_or(true), 937 state_event_display: self.state_event_display.unwrap_or(true),
src/tests.rs +1
@@ -176,6 +176,7 @@ pub fn mock_tunables() -> TunableValues {
176 reaction_display: true, 176 reaction_display: true,
177 reaction_shortcode_display: false, 177 reaction_shortcode_display: false,
178 read_receipt_send: true, 178 read_receipt_send: true,
179 read_receipt_trigger: Default::default(),
179 read_receipt_display: true, 180 read_receipt_display: true,
180 request_timeout: 120, 181 request_timeout: 120,
181 sort: SortOverrides::default().values(), 182 sort: SortOverrides::default().values(),
src/windows/room/chat.rs +8
@@ -564,6 +564,8 @@ impl ChatState {
564 _: ProgramContext, 564 _: ProgramContext,
565 store: &mut ProgramStore, 565 store: &mut ProgramStore,
566 ) -> IambResult<EditInfo> { 566 ) -> IambResult<EditInfo> {
567 let settings = &store.application.settings;
568 let tunables = &settings.tunables;
567 let room = self.get_joined(&store.application.worker)?; 569 let room = self.get_joined(&store.application.worker)?;
568 let info = store.application.rooms.get_or_default(self.id().to_owned()); 570 let info = store.application.rooms.get_or_default(self.id().to_owned());
569 571
@@ -692,6 +694,12 @@ impl ChatState {
692 // Jump to the end of the scrollback to show the message. 694 // Jump to the end of the scrollback to show the message.
693 self.scrollback.goto_latest(); 695 self.scrollback.goto_latest();
694 696
697 if tunables.read_receipt_trigger.on_message() {
698 if let Some(thread) = self.scrollback.get_thread(info) {
699 info.fully_read(settings.profile.user_id.clone(), thread.1.clone());
700 }
701 }
702
695 Ok(None) 703 Ok(None)
696 } 704 }
697 705
src/windows/room/scrollback.rs +6 −2
@@ -1459,8 +1459,12 @@ impl StatefulWidget for Scrollback<'_> {
1459 } 1459 }
1460 } 1460 }
1461 1461
1462 if self.room_focused && state.cursor.timestamp.is_none() { 1462 // Check if we should update the user's read receipt for this room after this render:
1463 // If the cursor is at the last message, then update the read marker. 1463 if settings
1464 .tunables
1465 .read_receipt_trigger
1466 .on_render(state.cursor.timestamp.is_none(), self.room_focused)
1467 {
1464 info.fully_read(settings.profile.user_id.clone(), thread.1.clone()); 1468 info.fully_read(settings.profile.user_id.clone(), thread.1.clone());
1465 } 1469 }
1466 1470