Skip to content

fix icon colors for macos#1579

Merged
richiemcilroy merged 1 commit intoCapSoftware:mainfrom
josiahsrc:main
Feb 4, 2026
Merged

fix icon colors for macos#1579
richiemcilroy merged 1 commit intoCapSoftware:mainfrom
josiahsrc:main

Conversation

@josiahsrc
Copy link
Copy Markdown
Contributor

@josiahsrc josiahsrc commented Feb 4, 2026

The icon tray menu colors on macOS weren't responding to dark/light mode. They were displaying white on a white background. This PR updates the project to use dynamically colored tray icons for the menu bar using the macOS template API. Should work with windows and linux too since they use tray-default-icon.png. Uses the same solution that my https://github.com/josiahsrc/voquill project uses.

Before After
image image

Greptile Overview

Greptile Summary

This PR fixes tray icon visibility issues on macOS by enabling template icon mode, which allows the system to automatically adapt icon colors based on the current theme (light/dark mode).

Changes Made:

  • Added set_icon_as_template(true) calls in four locations where tray icons are updated (tray.rs:630, tray.rs:892, tray.rs:914)
  • Added conditional icon_as_template(cfg!(target_os = "macos")) during initial tray creation (tray.rs:664)
  • Converted all tray icon PNGs to black-and-white template format suitable for macOS template rendering

Technical Implementation:
The fix uses the macOS template icon API, which requires icons to be monochrome (black with transparency). The system then inverts and adjusts these icons based on the menu bar appearance. The implementation correctly:

  • Only enables template mode on macOS during initialization using cfg!(target_os = "macos")
  • Unconditionally sets template mode when updating icons dynamically (since non-macOS platforms are already filtered out earlier in the code with cfg!(target_os = "windows") guards)
  • Maintains consistency across all icon update locations: mode changes, recording start, and recording stop

Cross-platform Compatibility:
Windows and Linux continue using tray-default-icon.png (unchanged) and don't call set_icon_as_template, so this change is macOS-specific with no impact on other platforms.

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The changes are minimal, well-scoped, and use a standard Tauri API for macOS template icons. The implementation is correct and follows established patterns in the codebase. Icons are properly formatted as black-and-white templates, and platform-specific logic is correctly implemented.
  • No files require special attention

Important Files Changed

Filename Overview
apps/desktop/src-tauri/src/tray.rs Added set_icon_as_template(true) calls to enable macOS template icon rendering for proper dark/light mode support
apps/desktop/src-tauri/icons/tray-default-icon-studio.png Updated icon to black and white format suitable for macOS template rendering
apps/desktop/src-tauri/icons/tray-default-icon-instant.png Updated icon to black and white format suitable for macOS template rendering
apps/desktop/src-tauri/icons/tray-default-icon-screenshot.png Updated icon to black and white format suitable for macOS template rendering
apps/desktop/src-tauri/icons/tray-stop-icon.png Updated icon to black and white format suitable for macOS template rendering

Sequence Diagram

sequenceDiagram
    participant App as AppHandle
    participant Tray as TrayIcon
    participant System as macOS System
    participant User as User Display

    Note over App,User: Tray Icon Initialization (create_tray)
    App->>Tray: TrayIconBuilder::with_id("tray")
    App->>Tray: .icon(initial_icon)
    App->>Tray: .icon_as_template(cfg!(target_os = "macos"))
    Note over Tray,System: Template flag set for macOS only
    Tray->>System: Register tray icon with template mode
    System->>User: Display icon (adapts to light/dark mode)

    Note over App,User: Mode Change (update_tray_icon_for_mode)
    App->>Tray: set_icon(Some(icon))
    App->>Tray: set_icon_as_template(true)
    System->>User: Update icon display (maintains theme adaptation)

    Note over App,User: Recording Started Event
    App->>Tray: set_icon(stop_icon)
    App->>Tray: set_icon_as_template(true)
    System->>User: Show stop icon (adapts to light/dark mode)

    Note over App,User: Recording Stopped Event
    App->>Tray: set_icon(mode_icon)
    App->>Tray: set_icon_as_template(true)
    System->>User: Restore mode icon (adapts to light/dark mode)
Loading

(2/5) Greptile learns from your feedback when you react with thumbs up/down!


if let Ok(icon) = Image::from_bytes(get_mode_icon(mode)) {
let _ = tray.set_icon(Some(icon));
let _ = tray.set_icon_as_template(true);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we gate template mode to macOS for consistency with .icon_as_template(cfg!(target_os = "macos"))? If set_icon_as_template(true) isn’t a no-op on Linux, it could affect icon colors.

Suggested change
let _ = tray.set_icon_as_template(true);
let _ = tray.set_icon_as_template(cfg!(target_os = "macos"));

@richiemcilroy
Copy link
Copy Markdown
Member

Lovely!

@richiemcilroy richiemcilroy merged commit 282a7a8 into CapSoftware:main Feb 4, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants