support browser icons

This commit is contained in:
Julian Freeman
2026-04-16 15:25:57 -04:00
parent ac5bedd73f
commit 97d156f606
11 changed files with 140 additions and 26 deletions

View File

@@ -35,6 +35,7 @@ pub fn resolve_browser_configs(app: &AppHandle) -> Result<Vec<BrowserConfigEntry
id: config.id,
source: BrowserConfigSource::Custom,
browser_family_id: None,
icon_key: config.icon_key,
name: config.name,
executable_path: config.executable_path,
user_data_path: config.user_data_path,
@@ -50,6 +51,14 @@ pub fn create_custom_browser_config(
input: CreateCustomBrowserConfigInput,
) -> Result<BrowserConfigListResponse, String> {
let name = input.name.trim();
let icon_key = input.icon_key.and_then(|value| {
let trimmed = value.trim().to_string();
if trimmed.is_empty() {
None
} else {
Some(trimmed)
}
});
let executable_path = input.executable_path.trim();
let user_data_path = input.user_data_path.trim();
@@ -67,6 +76,7 @@ pub fn create_custom_browser_config(
stored.custom_configs.push(CustomBrowserConfigRecord {
id: generate_custom_config_id(),
name: name.to_string(),
icon_key,
executable_path: executable_path.to_string(),
user_data_path: user_data_path.to_string(),
});
@@ -117,6 +127,7 @@ fn default_browser_configs() -> Result<Vec<BrowserConfigEntry>, String> {
id: definition.id.to_string(),
source: BrowserConfigSource::Default,
browser_family_id: Some(definition.id.to_string()),
icon_key: Some(definition.id.to_string()),
name: definition.name.to_string(),
executable_path: resolve_browser_executable(definition.id)
.map(|path| path.display().to_string())

View File

@@ -14,6 +14,7 @@ pub struct BrowserView {
pub browser_id: String,
pub browser_family_id: Option<String>,
pub browser_name: String,
pub icon_key: Option<String>,
pub data_root: String,
pub profiles: Vec<ProfileSummary>,
pub extensions: Vec<ExtensionSummary>,
@@ -70,6 +71,7 @@ pub struct BrowserConfigEntry {
pub id: String,
pub source: BrowserConfigSource,
pub browser_family_id: Option<String>,
pub icon_key: Option<String>,
pub name: String,
pub executable_path: String,
pub user_data_path: String,
@@ -87,6 +89,7 @@ pub enum BrowserConfigSource {
#[serde(rename_all = "camelCase")]
pub struct CreateCustomBrowserConfigInput {
pub name: String,
pub icon_key: Option<String>,
pub executable_path: String,
pub user_data_path: String,
}
@@ -102,6 +105,8 @@ pub struct StoredBrowserConfigs {
pub struct CustomBrowserConfigRecord {
pub id: String,
pub name: String,
#[serde(default)]
pub icon_key: Option<String>,
pub executable_path: String,
pub user_data_path: String,
}

View File

@@ -91,6 +91,7 @@ fn scan_browser(config: BrowserConfigEntry) -> Option<BrowserView> {
browser_id: config.id,
browser_family_id: config.browser_family_id,
browser_name: config.name,
icon_key: config.icon_key,
data_root: root.display().to_string(),
stats: BrowserStats {
profile_count: profiles.len(),