From 07fc6b175e468f8df2f255d93b4b52a20c306410 Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 23 Jan 2026 09:45:57 +0800 Subject: [PATCH] fix(proxy): change rectifier default state to disabled Change the default state of the rectifier from enabled to disabled. This allows users to opt-in to the rectifier feature rather than having it enabled by default. Changes: - Set RectifierConfig::default() enabled and request_thinking_signature to false - Update serde default attributes from default_true to default - Update unit tests to reflect new default behavior --- src-tauri/src/proxy/types.rs | 39 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src-tauri/src/proxy/types.rs b/src-tauri/src/proxy/types.rs index cbb20f98c..9ff8b5253 100644 --- a/src-tauri/src/proxy/types.rs +++ b/src-tauri/src/proxy/types.rs @@ -199,20 +199,20 @@ pub struct AppProxyConfig { #[serde(rename_all = "camelCase")] pub struct RectifierConfig { /// 总开关:是否启用整流器 - #[serde(default = "default_true")] + #[serde(default)] pub enabled: bool, /// 请求整流:启用 thinking 签名整流器 /// /// 处理错误:Invalid 'signature' in 'thinking' block - #[serde(default = "default_true")] + #[serde(default)] pub request_thinking_signature: bool, } impl Default for RectifierConfig { fn default() -> Self { Self { - enabled: true, - request_thinking_signature: true, + enabled: false, + request_thinking_signature: false, } } } @@ -270,35 +270,34 @@ mod tests { use super::*; #[test] - fn test_rectifier_config_default_enabled() { - // 验证 RectifierConfig::default() 返回全启用状态 - // 防止回归:#[derive(Default)] 会使 bool 默认为 false + fn test_rectifier_config_default_disabled() { + // 验证 RectifierConfig::default() 返回全禁用状态 let config = RectifierConfig::default(); - assert!(config.enabled, "整流器总开关默认应为 true"); + assert!(!config.enabled, "整流器总开关默认应为 false"); assert!( - config.request_thinking_signature, - "thinking 签名整流器默认应为 true" + !config.request_thinking_signature, + "thinking 签名整流器默认应为 false" ); } #[test] fn test_rectifier_config_serde_default() { - // 验证反序列化缺字段时使用 default_true + // 验证反序列化缺字段时使用默认值 false let json = "{}"; let config: RectifierConfig = serde_json::from_str(json).unwrap(); - assert!(config.enabled); - assert!(config.request_thinking_signature); - } - - #[test] - fn test_rectifier_config_serde_explicit_false() { - // 验证显式设置 false 时正确反序列化 - let json = r#"{"enabled": false, "requestThinkingSignature": false}"#; - let config: RectifierConfig = serde_json::from_str(json).unwrap(); assert!(!config.enabled); assert!(!config.request_thinking_signature); } + #[test] + fn test_rectifier_config_serde_explicit_true() { + // 验证显式设置 true 时正确反序列化 + let json = r#"{"enabled": true, "requestThinkingSignature": true}"#; + let config: RectifierConfig = serde_json::from_str(json).unwrap(); + assert!(config.enabled); + assert!(config.request_thinking_signature); + } + #[test] fn test_log_config_default() { let config = LogConfig::default();