Skip to content

Commit 8771fda

Browse files
committed
fix(attach): a live ask arriving late in a rung wait still rings (TM-933)
1 parent a12274e commit 8771fda

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎crates/tmgr-runner/src/attach/signal.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ struct Wait {
117117
since_ms: u64,
118118
kind: NeedKind,
119119
open: usize,
120+
ask: bool,
120121
}
121122

122123
impl SignalTracker {
@@ -156,7 +157,9 @@ impl SignalTracker {
156157
let due = match self.seen.get(&row.id).filter(|w| w.since_ms == since) {
157158
None => true,
158159
Some(w) => {
159-
need.kind > w.kind || (need.kind == NeedKind::Question && open > w.open)
160+
need.kind > w.kind
161+
|| (need.kind == NeedKind::Question && open > w.open)
162+
|| (ask.is_some() && !w.ask)
160163
}
161164
};
162165
if due && need.kind == NeedKind::Question {
@@ -178,6 +181,7 @@ impl SignalTracker {
178181
since_ms: since,
179182
kind,
180183
open,
184+
ask: ask.is_some(),
181185
},
182186
);
183187
current.insert(row.id.clone(), need);

‎crates/tmgr-runner/src/attach/tests.rs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9824,9 +9824,26 @@ mod pocket_signals {
98249824
);
98259825
assert_eq!(rings(&mut t, &v), 1);
98269826
v.status.clear();
9827+
v.sessions[1].state.since_ms = 3;
98279828
assert_eq!(rings(&mut t, &v), 0);
98289829
}
98299830

9831+
#[test]
9832+
fn a_live_ask_arriving_late_in_a_rung_wait_rings() {
9833+
let mut t = SignalTracker::new();
9834+
t.update(&view(0, 1), &SignalSettings::default());
9835+
let mut v = view(2, 2);
9836+
assert_eq!(rings(&mut t, &v), 1);
9837+
v.status.insert(
9838+
"b".into(),
9839+
SessionStatus {
9840+
ask: Some("Which?".into()),
9841+
..Default::default()
9842+
},
9843+
);
9844+
assert_eq!(rings(&mut t, &v), 1);
9845+
}
9846+
98309847
#[test]
98319848
fn questions_seen_in_quiet_hours_or_a_watched_pane_count_as_told() {
98329849
let mut t = SignalTracker::new();

0 commit comments

Comments
 (0)