fix: use queuedJobs membership for focus check instead of progress map

A freshly started job won't appear in nodeProgressStatesByJob until its
first progress_state arrives. Using queuedJobs membership avoids
incorrectly stealing focus during that window.

Also gate handleProgress to focused job only and reset
_executingNodeProgress on focus change to prevent progress drift
between concurrent jobs.

Addresses review feedback:
https://github.com/Comfy-Org/ComfyUI_frontend/pull/9786#discussion_r2924372101
https://github.com/Comfy-Org/ComfyUI_frontend/pull/9786#discussion_r2924372109
This commit is contained in:
bymyself
2026-03-12 07:51:07 -07:00
parent 304516a9ed
commit 2664e5d629

View File

@@ -263,7 +263,7 @@ export const useExecutionStore = defineStore('execution', () => {
// Auto-focus the first job, or if the current focused job is no longer running
if (
!focusedJobId.value ||
!nodeProgressStatesByJob.value[focusedJobId.value]
!queuedJobs.value[focusedJobId.value]
) {
focusedJobId.value = activeJobId.value
}
@@ -390,6 +390,7 @@ export const useExecutionStore = defineStore('execution', () => {
}
function handleProgress(e: CustomEvent<ProgressWsMessage>) {
if (e.detail.prompt_id !== focusedJobId.value) return
_executingNodeProgress.value = e.detail
}
@@ -540,6 +541,7 @@ export const useExecutionStore = defineStore('execution', () => {
function setFocusedJob(jobId: string | null) {
focusedJobId.value = jobId
_executingNodeProgress.value = null
if (jobId) {
nodeProgressStates.value = nodeProgressStatesByJob.value[jobId] ?? {}
} else {