diff --git a/frontend/src/lib/components/CompareWorkspaces.svelte b/frontend/src/lib/components/CompareWorkspaces.svelte index e139d22910..5a22ed012d 100644 --- a/frontend/src/lib/components/CompareWorkspaces.svelte +++ b/frontend/src/lib/components/CompareWorkspaces.svelte @@ -813,7 +813,19 @@ } let deploymentErrorMessage = $state('') - let allowBehindChangesOverride = $state(false) + // The override acknowledges the outdated items listed next to it, not the + // selection, so it holds while every outdated item is one the user ticked it + // for: a refresh bringing in a new one asks again, one leaving the list does not. + let acknowledgedBehindKeys = $state | undefined>() + let allowBehindChangesOverride = $derived( + acknowledgedBehindKeys != undefined && + itemsWithBehindChanges.every((d) => acknowledgedBehindKeys!.has(getItemKey(d))) + ) + function setBehindChangesOverride(allow: boolean) { + acknowledgedBehindKeys = allow + ? new Set(itemsWithBehindChanges.map((d) => getItemKey(d))) + : undefined + } async function isComparisonUpToDate(): Promise { if (!comparison) { @@ -1122,18 +1134,17 @@ const current = new Set(diffs.filter(removesInTarget).map((d) => getItemKey(d))) const flipped = [...current].filter((k) => !removalKeys.has(k)) removalKeys = current - if (flipped.some((k) => selectedItems.includes(k))) { - selectedItems = selectedItems.filter((k) => !flipped.includes(k)) + // A row that left the list (made workspace specific, synced elsewhere) takes its + // tick with it: the deploy button counts the selection, and a key with no row + // would be reported as undeployable. + const listed = new Set(selectableDiffs.map((d) => getItemKey(d))) + const kept = selectedItems.filter((k) => listed.has(k) && !flipped.includes(k)) + if (kept.length !== selectedItems.length) { + selectedItems = kept } }) }) - // Reset override when selection or direction changes - $effect(() => { - ;[selectedItems, mergeIntoParent] - allowBehindChangesOverride = false - }) - // Trigger and schedule rows now flow through `comparison.diffs` like every // other deployable kind — the backend's `compareWorkspaces` populates them // from `workspace_diff`, with runtime fields ignored by `compare_two_*`. @@ -1582,7 +1593,8 @@ setBehindChangesOverride(e.currentTarget.checked)} class="rounded max-w-4" /> Override: Deploy despite {itemsWithBehindChanges.length} outdated item{itemsWithBehindChanges.length !==