feat: add rebuild and restart functionality for agents, including build process and status reporting

This commit is contained in:
2026-03-06 00:13:15 +00:00
parent f2626f7007
commit d26be78c46
6 changed files with 127 additions and 4 deletions
+9
View File
@@ -24,5 +24,14 @@ type MsgServerActionDone struct {
Errors []string
}
// MsgRebuildDone reports the result of a rebuild & restart cycle.
type MsgRebuildDone struct {
BuildOK bool
BuildLog string // last lines of build output
Restarted int // agents restarted after build
Failed int
Errors []string
}
// MsgTick triggers a periodic refresh.
type MsgTick struct{}
+1
View File
@@ -64,6 +64,7 @@ func ServerMenuOptions() []MenuOption {
{Label: "Stop All", Desc: "Detener todos los agentes"},
{Label: "Restart All", Desc: "Reiniciar todos los agentes"},
{Label: "Kill All", Desc: "SIGKILL forzado a todos"},
{Label: "Rebuild & Restart", Desc: "Build + reiniciar activos"},
}
}
+18 -4
View File
@@ -16,10 +16,11 @@ const (
IntentQuit IntentKind = "quit"
// Server-wide bulk operations
IntentStartAll IntentKind = "start_all"
IntentStopAll IntentKind = "stop_all"
IntentRestartAll IntentKind = "restart_all"
IntentKillAll IntentKind = "kill_all"
IntentStartAll IntentKind = "start_all"
IntentStopAll IntentKind = "stop_all"
IntentRestartAll IntentKind = "restart_all"
IntentKillAll IntentKind = "kill_all"
IntentRebuildRestart IntentKind = "rebuild_restart"
)
// Intent is pure data describing a side effect to execute.
@@ -67,6 +68,16 @@ func Update(model Model, msg interface{}) (Model, []Intent) {
}
return model, []Intent{{Kind: IntentLoadAgents}}
case MsgRebuildDone:
if !m.BuildOK {
model.StatusMsg = fmt.Sprintf("Build failed: %s", m.BuildLog)
} else if m.Failed > 0 {
model.StatusMsg = fmt.Sprintf("Built OK, %d/%d agents failed to restart", m.Failed, m.Restarted+m.Failed)
} else {
model.StatusMsg = fmt.Sprintf("Built OK, %d agents restarted", m.Restarted)
}
return model, []Intent{{Kind: IntentLoadAgents}}
case MsgServerActionDone:
if m.Failed == 0 {
model.StatusMsg = fmt.Sprintf("%s: %d agents OK", m.Action, m.Total)
@@ -267,6 +278,9 @@ func executeServerAction(model Model, action string) (Model, []Intent) {
case "Kill All":
model.StatusMsg = "Killing all agents..."
return model, []Intent{{Kind: IntentKillAll}}
case "Rebuild & Restart":
model.StatusMsg = "Building & restarting..."
return model, []Intent{{Kind: IntentRebuildRestart}}
}
return model, nil
}