Commit 4ef69751bc

4ef69751bcd6b01f01f39edffa2b97bdcc9629e2

parent: c53d68494a

Unregistered key

Ulyssa <git@ulyssa.dev> · 2026-09-20 19:15 UTC
committer: <noreply@github.com>

Add `sync_delay_ms` option for preventing back-to-back syncs (#723)

Layout: unified · split

config.example.toml +1
@@ -22,6 +22,7 @@ reaction_shortcode_display = false
22read_receipt_display = true 22read_receipt_display = true
23read_receipt_send = true 23read_receipt_send = true
24request_timeout = 10000 24request_timeout = 10000
25sync_delay_ms = 1000
25typing_notice_display = true 26typing_notice_display = true
26typing_notice_send = true 27typing_notice_send = true
27user_gutter_width = 30 28user_gutter_width = 30
docs/iamb.5 +3
@@ -277,6 +277,9 @@ See
277for more details. 277for more details.
278.It Sy state_event_display 278.It Sy state_event_display
279Defines whether the state events like joined or left are shown. 279Defines whether the state events like joined or left are shown.
280.It Sy sync_delay_ms
281How long to wait after a sync completes before doing the next one.
282Defaults to 250 milliseconds.
280.It Sy terminal 283.It Sy terminal
281Subsection for configuring how specific terminal features are used (or not used). 284Subsection for configuring how specific terminal features are used (or not used).
282See 285See
src/config.rs +5
@@ -58,6 +58,7 @@ const DEFAULT_ROOM_SORT: [SortColumn<SortFieldRoom>; 5] = [
58 58
59const DEFAULT_ENABLE_TITLE: bool = true; 59const DEFAULT_ENABLE_TITLE: bool = true;
60const DEFAULT_REQ_TIMEOUT: u64 = 120; 60const DEFAULT_REQ_TIMEOUT: u64 = 120;
61const DEFAULT_SYNC_FREQUENCY: u64 = 250;
61 62
62const DEFAULT_ENC_INDICATOR_LOC: EncryptionIndicatorLocation = EncryptionIndicatorLocation::PROMPT; 63const DEFAULT_ENC_INDICATOR_LOC: EncryptionIndicatorLocation = EncryptionIndicatorLocation::PROMPT;
63const DEFAULT_ICON_ENC: Cow<'static, str> = Cow::Borrowed("[E] "); 64const DEFAULT_ICON_ENC: Cow<'static, str> = Cow::Borrowed("[E] ");
@@ -849,6 +850,7 @@ pub struct TunableValues {
849 pub request_timeout: u64, 850 pub request_timeout: u64,
850 pub sort: SortValues, 851 pub sort: SortValues,
851 pub state_event_display: bool, 852 pub state_event_display: bool,
853 pub sync_delay_ms: u64,
852 pub typing_notice_send: bool, 854 pub typing_notice_send: bool,
853 pub typing_notice_display: bool, 855 pub typing_notice_display: bool,
854 pub users: UserOverrides, 856 pub users: UserOverrides,
@@ -905,6 +907,7 @@ pub struct Tunables {
905 pub read_receipt_display: Option<bool>, 907 pub read_receipt_display: Option<bool>,
906 pub request_timeout: Option<u64>, 908 pub request_timeout: Option<u64>,
907 pub state_event_display: Option<bool>, 909 pub state_event_display: Option<bool>,
910 pub sync_delay_ms: Option<u64>,
908 pub typing_notice_send: Option<bool>, 911 pub typing_notice_send: Option<bool>,
909 pub typing_notice_display: Option<bool>, 912 pub typing_notice_display: Option<bool>,
910 pub username_display: Option<UserDisplayStyle>, 913 pub username_display: Option<UserDisplayStyle>,
@@ -957,6 +960,7 @@ impl Tunables {
957 read_receipt_display: self.read_receipt_display.or(other.read_receipt_display), 960 read_receipt_display: self.read_receipt_display.or(other.read_receipt_display),
958 request_timeout: self.request_timeout.or(other.request_timeout), 961 request_timeout: self.request_timeout.or(other.request_timeout),
959 state_event_display: self.state_event_display.or(other.state_event_display), 962 state_event_display: self.state_event_display.or(other.state_event_display),
963 sync_delay_ms: self.sync_delay_ms.or(other.sync_delay_ms),
960 typing_notice_send: self.typing_notice_send.or(other.typing_notice_send), 964 typing_notice_send: self.typing_notice_send.or(other.typing_notice_send),
961 typing_notice_display: self.typing_notice_display.or(other.typing_notice_display), 965 typing_notice_display: self.typing_notice_display.or(other.typing_notice_display),
962 username_display: self.username_display.or(other.username_display), 966 username_display: self.username_display.or(other.username_display),
@@ -1002,6 +1006,7 @@ impl Tunables {
1002 read_receipt_display: self.read_receipt_display.unwrap_or(true), 1006 read_receipt_display: self.read_receipt_display.unwrap_or(true),
1003 request_timeout: self.request_timeout.unwrap_or(DEFAULT_REQ_TIMEOUT), 1007 request_timeout: self.request_timeout.unwrap_or(DEFAULT_REQ_TIMEOUT),
1004 state_event_display: self.state_event_display.unwrap_or(true), 1008 state_event_display: self.state_event_display.unwrap_or(true),
1009 sync_delay_ms: self.sync_delay_ms.unwrap_or(DEFAULT_SYNC_FREQUENCY),
1005 typing_notice_send: self.typing_notice_send.unwrap_or(true), 1010 typing_notice_send: self.typing_notice_send.unwrap_or(true),
1006 typing_notice_display: self.typing_notice_display.unwrap_or(true), 1011 typing_notice_display: self.typing_notice_display.unwrap_or(true),
1007 username_display: self.username_display.unwrap_or_default(), 1012 username_display: self.username_display.unwrap_or_default(),
src/tests.rs +1
@@ -173,6 +173,7 @@ pub fn mock_tunables() -> TunableValues {
173 request_timeout: 120, 173 request_timeout: 120,
174 sort: SortOverrides::default().values(), 174 sort: SortOverrides::default().values(),
175 state_event_display: true, 175 state_event_display: true,
176 sync_delay_ms: 1000,
176 terminal: Terminal::default().values(), 177 terminal: Terminal::default().values(),
177 typing_notice_send: true, 178 typing_notice_send: true,
178 typing_notice_display: true, 179 typing_notice_display: true,
src/worker.rs +2 −1
@@ -1819,11 +1819,12 @@ impl ClientWorker {
1819 }, 1819 },
1820 } 1820 }
1821 1821
1822 let sync_delay = Duration::from_millis(self.settings.tunables.sync_delay_ms);
1822 self.sync_handle = tokio::spawn(async move { 1823 self.sync_handle = tokio::spawn(async move {
1823 loop { 1824 loop {
1824 let settings = SyncSettings::default(); 1825 let settings = SyncSettings::default();
1825
1826 let _ = client.sync(settings).await; 1826 let _ = client.sync(settings).await;
1827 tokio::time::sleep(sync_delay).await;
1827 } 1828 }
1828 }) 1829 })
1829 .into(); 1830 .into();