From 43fb0be448f710c668761786ed487ba86dc9544c Mon Sep 17 00:00:00 2001 From: Jean-Paul van Ravensberg <14926452+DevSecNinja@users.noreply.github.com> Date: Sun, 15 Nov 2026 14:57:27 +0100 Subject: [PATCH 1/2] fix(reminders): keep calls whole across unclear checks and honor the shown interval - Extend the open call when no check saw it end, so checks that could not tell during a long overrun no longer split it and cut the reminder window short. - Schedule in-call lookups with the interval shown in Settings, so a hand-edited value such as 7 minutes runs every 10 as displayed. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- apps/noteiq-windows/src/ui.rs | 24 +++++++++++++-- crates/noteiq-core/src/meeting_reminder.rs | 8 +++-- .../tests/meeting_reminder_tests.rs | 29 +++++++++++++++---- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/apps/noteiq-windows/src/ui.rs b/apps/noteiq-windows/src/ui.rs index f688d9f..962a371 100644 --- a/apps/noteiq-windows/src/ui.rs +++ b/apps/noteiq-windows/src/ui.rs @@ -99,6 +99,14 @@ fn in_call_refresh_index(minutes: u32) -> i32 { }; i32::try_from(index).unwrap_or_default() } + +/// The interval actually used, which is always the choice shown in Settings. +fn effective_in_call_refresh_minutes(minutes: u32) -> u32 { + usize::try_from(in_call_refresh_index(minutes)) + .ok() + .and_then(|index| IN_CALL_REFRESH_CHOICES.get(index).copied()) + .unwrap_or(0) +} const NO_MEETING: &str = "No meeting"; fn no_meeting_row() -> MeetingRow { @@ -894,7 +902,8 @@ fn check_meeting_reminders( let defer = call.is_some_and(|in_call| in_call != Some(false)); state.reminders.blocked.store(defer, Ordering::Relaxed); let in_call = call.flatten() == Some(true); - let call_started = in_call && state.reminders.history.record_call(now); + let continuing = state.reminders.in_call; + let call_started = in_call && state.reminders.history.record_call(now, continuing); let call_ended = state.reminders.in_call && call == Some(Some(false)); let call_save_due = in_call && state @@ -968,7 +977,7 @@ fn refresh_meetings_during_call( } fn in_call_lookup_due(state: &AppState, now: DateTime) -> bool { - let minutes = state.settings.in_call_refresh_minutes; + let minutes = effective_in_call_refresh_minutes(state.settings.in_call_refresh_minutes); if minutes == 0 || !state.capture_open || meetings_in_progress(&state.meetings, now) == 0 { return false; } @@ -3063,7 +3072,7 @@ mod tests { state .reminders .history - .record_call(ended.start.unwrap() + TimeDelta::minutes(1)); + .record_call(ended.start.unwrap() + TimeDelta::minutes(1), false); state.reminders.last_lookup = Some(Instant::now()); let (notifier, jobs) = mpsc::channel(); state.reminders.notifier = Some(notifier); @@ -3204,6 +3213,15 @@ mod tests { assert!(in_call_lookup_due(&state, now)); state.settings.in_call_refresh_minutes = minutes + 5; assert!(!in_call_lookup_due(&state, now), "a longer interval waits"); + // A hand-edited 7 shows as "Every 10 minutes", and that is also what is used. + state.settings.in_call_refresh_minutes = 7; + let seven = Instant::now() + .checked_sub(Duration::from_secs(8 * 60)) + .unwrap(); + state.last_meeting_refresh = Some(seven); + assert_eq!(effective_in_call_refresh_minutes(7), 10); + assert!(!in_call_lookup_due(&state, now), "uses the shown interval"); + state.last_meeting_refresh = Some(stale); state.settings.in_call_refresh_minutes = 0; assert!(!in_call_lookup_due(&state, now), "Off never checks"); state.settings.in_call_refresh_minutes = minutes; diff --git a/crates/noteiq-core/src/meeting_reminder.rs b/crates/noteiq-core/src/meeting_reminder.rs index f3cbf71..bb188ef 100644 --- a/crates/noteiq-core/src/meeting_reminder.rs +++ b/crates/noteiq-core/src/meeting_reminder.rs @@ -346,11 +346,13 @@ impl ReminderHistory { } /// Records that the user is in a call at `now`, extending the latest call when the - /// previous check also saw one. Returns whether a new call started, which is worth saving. - pub fn record_call(&mut self, now: DateTime) -> bool { + /// previous check also saw one, or when `continuing` says no check saw the call end since, + /// so checks that could not tell do not split a call. Returns whether a new call started, + /// which is worth saving. + pub fn record_call(&mut self, now: DateTime, continuing: bool) -> bool { if let Some(last) = self.calls.last_mut() && now >= last.end - && now - last.end <= CALL_GAP + && (continuing || now - last.end <= CALL_GAP) { last.end = now; return false; diff --git a/crates/noteiq-core/tests/meeting_reminder_tests.rs b/crates/noteiq-core/tests/meeting_reminder_tests.rs index 47dc01b..25b35ca 100644 --- a/crates/noteiq-core/tests/meeting_reminder_tests.rs +++ b/crates/noteiq-core/tests/meeting_reminder_tests.rs @@ -31,7 +31,7 @@ fn looked_up(meetings: &[Meeting], minutes: i64) -> ReminderTracker { /// A history in which the user was in a call during `meeting()`. fn joined() -> ReminderHistory { let mut history = ReminderHistory::default(); - history.record_call(end() - TimeDelta::minutes(10)); + history.record_call(end() - TimeDelta::minutes(10), false); history } @@ -75,9 +75,9 @@ fn only_meetings_the_user_was_in_a_call_for_are_reminded() { }; // The call is seen before any calendar details, as when NoteIQ starts late in a meeting. let mut history = ReminderHistory::default(); - assert!(history.record_call(end() - TimeDelta::minutes(1))); + assert!(history.record_call(end() - TimeDelta::minutes(1), false)); assert!( - !history.record_call(end() - TimeDelta::seconds(30)), + !history.record_call(end() - TimeDelta::seconds(30), false), "the same call" ); let tracker = looked_up(&[meeting(), earlier.clone()], 6); @@ -106,7 +106,7 @@ fn a_call_that_runs_on_starts_the_reminder_window_when_it_ends() { let mut history = ReminderHistory::default(); let mut at = end() - TimeDelta::minutes(5); while at <= after_end(3 * 60) { - history.record_call(at); + history.record_call(at, false); at += TimeDelta::seconds(30); } let tracker = looked_up(&[meeting()], 3 * 60); @@ -121,6 +121,25 @@ fn a_call_that_runs_on_starts_the_reminder_window_when_it_ends() { ); } +#[test] +fn checks_that_could_not_tell_do_not_split_a_call_that_runs_on() { + let mut history = ReminderHistory::default(); + history.record_call(end() - TimeDelta::minutes(5), false); + // Checks that could not tell for 2.5 hours, then the same call is seen again. + assert!(!history.record_call(after_end(150), true)); + assert_eq!(history.calls.len(), 1); + let tracker = looked_up(&[meeting()], 151); + assert_eq!( + ids(tracker.due(after_end(151), DELAY, &history, &[])), + ["event-42"], + "the window counts from the end of the call, not from before the gap" + ); + + // Without a call in progress, a long gap starts a new call. + assert!(history.record_call(after_end(400), false)); + assert_eq!(history.calls.len(), 2); +} + #[test] fn skips_meetings_that_need_no_note() { let skipped = [ @@ -281,7 +300,7 @@ fn entries_saved_with_an_older_key_still_suppress_their_meeting() { let mut history = ReminderHistory::load(&path); assert!(history.contains(&meeting())); assert_eq!(history.meeting("ffffffffffffffff"), Some(&meeting())); - history.record_call(end() - TimeDelta::minutes(10)); + history.record_call(end() - TimeDelta::minutes(10), false); let tracker = looked_up(&[meeting()], 6); assert!(tracker.due(after_end(6), DELAY, &history, &[]).is_empty()); } From e8637daa1205c60f1ec7b7aa28d134015498c19a Mon Sep 17 00:00:00 2001 From: Jean-Paul van Ravensberg <14926452+DevSecNinja@users.noreply.github.com> Date: Sun, 15 Nov 2026 15:14:57 +0100 Subject: [PATCH 2/2] fix(reminders): forget the call in progress when reminders are turned off Re-enabling reminders during a later call could bridge the gap and count meetings in between as attended. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- apps/noteiq-windows/src/ui.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/apps/noteiq-windows/src/ui.rs b/apps/noteiq-windows/src/ui.rs index 962a371..d74f40b 100644 --- a/apps/noteiq-windows/src/ui.rs +++ b/apps/noteiq-windows/src/ui.rs @@ -578,6 +578,9 @@ fn bind_callbacks( let mut state = state.borrow_mut(); state.settings.meeting_reminders_enabled = enabled; state.reminders.enabled.store(enabled, Ordering::Relaxed); + if !enabled { + state.reminders.in_call = false; + } persist_settings(&mut state); refresh_view(&ui, &state); }); @@ -887,6 +890,8 @@ fn check_meeting_reminders( .enabled .store(state.settings.meeting_reminders_enabled, Ordering::Relaxed); if !state.settings.meeting_reminders_enabled { + // Calls are not followed while reminders are off, so the next call seen is new. + state.reminders.in_call = false; return; } let delay = reminder_delay(state.settings.meeting_reminder_delay_minutes); @@ -3134,6 +3139,27 @@ mod tests { ); } + #[test] + fn calls_seen_before_and_after_reminders_were_off_are_separate() { + let now = Local::now().fixed_offset(); + let (_window, mut state) = window_with(Vec::new(), now); + state.reminders.call_probe = Some(|| Some(true)); + let (sender, _events) = mpsc::channel(); + + check_meeting_reminders(&mut state, &sender, now); + state.settings.meeting_reminders_enabled = false; + check_meeting_reminders(&mut state, &sender, now + TimeDelta::minutes(1)); + assert!(!state.reminders.in_call); + + state.settings.meeting_reminders_enabled = true; + check_meeting_reminders(&mut state, &sender, now + TimeDelta::hours(2)); + assert_eq!( + state.reminders.history.calls.len(), + 2, + "the gap while reminders were off is not bridged" + ); + } + #[test] fn a_call_in_progress_is_saved_every_few_minutes() { let folder = tempfile::tempdir().unwrap();