use super::*;
pub(super) fn format_duration(secs: f32) -> String {
let secs = secs.round() as u32;
if secs < 60 { format!("{secs}s") } else { format!("{}m {:02}s", secs / 60, secs % 60) }
}
pub(super) fn notify_done(st: &mut State, done: Done, threshold: f32) {
if threshold <= 0.0 || done.secs < threshold || st.window_focused {
return;
}
let took = format_duration(done.secs);
let what: String = done.what.chars().take(60).collect();
st.notice = Some(if what == "Claude" {
format!("✓ Claude is ready · worked {took}")
} else {
format!("✓ {what} · finished in {took}")
});
st.window.request_user_attention(Some(UserAttentionType::Informational));
st.window.request_redraw();
}
pub(super) fn notify_focus(st: &State, prev: PaneId) {
if prev == st.focused {
return;
}
for p in st.panes.iter().filter(|p| p.id == prev || p.id == st.focused) {
let focused_now = p.id == st.focused && st.window_focused;
let mut term = p.term.lock();
term.is_focused = focused_now;
let report = term.mode().contains(TermMode::FOCUS_IN_OUT);
drop(term);
if report {
p.write(if focused_now { b"\x1b[I".to_vec() } else { b"\x1b[O".to_vec() });
}
}
}