errors at top of status are distracting

This commit is contained in:
Ian Gulliver
2026-10-19 19:01:24 -07:00
parent 6d9abc8585
commit fae286a7d8
2 changed files with 20 additions and 15 deletions
+19 -14
View File
@@ -107,11 +107,26 @@ type procInfo struct {
}
func (m *Manager) Health(ctx context.Context) (Health, error) {
running, err := m.store.SessionsInState(ctx, api.AgentSessionStateRunning)
if err != nil {
return Health{}, err
}
children, err := claudeChildren(ctx, os.Getpid())
if err != nil {
return Health{}, err
}
// Snapshot live and starting after running and children, so a start that shows in either is already registered.
m.mu.Lock()
all := []*live{}
for _, l := range m.live {
all = append(all, l)
}
starting := map[string]bool{}
for id := range m.starting {
starting[id] = true
}
m.mu.Unlock()
procs := []procInfo{}
@@ -132,20 +147,10 @@ func (m *Manager) Health(ctx context.Context) (Health, error) {
})
}
running, err := m.store.SessionsInState(ctx, api.AgentSessionStateRunning)
if err != nil {
return Health{}, err
}
children, err := claudeChildren(ctx, os.Getpid())
if err != nil {
return Health{}, err
}
return assess(time.Now(), procs, running, children), nil
return assess(time.Now(), procs, running, children, starting), nil
}
func assess(now time.Time, procs []procInfo, running []api.AgentSession, children []int) Health {
func assess(now time.Time, procs []procInfo, running []api.AgentSession, children []int, starting map[string]bool) Health {
slices.SortFunc(procs, func(a, b procInfo) int { return strings.Compare(a.sessionID, b.sessionID) })
h := Health{Processes: []api.AgentProcess{}, Zombies: []api.Zombie{}}
@@ -187,7 +192,7 @@ func assess(now time.Time, procs []procInfo, running []api.AgentSession, childre
for _, sess := range running {
p, ok := bySession[sess.Id]
if ok && !p.exited {
if (ok && !p.exited) || starting[sess.Id] {
continue
}
detail := "no agent process"
@@ -203,7 +208,7 @@ func assess(now time.Time, procs []procInfo, running []api.AgentSession, childre
}
for _, pid := range children {
if tracked[pid] {
if tracked[pid] || len(starting) > 0 {
continue
}
h.Zombies = append(h.Zombies, api.Zombie{