fix(render): node reports progress → moving bar + ETA (was stuck 0%/Preparing)
Build backend images / build content-svc (push) Failing after 58s
Build backend images / build file-svc (push) Failing after 45s
Build backend images / build gateway (push) Failing after 52s
Build backend images / build identity-svc (push) Failing after 54s
Build backend images / build notification-svc (push) Failing after 56s
Build backend images / build render-svc (push) Failing after 56s
Build backend images / build studio-svc (push) Failing after 49s
Build backend images / build content-svc (push) Failing after 58s
Build backend images / build file-svc (push) Failing after 45s
Build backend images / build gateway (push) Failing after 52s
Build backend images / build identity-svc (push) Failing after 54s
Build backend images / build notification-svc (push) Failing after 56s
Build backend images / build render-svc (push) Failing after 56s
Build backend images / build studio-svc (push) Failing after 49s
The node's onProgress callback only LOGGED — it never POSTed, so render_progress stayed
0 and step stayed Preparing (no bar, no ETA). Add render-svc POST
/v1/internal/render/jobs/{id}/progress (UpdateJobProgress: set render_progress + bump
step Queued/Preparing→Rendering once >0) + client UpdateProgress + wire onProgress to
post it (8s best-effort timeout, AE-CPU/DB-starvation tolerant). Preview already posts;
real-frame preview is epic C.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -750,6 +750,29 @@ func (s *Store) UpdateJobPreview(ctx context.Context, jobID uuid.UUID, imageB64
|
||||
return err
|
||||
}
|
||||
|
||||
// UpdateJobProgress stores the render percentage for a running job and advances the
|
||||
// step to 'Rendering' once it actually starts (so the UI shows progress + ETA, not a
|
||||
// stuck 'Preparing'). Called by the node agent every few seconds during a render.
|
||||
func (s *Store) UpdateJobProgress(ctx context.Context, jobID uuid.UUID, progress int) error {
|
||||
if progress < 0 {
|
||||
progress = 0
|
||||
}
|
||||
if progress > 100 {
|
||||
progress = 100
|
||||
}
|
||||
_, err := s.pool.Exec(ctx, `
|
||||
UPDATE render.render_jobs
|
||||
SET render_progress = $1,
|
||||
step = CASE WHEN step IN ('Queued'::render_step, 'Preparing'::render_step) AND $1 > 0
|
||||
THEN 'Rendering'::render_step ELSE step END,
|
||||
started_at = COALESCE(started_at, NOW()),
|
||||
updated_at = NOW()
|
||||
WHERE id = $2
|
||||
AND step NOT IN ('Done'::render_step, 'Failed'::render_step, 'Cancelled'::render_step)`,
|
||||
progress, jobID)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Store) CancelJob(ctx context.Context, id, userID uuid.UUID) (bool, error) {
|
||||
tag, err := s.pool.Exec(ctx, `
|
||||
UPDATE render.render_jobs
|
||||
|
||||
@@ -235,6 +235,28 @@ func (h *InternalHandler) Preview(c *gin.Context) {
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// POST /v1/internal/render/jobs/:job_id/progress
|
||||
// Node agent pushes the render percentage so the UI shows a moving bar + ETA.
|
||||
func (h *InternalHandler) RenderProgress(c *gin.Context) {
|
||||
jobID, err := uuid.Parse(c.Param("job_id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, models.APIError{Code: "bad_request", Message: "invalid job_id"})
|
||||
return
|
||||
}
|
||||
var req struct {
|
||||
Progress int `json:"progress"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, models.APIError{Code: "bad_request", Message: err.Error()})
|
||||
return
|
||||
}
|
||||
if err := h.store.UpdateJobProgress(c.Request.Context(), jobID, req.Progress); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, models.APIError{Code: "internal_error", Message: err.Error()})
|
||||
return
|
||||
}
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// POST /v1/internal/render/jobs/claim
|
||||
// Node agent calls this to atomically claim the next queued job.
|
||||
// Returns 204 when there is nothing queued (agent should back off and retry).
|
||||
|
||||
Reference in New Issue
Block a user