forge
Explore
Log in

Don't you dare go Hollow

iz-core: reminder countdown uses due time, not mint time

Browse files at this commit

7d488cd431cab798c658f8c3a197a5b6258f781cAhmet Kaan GümüşParent: 4a255c5
A meeting hours or days out was warning "in 2471 minutes" because remaining
was frozen when the clock was set. Count from when the mail falls due.
crates/iz-core/src/store/turso_store.rsmodified+6 -1
@@ -771,7 +771,12 @@ impl TursoStore {
771771 // The mail falls due this many minutes before the clock; a meeting
772772 // already inside the window warns the moment the write commits.
773773 let due = (clock_at - Duration::minutes(i64::from(reminder_minutes))).max(now);
774- let minutes_left = (clock_at - now).whole_minutes();
774+ // Remaining is what the reader has when the mail is due, not when
775+ // the row is minted. A meeting two days out with a fifteen-minute
776+ // lead must say "in 15 minutes", not the two days that sat on the
777+ // queue. A meeting already inside the window is due now, so this
778+ // is the minutes actually left.
779+ let minutes_left = (clock_at - due).whole_minutes().max(0);
775780
776781 let mut rows = tx
777782 .query(
crates/iz-core/tests/store.rsmodified+10 -10
@@ -7112,17 +7112,12 @@ async fn a_clocked_task_owes_each_assignee_one_reminder_before_the_meeting() {
71127112 let body = row.body.as_deref().unwrap();
71137113 assert!(body.contains("The quarterly review"), "body was: {body}");
71147114 assert!(body.contains("Meets at"), "body was: {body}");
7115- // The countdown is whole minutes at mint time, and a few ticks pass
7116- // between picking the clock and creating the task.
7117- let minutes: u32 = body
7118- .split("in ")
7119- .nth(1)
7120- .and_then(|rest| rest.split(' ').next())
7121- .and_then(|n| n.parse().ok())
7122- .unwrap_or(0);
7115+ // Remaining is counted from when the mail falls due, not from mint:
7116+ // a meeting two hours out with a fifteen-minute lead warns of fifteen
7117+ // minutes, which is what the reader has when the mail actually lands.
71237118 assert!(
7124- (117..=120).contains(&minutes),
7125- "the countdown names the meeting two hours out: {body}"
7119+ body.contains("in 15 minutes"),
7120+ "the countdown names the lead, not the mint distance: {body}"
71267121 );
71277122 }
71287123 assert_eq!(rows[0].recipient, "emre@iz.sh");
@@ -7160,6 +7155,11 @@ async fn the_reminder_falls_due_at_the_workspaces_own_lead() {
71607155 clock - Duration::minutes(60),
71617156 "an hour before the meeting, not the default quarter"
71627157 );
7158+ let body = rows[0].body.as_deref().unwrap();
7159+ assert!(
7160+ body.contains("in 60 minutes"),
7161+ "the countdown follows the lead, not how far mint sat from the clock: {body}"
7162+ );
71637163 let _ = std::fs::remove_dir_all(&dir);
71647164 }
71657165