Skip to content

refactor(settings): resolve monitor wallpapers in rust - #766

Merged
thep0y merged 3 commits into
mainfrom
refactor/monitor-wallpapers-command
Oct 23, 2026
Merged

thep0y merged 3 commits into
mainfrom
refactor/monitor-wallpapers-command

Conversation

@thep0y

@thep0y thep0y commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Section 2.3 of the 2026-10-22 review: store/fixed.store.ts built the monitor_specific_wallpapers union and the "all" pseudo-monitor by hand in JavaScript, while AGENTS.md says business logic lives in Rust.

Rust now owns the mapping. A new monitor_wallpapers.rs resolves MonitorSpecificWallpapers into an ordered Vec<MonitorTheme> — "all" first, All expanded over every reported monitor, an Individual map yielding only its stored entries plus a synthetic "all" representative, and a monitor with no entry simply absent — and turns an apply or stop request into the next WallpaperMode. One narrow command, resolve_monitor_themes_cmd, returns { unified, themes, configured, mode }; no dwall crate public API changed. Twelve unit tests pin exact values for each of those cases, including the empty map and random-to-fixed.

The frontend no longer interprets the union: fixed.store.ts asks the backend for the effective mapping and for the mode to write, configuredThemeId is gone from models/config.ts, and the bindings were regenerated with bun run typegen. random.store needed no change — it only writes { mode: "random", pool } and never built the union, so the review's reference to it was stale.

Live-checked over CDP, because this changes what the app sends:

  • per-monitor: resolve_monitor_themes_cmd saw { monitorId: <Lenovo path>, themeId: "Catalina", unified: false }, then apply_theme_cmd wrote monitor_specific_wallpapers = { <Lenovo path>: "Catalina" };
  • all monitors: { monitorId: "all", themeId: "Minya Konka", unified: true }, then monitor_specific_wallpapers = "Minya Konka" as a string.

The UI showed applied and stop correctly in both cases, and the config file was restored afterwards.

Verified: cargo test for the whole workspace, cargo fmt --all -- --check, clippy clean in both profiles and in the shipped feature sets, bun run fix, bun run check, bun run test (93) and bun run build:vite.

Known trade-off, left as-is deliberately: configThemes is now a cache refreshed on load and optimistically on apply. If an apply fails and the user then clicks Discard in Settings, the cache stays stale until the next reload — the old code read the config directly at that point. It is an obscure failure-then-discard path and untested either way; worth a follow-up if it ever bites.

Summary by CodeRabbit

  • New Features
    • Added support for resolving fixed wallpaper themes across all monitors or configuring them per monitor.
    • Applying or stopping a theme for one monitor now updates that monitor’s configuration without changing other monitors.
    • Changing themes from random mode now creates a fixed wallpaper configuration.
  • Bug Fixes
    • Fixed wallpaper settings are synchronized before random-theme settings during app startup.

The fixed mode stores either one theme for every monitor or one entry per monitor, and the renderer rebuilt that union and the all pseudo-monitor by hand. A narrow command now returns the effective mapping and the mode a requested apply or stop writes.
The fixed store no longer interprets or builds the two wallpaper shapes: it asks the backend for the effective mapping and for the mode an apply or stop writes. The all-monitors expansion and the individual-map representative now live beside the command that tests them.
@thep0y thep0y added refactor rust Pull requests that update rust code typescript automerge labels Oct 23, 2026
@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2c0c98cd-7dd0-450a-8e50-fb36d571aaf8
📥 Commits

Reviewing files that changed from the base of the PR and between 7844d76 and 950f6b4.

📒 Files selected for processing: 13
  • crates/dwall-settings/src/commands/monitor.rs
  • crates/dwall-settings/src/main.rs
  • crates/dwall-settings/src/monitor_wallpapers.rs
  • docs/code-review-2026-10-22.md
  • src/App.tsx
  • src/ipc/bindings/MonitorTheme.ts
  • src/ipc/bindings/MonitorThemeChange.ts
  • src/ipc/bindings/MonitorThemes.ts
  • src/ipc/index.ts
  • src/ipc/types.ts
  • src/ipc/wallpaper.ts
  • src/models/config.ts
  • src/store/fixed.store.ts
+-----------------------------------------------------------------+
| You know what they call CodeRabbit in Paris? Royale with Debug. |
+-----------------------------------------------------------------+
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@thep0y
thep0y merged commit 72a11c8 into main Oct 23, 2026
11 of 12 checks passed
@thep0y thep0y removed the automerge label Oct 23, 2026
@github-actions
github-actions Bot deleted the refactor/monitor-wallpapers-command branch October 23, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor rust Pull requests that update rust code typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant