fix(wallpaper): show the preview for the default and any chosen wallpaper #80

Merged
Breadway merged 2 commits from fix/bset-70-wallpaper-preview into main 2026-10-14 14:14:29 +08:00
Owner

Closes BSET-70

What

The asset protocol scope only covered ~/Pictures/Backgrounds/**. So the stock BOS wallpaper in /usr/share/backgrounds/bos, which every fresh install starts with, and any image chosen from another folder rendered as an empty box with only its filename.

  • tauri.conf.json: the scope also covers /usr/share/backgrounds/** and /usr/share/wallpapers/**.
  • breadpaper.rs: get_current_wallpaper and get_wallpapers_by_output allow the current wallpaper path as a single file, via asset_protocol_scope().allow_file. They only do this when the path is absolute, has a wallpaper image extension and is an existing file. A pick from Downloads therefore previews too, and nothing broader is opened.

Tests

  • On top of current main: svelte-check 0/0, npm test, build, cargo fmt, clippy -D warnings, cargo test (179).
  • Live BOS VM: Appearance > Wallpaper shows bread-background.png from /usr/share/backgrounds/bos. On main it was a blank box.

Capability changes

None. The webview can additionally load images from the system wallpaper folders and the exact current wallpaper file.

Closes BSET-70 ## What The asset protocol scope only covered `~/Pictures/Backgrounds/**`. So the stock BOS wallpaper in `/usr/share/backgrounds/bos`, which every fresh install starts with, and any image chosen from another folder rendered as an empty box with only its filename. - `tauri.conf.json`: the scope also covers `/usr/share/backgrounds/**` and `/usr/share/wallpapers/**`. - `breadpaper.rs`: `get_current_wallpaper` and `get_wallpapers_by_output` allow the current wallpaper path as a single file, via `asset_protocol_scope().allow_file`. They only do this when the path is absolute, has a wallpaper image extension and is an existing file. A pick from Downloads therefore previews too, and nothing broader is opened. ## Tests - On top of current main: svelte-check 0/0, npm test, build, cargo fmt, clippy -D warnings, cargo test (179). - Live BOS VM: Appearance > Wallpaper shows `bread-background.png` from `/usr/share/backgrounds/bos`. On main it was a blank box. ## Capability changes None. The webview can additionally load images from the system wallpaper folders and the exact current wallpaper file.
fix(wallpaper): show the preview for the default and any chosen wallpaper
All checks were successful
check / check (push) Successful in 2m59s
cf6a4c8666
The asset protocol scope only covered ~/Pictures/Backgrounds, so the stock
BOS wallpaper in /usr/share/backgrounds (every fresh install) and any image
chosen from another folder rendered as an empty box. The static scope now
also covers /usr/share/backgrounds and /usr/share/wallpapers, and the
current wallpaper paths are allowed as single files when they are existing
image files, so a pick from Downloads previews too.

Verified in a BOS VM: Appearance shows bread-background.png from
/usr/share/backgrounds/bos (it was a blank box on main).
Merge remote-tracking branch 'origin/main' into fix/bset-70-wallpaper-preview
All checks were successful
check / check (push) Successful in 8m29s
e1ca0f5e9a
Author
Owner

Review verdict for BSET-70: PASS on head e1ca0f5e9a (base main d432319, unchanged at review time).

Criteria

  • Stock wallpaper preview (/usr/share/backgrounds/bos): src/tauri.conf.json adds /usr/share/backgrounds/** to assetProtocol.scope. The coordinator's BOS VM run showed bread-background.png rendering (blank on main). I did not reproduce the VM render myself.
  • Image chosen from outside ~/Pictures/Backgrounds: breadpaper.rs allow_preview() runs in get_current_wallpaper and get_wallpapers_by_output and calls asset_protocol_scope().allow_file(). I checked this against tauri 2.11.5 with a throwaway mock-runtime test (not committed, worktree removed): an absolute, existing .png is allowed and its sibling images are not. A non-image extension, a relative path, a missing file and a glob-character filename allow nothing extra. allow_file escapes glob metacharacters.
  • Security: static scope additions are only /usr/share/backgrounds/** and /usr/share/wallpapers/** (root-owned system wallpaper folders). The runtime allow is not caller-supplied: neither command takes a path argument. The path comes from "breadpaper get" or current.json. The guard is absolute path + wallpaper extension (png/jpg/jpeg/webp/gif/bmp) + is_file(). The CSP is unchanged and img-src only. No capability or permission changes in src/capabilities.
  • No capability regressions: diff is 2 files, +19/-4, no unrelated churn.

Non-blocking notes

  1. allow_file takes the literal path; tauri resolves one symlink level at check time, so a current wallpaper that is a symlink named *.png makes the link target readable by the webview. Needs the user's own breadpaper state to point at it, so low risk. Canonicalizing before allow_file would close it.
  2. The scope only grows for the app lifetime (no revoke when the wallpaper changes). Bounded by the number of wallpapers set in a session.
  3. No unit test covers allow_preview (needs the mock runtime). Suggest a follow-up.

Checks on the exact head

  • frontend: npm ci, npm run check, npm test, npm run build: all rc=0
  • src: cargo fmt --check rc=0; cargo clippy --locked --all-targets -- -D warnings rc=0; cargo test --locked 179 passed, 0 failed
  • Forgejo CI "check / check (push)": success on e1ca0f5e9a
  • No existing reviews or change requests; PR mergeable.
Review verdict for BSET-70: PASS on head e1ca0f5e9a7833e30994e64ee0ad27cc95266997 (base main d432319, unchanged at review time). Criteria - Stock wallpaper preview (/usr/share/backgrounds/bos): src/tauri.conf.json adds /usr/share/backgrounds/** to assetProtocol.scope. The coordinator's BOS VM run showed bread-background.png rendering (blank on main). I did not reproduce the VM render myself. - Image chosen from outside ~/Pictures/Backgrounds: breadpaper.rs allow_preview() runs in get_current_wallpaper and get_wallpapers_by_output and calls asset_protocol_scope().allow_file(). I checked this against tauri 2.11.5 with a throwaway mock-runtime test (not committed, worktree removed): an absolute, existing .png is allowed and its sibling images are not. A non-image extension, a relative path, a missing file and a glob-character filename allow nothing extra. allow_file escapes glob metacharacters. - Security: static scope additions are only /usr/share/backgrounds/** and /usr/share/wallpapers/** (root-owned system wallpaper folders). The runtime allow is not caller-supplied: neither command takes a path argument. The path comes from "breadpaper get" or current.json. The guard is absolute path + wallpaper extension (png/jpg/jpeg/webp/gif/bmp) + is_file(). The CSP is unchanged and img-src only. No capability or permission changes in src/capabilities. - No capability regressions: diff is 2 files, +19/-4, no unrelated churn. Non-blocking notes 1. allow_file takes the literal path; tauri resolves one symlink level at check time, so a current wallpaper that is a symlink named *.png makes the link target readable by the webview. Needs the user's own breadpaper state to point at it, so low risk. Canonicalizing before allow_file would close it. 2. The scope only grows for the app lifetime (no revoke when the wallpaper changes). Bounded by the number of wallpapers set in a session. 3. No unit test covers allow_preview (needs the mock runtime). Suggest a follow-up. Checks on the exact head - frontend: npm ci, npm run check, npm test, npm run build: all rc=0 - src: cargo fmt --check rc=0; cargo clippy --locked --all-targets -- -D warnings rc=0; cargo test --locked 179 passed, 0 failed - Forgejo CI "check / check (push)": success on e1ca0f5e9a7833e30994e64ee0ad27cc95266997 - No existing reviews or change requests; PR mergeable.
Author
Owner

Merged with a merge commit: 7c7749db9e (parents a80bdf3 and reviewed head e1ca0f5). main moved three times during review (#79, #82, #81/#83, none touching the wallpaper files). I re-ran fmt, clippy --locked -D warnings, cargo test --locked (183 passed), npm ci, check, test and build on the PR merged into a80bdf3 immediately before merging; all green. Forgejo CI check was green on e1ca0f5. The merged diff on main is exactly the 2 reviewed files (+19/-4). Awaiting live verification of the wallpaper preview on the integrated build, so the card stays in review.

Merged with a merge commit: 7c7749db9e36fe30543df506c8f3bf4ab4f62050 (parents a80bdf3 and reviewed head e1ca0f5). main moved three times during review (#79, #82, #81/#83, none touching the wallpaper files). I re-ran fmt, clippy --locked -D warnings, cargo test --locked (183 passed), npm ci, check, test and build on the PR merged into a80bdf3 immediately before merging; all green. Forgejo CI check was green on e1ca0f5. The merged diff on main is exactly the 2 reviewed files (+19/-4). Awaiting live verification of the wallpaper preview on the integrated build, so the card stays in review.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Breadway/bos-settings!80
No description provided.