Skip to content

Commit 07fc6b1

Browse files
committed
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
1 parent 79d3ecc commit 07fc6b1

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

src-tauri/src/proxy/types.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -199,20 +199,20 @@ pub struct AppProxyConfig {
199199
#[serde(rename_all = "camelCase")]
200200
pub struct RectifierConfig {
201201
/// 总开关:是否启用整流器
202-
#[serde(default = "default_true")]
202+
#[serde(default)]
203203
pub enabled: bool,
204204
/// 请求整流:启用 thinking 签名整流器
205205
///
206206
/// 处理错误:Invalid 'signature' in 'thinking' block
207-
#[serde(default = "default_true")]
207+
#[serde(default)]
208208
pub request_thinking_signature: bool,
209209
}
210210

211211
impl Default for RectifierConfig {
212212
fn default() -> Self {
213213
Self {
214-
enabled: true,
215-
request_thinking_signature: true,
214+
enabled: false,
215+
request_thinking_signature: false,
216216
}
217217
}
218218
}
@@ -270,33 +270,32 @@ mod tests {
270270
use super::*;
271271

272272
#[test]
273-
fn test_rectifier_config_default_enabled() {
274-
// 验证 RectifierConfig::default() 返回全启用状态
275-
// 防止回归:#[derive(Default)] 会使 bool 默认为 false
273+
fn test_rectifier_config_default_disabled() {
274+
// 验证 RectifierConfig::default() 返回全禁用状态
276275
let config = RectifierConfig::default();
277-
assert!(config.enabled, "整流器总开关默认应为 true");
276+
assert!(!config.enabled, "整流器总开关默认应为 false");
278277
assert!(
279-
config.request_thinking_signature,
280-
"thinking 签名整流器默认应为 true"
278+
!config.request_thinking_signature,
279+
"thinking 签名整流器默认应为 false"
281280
);
282281
}
283282

284283
#[test]
285284
fn test_rectifier_config_serde_default() {
286-
// 验证反序列化缺字段时使用 default_true
285+
// 验证反序列化缺字段时使用默认值 false
287286
let json = "{}";
288287
let config: RectifierConfig = serde_json::from_str(json).unwrap();
289-
assert!(config.enabled);
290-
assert!(config.request_thinking_signature);
288+
assert!(!config.enabled);
289+
assert!(!config.request_thinking_signature);
291290
}
292291

293292
#[test]
294-
fn test_rectifier_config_serde_explicit_false() {
295-
// 验证显式设置 false 时正确反序列化
296-
let json = r#"{"enabled": false, "requestThinkingSignature": false}"#;
293+
fn test_rectifier_config_serde_explicit_true() {
294+
// 验证显式设置 true 时正确反序列化
295+
let json = r#"{"enabled": true, "requestThinkingSignature": true}"#;
297296
let config: RectifierConfig = serde_json::from_str(json).unwrap();
298-
assert!(!config.enabled);
299-
assert!(!config.request_thinking_signature);
297+
assert!(config.enabled);
298+
assert!(config.request_thinking_signature);
300299
}
301300

302301
#[test]

0 commit comments

Comments
 (0)