codetether_agent/tui/app/watchdog/
detector.rs1use std::time::Duration;
4
5use crate::tui::app::state::AppState;
6use crate::tui::app::watchdog::state::WatchdogNotification;
7
8pub fn check_watchdog_stall(state: &AppState, timeout: Duration) -> Option<WatchdogNotification> {
10 if !state.processing {
11 return None;
12 }
13 let timed_out = state
14 .main_last_event_at
15 .map(|t| t.elapsed() >= timeout)
16 .unwrap_or(true);
17 if !timed_out {
18 return None;
19 }
20 let count = state.main_watchdog_restart_count;
21 Some(WatchdogNotification::new(
22 format!(
23 "⚠ No events for {}s. Stalled request detected.",
24 timeout.as_secs()
25 ),
26 count,
27 ))
28}