Keep Enhance + Generate as one queue row with shared progress.

The PE stage now stays on the same jobId so the header and queue badge agree, and jobs behind it do not promote when enhance finishes.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-09-26 14:42:22 -05:00
co-authored by Cursor
parent 30be4bd5b0
commit 99b61e67d7
9 changed files with 129 additions and 8 deletions
+30 -1
View File
@@ -1,5 +1,6 @@
const terminal = new Set(['complete','failed','cancelled'])
const running = new Set(['waking','submitting','rendering','saving'])
// Include enhancing so PE is the same queue row as generate (not a vanished "Queue 0").
const running = new Set(['waking','enhancing','submitting','rendering','saving'])
export function queueJobs(jobs) {
return jobs.filter(j=>running.has(j.state)||['waiting','queued','held'].includes(j.state)).sort((a,b)=>Number(running.has(b.state))-Number(running.has(a.state)) || (a.queuedAt||0)-(b.queuedAt||0))
}
@@ -14,3 +15,31 @@ export function elapsedSeconds(job, now) {
const end=terminal.has(job.state)?job.finishedAt || job.savedAt || job.updatedAt || start:now
return Number.isFinite(start)&&Number.isFinite(end)?Math.max(0,Math.floor((end-start)/1000)):0
}
/** Stage label shown on the queue row (header pill uses status.mjs). */
export function jobStageLabel(state) {
const labels={
waiting:'Queued',queued:'Queued',held:'Held',
waking:'Waking up',enhancing:'Enhancing prompt…',
submitting:'Generating…',rendering:'Generating…',saving:'Saving',
complete:'Ready',failed:'Failed',cancelled:'Cancelled',
}
return labels[state] || state
}
/** Compact progress for the queue row. Enhancing prefers indeterminate over a fake 0%. */
export function jobProgressView(job) {
const state=job?.state
if(!['enhancing','submitting','rendering','waking','saving'].includes(state)) return null
const p=job?.progress
if(state==='enhancing'){
if(p && Number(p.maxStep)>0 && Number(p.step)>=0)
return {indeterminate:false,percent:Math.max(0,Math.min(100,Number(p.percent)||Math.round(Number(p.step)/Number(p.maxStep)*100)))}
return {indeterminate:true,percent:null}
}
if(state==='rendering' && p && Number(p.maxStep)>0)
return {indeterminate:false,percent:Math.max(0,Math.min(100,Number(p.percent)||Math.round(Number(p.step)/Number(p.maxStep)*100)))}
// waking / submitting / saving / rendering without steps: no fake bar
if(state==='submitting' || state==='waking') return {indeterminate:true,percent:null}
return null
}