ui: P2R-09 auto-init UX — init line in chrome + danger-zone re-init

Latest 'init' job status surfaced under the host-detail vitals strip
(succeeded/failed/running/queued, with link to the live job log on
non-success). New POST /hosts/{id}/repo/reinit handler dispatches a
fresh init job after the operator types the host name to confirm;
audit row records 'host.repo_reinit'.
This commit is contained in:
2026-05-04 10:49:57 +01:00
parent d02a093eeb
commit c9b49637d1
6 changed files with 374 additions and 2 deletions
+15
View File
@@ -499,6 +499,12 @@ type hostChromeData struct {
SourceGroupCount int
ScheduleCount int
ScheduleVersion int64 // host_schedule_version (latest desired)
// Auto-init status surfaced from the latest 'init' job.
// InitStatus is "succeeded" | "failed" | "running" | "queued" | "" (never run).
InitStatus string
InitAt *time.Time // started_at if non-nil else created_at
InitJobID string
}
// loadHostChrome fetches the per-tab counts that every host-detail tab
@@ -520,6 +526,15 @@ func (s *Server) loadHostChrome(r *stdhttp.Request, host store.Host, subtab, cru
if v, err := s.deps.Store.GetHostScheduleVersion(r.Context(), host.ID); err == nil {
d.ScheduleVersion = v
}
if j, err := s.deps.Store.LatestJobByKind(r.Context(), host.ID, "init"); err == nil && j != nil {
d.InitStatus = j.Status
d.InitJobID = j.ID
t := j.CreatedAt
if j.StartedAt != nil {
t = *j.StartedAt
}
d.InitAt = &t
}
return d
}