🐛 use PID liveness for stale, not file age #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "worktree-fix-stale-pid-liveness"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
stalebecause Claude Code only updates~/.claude/sessions/<pid>.jsonon state transitions — a long tool call easily goes >60s between writes, tripping the oldSTALE_AFTER_SECS = 60threshold. The officialclaude agentsdoesn't have this problem because it probes the PID; this PR matches that.classifynow useskill(pid, 0)(via apid_alivehelper injected as a closure so tests stay deterministic).donestill wins for completed jobs; a dead PID isstaleregardless of status; otherwise the raw status maps towork/idle/ newwait.Status::Waitingsurfaces Claude Code's"status":"waiting"value (permission-prompt pause), styled cyan; previously it silently mapped toidle.Test plan
cargo test— 20 pass, including new cases (dead_pid_classified_stale_even_if_status_busy,waiting_status_maps_to_waiting,done_overrides_dead_pid).~/.claude/sessions/— the "agent tui dashboard" agent that triggered the bug now classifies aswork; the onlystaleentries are sessions whose PID is actually gone.ui.rstests pass but I didn't drive a real terminal in this session).