feat: add TypeX app icons#27
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for a macOS-specific tray icon template by enabling the image-png feature in Tauri and conditionally loading a template image. The review feedback suggests using conditional compilation attributes (#[cfg(...)]) instead of runtime cfg! checks to prevent embedding the macOS icon in non-macOS binaries and to safely handle potential panics when retrieving the default window icon.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| let tray_icon = if cfg!(target_os = "macos") { | ||
| Image::from_bytes(include_bytes!("../icons/tray-template.png"))? | ||
| } else { | ||
| app.default_window_icon().unwrap().clone() | ||
| }; |
There was a problem hiding this comment.
Using cfg!(target_os = "macos") inside a runtime if expression means both branches are compiled on all platforms. This causes include_bytes!("../icons/tray-template.png") to embed the macOS tray icon into Windows and Linux binaries, unnecessarily increasing their size. Additionally, calling .unwrap() on default_window_icon() can cause a runtime panic if the icon is missing.
Using conditional compilation attributes (#[cfg(...)]) resolves both issues by only compiling the relevant branch and safely handling the missing icon case.
| let tray_icon = if cfg!(target_os = "macos") { | |
| Image::from_bytes(include_bytes!("../icons/tray-template.png"))? | |
| } else { | |
| app.default_window_icon().unwrap().clone() | |
| }; | |
| #[cfg(target_os = "macos")] | |
| let tray_icon = Image::from_bytes(include_bytes!("../icons/tray-template.png"))?; | |
| #[cfg(not(target_os = "macos"))] | |
| let tray_icon = app.default_window_icon() | |
| .cloned() | |
| .ok_or("default window icon is missing")?; |
Replace the placeholder desktop icon, add a macOS template tray icon, tune icon sizing, and use the default app icon for non-macOS trays. Co-Authored-By: Claude <noreply@anthropic.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request configures a platform-specific tray icon for macOS using a template image, while falling back to the default window icon on other platforms. It also updates the Tauri configuration and Cargo dependencies to support PNG images. The review feedback suggests importing Image unconditionally and adding a fallback to an embedded icon.png on non-macOS platforms to prevent application startup failures when running directly via cargo run.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| #[cfg(target_os = "macos")] | ||
| use tauri::image::Image; |
| #[cfg(target_os = "macos")] | ||
| let tray_icon = Image::from_bytes(include_bytes!("../icons/tray-template.png"))?; | ||
| #[cfg(not(target_os = "macos"))] | ||
| let tray_icon = app | ||
| .default_window_icon() | ||
| .cloned() | ||
| .ok_or("default window icon is missing")?; |
There was a problem hiding this comment.
When running the application directly via cargo run (instead of cargo tauri dev or tauri build), app.default_window_icon() can return None because the resources are not packaged. This causes the application to fail to start. Adding a fallback to the embedded icon.png improves the developer experience and application robustness.
#[cfg(target_os = "macos")]
let tray_icon = Image::from_bytes(include_bytes!("../icons/tray-template.png"))?;
#[cfg(not(target_os = "macos"))]
let tray_icon = match app.default_window_icon().cloned() {
Some(icon) => icon,
None => {
tracing::warn!("Default window icon is missing, falling back to embedded icon.png");
Image::from_bytes(include_bytes!("../icons/icon.png"))?
}
};
Summary
🤖 Generated with Claude Code