Orphaned .backgrounds/ files get tidied — a repoint trims the one it leaves behind, and every open sweeps what got away

Follow-up to d0c5461's .backgrounds/ folder: generating, pasting, or
choosing solid now trims the app's own prior file in .backgrounds/ as
part of the same write when it repoints or unsets background.image
away from it — silent, best-effort, never blocking the gesture that
triggered it. A scheduled heal at every board open sweeps whatever
that trim declined or missed: any .backgrounds/ file the board's
current background.image no longer names, announced with a loss-row
notice in the loose-file relocation's own voice. Legacy root-level
references are untouched by both paths — the tidy scopes to
.backgrounds/ only, since that is the one folder the app can prove it
wrote into.

Removal is via FileManager.trashItem, matching the attachment-removal
precedent (recoverable, never a hard delete).

Supersedes applySolidBackground's earlier "facets.png survives on
disk" contract for the settled case: the ruling reads "unsets" as one
more shape of "repoints away from a .backgrounds/ file", so a settled
solid choice now trims the generated picture it displaces, same as
switching producers does. The superseded test and doc comment are
updated to the new behavior; the echo-window (no-reload-yet) case is
unaffected and still leaves the file in place.

Claude-Session: https://claude.ai/code/session_014PtZdPwqZuqEDLc6wZMtEy
This commit is contained in:
2026-08-09 09:44:30 -04:00
parent d905e73960
commit ca0328be2e
9 changed files with 858 additions and 26 deletions
+7
View File
@@ -778,6 +778,12 @@ public enum IntegrityRules: Sendable {
/// card window closes; crash residue sweeps at the next card-window open, armed-then-cleared
/// like every heal memo"). The board walk never opens a thread, so no tree walk could report
/// it.
///
/// `orphanedBackgroundImages` joins this no-`Defect`-case group for the identical reason: what
/// is orphaned is a property of **two** board-root readings taken together at the moment of
/// healing the `.backgrounds/` folder's current listing and `background.image`'s current
/// value (`BoardStore.tidyBackgroundImages`, ruled 2026-08-09) not something a tree walk over
/// lanes and cards could carry forward to the heal that acts on it.
public enum Class: Sendable, Equatable, Hashable, CaseIterable {
case looseCardFiles
case legacyTombstone
@@ -786,6 +792,7 @@ public enum IntegrityRules: Sendable {
case staleAgentGuide
case missingGitignore
case commentTrashResidue
case orphanedBackgroundImages
}
/// The scheduled-heal class this defect belongs to, or **`nil` where there is no heal** the