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:
parent
d0080698f3
commit
81d3ce93fe
2 changed files with 7 additions and 7 deletions
|
|
@ -110,8 +110,6 @@ impl State {
|
||||||
pub fn load(&mut self) {
|
pub fn load(&mut self) {
|
||||||
if let Ok(data) = fs::read_to_string(state_path()) {
|
if let Ok(data) = fs::read_to_string(state_path()) {
|
||||||
if let Ok(p) = serde_json::from_str::<Persisted>(&data) {
|
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.sleep_until = p.sleep_until;
|
||||||
self.claude_pane = p.claude_pane;
|
self.claude_pane = p.claude_pane;
|
||||||
if p.idle_timeout > 0.0 {
|
if p.idle_timeout > 0.0 {
|
||||||
|
|
@ -120,9 +118,11 @@ impl State {
|
||||||
if p.notify_timeout > 0.0 {
|
if p.notify_timeout > 0.0 {
|
||||||
self.notify_timeout = p.notify_timeout;
|
self.notify_timeout = p.notify_timeout;
|
||||||
}
|
}
|
||||||
// Suppress immediate fire after restart — wait for fresh
|
// Reset activity timestamps to now — timers count from
|
||||||
// user/response signal before allowing the idle timer
|
// restart, not from stale pre-restart state
|
||||||
self.fired = true;
|
let t = now();
|
||||||
|
self.last_user_msg = t;
|
||||||
|
self.last_response = t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ fn daemon_cmd(args: &[&str]) {
|
||||||
.args(args)
|
.args(args)
|
||||||
.stdout(std::process::Stdio::null())
|
.stdout(std::process::Stdio::null())
|
||||||
.stderr(std::process::Stdio::null())
|
.stderr(std::process::Stdio::null())
|
||||||
.spawn()
|
.status()
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -134,7 +134,7 @@ fn main() {
|
||||||
Err(_) => return,
|
Err(_) => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
let hook_type = hook["type"].as_str().unwrap_or("unknown");
|
let hook_type = hook["hook_event_name"].as_str().unwrap_or("unknown");
|
||||||
let transcript = hook["transcript_path"]
|
let transcript = hook["transcript_path"]
|
||||||
.as_str()
|
.as_str()
|
||||||
.filter(|p| !p.is_empty())
|
.filter(|p| !p.is_empty())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue