fix idle timer restart and hook event detection

Two fixes:

1. Reset activity timestamps to now() on daemon restart instead of
   loading stale values and suppressing with fired=true. Timers
   count cleanly from restart.

2. Fix poc-hook to read hook_event_name (not type) from Claude Code's
   JSON input. The hook was being called but never matched any event.
   Also switch daemon_cmd from spawn() to status() since the command
   takes 2ms — no reason to fire-and-forget.

Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
This commit is contained in:
ProofOfConcept 2026-03-05 21:43:04 -05:00
parent d0080698f3
commit 81d3ce93fe
2 changed files with 7 additions and 7 deletions

View file

@ -110,8 +110,6 @@ impl State {
pub fn load(&mut self) {
if let Ok(data) = fs::read_to_string(state_path()) {
if let Ok(p) = serde_json::from_str::<Persisted>(&data) {
self.last_user_msg = p.last_user_msg;
self.last_response = p.last_response;
self.sleep_until = p.sleep_until;
self.claude_pane = p.claude_pane;
if p.idle_timeout > 0.0 {
@ -120,9 +118,11 @@ impl State {
if p.notify_timeout > 0.0 {
self.notify_timeout = p.notify_timeout;
}
// Suppress immediate fire after restart — wait for fresh
// user/response signal before allowing the idle timer
self.fired = true;
// Reset activity timestamps to now — timers count from
// restart, not from stale pre-restart state
let t = now();
self.last_user_msg = t;
self.last_response = t;
}
}