From c5215c2d3ffbdf0799bd4f9d6516e11b99b8edae Mon Sep 17 00:00:00 2001 From: Dariusz L Date: Wed, 22 Jul 2026 12:48:05 +0200 Subject: [PATCH] Stabilize download workflow scope during missing-model render --- .../actions/resolve_download_methods.js | 17 ++++++++++------- web/resolver/views/missing_browser_methods.js | 8 ++++++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/web/resolver/actions/resolve_download_methods.js b/web/resolver/actions/resolve_download_methods.js index 04591ee..83911e9 100644 --- a/web/resolver/actions/resolve_download_methods.js +++ b/web/resolver/actions/resolve_download_methods.js @@ -394,6 +394,7 @@ export const resolveDownloadMethods = { }, getDownloadWorkflowScopeIdentity(context = {}) { + if (typeof context === 'string') return context.trim(); const workflowKey = String(context.workflowKey || context.workflow_key || '').trim(); return String( context.workflowTabId @@ -417,10 +418,10 @@ export const resolveDownloadMethods = { }); }, - isDownloadInCurrentWorkflowScope(info = {}) { + isDownloadInCurrentWorkflowScope(info = {}, currentScope = null) { const downloadScope = this.getDownloadWorkflowScopeIdentity(info); - const currentScope = this.getCurrentDownloadWorkflowScopeIdentity(); - return !downloadScope || !currentScope || downloadScope === currentScope; + const scope = currentScope || this.getCurrentDownloadWorkflowScopeIdentity(); + return !downloadScope || !scope || downloadScope === scope; }, getDownloadMissingIdentity(missing) { @@ -791,10 +792,12 @@ export const resolveDownloadMethods = { return snapshot; }, - restoreDownloadedLocalMatchesForMissing(missing) { + restoreDownloadedLocalMatchesForMissing(missing, workflowScope = null) { if (!missing) return missing; - const snapshot = this.getDownloadProgressStore().get(this.getDownloadStateKey(missing)); + const snapshot = this.getDownloadProgressStore().get( + this.getDownloadStateKey(missing, workflowScope || null) + ); const storedMatches = Array.isArray(snapshot?.localMatches) ? snapshot.localMatches : []; if (!storedMatches.length) return missing; @@ -803,7 +806,7 @@ export const resolveDownloadMethods = { return missing; }, - preserveActiveDownloadLocalMatches(missing, nextMatches = []) { + preserveActiveDownloadLocalMatches(missing, nextMatches = [], workflowScope = null) { if (!missing) return Array.isArray(nextMatches) ? nextMatches : []; const activeEntries = this.getActiveDownloadEntriesForMissing?.(missing) || []; @@ -828,7 +831,7 @@ export const resolveDownloadMethods = { const activeEntry = this.activeDownloads?.[activeDownload.download_id]; if ( activeEntry - && (!this.isDownloadInCurrentWorkflowScope || this.isDownloadInCurrentWorkflowScope(activeEntry)) + && (!this.isDownloadInCurrentWorkflowScope || this.isDownloadInCurrentWorkflowScope(activeEntry, workflowScope)) && activeEntry.missing !== missing ) { activeEntry.missing = missing; diff --git a/web/resolver/views/missing_browser_methods.js b/web/resolver/views/missing_browser_methods.js index 86740b8..8c0bf04 100644 --- a/web/resolver/views/missing_browser_methods.js +++ b/web/resolver/views/missing_browser_methods.js @@ -1811,12 +1811,16 @@ export const missingBrowserMethods = { displayMissingModels(container, data, options = {}) { const selectionOnly = !!options.selectionOnly; const listScrollSnapshot = this.getMissingListScrollSnapshot(container); + // Resolving the download state used to serialize the whole workflow for + // every missing model. Keep the scope stable for this render pass. + const downloadWorkflowScope = this.getCurrentDownloadWorkflowScopeIdentity?.() || ''; const missingModels = (data.missing_models || []).map(missing => { - let restored = this.restoreDownloadedLocalMatchesForMissing?.(missing) || missing; + let restored = this.restoreDownloadedLocalMatchesForMissing?.(missing, downloadWorkflowScope) || missing; restored = this.restoreSearchLocalHashMatchesForMissing?.(restored) || restored; restored.matches = this.preserveActiveDownloadLocalMatches?.( restored, - restored.matches || [] + restored.matches || [], + downloadWorkflowScope ) || restored.matches || []; return restored; });