Fix: Proper color scheme preview to avoid watcher creation spam #150

Merged
zach merged 5 commits from fix/proper-scheme-previews into main 2026-08-17 21:01:26 +02:00
Owner

What & why

Adds new cli flag to generate subcommand: --preview/-p which prints scheme to stdout and then early returns. This is used in Services/Colors.load().

Adds short versions of existing flags (--image-path -> -i).

The "preview" state on the QML side was lazy and wasn't really a preview at all. It was effectively performing all operations for setting a wallpaper every time currentIndex updated in the wallpaper carousel, most importantly it was writing the ${Paths.state}/scheme.json file every time.

This is okay behavior, but wasteful. Due to how file watchers work by "attaching" to a specific file, when said file is overwritten by an atomic write (which we always use), then the original file no longer exists and the current watcher needs to be killed only for a new one to be spawned to watch the new file.

This PR solves this by loading the color scheme through stdout and only once the user sets/accepts the selected wallpaper will it write the scheme file, and if the user cancels then no write will happen.

Related issue

No response

Type

Bug fix

Tested

  • Build succeeds
  • Existing tests pass
  • Manually verified

Breaking changes?

No response

Checklist

  • CI passes (format, lint, typecheck)
  • Clean commits
  • No new warnings
  • Docs updated if needed
### What & why Adds new cli flag to `generate` subcommand: `--preview`/`-p` which prints scheme to `stdout` and then early returns. This is used in `Services/Colors.load()`. Adds short versions of existing flags (`--image-path` -> `-i`). The "preview" state on the QML side was lazy and wasn't really a preview at all. It was effectively performing all operations for setting a wallpaper every time `currentIndex` updated in the wallpaper carousel, most importantly it was writing the `${Paths.state}/scheme.json` file every time. This is okay behavior, but wasteful. Due to how file watchers work by "attaching" to a specific file, when said file is overwritten by an atomic write (which we always use), then the original file no longer exists and the current watcher needs to be killed only for a new one to be spawned to watch the new file. This PR solves this by loading the color scheme through `stdout` and only once the user sets/accepts the selected wallpaper will it write the scheme file, and if the user cancels then no write will happen. ### Related issue _No response_ ### Type Bug fix ### Tested - [x] Build succeeds - [x] Existing tests pass - [x] Manually verified ### Breaking changes? _No response_ ### Checklist - [ ] CI passes (format, lint, typecheck) - [x] Clean commits - [x] No new warnings - [x] Docs updated if needed
zach added 1 commit 2026-08-17 14:32:01 +02:00
proper color scheme preview to avoid watcher creation spam
C++ / fmt (pull_request) Successful in 6s
JS/TS / fmt (pull_request) Successful in 19s
JS/TS / lint (pull_request) Successful in 21s
Python / static (pull_request) Successful in 53s
Rust / fmt (pull_request) Successful in 47s
C++ / build (pull_request) Successful in 1m54s
Rust / build (pull_request) Successful in 2m7s
Rust / clippy (pull_request) Successful in 1m31s
Python / verify (pull_request) Successful in 2m57s
C++ / clang-tidy (pull_request) Successful in 3m49s
177b0f319c
zach requested review from AramJonghu 2026-08-17 14:33:09 +02:00
zach requested review from Inorishio 2026-08-17 14:33:09 +02:00
zach added 1 commit 2026-08-17 16:54:52 +02:00
Merge branch 'main' into fix/proper-scheme-previews
C++ / fmt (pull_request) Successful in 4s
JS/TS / fmt (pull_request) Successful in 19s
JS/TS / lint (pull_request) Successful in 21s
Python / static (pull_request) Successful in 1m0s
Rust / fmt (pull_request) Successful in 1m6s
C++ / build (pull_request) Successful in 2m38s
Rust / build (pull_request) Successful in 2m18s
Rust / clippy (pull_request) Successful in 1m51s
Python / verify (pull_request) Successful in 3m28s
C++ / clang-tidy (pull_request) Successful in 7m1s
c35e73886a
zach added 1 commit 2026-08-17 18:02:23 +02:00
Merge branch 'main' into fix/proper-scheme-previews
C++ / fmt (pull_request) Successful in 3s
JS/TS / fmt (pull_request) Successful in 16s
JS/TS / lint (pull_request) Successful in 17s
Python / static (pull_request) Successful in 1m0s
Rust / fmt (pull_request) Successful in 1m0s
C++ / build (pull_request) Successful in 2m14s
Rust / build (pull_request) Successful in 2m9s
Rust / clippy (pull_request) Successful in 1m26s
Python / verify (pull_request) Successful in 2m50s
C++ / clang-tidy (pull_request) Successful in 4m1s
97c48d03f4
zach added 1 commit 2026-08-17 18:46:41 +02:00
Merge branch 'main' into fix/proper-scheme-previews
C++ / fmt (pull_request) Successful in 4s
JS/TS / fmt (pull_request) Successful in 28s
JS/TS / lint (pull_request) Successful in 20s
Python / static (pull_request) Successful in 58s
Rust / fmt (pull_request) Successful in 1m4s
Rust / build (pull_request) Successful in 1m52s
C++ / build (pull_request) Successful in 2m29s
Rust / clippy (pull_request) Successful in 1m23s
Python / verify (pull_request) Successful in 2m43s
C++ / clang-tidy (pull_request) Successful in 3m59s
de55b5f1e4
Collaborator

Works perfectly 😇

Works perfectly 😇
zach added 1 commit 2026-08-17 21:01:17 +02:00
Merge branch 'main' into fix/proper-scheme-previews
C++ / fmt (pull_request) Successful in 3s
JS/TS / fmt (pull_request) Successful in 20s
JS/TS / lint (pull_request) Successful in 21s
Python / static (pull_request) Successful in 1m1s
Rust / fmt (pull_request) Successful in 54s
C++ / build (pull_request) Successful in 2m31s
Rust / build (pull_request) Successful in 2m5s
Rust / clippy (pull_request) Successful in 1m29s
Python / verify (pull_request) Successful in 2m41s
C++ / clang-tidy (pull_request) Successful in 4m0s
78c0a6fdfc
zach merged commit dfc203f905 into main 2026-08-17 21:01:26 +02:00
zach deleted branch fix/proper-scheme-previews 2026-08-17 21:01:26 +02:00
AramJonghu reviewed 2026-08-17 21:01:52 +02:00
AramJonghu left a comment
Collaborator

Reviewed python code. lgtm.

Reviewed python code. lgtm.
Sign in to join this conversation.