fix(daemon): spawn Deacon immediately after killing stuck session (#729)

When checkDeaconHeartbeat detects a stuck Deacon and kills it, the code
relied on ensureDeaconRunning being called on the next heartbeat. However,
on the next heartbeat, checkDeaconHeartbeat exits early when it finds no
session (assuming ensureDeaconRunning already ran), creating a deadlock
where the Deacon is never restarted.

This fix calls ensureDeaconRunning immediately after the kill attempt,
regardless of success or failure, ensuring the Deacon is restarted
promptly.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: mayor
Role: mayor
This commit is contained in:
aleiby
2026-01-21 19:31:38 -08:00
committed by GitHub
parent aba0a5069c
commit 0cdcd0a20b

View File

@@ -436,7 +436,9 @@ func (d *Daemon) checkDeaconHeartbeat() {
if err := d.tmux.KillSessionWithProcesses(sessionName); err != nil {
d.logger.Printf("Error killing stuck Deacon: %v", err)
}
// ensureDeaconRunning will restart on next heartbeat
// Spawn new Deacon immediately instead of waiting for next heartbeat
// (kill may fail if session disappeared between check and kill)
d.ensureDeaconRunning()
} else {
// Stuck but not critically - nudge to wake up
d.logger.Printf("Deacon stuck for %s - nudging session", age.Round(time.Minute))