feat: implement wallpaper match color mode with fallback extractor#330
Conversation
|
@bhavyasanthoshi02 is attempting to deploy a commit to the Dot_NotSam's projects Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughAdds a "Wallpaper Match" color mode: a native audio-helper ChangesWallpaper Match Feature
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Helper as AudioHelperProcess
participant Bridge as audioBridge.js
participant Main as main.js
participant Renderer as renderer.js
Helper->>Helper: WallpaperColorExtractor.GetWallpaperColors()
Helper->>Bridge: stdout {type:"colors", value}
Bridge->>Main: sendColors(colors)
Main->>Main: updateWallpaperColors(colors)
Main->>Main: reconcileWallpaperPolling()
Main->>Renderer: sendVisualizerSettings(wallpaperColors)
Renderer->>Renderer: syncAdaptivePaletteTarget() / getResolvedThemeSettings()
Renderer->>Renderer: render themed visualizer with wallpaper palette
Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
SamXop123
left a comment
There was a problem hiding this comment.
Great work on the PR 👍🏻
The code is very well written
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
81f71b6 to
e933409
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
🎉 Congratulations @bhavyasanthoshi02! 🎉 Your pull request has been successfully merged into Paraline! Thank you so much for your valuable contribution and effort. Every single improvement helps make Paraline a better desktop experience for everyone! 🙌 🚀 What's Next?
💬 Stay Connected: Thank you again, and keep up the amazing work! 💻✨ |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
audio-helper/Program.cs (1)
585-610: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low valueRelaxed second pass may emit near-duplicate colors.
The fallback loop only rejects colors within
< 5.0distance, so when fewer than 3 distinct colors are found it can add visually indistinguishable buckets. Consider progressively lowering the primary45.0threshold rather than dropping to5.0, to keep the palette meaningfully distinct.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@audio-helper/Program.cs` around lines 585 - 610, The fallback palette selection in Program.cs can still add visually near-duplicate colors because the second pass only checks a very small ColorDistance threshold. Update the distinct-colors logic in the fallback loop to keep using a meaningful separation by progressively relaxing the primary threshold from the initial distinct-colors pass instead of switching to the much looser check; focus on the distinctColors, sortedBuckets, and ColorDistance logic so the final three colors remain clearly different.main.js (1)
221-223: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low valuePrefer
execFileoverexecfor the static registry query.The command has no user input so this isn't exploitable, but
execFile("reg", ["query", "HKCU\\Control Panel\\Desktop", "/v", "Wallpaper"])avoids a shell and silences thedetect-child-processwarning.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@main.js` around lines 221 - 223, The Windows wallpaper lookup in the registry query block uses child_process exec for a static command, which triggers an unnecessary shell warning. Update the logic around the exec call in main.js to use execFile instead, invoking reg with the fixed query arguments directly from the same Windows-only branch so the behavior stays the same without a shell.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@audio-helper/Program.cs`:
- Around line 36-52: Move wallpaper color extraction out of the main capture
loop so `ReadLevel()` and level emission are not delayed by
`WallpaperColorExtractor.GetWallpaperColors()`. Refactor the wallpaper refresh
logic in `Program.Main` into a separate background worker or `Timer`, and keep
the existing `while (true)` loop focused on audio capture and payload output.
Preserve the current `lastWallpaperCheck` cadence or equivalent scheduling in
the background path, and continue serializing and writing the colors payload
from there.
In `@main.js`:
- Around line 225-226: The fallback wallpaper registry parsing in stdout.match
is using a regex that matches literal backslash-s sequences instead of
whitespace, so it returns early on normal reg query output. Update the regex in
the main.js fallback logic around stdout.match and the match check to use a
whitespace matcher that correctly captures the Wallpaper REG_SZ value, while
keeping the early return only when the capture is actually missing.
---
Nitpick comments:
In `@audio-helper/Program.cs`:
- Around line 585-610: The fallback palette selection in Program.cs can still
add visually near-duplicate colors because the second pass only checks a very
small ColorDistance threshold. Update the distinct-colors logic in the fallback
loop to keep using a meaningful separation by progressively relaxing the primary
threshold from the initial distinct-colors pass instead of switching to the much
looser check; focus on the distinctColors, sortedBuckets, and ColorDistance
logic so the final three colors remain clearly different.
In `@main.js`:
- Around line 221-223: The Windows wallpaper lookup in the registry query block
uses child_process exec for a static command, which triggers an unnecessary
shell warning. Update the logic around the exec call in main.js to use execFile
instead, invoking reg with the fixed query arguments directly from the same
Windows-only branch so the behavior stays the same without a shell.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f9af7f0b-128b-4911-9117-82ca344b84fa
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (8)
audio-helper/Paraline.AudioBridge.csprojaudio-helper/Program.csaudioBridge.jsmain.jsrenderer.jssettings.htmlsettingsStore.jstest/settingsStore.test.js
|
|
||
| // Periodically check wallpaper (every 5 seconds) | ||
| if ((DateTime.Now - lastWallpaperCheck).TotalSeconds >= 5) | ||
| { | ||
| lastWallpaperCheck = DateTime.Now; | ||
| var colors = WallpaperColorExtractor.GetWallpaperColors(); | ||
| if (colors != null) | ||
| { | ||
| var colorsPayload = JsonSerializer.Serialize(new | ||
| { | ||
| type = "colors", | ||
| value = colors | ||
| }); | ||
| Console.WriteLine(colorsPayload); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Map the relevant file and inspect the surrounding code.
git ls-files audio-helper/Program.cs
wc -l audio-helper/Program.cs
cat -n audio-helper/Program.cs | sed -n '1,220p'Repository: SamXop123/Paraline
Length of output: 9433
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the wallpaper extraction implementation and any related call sites.
ast-grep outline audio-helper/Program.cs --view expanded
printf '\n---\n'
rg -n "GetWallpaperColors|WallpaperColorExtractor|GetPixel|Resize|Clone|Bitmap" audio-helper/Program.cs
printf '\n--- function slice ---\n'
cat -n audio-helper/Program.cs | sed -n '520,640p'Repository: SamXop123/Paraline
Length of output: 6481
Move wallpaper extraction off the capture loop. GetWallpaperColors() runs synchronously in the same while (true) loop as ReadLevel(), so every wallpaper refresh can delay level emission. A background worker/Timer would keep the audio cadence steady.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@audio-helper/Program.cs` around lines 36 - 52, Move wallpaper color
extraction out of the main capture loop so `ReadLevel()` and level emission are
not delayed by `WallpaperColorExtractor.GetWallpaperColors()`. Refactor the
wallpaper refresh logic in `Program.Main` into a separate background worker or
`Timer`, and keep the existing `while (true)` loop focused on audio capture and
payload output. Preserve the current `lastWallpaperCheck` cadence or equivalent
scheduling in the background path, and continue serializing and writing the
colors payload from there.
| const match = stdout.match(/Wallpaper\\s+REG_SZ\\s+(.*)/); | ||
| if (!match || !match[1]) return; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Confirm the buggy escaping in the wallpaper registry parse
rg -nP 'Wallpaper\\\\s\+REG_SZ' main.jsRepository: SamXop123/Paraline
Length of output: 223
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the relevant section of main.js with line numbers.
sed -n '210,240p' main.js
# Show the exact regex text and nearby logic.
grep -n "Wallpaper\\\\s\\+REG_SZ" -n main.js || true
# Demonstrate how the current regex behaves against typical reg query output.
node - <<'JS'
const samples = [
'Wallpaper REG_SZ C:\\Users\\me\\wall.jpg',
'Wallpaper\tREG_SZ\tC:\\Users\\me\\wall.jpg',
'Wallpaper\\sREG_SZ\\sC:\\Users\\me\\wall.jpg',
];
const re = /Wallpaper\\s+REG_SZ\\s+(.*)/;
for (const s of samples) {
const m = s.match(re);
console.log(JSON.stringify({sample: s, matched: !!m, capture: m && m[1] || null}));
}
JSRepository: SamXop123/Paraline
Length of output: 1367
Fix the wallpaper registry regex
stdout.match() never hits here because /Wallpaper\\s+REG_SZ\\s+(.*)/ looks for literal \s, not whitespace. The Node fallback returns early on normal reg query output, so wallpaper colors stay at defaults when the C# helper isn’t used.
Proposed fix
- const match = stdout.match(/Wallpaper\\s+REG_SZ\\s+(.*)/);
+ const match = stdout.match(/Wallpaper\s+REG_SZ\s+(.*)/);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const match = stdout.match(/Wallpaper\\s+REG_SZ\\s+(.*)/); | |
| if (!match || !match[1]) return; | |
| const match = stdout.match(/Wallpaper\s+REG_SZ\s+(.*)/); | |
| if (!match || !match[1]) return; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@main.js` around lines 225 - 226, The fallback wallpaper registry parsing in
stdout.match is using a regex that matches literal backslash-s sequences instead
of whitespace, so it returns early on normal reg query output. Update the regex
in the main.js fallback logic around stdout.match and the match check to use a
whitespace matcher that correctly captures the Wallpaper REG_SZ value, while
keeping the early return only when the capture is actually missing.
Description
This PR implements the "Wallpaper Match" color mode feature, allowing Paraline to dynamically capture and adapt to the dominant accent colors of the user's active Windows desktop wallpaper.
Key Changes
main.jsthat triggers if the C# helper is unavailable or in simulated mode, using Electron'snativeImageto ensure robustness.settings.htmland integrated validation insettingsStore.js.renderer.jsto dynamically apply the wallpaper colors with smooth animation blending.Summary by CodeRabbit
New Features
Bug Fixes
Tests