refactor(backend): phase 4 - extract provider service layer
Architecture improvements: - Extract ProviderService with switch/backfill/write methods - Reduce command layer from 160 to 13 lines via delegation - Separate business logic (services) from state management (commands) - Introduce precise error handling with structured validation Refactoring details: - Split Codex/Claude switching into symmetric private methods - Add multi-layer validation for Codex auth field (existence + type) - Extract import_config_from_path for command and test reuse - Expose export_config_to_file and ProviderService in public API Test coverage: - Add 10+ integration tests for Claude/Codex switching flows - Cover import/export success and failure scenarios (JSON parse, missing file) - Verify state consistency on error paths (current remains unchanged) - Test snapshot backfill for both old and new providers after switching
This commit is contained in:
@@ -13,17 +13,21 @@ mod provider;
|
||||
mod settings;
|
||||
mod speedtest;
|
||||
mod store;
|
||||
mod services;
|
||||
mod usage_script;
|
||||
|
||||
pub use app_config::{AppType, MultiAppConfig};
|
||||
pub use codex_config::{get_codex_auth_path, get_codex_config_path, write_codex_live_atomic};
|
||||
pub use config::{get_claude_mcp_path, get_claude_settings_path, read_json_file};
|
||||
pub use import_export::{create_backup, sync_current_providers_to_live};
|
||||
pub use import_export::{
|
||||
create_backup, export_config_to_file, import_config_from_path, sync_current_providers_to_live,
|
||||
};
|
||||
pub use provider::Provider;
|
||||
pub use settings::{update_settings, AppSettings};
|
||||
pub use mcp::{import_from_claude, import_from_codex, sync_enabled_to_claude, sync_enabled_to_codex};
|
||||
pub use error::AppError;
|
||||
pub use store::AppState;
|
||||
pub use services::ProviderService;
|
||||
pub use commands::*;
|
||||
|
||||
use tauri::{
|
||||
|
||||
Reference in New Issue
Block a user