Skip to content
Draft
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: 1 addition & 1 deletion src-tauri/src/cli/commands/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ fn show_path() -> Result<(), AppError> {
Ok(())
}

fn export_config(file: &PathBuf) -> Result<(), AppError> {
fn export_config(file: &Path) -> Result<(), AppError> {
println!(
"{}",
info(&format!("Exporting configuration to {}...", file.display()))
Expand Down
10 changes: 5 additions & 5 deletions src-tauri/src/cli/commands/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,27 +530,27 @@ fn extract_claude_config(settings_config: &serde_json::Value) -> ClaudeConfig {
.get("ANTHROPIC_AUTH_TOKEN")
.or_else(|| env.get("ANTHROPIC_API_KEY"))
.and_then(|v| v.as_str())
.map(|s| mask_api_key(s)),
.map(mask_api_key),
base_url: env
.get("ANTHROPIC_BASE_URL")
.and_then(|v| v.as_str())
.map(|s| s.to_string()),
model: env
.get("ANTHROPIC_MODEL")
.and_then(|v| v.as_str())
.map(|s| simplify_model_name(s)),
.map(simplify_model_name),
haiku_model: env
.get("ANTHROPIC_DEFAULT_HAIKU_MODEL")
.and_then(|v| v.as_str())
.map(|s| simplify_model_name(s)),
.map(simplify_model_name),
sonnet_model: env
.get("ANTHROPIC_DEFAULT_SONNET_MODEL")
.and_then(|v| v.as_str())
.map(|s| simplify_model_name(s)),
.map(simplify_model_name),
opus_model: env
.get("ANTHROPIC_DEFAULT_OPUS_MODEL")
.and_then(|v| v.as_str())
.map(|s| simplify_model_name(s)),
.map(simplify_model_name),
}
} else {
ClaudeConfig::default()
Expand Down
2 changes: 0 additions & 2 deletions src-tauri/src/cli/commands/provider_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ pub fn generate_provider_id(name: &str, existing_ids: &[String]) -> String {
.chars()
.map(|c| if c.is_alphanumeric() || c == '-' || c == '_' {
c
} else if c.is_whitespace() {
'-'
} else {
'-'
})
Expand Down
54 changes: 9 additions & 45 deletions src-tauri/src/cli/i18n.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,19 +835,11 @@ pub mod texts {
}

pub fn auth_type_api_key() -> &'static str {
if is_chinese() {
"API Key"
} else {
"API Key"
}
"API Key"
}

pub fn auth_type_service_account() -> &'static str {
if is_chinese() {
"Service Account (ADC)"
} else {
"Service Account (ADC)"
}
"Service Account (ADC)"
}

pub fn gemini_api_key_label() -> &'static str {
Expand Down Expand Up @@ -915,11 +907,7 @@ pub mod texts {
}

pub fn packycode_api_key() -> &'static str {
if is_chinese() {
"PackyCode API Key"
} else {
"PackyCode API Key"
}
"PackyCode API Key"
}

pub fn generic_api_key() -> &'static str {
Expand Down Expand Up @@ -1084,11 +1072,7 @@ pub mod texts {
}

pub fn id_label() -> &'static str {
if is_chinese() {
"ID"
} else {
"ID"
}
"ID"
}

pub fn website_label() -> &'static str {
Expand Down Expand Up @@ -1201,19 +1185,11 @@ pub mod texts {
}

pub fn api_key_display_label() -> &'static str {
if is_chinese() {
"API Key"
} else {
"API Key"
}
"API Key"
}

pub fn base_url_display_label() -> &'static str {
if is_chinese() {
"Base URL"
} else {
"Base URL"
}
"Base URL"
}

pub fn model_config_header() -> &'static str {
Expand All @@ -1233,27 +1209,15 @@ pub mod texts {
}

pub fn haiku_model_display() -> &'static str {
if is_chinese() {
"Haiku"
} else {
"Haiku"
}
"Haiku"
}

pub fn sonnet_model_display() -> &'static str {
if is_chinese() {
"Sonnet"
} else {
"Sonnet"
}
"Sonnet"
}

pub fn opus_model_display() -> &'static str {
if is_chinese() {
"Opus"
} else {
"Opus"
}
"Opus"
}

pub fn auth_type_display_label() -> &'static str {
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/cli/interactive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ fn view_current_config(app_type: &AppType) -> Result<(), AppError> {
if let Some(provider) = providers.get(&current_provider) {
println!("\n{}", highlight(texts::provider_label()));
println!(" 名称: {}", provider.name);
let api_url = provider::extract_api_url(&provider.settings_config, &app_type)
let api_url = provider::extract_api_url(&provider.settings_config, app_type)
.unwrap_or_else(|| "N/A".to_string());
println!(" API URL: {}", api_url);
}
Expand Down
10 changes: 5 additions & 5 deletions src-tauri/src/cli/interactive/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,27 +426,27 @@ fn extract_claude_config(settings_config: &serde_json::Value) -> ClaudeConfig {
.get("ANTHROPIC_AUTH_TOKEN")
.or_else(|| env.get("ANTHROPIC_API_KEY"))
.and_then(|v| v.as_str())
.map(|s| mask_api_key(s)),
.map(mask_api_key),
base_url: env
.get("ANTHROPIC_BASE_URL")
.and_then(|v| v.as_str())
.map(|s| s.to_string()),
model: env
.get("ANTHROPIC_MODEL")
.and_then(|v| v.as_str())
.map(|s| simplify_model_name(s)),
.map(simplify_model_name),
haiku_model: env
.get("ANTHROPIC_DEFAULT_HAIKU_MODEL")
.and_then(|v| v.as_str())
.map(|s| simplify_model_name(s)),
.map(simplify_model_name),
sonnet_model: env
.get("ANTHROPIC_DEFAULT_SONNET_MODEL")
.and_then(|v| v.as_str())
.map(|s| simplify_model_name(s)),
.map(simplify_model_name),
opus_model: env
.get("ANTHROPIC_DEFAULT_OPUS_MODEL")
.and_then(|v| v.as_str())
.map(|s| simplify_model_name(s)),
.map(simplify_model_name),
}
} else {
ClaudeConfig::default()
Expand Down
19 changes: 10 additions & 9 deletions src-tauri/src/services/speedtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,21 @@ mod tests {
);
}

#[test]
fn test_endpoints_handles_empty_list() {
let result =
tauri::async_runtime::block_on(SpeedtestService::test_endpoints(Vec::new(), Some(5)))
.expect("empty list should succeed");
#[tokio::test]
async fn test_endpoints_handles_empty_list() {
let result = SpeedtestService::test_endpoints(Vec::new(), Some(5))
.await
.expect("empty list should succeed");
assert!(result.is_empty());
}

#[test]
fn test_endpoints_reports_invalid_url() {
let result = tauri::async_runtime::block_on(SpeedtestService::test_endpoints(
#[tokio::test]
async fn test_endpoints_reports_invalid_url() {
let result = SpeedtestService::test_endpoints(
vec!["not a url".into(), "".into()],
None,
))
)
.await
.expect("invalid inputs should still succeed");

assert_eq!(result.len(), 2);
Expand Down