Lead status tool
This commit is contained in:
+16
-10
@@ -68,7 +68,7 @@ func New(dataDir string, portFirst int, spa fs.FS) (*Server, error) {
|
||||
}
|
||||
}
|
||||
|
||||
s.agents = agents.New(s.store, filepath.Join(dataDir, "worktrees"), filepath.Join(dataDir, "leads"), filepath.Join(dataDir, "codex"))
|
||||
s.agents = agents.New(s.store, filepath.Join(dataDir, "worktrees"), filepath.Join(dataDir, "leads"), filepath.Join(dataDir, "codex"), s.status)
|
||||
err = s.agents.Recover(context.Background())
|
||||
if err != nil {
|
||||
s.store.Close()
|
||||
@@ -531,22 +531,28 @@ func (s *Server) activeTask(w http.ResponseWriter, r *http.Request, taskID strin
|
||||
}
|
||||
|
||||
func (s *Server) GetStatus(w http.ResponseWriter, r *http.Request) {
|
||||
c, err := s.store.Counts(r.Context())
|
||||
status, err := s.status(r.Context())
|
||||
if err != nil {
|
||||
writeStoreError(w, err)
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, status)
|
||||
}
|
||||
|
||||
usage, err := s.agents.Usage(r.Context())
|
||||
func (s *Server) status(ctx context.Context) (api.Status, error) {
|
||||
c, err := s.store.Counts(ctx)
|
||||
if err != nil {
|
||||
writeStoreError(w, err)
|
||||
return
|
||||
return api.Status{}, err
|
||||
}
|
||||
|
||||
health, err := s.agents.Health(r.Context())
|
||||
usage, err := s.agents.Usage(ctx)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err)
|
||||
return
|
||||
return api.Status{}, err
|
||||
}
|
||||
|
||||
health, err := s.agents.Health(ctx)
|
||||
if err != nil {
|
||||
return api.Status{}, err
|
||||
}
|
||||
|
||||
dbBytes := int64(0)
|
||||
@@ -557,7 +563,7 @@ func (s *Server) GetStatus(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, api.Status{
|
||||
return api.Status{
|
||||
StartedAt: s.startedAt,
|
||||
DbBytes: dbBytes,
|
||||
LastEventSeq: c.LastEventSeq,
|
||||
@@ -572,7 +578,7 @@ func (s *Server) GetStatus(w http.ResponseWriter, r *http.Request) {
|
||||
Zombies: health.Zombies,
|
||||
StuckAfterSeconds: int(agents.StuckAfter / time.Second),
|
||||
ProtocolErrors: s.agents.ProtocolErrors(),
|
||||
})
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Server) ListTaskEvents(w http.ResponseWriter, r *http.Request, taskID string, params api.ListTaskEventsParams) {
|
||||
|
||||
Reference in New Issue
Block a user