fix: check restart/shutdown before cycle in lifecycle parser

The parseLifecycleRequest function was checking for "cycle" first,
but since the title already contains "lifecycle:" (which includes
"cycle"), all lifecycle messages matched as cycle actions, making
restart and shutdown unreachable.

Fixed by:
1. Checking restart/shutdown before cycle
2. Using " cycle" (with leading space) to match the word, not prefix

Closes gt-rixa

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-21 14:08:49 -08:00
parent 91a0f3b80f
commit 36d6fc28f3
4 changed files with 146 additions and 78 deletions

View File

@@ -82,12 +82,15 @@ func (d *Daemon) parseLifecycleRequest(msg *BeadsMessage) *LifecycleRequest {
var action LifecycleAction
var from string
if strings.Contains(title, "cycle") || strings.Contains(title, "cycling") {
action = ActionCycle
} else if strings.Contains(title, "restart") {
// Check restart/shutdown before cycle.
// Note: Can't use Contains(title, "cycle") because "lifecycle:" contains "cycle".
// Use " cycle" (with leading space) to match the word, not the prefix.
if strings.Contains(title, "restart") {
action = ActionRestart
} else if strings.Contains(title, "shutdown") || strings.Contains(title, "stop") {
action = ActionShutdown
} else if strings.Contains(title, " cycle") || strings.Contains(title, "cycling") {
action = ActionCycle
} else {
return nil
}