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.
229229Defines whether or not reactions should be shown as their respective shortcode.
230230.It Sy read_receipt_send
231231Defines 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
232251.It Sy read_receipt_display
233252Defines whether or not read confirmations are displayed.
234253.It Sy request_timeout
src/base.rs +3 −4
@@ -93,13 +93,12 @@ use modalkit::{
9393 prelude::{CommandType, WordStyle},
9494};
9595
96use crate::config::ImagePreviewProtocolValues;
97use crate::notifications::NotificationHandle;
98use crate::preview::{source_from_event, PreviewManager};
9996use crate::{
97 config::{ApplicationSettings, ImagePreviewProtocolValues},
10098 message::{Message, MessageEvent, MessageKey, MessageTimeStamp, Messages},
99 notifications::NotificationHandle,
100 preview::{source_from_event, PreviewManager},
101101 worker::Requester,
102 ApplicationSettings,
103102};
104103
105104/// The set of characters used in different Matrix IDs.
src/config.rs +40
@@ -347,6 +347,42 @@ where
347347 }
348348}
349349
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
350386#[derive(Copy, Clone, Debug, Default, Deserialize, Eq, PartialEq)]
351387#[serde(rename_all = "kebab-case")]
352388#[repr(u8)]
@@ -763,6 +799,7 @@ pub struct TunableValues {
763799 pub reaction_display: bool,
764800 pub reaction_shortcode_display: bool,
765801 pub read_receipt_send: bool,
802 pub read_receipt_trigger: ReadReceiptTrigger,
766803 pub read_receipt_display: bool,
767804 pub request_timeout: u64,
768805 pub sort: SortValues,
@@ -812,6 +849,7 @@ pub struct Tunables {
812849 pub reaction_display: Option<bool>,
813850 pub reaction_shortcode_display: Option<bool>,
814851 pub read_receipt_send: Option<bool>,
852 pub read_receipt_trigger: Option<ReadReceiptTrigger>,
815853 pub read_receipt_display: Option<bool>,
816854 pub request_timeout: Option<u64>,
817855 pub state_event_display: Option<bool>,
@@ -855,6 +893,7 @@ impl Tunables {
855893 .reaction_shortcode_display
856894 .or(other.reaction_shortcode_display),
857895 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),
858897 read_receipt_display: self.read_receipt_display.or(other.read_receipt_display),
859898 request_timeout: self.request_timeout.or(other.request_timeout),
860899 state_event_display: self.state_event_display.or(other.state_event_display),
@@ -892,6 +931,7 @@ impl Tunables {
892931 reaction_display: self.reaction_display.unwrap_or(true),
893932 reaction_shortcode_display: self.reaction_shortcode_display.unwrap_or(false),
894933 read_receipt_send: self.read_receipt_send.unwrap_or(true),
934 read_receipt_trigger: self.read_receipt_trigger.unwrap_or_default(),
895935 read_receipt_display: self.read_receipt_display.unwrap_or(true),
896936 request_timeout: self.request_timeout.unwrap_or(DEFAULT_REQ_TIMEOUT),
897937 state_event_display: self.state_event_display.unwrap_or(true),
src/tests.rs +1
@@ -176,6 +176,7 @@ pub fn mock_tunables() -> TunableValues {
176176 reaction_display: true,
177177 reaction_shortcode_display: false,
178178 read_receipt_send: true,
179 read_receipt_trigger: Default::default(),
179180 read_receipt_display: true,
180181 request_timeout: 120,
181182 sort: SortOverrides::default().values(),
src/windows/room/chat.rs +8
@@ -564,6 +564,8 @@ impl ChatState {
564564 _: ProgramContext,
565565 store: &mut ProgramStore,
566566 ) -> IambResult<EditInfo> {
567 let settings = &store.application.settings;
568 let tunables = &settings.tunables;
567569 let room = self.get_joined(&store.application.worker)?;
568570 let info = store.application.rooms.get_or_default(self.id().to_owned());
569571
@@ -692,6 +694,12 @@ impl ChatState {
692694 // Jump to the end of the scrollback to show the message.
693695 self.scrollback.goto_latest();
694696
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
695703 Ok(None)
696704 }
697705
src/windows/room/scrollback.rs +6 −2
@@ -1459,8 +1459,12 @@ impl StatefulWidget for Scrollback<'_> {
14591459 }
14601460 }
14611461
1462 if self.room_focused && state.cursor.timestamp.is_none() {
1463 // If the cursor is at the last message, then update the read marker.
1462 // Check if we should update the user's read receipt for this room after this render:
1463 if settings
1464 .tunables
1465 .read_receipt_trigger
1466 .on_render(state.cursor.timestamp.is_none(), self.room_focused)
1467 {
14641468 info.fully_read(settings.profile.user_id.clone(), thread.1.clone());
14651469 }
14661470