From 9875e503a43dd4c615ada7b57968bae05dfd0bd5 Mon Sep 17 00:00:00 2001 From: KimiSwitch Dev Date: Mon, 6 Jul 2026 17:40:17 +0800 Subject: [PATCH] refactor: redact secrets in Debug output --- src-tauri/src/config_io.rs | 2 ++ src-tauri/src/models.rs | 28 ++++++++++++++++++++++++++-- src-tauri/src/profile_manager.rs | 2 ++ src-tauri/src/validators.rs | 1 + 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/config_io.rs b/src-tauri/src/config_io.rs index e69de29..46a0f76 100644 --- a/src-tauri/src/config_io.rs +++ b/src-tauri/src/config_io.rs @@ -0,0 +1,2 @@ +//! Configuration file I/O for KimiSwitch. +//! Reads and writes the global config file and profile files. diff --git a/src-tauri/src/models.rs b/src-tauri/src/models.rs index bcadabe..eb4ec10 100644 --- a/src-tauri/src/models.rs +++ b/src-tauri/src/models.rs @@ -28,7 +28,7 @@ impl ProviderType { } } -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Clone, Serialize, Deserialize)] pub struct Provider { pub name: String, pub provider_type: ProviderType, @@ -39,6 +39,19 @@ pub struct Provider { pub raw_other: Table, } +impl std::fmt::Debug for Provider { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Provider") + .field("name", &self.name) + .field("provider_type", &self.provider_type) + .field("base_url", &self.base_url) + .field("api_key", &"") + .field("env", &"") + .field("raw_other", &"") + .finish() + } +} + #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Model { pub alias: String, @@ -50,7 +63,7 @@ pub struct Model { pub raw_other: Table, } -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Clone, Serialize, Deserialize)] pub struct Config { pub default_model: Option, pub providers: IndexMap, @@ -59,6 +72,17 @@ pub struct Config { pub raw_other: Table, } +impl std::fmt::Debug for Config { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Config") + .field("default_model", &self.default_model) + .field("providers", &format!("{} providers", self.providers.len())) + .field("models", &self.models) + .field("raw_other", &"
") + .finish() + } +} + #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ProfileSummary { pub name: String, diff --git a/src-tauri/src/profile_manager.rs b/src-tauri/src/profile_manager.rs index e69de29..236d135 100644 --- a/src-tauri/src/profile_manager.rs +++ b/src-tauri/src/profile_manager.rs @@ -0,0 +1,2 @@ +//! Profile management for KimiSwitch. +//! Loads, saves, and switches between configuration profiles. diff --git a/src-tauri/src/validators.rs b/src-tauri/src/validators.rs index e69de29..a0b22e4 100644 --- a/src-tauri/src/validators.rs +++ b/src-tauri/src/validators.rs @@ -0,0 +1 @@ +//! Validation helpers for KimiSwitch configuration and command inputs.