diff --git a/pkg/tui/model.go b/pkg/tui/model.go index 6a3dccf..f33d54f 100644 --- a/pkg/tui/model.go +++ b/pkg/tui/model.go @@ -89,11 +89,13 @@ func ServerMenuOptions(running bool) []MenuOption { func AgentActionOptions(enabled bool) []MenuOption { if enabled { return []MenuOption{ + {Label: "Restart", Desc: "Reiniciar launcher para aplicar cambios"}, {Label: "Disable", Desc: "Desactivar agente (requiere restart)"}, {Label: "Logs", Desc: "Ver log del launcher"}, } } return []MenuOption{ + {Label: "Restart", Desc: "Reiniciar launcher para aplicar cambios"}, {Label: "Enable", Desc: "Activar agente (requiere restart)"}, {Label: "Logs", Desc: "Ver log del launcher"}, } diff --git a/pkg/tui/update.go b/pkg/tui/update.go index f16b424..0c78e35 100644 --- a/pkg/tui/update.go +++ b/pkg/tui/update.go @@ -14,6 +14,7 @@ const ( // Agent-level IntentEnableAgent IntentKind = "enable_agent" IntentDisableAgent IntentKind = "disable_agent" + IntentRestartAgent IntentKind = "restart_agent" // Unified launcher operations IntentStartLauncher IntentKind = "start_launcher" @@ -69,6 +70,8 @@ func Update(model Model, msg interface{}) (Model, []Intent) { case MsgActionDone: if m.Err != nil { 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 { 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": model.StatusMsg = "Disabling " + 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": model.Screen = ScreenLogs model.LogLines = nil diff --git a/shell/tui/adapter.go b/shell/tui/adapter.go index 1cf5709..87ab944 100644 --- a/shell/tui/adapter.go +++ b/shell/tui/adapter.go @@ -37,6 +37,9 @@ func (a *Adapter) RunIntent(intent puretui.Intent) tea.Cmd { case puretui.IntentDisableAgent: return a.disableAgent(intent.AgentID) + case puretui.IntentRestartAgent: + return a.restartAgent(intent.AgentID) + case puretui.IntentLoadLogs: 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 { return func() tea.Msg { err := a.mgr.StartUnified()