Add background job queue system for generation

- Implements sequential job queue with background worker thread (_enqueue_job, _queue_worker)
- All generate routes now return job_id instead of prompt_id; frontend polls /api/queue/<id>/status
- Queue management UI in navbar with live badge, job list, pause/resume/remove controls
- Fix: replaced url_for() calls inside finalize callbacks with direct string paths (url_for raises RuntimeError without request context in background threads)
- Batch cover generation now uses two-phase pattern: queue all jobs upfront, then poll concurrently via Promise.all so page navigation doesn't interrupt the process
- Strengths gallery sweep migrated to same two-phase pattern; sgStop() cancels queued jobs server-side
- LoRA weight randomisation via lora_weight_min/lora_weight_max already present in _resolve_lora_weight

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Aodhan Collins
2026-03-03 02:32:50 +00:00
parent ae7ba961c1
commit 3c828a170f
21 changed files with 1451 additions and 2146 deletions

View File

@@ -121,6 +121,74 @@ a:hover { color: #9d98ff; }
opacity: 1;
}
/* ---- Queue button in navbar ---- */
.queue-btn {
position: relative;
background: transparent;
border: none;
color: var(--text-muted);
font-size: 1rem;
padding: 0.2rem 0.5rem;
border-radius: 6px;
transition: color 0.15s, background 0.15s;
line-height: 1;
}
.queue-btn:hover {
color: var(--text);
background: rgba(255, 255, 255, 0.07);
}
.queue-btn-active {
color: var(--accent) !important;
}
.queue-badge {
position: absolute;
top: -2px;
right: -4px;
background: var(--accent);
color: #fff;
font-size: 0.6rem;
font-weight: 700;
min-width: 16px;
height: 16px;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
padding: 0 3px;
line-height: 1;
}
.queue-icon {
font-size: 0.95rem;
}
/* Queue status dots */
.queue-status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
flex-shrink: 0;
display: inline-block;
}
.queue-status-pending { background: var(--text-muted); }
.queue-status-processing { background: var(--warning); animation: pulse 1s infinite; }
.queue-status-paused { background: var(--text-dim); }
.queue-status-done { background: var(--success); }
.queue-status-failed { background: var(--danger); }
.queue-status-removed { background: var(--border); }
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.4; }
}
/* Small button variant for queue actions */
.btn-xs {
padding: 0.1rem 0.35rem;
font-size: 0.7rem;
border-radius: 4px;
line-height: 1.4;
}
/* ============================================================
Cards
============================================================ */