feat: add Windows title bar theme support#136
feat: add Windows title bar theme support#136chengcheng84 wants to merge 2 commits intoerictli:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a Windows-only title bar theming module and a new Tauri command Changes
Sequence DiagramsequenceDiagram
participant React as React Theme Context
participant Tauri as Tauri Command Handler
participant WinAPI as Windows API (DwmSetWindowAttribute)
participant Window as Window Title Bar
React->>Tauri: invoke("set_title_bar_theme", {isDark: boolean})
activate Tauri
Tauri->>Tauri: enumerate webview windows (labels "main"/"preview-*")
Tauri->>WinAPI: DwmSetWindowAttribute (set immersive dark + caption colors)
activate WinAPI
WinAPI->>Window: apply dark/light and caption/border colors
deactivate WinAPI
Tauri-->>React: Ok(())
deactivate Tauri
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src-tauri/src/lib.rs (2)
3892-3903: Preview windows won't receive title bar theme updates.The command only applies the theme to the
"main"window. Preview windows (labeled"preview-*") created viacreate_preview_windowwon't have their title bars themed, causing visual inconsistency when editing files outside the notes folder.Consider iterating over all windows or accepting an optional window label:
🔧 Suggested fix to theme all windows
#[tauri::command] fn set_title_bar_theme(app: AppHandle, is_dark: bool) -> Result<(), String> { #[cfg(target_os = "windows")] { - if let Some(window) = app.get_webview_window("main") { - windows_title_bar::apply_title_bar_theme(&window, is_dark); + for (_, window) in app.webview_windows() { + windows_title_bar::apply_title_bar_theme(&window, is_dark); } } let _ = app; let _ = is_dark; Ok(()) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src-tauri/src/lib.rs` around lines 3892 - 3903, The set_title_bar_theme command currently only themes the "main" window; update it to apply the theme to all relevant windows (e.g., the "main" window and any preview windows created by create_preview_window with labels starting with "preview-") by iterating over app.windows() (or app.hooks/windows API) and calling windows_title_bar::apply_title_bar_theme(&window, is_dark) for each matching window label, or alternatively extend set_title_bar_theme to accept an optional window_label parameter and apply the theme only to that label if provided; adjust references to set_title_bar_theme and create_preview_window accordingly so preview windows receive updates too.
3705-3708: Initial title bar theme doesn't respect system preference.At startup,
apply_title_bar_themeis called withis_dark: false, regardless of the actual system theme. This may cause a brief flash of light title bar before the frontend'sThemeContextinvokesset_title_bar_themewith the correct resolved theme.Consider reading the system theme preference here, or deferring this call until after the frontend initializes:
🔧 Suggested fix to respect system preference at startup
#[cfg(target_os = "windows")] { - windows_title_bar::apply_title_bar_theme(&main_window, false); + // Let the frontend apply the theme after resolving user/system preference + // to avoid a brief flash of incorrect title bar color }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src-tauri/src/lib.rs` around lines 3705 - 3708, The Windows title bar is forced to light by calling windows_title_bar::apply_title_bar_theme(&main_window, false) at startup; change this to respect system preference by querying the system theme and passing the actual dark/light boolean (or defer the call and let the frontend call set_title_bar_theme after ThemeContext resolves). Update the #[cfg(target_os = "windows")] block: replace the hardcoded false with the system theme check (or remove the call and rely on set_title_bar_theme) so apply_title_bar_theme and main_window use the correct initial is_dark value.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src-tauri/src/lib.rs`:
- Around line 3892-3903: The set_title_bar_theme command currently only themes
the "main" window; update it to apply the theme to all relevant windows (e.g.,
the "main" window and any preview windows created by create_preview_window with
labels starting with "preview-") by iterating over app.windows() (or
app.hooks/windows API) and calling
windows_title_bar::apply_title_bar_theme(&window, is_dark) for each matching
window label, or alternatively extend set_title_bar_theme to accept an optional
window_label parameter and apply the theme only to that label if provided;
adjust references to set_title_bar_theme and create_preview_window accordingly
so preview windows receive updates too.
- Around line 3705-3708: The Windows title bar is forced to light by calling
windows_title_bar::apply_title_bar_theme(&main_window, false) at startup; change
this to respect system preference by querying the system theme and passing the
actual dark/light boolean (or defer the call and let the frontend call
set_title_bar_theme after ThemeContext resolves). Update the #[cfg(target_os =
"windows")] block: replace the hardcoded false with the system theme check (or
remove the call and rely on set_title_bar_theme) so apply_title_bar_theme and
main_window use the correct initial is_dark value.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d1fc1545-3c61-42a6-94ea-fc65d97dbff4
📒 Files selected for processing (2)
src-tauri/src/lib.rssrc/context/ThemeContext.tsx
Before
2026-04-06.093820.mp4
Now
2026-04-06.093437.mp4
Summary by CodeRabbit