Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/composables/graph/useErrorClearingHooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([])
Expand Down Expand Up @@ -963,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()
Expand Down
11 changes: 11 additions & 0 deletions src/platform/missingMedia/missingMediaScan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
})
})

describe('scanAllMediaCandidates', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/platform/missingMedia/missingMediaScan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading