feat(ui): enable windows mica effect#13476
Conversation
Signed-off-by: Yaron <yaronching@outlook.com>
EurFelux
left a comment
There was a problem hiding this comment.
Not sure what does it look like because I use macOS. The code seems generally OK.
There was a problem hiding this comment.
Could you add some test cases for getWindowsBackgroundMaterial?
isWindowsMicaSupported is never used by external module, so it should not be exported.
There was a problem hiding this comment.
removed unnecessary export
There was a problem hiding this comment.
Added some tests, not sure if they are necessary tho. I feel the main problem with current implementation is the way we get buildNumber is not very robust as @kangfenmao pointed out. But I didn't find a better way.
With that saying, worst case scenario, you simply lose Mica effect, nothing will break. Because:
...(windowsBackgroundMaterial ? { backgroundMaterial: windowsBackgroundMaterial } : {}),
backgroundColor: mainWindowBackgroundColor,
src/main/services/WindowService.ts
Outdated
| }), | ||
| backgroundColor: isMac ? undefined : nativeTheme.shouldUseDarkColors ? '#181818' : '#FFFFFF', | ||
| ...(windowsBackgroundMaterial ? { backgroundMaterial: windowsBackgroundMaterial } : {}), | ||
| backgroundColor: mainWindowBackgroundColor, |
There was a problem hiding this comment.
Should use consistent pattern like L91
There was a problem hiding this comment.
There will be 3 nested ternary operator if we choose to use it. Three conditions are !isMac, !windowsBackgroundMaterial, nativeTheme.shouldUseDarkColors.
Which is bad readability.
Or maybe you want to use an inline defined function?
backgroundColor: (() => {
if (!isMac && !windowsBackgroundMaterial) {
return nativeTheme.shouldUseDarkColors ? '#181818' : '#FFFFFF'
}
return undefined
})(),There was a problem hiding this comment.
| backgroundColor: mainWindowBackgroundColor, | |
| backgroundColor: ...(mainWindowBackgroundColor ? { backgroundColor: mainWindowBackgroundColor }), |
There was a problem hiding this comment.
before this PR, it was
backgroundColor: isMac ? undefined : nativeTheme.shouldUseDarkColors ? '#181818' : '#FFFFFF',I didn't intend to change this. But sure, fixed now.
kangfenmao
left a comment
There was a problem hiding this comment.
✅ LGTM - Clean implementation following macOS blur pattern. The version gating logic is appropriate for this feature.
One small suggestion for the version parsing:
This handles edge cases more robustly if the version format varies.
Signed-off-by: Yaron <yaronching@outlook.com>
Signed-off-by: Yaron <yaronching@outlook.com>
Signed-off-by: Yaron <yaronching@outlook.com>
EurFelux
left a comment
There was a problem hiding this comment.
LGTM! Clean implementation following the existing macOS vibrancy pattern. One minor nit about version parsing for future-proofing, but not blocking.
| const systemVersion = process.getSystemVersion() | ||
| const buildNumber = Number.parseInt(systemVersion.split('.')[2] ?? '', 10) | ||
|
|
||
| return Number.isFinite(buildNumber) && buildNumber >= WINDOWS_11_22H2_BUILD |
There was a problem hiding this comment.
nit: Only checking the build number while ignoring major.minor is not fully future-proof. Currently all Windows 11 versions use 10.0.xxxxx so this works fine in practice, but if a future Windows version ever changes the major version and decrease build number, this check would incorrectly disable Mica.
A more defensive approach would be to compare the full version tuple:
| const systemVersion = process.getSystemVersion() | |
| const buildNumber = Number.parseInt(systemVersion.split('.')[2] ?? '', 10) | |
| return Number.isFinite(buildNumber) && buildNumber >= WINDOWS_11_22H2_BUILD | |
| const systemVersion = process.getSystemVersion() | |
| const [major, minor, build] = systemVersion.split('.').map(Number) | |
| if ([major, minor, build].some((n) => !Number.isFinite(n))) return false | |
| // Windows 10.0.22621+ supports Mica; future major versions (11.x+) are assumed to support it too | |
| return major > 10 || (major === 10 && minor > 0) || (major === 10 && minor === 0 && build >= WINDOWS_11_22H2_BUILD) |
Not blocking — totally fine to keep as-is given Microsoft's current versioning.
What this PR does
This PR enables Mica backdrop effect on Windows11.
Before this PR:
Previously, CherryStudio only supports window blur effect on MacOS.

After this PR:
Now, Mica effect is enabled for Windows. No CSS change is being made. Use following custom css to change transparency of ui components so that you can see mica effect.
CSS below is generated by Codex. I didn't review it. Use it for testing purpose only.
Why we need it and why it was done in this way
The following tradeoffs were made:
No CSS change is made. This aligns with current implementation for MacOS. Even if window blur effect is currently enabled for MacOS, because the UI color is not transparent, the effect will not be visible unless you use a custom css. Below is a css I found for MacOS. https://github.com/hakadao/CherryStudio-Aero
Breaking changes
No breaking changes being made.
Special notes for your reviewer
Below are relevant docs
https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_systembackdrop_type
https://www.electronjs.org/zh/docs/latest/api/base-window#winsetbackgroundmaterialmaterial-windows
Checklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.
/gh-pr-review,gh pr diff, or GitHub UI) before requesting review from othersRelease note