fix: add job-level WS events so jobs show completed status
Some checks failed
CI Pipeline / Rust Format Check (push) Failing after 24s
CI Pipeline / Clippy Lints (push) Successful in 1m4s
CI Pipeline / Rust Unit Tests (push) Successful in 1m21s
CI Pipeline / Security Audit (push) Successful in 5s
CI Pipeline / Frontend Lint & Type Check (push) Successful in 16s
CI Pipeline / Build .deb & Release (push) Has been skipped
Some checks failed
CI Pipeline / Rust Format Check (push) Failing after 24s
CI Pipeline / Clippy Lints (push) Successful in 1m4s
CI Pipeline / Rust Unit Tests (push) Successful in 1m21s
CI Pipeline / Security Audit (push) Successful in 5s
CI Pipeline / Frontend Lint & Type Check (push) Successful in 16s
CI Pipeline / Build .deb & Release (push) Has been skipped
- Frontend: handleWsEvent now distinguishes host vs job events - Host events only update detail rows + optimistic counters - Job events (event_type=job) set authoritative status + counts - Backend ws_relay: NotifyPayload now includes event_type field - Host events: event_type=host - update_parent_job_status fires pg_notify with event_type=job - Backend job_executor: sync_job_status fires pg_notify with event_type=job - Backend jobs cancel endpoint fires pg_notify with event_type=job - Fixes jobs appearing stuck because host status was mapped to job status
This commit is contained in:
@ -488,6 +488,28 @@ async fn cancel_job(
|
||||
)
|
||||
})?;
|
||||
|
||||
// Fire job-level pg_notify so the frontend can update the job row.
|
||||
let notify_payload = json!({
|
||||
"event_type": "job",
|
||||
"job_id": id.to_string(),
|
||||
"host_id": "",
|
||||
"status": "cancelled",
|
||||
"succeeded_count": 0,
|
||||
"failed_count": 0,
|
||||
"host_count": 0,
|
||||
});
|
||||
if let Ok(payload_str) = serde_json::to_string(¬ify_payload) {
|
||||
if let Err(e) = sqlx::query("SELECT pg_notify('job_update', $1)")
|
||||
.bind(&payload_str)
|
||||
.execute(&state.db)
|
||||
.await
|
||||
{
|
||||
tracing::error!(error = %e, %id, "cancel_job: job-level pg_notify failed");
|
||||
} else {
|
||||
tracing::info!(%id, "cancel_job: job-level pg_notify sent");
|
||||
}
|
||||
}
|
||||
|
||||
log_event(
|
||||
&state.db,
|
||||
AuditAction::PatchJobCancelled,
|
||||
|
||||
Reference in New Issue
Block a user