feat: opción Restart en TUI dashboard de agentes
Añade botón "Restart" en el menú de acciones de agente en la TUI. Ejecuta stop + start del launcher unificado para aplicar cambios de configuración sin salir del dashboard. Incluye intent nuevo IntentRestartAgent y su implementación en el adapter impuro. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -89,11 +89,13 @@ func ServerMenuOptions(running bool) []MenuOption {
|
|||||||
func AgentActionOptions(enabled bool) []MenuOption {
|
func AgentActionOptions(enabled bool) []MenuOption {
|
||||||
if enabled {
|
if enabled {
|
||||||
return []MenuOption{
|
return []MenuOption{
|
||||||
|
{Label: "Restart", Desc: "Reiniciar launcher para aplicar cambios"},
|
||||||
{Label: "Disable", Desc: "Desactivar agente (requiere restart)"},
|
{Label: "Disable", Desc: "Desactivar agente (requiere restart)"},
|
||||||
{Label: "Logs", Desc: "Ver log del launcher"},
|
{Label: "Logs", Desc: "Ver log del launcher"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return []MenuOption{
|
return []MenuOption{
|
||||||
|
{Label: "Restart", Desc: "Reiniciar launcher para aplicar cambios"},
|
||||||
{Label: "Enable", Desc: "Activar agente (requiere restart)"},
|
{Label: "Enable", Desc: "Activar agente (requiere restart)"},
|
||||||
{Label: "Logs", Desc: "Ver log del launcher"},
|
{Label: "Logs", Desc: "Ver log del launcher"},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ const (
|
|||||||
// Agent-level
|
// Agent-level
|
||||||
IntentEnableAgent IntentKind = "enable_agent"
|
IntentEnableAgent IntentKind = "enable_agent"
|
||||||
IntentDisableAgent IntentKind = "disable_agent"
|
IntentDisableAgent IntentKind = "disable_agent"
|
||||||
|
IntentRestartAgent IntentKind = "restart_agent"
|
||||||
|
|
||||||
// Unified launcher operations
|
// Unified launcher operations
|
||||||
IntentStartLauncher IntentKind = "start_launcher"
|
IntentStartLauncher IntentKind = "start_launcher"
|
||||||
@@ -69,6 +70,8 @@ func Update(model Model, msg interface{}) (Model, []Intent) {
|
|||||||
case MsgActionDone:
|
case MsgActionDone:
|
||||||
if m.Err != nil {
|
if m.Err != nil {
|
||||||
model.StatusMsg = fmt.Sprintf("Error: %s %s: %v", m.Action, m.AgentID, m.Err)
|
model.StatusMsg = fmt.Sprintf("Error: %s %s: %v", m.Action, m.AgentID, m.Err)
|
||||||
|
} else if m.Action == "Restart" {
|
||||||
|
model.StatusMsg = fmt.Sprintf("Restart OK — all agents reloaded")
|
||||||
} else {
|
} else {
|
||||||
model.StatusMsg = fmt.Sprintf("%s %s OK — restart launcher to apply", m.Action, m.AgentID)
|
model.StatusMsg = fmt.Sprintf("%s %s OK — restart launcher to apply", m.Action, m.AgentID)
|
||||||
}
|
}
|
||||||
@@ -229,6 +232,9 @@ func executeAction(model Model, action string) (Model, []Intent) {
|
|||||||
case "Disable":
|
case "Disable":
|
||||||
model.StatusMsg = "Disabling " + id + "..."
|
model.StatusMsg = "Disabling " + id + "..."
|
||||||
return model, []Intent{{Kind: IntentDisableAgent, AgentID: id}}
|
return model, []Intent{{Kind: IntentDisableAgent, AgentID: id}}
|
||||||
|
case "Restart":
|
||||||
|
model.StatusMsg = "Restarting launcher (all agents)..."
|
||||||
|
return model, []Intent{{Kind: IntentRestartAgent, AgentID: id}}
|
||||||
case "Logs":
|
case "Logs":
|
||||||
model.Screen = ScreenLogs
|
model.Screen = ScreenLogs
|
||||||
model.LogLines = nil
|
model.LogLines = nil
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ func (a *Adapter) RunIntent(intent puretui.Intent) tea.Cmd {
|
|||||||
case puretui.IntentDisableAgent:
|
case puretui.IntentDisableAgent:
|
||||||
return a.disableAgent(intent.AgentID)
|
return a.disableAgent(intent.AgentID)
|
||||||
|
|
||||||
|
case puretui.IntentRestartAgent:
|
||||||
|
return a.restartAgent(intent.AgentID)
|
||||||
|
|
||||||
case puretui.IntentLoadLogs:
|
case puretui.IntentLoadLogs:
|
||||||
return a.loadLogs(intent.AgentID)
|
return a.loadLogs(intent.AgentID)
|
||||||
|
|
||||||
@@ -123,6 +126,18 @@ func (a *Adapter) disableAgent(id string) tea.Cmd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *Adapter) restartAgent(id string) tea.Cmd {
|
||||||
|
return func() tea.Msg {
|
||||||
|
_ = a.mgr.StopUnified()
|
||||||
|
time.Sleep(500 * time.Millisecond)
|
||||||
|
err := a.mgr.StartUnified()
|
||||||
|
if err == nil {
|
||||||
|
time.Sleep(500 * time.Millisecond)
|
||||||
|
}
|
||||||
|
return puretui.MsgActionDone{AgentID: id, Action: "Restart", Err: err}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (a *Adapter) startLauncher() tea.Cmd {
|
func (a *Adapter) startLauncher() tea.Cmd {
|
||||||
return func() tea.Msg {
|
return func() tea.Msg {
|
||||||
err := a.mgr.StartUnified()
|
err := a.mgr.StartUnified()
|
||||||
|
|||||||
Reference in New Issue
Block a user