feat: sync current providers to live files after config import

Core Improvements:
- Add sync_current_providers_live command to synchronize in-memory provider
  settings to corresponding live files (~/.claude/settings.json or ~/.codex/auth.json)
- Introduce partial-success state to distinguish between 'import succeeded
  but sync failed' scenario, providing clear user feedback
- Remove unused skip_live_backfill parameter from switch_provider command
- Separate responsibilities: backend handles import/backup, frontend handles
  sync/error presentation

Technical Details:
- Codex: sync auth.json + config.toml with MCP configuration
- Claude: sync settings.json
- Bidirectional sync: read back after write to update in-memory settings_config
- Full i18n support (English and Chinese)
- Graceful handling when no current provider is active

Affected Files:
- Backend: import_export.rs, commands.rs, lib.rs
- Frontend: useImportExport.ts, ImportExportSection.tsx, settings.ts
- i18n: en.json, zh.json

This ensures SSOT (Single Source of Truth) consistency between config.json
and live configuration files after import operations.
This commit is contained in:
Jason
2025-10-27 13:20:59 +08:00
parent 76a8d1760b
commit d064cb8555
8 changed files with 207 additions and 45 deletions

View File

@@ -11,8 +11,8 @@ mod migration;
mod provider;
mod settings;
mod speedtest;
mod usage_script;
mod store;
mod usage_script;
use store::AppState;
use tauri::{
@@ -509,6 +509,7 @@ pub fn run() {
import_export::import_config_from_file,
import_export::save_file_dialog,
import_export::open_file_dialog,
import_export::sync_current_providers_live,
update_tray_menu,
]);
@@ -537,4 +538,4 @@ pub fn run() {
let _ = (app_handle, event);
}
});
}
}