From c88382870300600dc58313568c068eb070a155d5 Mon Sep 17 00:00:00 2001 From: bymyself Date: Sat, 8 Aug 2026 16:36:32 -0700 Subject: [PATCH 1/3] test: add failing test for stale missing-media candidate after widget value change A candidate whose widget value changes while verification is pending still passes isMissingMediaCandidateScopeActive, so the stale value can be surfaced as missing after the user has already corrected it. Co-Authored-By: Claude Opus 5 --- src/platform/missingMedia/missingMediaScan.test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/platform/missingMedia/missingMediaScan.test.ts b/src/platform/missingMedia/missingMediaScan.test.ts index 404f3a64115..a5346be7cdc 100644 --- a/src/platform/missingMedia/missingMediaScan.test.ts +++ b/src/platform/missingMedia/missingMediaScan.test.ts @@ -503,6 +503,17 @@ describe('isMissingMediaCandidateScopeActive', () => { expect(isMissingMediaCandidateScopeActive(graph, candidate)).toBe(false) }) + + it('drops a candidate whose widget value changed while verification was pending', () => { + const { graph, node, widget } = createLoadImageGraph() + const candidate = makeCandidate(String(node.id), 'missing.png') + + expect.soft(isMissingMediaCandidateScopeActive(graph, candidate)).toBe(true) + + widget.value = 'valid.png' + + expect(isMissingMediaCandidateScopeActive(graph, candidate)).toBe(false) + }) }) describe('scanAllMediaCandidates', () => { From 40ae007bb9bbdb4d39269ef65c05dd489730d838 Mon Sep 17 00:00:00 2001 From: bymyself Date: Sat, 8 Aug 2026 16:53:36 -0700 Subject: [PATCH 2/3] fix: drop stale missing-media candidates when the widget value changes isMissingMediaCandidateScopeActive confirmed the node and widget were still the active value owner, but not that the widget still held the value the candidate captured. Verification is async, so correcting a value while it was in flight left the old candidate passing the predicate and being surfaced against a value that no longer existed. Closes the gap at the shared predicate so both the realtime and workflow-load paths are covered. The promoted-consumer fixture overrode the candidate name without moving the host widget with it, encoding a state that cannot occur: the scan derives candidate.name from the widget value. Seeded via hostValue instead so the two stay in sync. Co-Authored-By: Claude Opus 5 --- src/composables/graph/useErrorClearingHooks.test.ts | 3 +-- src/platform/missingMedia/missingMediaScan.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/composables/graph/useErrorClearingHooks.test.ts b/src/composables/graph/useErrorClearingHooks.test.ts index 8a64fb3f0aa..a9928518935 100644 --- a/src/composables/graph/useErrorClearingHooks.test.ts +++ b/src/composables/graph/useErrorClearingHooks.test.ts @@ -87,13 +87,12 @@ async function startPendingPromotedMediaVerification() { rootGraph, hosts: [outerHost], sourceNodes: [leafNode] - } = createPromotedMediaRuntime({ depth: 2 }) + } = createPromotedMediaRuntime({ depth: 2, hostValue: 'pending.png' }) outerHost.mode = LGraphEventMode.BYPASS vi.spyOn(app, 'rootGraph', 'get').mockReturnValue(rootGraph) const pendingCandidate = { ...createPromotedMissingMediaCandidate(outerHost), - name: 'pending.png', isMissing: undefined } vi.spyOn(missingModelScan, 'scanNodeModelCandidates').mockReturnValue([]) diff --git a/src/platform/missingMedia/missingMediaScan.ts b/src/platform/missingMedia/missingMediaScan.ts index 7560e64390c..40b6f05fd5d 100644 --- a/src/platform/missingMedia/missingMediaScan.ts +++ b/src/platform/missingMedia/missingMediaScan.ts @@ -176,7 +176,7 @@ export function isMissingMediaCandidateScopeActive( // Removed or renamed while verification was pending: nothing owns the value. if (!widget) return false - return isEditableValueOwner(node, widget) + return widget.value === candidate.name && isEditableValueOwner(node, widget) } export function isMissingMediaCandidateActive( From 9c599855b2b1c979c5bea04e294769df17cdc020 Mon Sep 17 00:00:00 2001 From: bymyself Date: Sat, 8 Aug 2026 19:44:18 -0700 Subject: [PATCH 3/3] test: cover the deferred-verification stale-value path end to end Adds behavioural coverage through the scan entry point with a deferred verifier, on a promoted host, per review feedback: the predicate-level test alone would not catch a regression in either caller. Verified mutation-killing: reverting the guard fails this test. Co-Authored-By: Claude Opus 5 --- src/composables/graph/useErrorClearingHooks.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/composables/graph/useErrorClearingHooks.test.ts b/src/composables/graph/useErrorClearingHooks.test.ts index a9928518935..6d32aaaed26 100644 --- a/src/composables/graph/useErrorClearingHooks.test.ts +++ b/src/composables/graph/useErrorClearingHooks.test.ts @@ -962,6 +962,19 @@ describe('realtime verification staleness guards', () => { }) }) + it('skips verified media whose host widget value changed while verification was pending', async () => { + const { outerHost, resolveVerification } = + await startPendingPromotedMediaVerification() + const hostWidget = outerHost.widgets?.[0] + if (!hostWidget) throw new Error('Expected promoted image host widget') + + hostWidget.value = 'corrected.png' + resolveVerification() + await new Promise((resolve) => setTimeout(resolve, 0)) + + expect(useMissingMediaStore().missingMediaCandidates).toBeNull() + }) + it('skips verified media when its sole promoted consumer becomes bypassed', async () => { const { leafNode, resolveVerification } = await startPendingPromotedMediaVerification()