Repository navigation
fix(editor): handle duplicate wallpaper basenames without a sync loop - #134
Merged
Merged
Conversation
The backend stages every background into one flat `backgrounds/` directory, so a blueprint that lists the same wallpaper twice — or two wallpapers that share a basename — is rejected with a basename collision and the whole apply fails. Loading, adding, restoring and swapping wallpapers now drop entries that cannot be staged (first entry wins, primary wallpaper counted): - `dedupeAdditionalImages` filters by full path and by basename; `loadBlueprintIntoEditor` reports the dropped count with an explicit toast, and `AdditionalImages.svelte` reports a skipped file instead of silently adding it. - `setWallpaperPath`, `restoreHistorySnapshot`, `setAdditionalImages` and `swapMainWithAdditional` apply the same filter, so undo or swap cannot reintroduce a collision. The same entries echoed back from the backend re-armed App's SyncState `$effect` with an unchanged snapshot, which pushed the identical state back to Go and re-triggered the echo. `applyBackendState` now skips values that already match local state, and the sync effect only dispatches a snapshot whose signature changed since the last dispatch. Refs omacom#130
Contributor
Author
|
Gentle check-in — nothing here needs a decision today. The branch is up to date with main and ready whenever you have a look; happy to change anything you want first. |
The real freeze in omacom#130 came from the keyed each block in AdditionalImages.svelte, which throws on a repeated path. Remove the key, and correct the comments that blamed a state echo loop. Go now stages an exact repeat of a path once, so the CLI and IPC apply paths accept blueprints with duplicate entries. Two different files with the same filename still fail with the collision error. Show a toast when a new main wallpaper or an undo drops an additional image, because undo cannot restore it. Reuse dedupeAdditionalImages in addAdditionalImage.
# Conflicts: # frontend/src/lib/components/editor/AdditionalImages.svelte
The favorites, local, Wallhaven and GitHub browsers showed "Added" even when addAdditionalImage rejected a file with a duplicate filename.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #130.
Problem
Two related failures around wallpapers.
flat
backgrounds/directory, so a blueprint that lists the same wallpapertwice, or two wallpapers that share a filename (e.g.
~/a/wall.pngand~/b/wall.png), is rejected with a basename collision. The editor happilyaccepted such a list and only failed when the user applied the theme.
ipc-state-changedsnapshot wasmirrored into the stores unconditionally. Re-writing equal arrays/objects
re-ran App's SyncState
$effect, which pushed the same snapshot straightback to Go and produced another echo.
Solution
Deduplicate where the set can still be acted on, and make the backend mirror
idempotent.
dedupeAdditionalImages(images, primaryWallpaper)drops entries by fullpath and by basename, first entry wins; the primary wallpaper is seeded into
the seen sets so an additional image cannot shadow it.
loadBlueprintIntoEditorruns the filter and showsSkipped N duplicate wallpaper(s)instead of the generic load toast when entries were dropped.addAdditionalImagereturns whether the file was accepted;AdditionalImages.sveltetoastsSkipped — another wallpaper already uses that filenamerather than reporting a successful add.setWallpaperPath,restoreHistorySnapshot,setAdditionalImagesandswapMainWithAdditionalreuse the filter, so undo and swap cannot restore acolliding pair.
applyBackendStatecompares each pushed value against local state(
sameSerializedfor maps,sameStringListfor slices) and skips no-opwrites;
App.sveltekeeps alastSyncedSignatureand only dispatchessyncStateToBackendwhen the snapshot actually changed.Verification
Observed while preparing this change:
vitest runinfrontend/: 122 tests pass, including the newfrontend/tests/duplicate-wallpapers.test.tssuite (blueprint load withduplicate paths and shared basenames, add/swap/undo, and the backend echo
round-trip).
svelte-check: 0 errors, 0 warnings.duplicated wallpaper keeps exactly one image and shows the skip warning.
is evidenced by the backend's flat staging directory rather than by a
reproduced end-to-end run.
Limitations
The reported freeze (#130) is addressed from the state-echo path in the
frontend source; the reporter's exact freeze was not reproduced in a native
Wails build, so this is a source-level fix for the loop plus a concrete fix
for the collision. Reporter confirmation on a native build would be
appreciated.