Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions apps/desktop-tauri/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ tauri-plugin-single-instance = "2"
tokio = { version = "1", features = ["rt", "time", "sync", "net", "io-util"] }
tracing = "0.1"
uuid = { version = "1", features = ["v4"] }

[target.'cfg(windows)'.dependencies]
winreg = "0.55"
2 changes: 2 additions & 0 deletions apps/desktop-tauri/src-tauri/src/commands/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ pub struct SettingsSnapshot {
float_bar_dark_text: bool,
float_bar_show_reset_inline: bool,
float_bar_show_cost: bool,
promote_tray_icon: bool,
}

#[tauri::command]
Expand Down Expand Up @@ -550,6 +551,7 @@ impl From<Settings> for SettingsSnapshot {
float_bar_dark_text: settings.float_bar_dark_text,
float_bar_show_reset_inline: settings.float_bar_show_reset_inline,
float_bar_show_cost: settings.float_bar_show_cost,
promote_tray_icon: settings.promote_tray_icon,
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions apps/desktop-tauri/src-tauri/src/commands/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub struct SettingsUpdate {
pub float_bar_dark_text: Option<bool>,
pub float_bar_show_reset_inline: Option<bool>,
pub float_bar_show_cost: Option<bool>,
pub promote_tray_icon: Option<bool>,
}

impl SettingsUpdate {
Expand All @@ -81,6 +82,10 @@ impl SettingsUpdate {
self.float_bar_enabled.is_some() || self.ui_language.is_some()
}

pub fn changes_tray_promotion(&self) -> bool {
self.promote_tray_icon.is_some()
}

fn refreshes_tray_presentation(&self) -> bool {
self.tray_icon_mode.is_some()
|| self.switcher_shows_icons.is_some()
Expand Down Expand Up @@ -186,6 +191,9 @@ impl SettingsUpdate {
if let Some(v) = self.show_all_token_accounts_in_menu {
settings.show_all_token_accounts_in_menu = v;
}
if let Some(v) = self.promote_tray_icon {
settings.promote_tray_icon = v;
}
self
}

Expand Down Expand Up @@ -350,6 +358,8 @@ pub async fn update_settings(
let clear_local_usage_cache = patch.codex_custom_sessions_dirs.is_some();
let rebuild_tray_menu = patch.rebuilds_tray_menu();
let refresh_tray_presentation = patch.refreshes_tray_presentation();
let tray_promotion_changed = patch.changes_tray_promotion();
let previous_promoted = settings.promote_tray_icon;
let previous_language = settings.ui_language;

patch.validate_shortcut_change(&app, &settings.global_shortcut)?;
Expand All @@ -371,6 +381,13 @@ pub async fn update_settings(
if refresh_tray_presentation {
crate::tray_bridge::refresh_tray_presentation(&app);
}
if tray_promotion_changed {
let new_promoted = settings.promote_tray_icon;
if new_promoted || crate::tray_visibility::should_write_demotion(previous_promoted, new_promoted) {
crate::tray_visibility::apply_promotion(new_promoted);
}
}

// Notify other windows (PopOut dashboard, tray, float bar) so they re-read
// settings live — e.g. the Display tab's window-scale slider takes effect
// immediately instead of only after the PopOut is reopened.
Expand Down
2 changes: 2 additions & 0 deletions apps/desktop-tauri/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ mod surface;
mod surface_target;
mod tray_bridge;
mod tray_menu;
mod tray_visibility;
mod window_positioner;

use std::sync::Mutex;
Expand Down Expand Up @@ -215,6 +216,7 @@ fn main() {
commands::get_locale_strings,
commands::set_ui_language,
commands::open_path,
tray_visibility::tray_visibility_status,
floatbar::show_float_bar,
floatbar::hide_float_bar,
floatbar::set_float_bar_opacity,
Expand Down
19 changes: 19 additions & 0 deletions apps/desktop-tauri/src-tauri/src/tray_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,25 @@ pub fn setup(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
})
.build(app)?;

// Apply tray promotion on startup. The NotifyIconSettings entry is created
// by Windows only after the icon is first registered, so on the very first
// run the subkey may not exist yet — apply_promotion tolerates that
// (returns EntryNotFound, logs a debug message). A one-time retry task is
// spawned so that subsequent refreshes of the icon on first-run also work.
let promote = codexbar::settings::Settings::load().promote_tray_icon;
if promote {
crate::tray_visibility::apply_promotion(true);
let app_handle = app.handle().clone();
tauri::async_runtime::spawn(async move {
tokio::time::sleep(std::time::Duration::from_secs(3)).await;
let still_promote = codexbar::settings::Settings::load().promote_tray_icon;
if still_promote {
crate::tray_visibility::apply_promotion(true);
}
drop(app_handle);
});
}

Ok(())
}

Expand Down
Loading
Loading