From 0b7451336917fded4fdbda64ee3ec8b03d430ec4 Mon Sep 17 00:00:00 2001 From: Enmanuel Date: Sun, 8 Mar 2026 18:42:05 +0000 Subject: [PATCH] feat: TUI usa SIGHUP para hot-reload de agente individual MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit restartAgent() ahora escribe run/reload.txt con el agentID y envía SIGHUP al launcher en lugar de matar y reiniciar el proceso completo. Si el launcher no está corriendo, conserva el comportamiento anterior (stop + start completo). Co-Authored-By: Claude Sonnet 4.6 --- shell/tui/adapter.go | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/shell/tui/adapter.go b/shell/tui/adapter.go index fd7248b..72264e3 100644 --- a/shell/tui/adapter.go +++ b/shell/tui/adapter.go @@ -4,8 +4,10 @@ package tui import ( "fmt" + "os" "os/exec" "strings" + "syscall" "time" tea "github.com/charmbracelet/bubbletea" @@ -140,13 +142,28 @@ 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 { + pid := a.mgr.UnifiedPID() + if pid <= 0 { + // Launcher not running — fall back to full restart. + _ = 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} } - return puretui.MsgActionDone{AgentID: id, Action: "Restart", Err: err} + + // Launcher is running — write target and send SIGHUP for hot-reload. + if id != "" { + _ = os.WriteFile("run/reload.txt", []byte(id), 0o644) + } + err := syscall.Kill(pid, syscall.SIGHUP) + if err != nil { + return puretui.MsgActionDone{AgentID: id, Action: "Restart", Err: err} + } + time.Sleep(1 * time.Second) + return puretui.MsgActionDone{AgentID: id, Action: "Restart", Err: nil} } }