feat: implement server-wide management actions and enhance TUI dashboard

This commit is contained in:
2026-03-04 20:51:02 +00:00
parent 150f9d2990
commit ddec55871b
13 changed files with 621 additions and 52 deletions
+54
View File
@@ -16,6 +16,8 @@ func View(model Model) string {
return viewAgentActions(model)
case ScreenLogs:
return viewLogs(model)
case ScreenServer:
return viewServer(model)
default:
return ""
}
@@ -78,6 +80,10 @@ func viewAgentList(m Model) string {
b.WriteString(fmt.Sprintf(" %s%s %-20s %-8s %s\n",
cursor, icon, a.ID, a.Version, status))
if a.Instances > 1 {
b.WriteString(fmt.Sprintf(" ⚠ WARNING: %d instances running!\n", a.Instances))
}
}
if m.StatusMsg != "" {
@@ -177,6 +183,54 @@ func viewLogs(m Model) string {
return b.String()
}
func viewServer(m Model) string {
var b strings.Builder
b.WriteString("\n Server Management\n")
b.WriteString(" " + strings.Repeat("─", 44) + "\n")
// Summary
running, stopped, disabled := countStatuses(m.Agents)
total := len(m.Agents)
if total > 0 {
b.WriteString(fmt.Sprintf(" %d agents: %d running, %d stopped, %d disabled\n", total, running, stopped, disabled))
} else {
b.WriteString(" Loading...\n")
}
// Agent status list (compact)
if total > 0 {
b.WriteString("\n")
for _, a := range m.Agents {
icon := "○"
if !a.Enabled {
icon = " "
} else if a.Running {
icon = "●"
}
b.WriteString(fmt.Sprintf(" %s %s\n", icon, a.ID))
}
}
b.WriteString("\n")
// Action menu
for i, opt := range ServerMenuOptions() {
cursor := " "
if i == m.Cursor {
cursor = "> "
}
b.WriteString(fmt.Sprintf(" %s%-16s %s\n", cursor, opt.Label, opt.Desc))
}
if m.StatusMsg != "" {
b.WriteString("\n " + m.StatusMsg + "\n")
}
b.WriteString("\n ↑↓ navegar enter ejecutar 0 volver\n")
return b.String()
}
func countStatuses(agents []AgentView) (running, stopped, disabled int) {
for _, a := range agents {
switch {