Run classification previews in the background with live progress
The preview endpoint held one HTTP request open while classifying serially at three-second pacing, so any real range meant minutes of a grayed-out button and per-row errors were invisible until the loop ended. Analyse now starts a single background run against its own snapshot; a progress endpoint reports analysed counts, proposed changes and errors as they happen, and the page polls it with a progress bar, pace-based estimate and a Stop button. Navigating away no longer orphans the run: the page re-attaches to it on return. A run that has produced no successful proposal and fails three times in a row with the identical error stops early and reports that error, so a wrong key or unsupported model surfaces in seconds instead of repeating across the whole paced range. Also normalize a null settings.private_names, which crashed the whole UI on a workspace that had never saved preferences.
This commit is contained in:
@@ -68,6 +68,7 @@ func New(a *app.App, assets fs.FS, publicURL string) (http.Handler, error) {
|
||||
respond(w, v, e)
|
||||
})
|
||||
s.mux.HandleFunc("POST /api/reclassify/preview", s.preview)
|
||||
s.mux.HandleFunc("POST /api/reclassify/progress", s.previewProgress)
|
||||
s.mux.HandleFunc("POST /api/reclassify/apply", s.apply)
|
||||
s.mux.HandleFunc("POST /api/reclassify/cancel", s.cancel)
|
||||
s.mux.HandleFunc("POST /api/taxonomy/propose", s.taxonomyPropose)
|
||||
@@ -490,7 +491,17 @@ func (s *Server) preview(w http.ResponseWriter, r *http.Request) {
|
||||
if !decode(w, r, &b) {
|
||||
return
|
||||
}
|
||||
v, e := s.app.Preview(r.Context(), b)
|
||||
v, e := s.app.StartPreview(r.Context(), b)
|
||||
respond(w, v, e)
|
||||
}
|
||||
func (s *Server) previewProgress(w http.ResponseWriter, r *http.Request) {
|
||||
var b struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
if !decode(w, r, &b) {
|
||||
return
|
||||
}
|
||||
v, e := s.app.PreviewProgress(b.ID)
|
||||
respond(w, v, e)
|
||||
}
|
||||
func (s *Server) apply(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user