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
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 @@ -845,6 +845,7 @@ pub struct SettingsSnapshot {
menu_bar_shows_highest_usage: bool,
menu_bar_shows_percent: bool,
menu_bar_color_pace: bool,
providers_sorted_alphabetically: bool,
show_as_used: bool,
show_all_token_accounts_in_menu: bool,
enable_animations: bool,
Expand Down Expand Up @@ -982,6 +983,7 @@ impl From<Settings> for SettingsSnapshot {
menu_bar_shows_highest_usage: settings.menu_bar_shows_highest_usage,
menu_bar_shows_percent: settings.menu_bar_shows_percent,
menu_bar_color_pace: settings.menu_bar_color_pace,
providers_sorted_alphabetically: settings.providers_sorted_alphabetically,
show_as_used: settings.show_as_used,
show_all_token_accounts_in_menu: settings.show_all_token_accounts_in_menu,
enable_animations: settings.enable_animations,
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop-tauri/src-tauri/src/commands/locale_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ mod locale_tests {
.entries
.get("ProviderSidebarSearch")
.map(String::as_str),
Some("Search"),
Some("Search providers"),
"ProviderSidebarSearch should resolve instead of leaking the key"
);
assert_eq!(bundle.entries.len(), locale::LocaleKey::ALL.len());
Expand Down
16 changes: 16 additions & 0 deletions apps/desktop-tauri/src-tauri/src/commands/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub struct SettingsUpdate {
pub menu_bar_shows_highest_usage: Option<bool>,
pub menu_bar_shows_percent: Option<bool>,
pub menu_bar_color_pace: Option<bool>,
pub providers_sorted_alphabetically: Option<bool>,
pub show_as_used: Option<bool>,
pub show_all_token_accounts_in_menu: Option<bool>,
pub enable_animations: Option<bool>,
Expand Down Expand Up @@ -298,6 +299,9 @@ impl SettingsUpdate {
if let Some(v) = self.menu_bar_color_pace {
settings.menu_bar_color_pace = v;
}
if let Some(v) = self.providers_sorted_alphabetically {
settings.providers_sorted_alphabetically = v;
}
if let Some(v) = self.show_all_token_accounts_in_menu {
settings.show_all_token_accounts_in_menu = v;
}
Expand Down Expand Up @@ -855,6 +859,18 @@ mod tests {
assert!(!settings.menu_bar_color_pace);
}

#[test]
fn providers_sidebar_sort_applies_without_touching_order_or_tray() {
let mut settings = Settings::default();
let order = settings.provider_order.clone();
let update: SettingsUpdate =
serde_json::from_str(r#"{"providersSortedAlphabetically":true}"#).unwrap();
assert!(!update.refreshes_tray_presentation());
update.apply_display_settings(&mut settings);
assert!(settings.providers_sorted_alphabetically);
assert_eq!(settings.provider_order, order);
}

#[test]
fn stacked_tray_update_accepts_mode_and_clears_automatic_provider() {
let mut settings = Settings {
Expand Down
18 changes: 18 additions & 0 deletions apps/desktop-tauri/src-tauri/src/proof_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//! - `settings:menuBar` — show settings on the Menu Bar tab
//! - `settings:usageSpend` — show settings on the Usage & Spend tab
//! - `settings:about` — show settings on the About tab
//! - `settings:providers:codex` — show settings on the Codex provider pane
//!
//! In proof mode the shell immediately transitions to the requested surface
//! and suppresses blur-dismiss so the window stays visible for automated
Expand Down Expand Up @@ -523,6 +524,23 @@ mod tests {
});
}

#[test]
fn parse_settings_provider_pane_proof_target() {
with_proof_mode_env(Some("settings:providers:codex"), || {
let cfg = ProofConfig::from_env().unwrap();
assert_eq!(cfg.settings_tab.as_deref(), Some("providers:codex"));
assert_eq!(
cfg.surface_target(),
SurfaceTarget::Settings {
tab: "providers:codex".into()
}
);
});
with_proof_mode_env(Some("settings:providers:nope"), || {
assert!(ProofConfig::from_env().is_none());
});
}

#[test]
fn retired_popout_provider_proof_targets_are_rejected() {
// The legacy PopOut layout (with provider deep links) is retired;
Expand Down
13 changes: 8 additions & 5 deletions apps/desktop-tauri/src-tauri/src/shell/settings_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ use tauri::{Emitter, Manager, PhysicalPosition, WebviewUrl};
use super::activation::{self, Activation};

const SETTINGS_LABEL: &str = "settings";
const SETTINGS_WIDTH: f64 = 720.0;
const SETTINGS_HEIGHT: f64 = 580.0;
use crate::surface::{
SETTINGS_WINDOW_HEIGHT, SETTINGS_WINDOW_MIN_HEIGHT, SETTINGS_WINDOW_MIN_WIDTH,
SETTINGS_WINDOW_WIDTH,
};

/// Open the detached Settings window, or focus it if already open.
///
Expand All @@ -32,7 +34,8 @@ pub fn open_or_focus(app: &tauri::AppHandle, tab: &str) -> Result<(), String> {
// `activation::apply` below decides whether it takes focus.
let win = tauri::WebviewWindowBuilder::new(app, SETTINGS_LABEL, url)
.title("CodexBar Settings")
.inner_size(SETTINGS_WIDTH, SETTINGS_HEIGHT)
.inner_size(SETTINGS_WINDOW_WIDTH, SETTINGS_WINDOW_HEIGHT)
.min_inner_size(SETTINGS_WINDOW_MIN_WIDTH, SETTINGS_WINDOW_MIN_HEIGHT)
.decorations(false)
.shadow(false)
.theme(Some(tauri::Theme::Dark))
Expand All @@ -50,8 +53,8 @@ pub fn open_or_focus(app: &tauri::AppHandle, tab: &str) -> Result<(), String> {
let pos = monitor.position();
let size = monitor.size();
let scale = win.scale_factor().unwrap_or(1.0);
let win_w = (SETTINGS_WIDTH * scale) as i32;
let win_h = (SETTINGS_HEIGHT * scale) as i32;
let win_w = (SETTINGS_WINDOW_WIDTH * scale) as i32;
let win_h = (SETTINGS_WINDOW_HEIGHT * scale) as i32;
let x = pos.x + (size.width as i32 - win_w) / 2;
let y = pos.y + (size.height as i32 - win_h) / 2;
let _ = win.set_position(PhysicalPosition::new(x, y));
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop-tauri/src-tauri/src/shell/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ fn larger_visible_destination_reclamps_preserved_top_left() {
let reclamped =
reclamp_preserved_visible_position(current_top_left, &monitor, SurfaceMode::Settings, 1.0);

assert_eq!(reclamped, (1416, 492));
assert_eq!(reclamped, (1032, 452));
}

#[test]
Expand Down
23 changes: 17 additions & 6 deletions apps/desktop-tauri/src-tauri/src/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ impl SurfaceMode {
visible: true,
decorations: true,
resizable: true,
width: 496.0,
height: 580.0,
min_width: None,
min_height: None,
width: SETTINGS_WINDOW_WIDTH,
height: SETTINGS_WINDOW_HEIGHT,
min_width: Some(SETTINGS_WINDOW_MIN_WIDTH),
min_height: Some(SETTINGS_WINDOW_MIN_HEIGHT),
always_on_top: false,
blur_dismiss: false,
skip_taskbar: false,
Expand All @@ -96,6 +96,15 @@ impl SurfaceMode {
}
}

/// Settings window size (logical px): sidebar plus detail column, as the
/// macOS 0.70 Settings window. Shared by the main-window Settings surface and
/// the detached Settings window; the frontend `applySettingsWindowSize`
/// mirrors these numbers.
pub const SETTINGS_WINDOW_WIDTH: f64 = 880.0;
pub const SETTINGS_WINDOW_HEIGHT: f64 = 620.0;
pub const SETTINGS_WINDOW_MIN_WIDTH: f64 = 800.0;
pub const SETTINGS_WINDOW_MIN_HEIGHT: f64 = 540.0;

/// Describes what the window should look like in a given surface mode.
#[derive(Debug, Clone)]
pub struct WindowProperties {
Expand Down Expand Up @@ -328,8 +337,10 @@ mod tests {
#[test]
fn settings_properties() {
let props = SurfaceMode::Settings.window_properties();
assert_eq!(props.width, 496.0);
assert_eq!(props.height, 580.0);
assert_eq!(props.width, 880.0);
assert_eq!(props.height, 620.0);
assert_eq!(props.min_width, Some(800.0));
assert_eq!(props.min_height, Some(540.0));
}

#[test]
Expand Down
29 changes: 28 additions & 1 deletion apps/desktop-tauri/src-tauri/src/surface_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::surface::SurfaceMode;

// Must mirror the frontend `SettingsTabId` union
// (apps/desktop-tauri/src/types/bridge.ts) and `TAB_META` in
// apps/desktop-tauri/src/surfaces/Settings.tsx.
// apps/desktop-tauri/src/surfaces/settings/settingsTabs.ts.
const SETTINGS_TAB_IDS: &[&str] = &[
"general",
"providers",
Expand Down Expand Up @@ -81,7 +81,14 @@ impl SurfaceTarget {
}
}

/// A settings tab id, or `providers:<cli_name>` for one provider's pane in
/// the Settings sidebar (frontend `parseSettingsTabRequest`). Only the exact
/// canonical `cli_name` is accepted, not CLI aliases such as `openai`.
pub fn is_supported_settings_tab(tab: &str) -> bool {
if let Some(provider) = tab.strip_prefix("providers:") {
return codexbar::core::ProviderId::from_cli_name(provider)
.is_some_and(|id| id.cli_name() == provider);
}
SETTINGS_TAB_IDS.contains(&tab)
}

Expand Down Expand Up @@ -168,4 +175,24 @@ mod tests {
assert!(!is_supported_settings_tab("apiKeys"));
assert!(!is_supported_settings_tab("security"));
}

#[test]
fn provider_pane_tabs_need_a_known_provider() {
assert!(is_supported_settings_tab("providers:codex"));
assert!(is_supported_settings_tab("providers:claude"));
assert!(!is_supported_settings_tab("providers:nope"));
assert!(!is_supported_settings_tab("providers:"));
assert!(!is_supported_settings_tab("providers:openai"));
assert!(!is_supported_settings_tab("apiKeys"));
}

#[test]
fn every_provider_catalog_id_is_a_valid_provider_pane_tab() {
// The Settings catalog sends `cli_name` as the provider id, and the
// sidebar builds `providers:<id>` from it.
for id in codexbar::core::ProviderId::all() {
let tab = format!("providers:{}", id.cli_name());
assert!(is_supported_settings_tab(&tab), "{tab} rejected");
}
}
}
1 change: 1 addition & 0 deletions apps/desktop-tauri/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ function settings(overrides: Partial<SettingsSnapshot> = {}): SettingsSnapshot {
menuBarShowsHighestUsage: false,
menuBarShowsPercent: false,
menuBarColorPace: false,
providersSortedAlphabetically: false,
showAsUsed: true,
showAllTokenAccountsInMenu: false,
enableAnimations: true,
Expand Down
1 change: 1 addition & 0 deletions apps/desktop-tauri/src/floatbar/FloatBar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ function settings(overrides: Partial<SettingsSnapshot> = {}): SettingsSnapshot {
menuBarShowsHighestUsage: false,
menuBarShowsPercent: false,
menuBarColorPace: false,
providersSortedAlphabetically: false,
showAsUsed: true,
showAllTokenAccountsInMenu: false,
enableAnimations: true,
Expand Down
7 changes: 7 additions & 0 deletions apps/desktop-tauri/src/i18n/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,13 @@ export const ALL_LOCALE_KEYS = [
"ProviderSidebarReorderHint",
"ProviderSidebarMoveUp",
"ProviderSidebarMoveDown",
"SettingsSidebarSortProviders",
"SettingsSidebarSortOffHint",
"SettingsSidebarSortOnHint",
"SettingsSidebarProvidersOnCount",
"ProviderContextEnable",
"ProviderContextDisable",
"SettingsSidebarAriaLabel",
"ProviderStatusOk",
"ProviderStatusStale",
"ProviderStatusError",
Expand Down
Loading