a37a6e0934
- CLI: empty list/runs/drafts/skills say so on stderr with the next command (stdout and --json unchanged); empty stats skip the zero table; connection shows ntfy not configured. - CLI: a refused or unresolvable server says where it dialled and how to start it (pipelines start/doctor, or pipelines serve), redacting the URL. - skills list/show/import dial the saved client.json address like every other server command instead of always 127.0.0.1:8080. - Status: an unreachable server says how to start it; unconfigured ntfy reads as optional phone notifications rather than a Docker misconfiguration. - Installer: missing tools name where to get them; Docker missing vs not running are told apart; the summary ends with numbered next steps (open the URL, sign in with the password just chosen, set up harnesses, start a chat or example pipeline). - README: prerequisites, password and a short First steps; install docs updated (password rule was stale). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
75 lines
2.5 KiB
Go
75 lines
2.5 KiB
Go
package statusview
|
|
|
|
import (
|
|
"git.a-wan.net/alan/pipelines/internal/protocol"
|
|
"net"
|
|
"net/url"
|
|
"strings"
|
|
)
|
|
|
|
func Offline(endpoint string) *protocol.SystemStatus {
|
|
s := &protocol.SystemStatus{Server: protocol.ServiceStatus{Health: "unreachable"}, Ntfy: protocol.ServiceStatus{Health: "unknown (server unavailable)"}}
|
|
if u, err := url.Parse(endpoint); err == nil {
|
|
s.Server.Port = u.Port()
|
|
}
|
|
return s
|
|
}
|
|
|
|
func ServerLines(s *protocol.SystemStatus) []string {
|
|
if s == nil {
|
|
return []string{"Checking server…"}
|
|
}
|
|
lines := []string{"Status: " + s.Server.Health}
|
|
seen := map[string]bool{}
|
|
for _, address := range s.Addresses {
|
|
ip := net.ParseIP(strings.Split(address.IP, "%")[0])
|
|
if ip == nil || ip.IsLoopback() || ip.IsUnspecified() || ip.IsLinkLocalUnicast() || seen[address.IP] {
|
|
continue
|
|
}
|
|
seen[address.IP] = true
|
|
lines = append(lines, net.JoinHostPort(address.IP, s.Server.Port))
|
|
if len(seen) == 6 {
|
|
break
|
|
}
|
|
}
|
|
if s.Server.Health == "unreachable" {
|
|
lines = append(lines, "Is it running? Start it with `pipelines start` (installed service) or `pipelines serve`.")
|
|
} else if len(seen) == 0 {
|
|
lines = append(lines, "LAN address unavailable.", "For a Docker install: rerun ./install --docker on the server.")
|
|
}
|
|
if s.Server.Port != "" {
|
|
lines = append(lines, "Port: "+s.Server.Port)
|
|
}
|
|
return lines
|
|
}
|
|
|
|
func NtfyLines(s *protocol.SystemStatus) []string {
|
|
if s == nil {
|
|
return []string{"Checking ntfy…"}
|
|
}
|
|
lines := []string{"Status: " + s.Ntfy.Health}
|
|
if s.Ntfy.URL != "" {
|
|
lines = append(lines, "Server: "+s.Ntfy.URL)
|
|
}
|
|
if s.Topic != "" {
|
|
lines = append(lines, "Topic: "+s.Topic)
|
|
}
|
|
if s.NtfyUser != "" {
|
|
lines = append(lines, "Login: "+s.NtfyUser, "Use the password set during installation.")
|
|
}
|
|
if s.Ntfy.Health == "not configured" {
|
|
lines = append(lines, "Phone notifications are off: the connected Pipelines server has no ntfy publishing configuration (optional).",
|
|
"./install sets it up; a plain `pipelines serve` runs without it.",
|
|
"Expected it? Check this is the intended server (--url / PIPELINES_URL); for Docker: docker compose port pipelines 8080.")
|
|
} else if s.Ntfy.Health == "unreachable" || s.Ntfy.Health == "unhealthy" {
|
|
lines = append(lines, "On the server: pipelines doctor (Docker: docker compose logs ntfy)")
|
|
}
|
|
return lines
|
|
}
|
|
|
|
// The human view has exactly two focused sections. --json retains full data.
|
|
func Lines(s *protocol.SystemStatus) []string {
|
|
lines := append([]string{"Pipelines server"}, ServerLines(s)...)
|
|
return append(append(lines, "", "ntfy"), NtfyLines(s)...)
|
|
}
|