From c669ffb07b6581c1ff684f7006ac872f734102f2 Mon Sep 17 00:00:00 2001 From: Benjamin Lu Date: Mon, 24 Nov 2025 16:11:00 -0800 Subject: [PATCH] Revert "Fix queue overlay grouping by recency" This reverts commit be1b87d95d17bc90a9a91fadbeeacd9f6570f993. --- src/composables/queue/useJobList.ts | 53 ++++++++--------------------- 1 file changed, 15 insertions(+), 38 deletions(-) diff --git a/src/composables/queue/useJobList.ts b/src/composables/queue/useJobList.ts index d9ac67515c..2a36abc94f 100644 --- a/src/composables/queue/useJobList.ts +++ b/src/composables/queue/useJobList.ts @@ -87,30 +87,6 @@ type TaskWithState = { state: JobState } -const orderingTimestamp = (task: TaskItemImpl, state: JobState) => { - if (state === 'completed' || state === 'failed') { - return ( - task.executionEndTimestamp ?? - task.executionStartTimestamp ?? - task.createTime - ) - } - return task.createTime -} - -const compareTasksByRecency = (a: TaskWithState, b: TaskWithState) => { - const tsA = orderingTimestamp(a.task, a.state) - const tsB = orderingTimestamp(b.task, b.state) - - if (tsA !== undefined && tsB !== undefined && tsA !== tsB) { - return tsB - tsA - } - if (tsA !== undefined && tsB === undefined) return -1 - if (tsA === undefined && tsB !== undefined) return 1 - - return b.task.queueIndex - a.task.queueIndex -} - /** * Builds the reactive job list, filters, and grouped view for the queue overlay. */ @@ -214,21 +190,20 @@ export function useJobList() { const selectedWorkflowFilter = ref<'all' | 'current'>('all') const selectedSortMode = ref('mostRecent') - const tasksWithJobState = computed(() => { - const entries: TaskWithState[] = [ + const allTasksSorted = computed(() => { + const all = [ ...queueStore.pendingTasks, ...queueStore.runningTasks, ...queueStore.historyTasks - ].map((task) => ({ + ] + return all.sort((a, b) => b.queueIndex - a.queueIndex) + }) + + const tasksWithJobState = computed(() => + allTasksSorted.value.map((task) => ({ task, state: jobStateFromTask(task, isJobInitializing(task?.promptId)) })) - - return entries.sort(compareTasksByRecency) - }) - - const allTasksSorted = computed(() => - tasksWithJobState.value.map(({ task }) => task) ) const hasFailedJobs = computed(() => @@ -322,7 +297,12 @@ export function useJobList() { const index = new Map() const localeValue = locale.value for (const { task, state } of filteredTaskEntries.value) { - const ts = orderingTimestamp(task, state) + let ts: number | undefined + if (state === 'completed' || state === 'failed') { + ts = task.executionEndTimestamp + } else { + ts = task.createTime + } const key = ts === undefined ? 'undated' : dateKey(ts) let groupIdx = index.get(key) if (groupIdx === undefined) { @@ -353,10 +333,7 @@ export function useJobList() { }) } - const undated = groups.filter((group) => group.key === 'undated') - const dated = groups.filter((group) => group.key !== 'undated') - - return [...undated, ...dated] + return groups }) return {