Merge polecat/furiosa: fix lifecycle parser order (gt-rixa)

Check restart/shutdown before cycle to avoid matching 'lifecycle:' prefix.
Use ' cycle' (with leading space) for word boundary matching.

Resolved conflict: fixed variable name (title → subject).
This commit is contained in:
Steve Yegge
2025-12-21 14:14:53 -08:00
3 changed files with 20 additions and 18 deletions

View File

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