Commit Graph

63 Commits

  • docs: update user manual to v3.12.3 with new features coverage (en/zh/ja)
    Add documentation for features introduced since v3.12.0:
    
    New docs:
    - 3.4 Session Manager: browse, search, resume, delete sessions
    - 3.5 Workspace & Daily Memory: OpenClaw workspace file editing
    
    Updated docs:
    - Add Lightweight Mode to interface overview and FAQ
    - Add tray submenu structure (providers grouped by app)
    - Add API Format selection (Anthropic/OpenAI Chat/OpenAI Responses)
    - Add Auto-Fetch Models button documentation
    - Add Claude Common Config quick toggles
    - Add Codex 1M Context Window toggle
    - Add Skill backup/restore lifecycle
    - Expand Backup Management panel documentation
    - Update WebDAV sync to v2 protocol with dual-layer versioning
    - Add OpenCode/OpenClaw to quickstart activation table
    - Update README version to v3.12.3
    
    All changes synced across en, zh, and ja locales.
  • docs: fix outdated README content and sync across languages
    - Fix JA README macOS FAQ still claiming app is unsigned (now code-signed & notarized)
    - Update SessionManager description from "Claude Code only" to "all supported apps" (EN/ZH/JA)
    - Replace non-existent Flatpak download entry with self-build reference (EN/ZH/JA)
    - Add OpenCode and OpenClaw filesystem paths to Flatpak minimal permissions
    - Bump user manual version to v3.12.3
  • docs(release): add Copilot reverse proxy risk notice to v3.12.3 release notes
    Add risk disclaimer section in all three languages (EN/ZH/JA) warning
    users about potential GitHub ToS violations, account suspension risks,
    and no long-term availability guarantee for the Copilot reverse proxy.
  • chore(release): consolidate v3.12.3 release notes, changelog and test fixes
    Merge previously unreleased v3.12.4 content into v3.12.3:
    - CHANGELOG: combine [Unreleased] into [3.12.3], clear [Unreleased]
    - Release notes (zh/en/ja): add Copilot proxy, macOS signing,
      Reasoning Effort, OpenCode SQLite, Codex 1M toggle, Disable
      Auto-Upgrade toggle, and contributor thanks
    - Fix test mocks for skill backup/restore hooks
    - Fix schema migration test missing providers table
    - Fix TempHome to save/restore CC_SWITCH_TEST_HOME env var
  • feat(ci): add macOS code signing and Apple notarization to release workflow
    - Import Developer ID Application certificate into temporary keychain
    - Inject APPLE_SIGNING_IDENTITY/APPLE_ID/APPLE_PASSWORD/APPLE_TEAM_ID
      into Tauri build step for automatic signing and notarization
    - Staple notarization tickets to both .app and .dmg (hard-fail)
    - Add verification step: codesign --verify + spctl -a + stapler validate
      for both .app and .dmg, gating the release on success
    - Collect .dmg alongside .tar.gz and .zip in release assets
    - Clean up temporary keychain with original default restored
    - Update release notes to recommend .dmg and note Apple notarization
    - Remove all xattr workarounds and "unidentified developer" warnings
      from README, README_ZH, installation guides, and FAQ (EN/ZH/JA)
  • chore(release): update release notes, changelog and macOS minimum version for v3.12.3
    Update CHANGELOG.md with full v3.12.3 entry, create release notes in
    three languages (en/zh/ja), bump macOS minimumSystemVersion from 10.15
    to 12.0 (Monterey) to match actual runtime requirements, and update
    README version badges and links.
  • feat(skills): auto-backup skill files before uninstall
    Create a local backup under ~/.cc-switch/skill-backups/ before removing
    skill directories. The backup includes all skill files and a meta.json
    with original skill metadata. Old backups are pruned to keep at most 20.
    The backup path is returned to the frontend and shown in the success
    toast. Bump version to 3.12.3.
  • feat: add StepFun provider presets and step-3.5-flash (#1369)
    * feat: add StepFun provider presets
    
    * docs: regroup StepFun pricing entry
    
    * docs: tweak StepFun zh label
    
    * style: apply prettier fixes
    
    * Revert "style: apply prettier fixes"
    
    This reverts commit cff7bf2e65.
  • docs: reorganize docs directory structure
    - Delete 9 completed planning/roadmap documents
    - Move 23 release notes into docs/release-notes/ with simplified filenames
    - Update all cross-references in READMEs, CHANGELOG, and release notes
    - Remove dangling doc reference in deeplink/mod.rs
  • docs: restructure user manual for i18n and add EN/JA translations
    Reorganize docs/user-manual/ from flat structure to language subdirectories
    (zh/, en/, ja/) with shared assets/. Move existing Chinese docs into zh/,
    fix image paths, add multilingual navigation README, and translate all 23
    markdown files (~4500 lines each) to English and Japanese.
  • docs: add OpenClaw coverage and complete settings docs for user manual
    - Add OpenClaw as the 5th supported app across all doc chapters (1-3, 5)
    - Add OpenClaw provider presets table to 2.1-add.md (30 presets)
    - Add OpenClaw config section to 5.1-config-files.md (JSON5 format)
    - Complete 1.5-settings.md with missing sections: app visibility,
      skill sync method, terminal settings, proxy tab, WebDAV cloud sync,
      backup/restore, and log configuration
    - Fix deeplink parser.rs to accept 'opencode' and 'openclaw' app types
    - Update 5.3-deeplink.md with new app type parameters
    - Remove incorrect OpenCode references from proxy docs (4.1-4.4)
  • docs: highlight Common Config Snippet removal as breaking change in release notes
    Expand the partial key-field merging section with Before/After explanation
    and migration guide. Mark it as a breaking change in Highlights and Notes
    sections across all three languages (zh/en/ja) and CHANGELOG.md.
  • chore: bump version to v3.11.0 and add release notes
    - Update version numbers in package.json, Cargo.toml, tauri.conf.json
    - Add CHANGELOG.md entry for v3.11.0
    - Add trilingual release notes (zh/en/ja)
    - Update user manual version info
  • docs: add user manual documentation (#979)
    * docs: add user manual documentation
    
    Add comprehensive user manual covering getting started, provider management,
    extensions (MCP/prompts/skills), proxy configuration, and FAQ sections.
    Includes screenshots and a README index.
    
    * fix(docs): align user manual with v3.10.3 codebase
    
    - Add OpenCode as 4th supported app throughout all docs
    - Fix proxy default port 15762 → 15721
    - Update Claude presets (9 → 26), Codex (3 → 10), Gemini (3 → 7)
    - Add OpenCode presets (25 entries)
    - Fix timeout defaults and ranges (stream first byte 60s/90s, etc.)
    - Fix circuit breaker defaults with per-app values (Claude vs general)
    - Fix Skills support: all 4 apps, not just Claude/Codex
    - Remove non-existent Gemini authMode field
    - Fix prompt deletion behavior: enabled prompts cannot be deleted
    - Remove non-existent Legacy deeplink protocol, use V1 only
    - Fix DB table names (usage_logs → proxy_request_logs) and add missing tables
    - Fix migration version v3.8.0 → v3.7.0
    - Add missing V1 deeplink parameters (config, configFormat, etc.)
    - Update doc version v3.9.1 → v3.10.3
    - Add claude-opus-4-1 to pricing table
    - Fix recovery wait time range 10-300 → 0-300
    
    ---------
    
    Co-authored-by: Jason <farion1231@gmail.com>
  • docs: add OpenCode implementation plan
    Add comprehensive implementation plan for OpenCode (4th app) support:
    - Additive provider management (vs. replacement model)
    - MCP format conversion (stdio<->local, sse<->remote)
    - Config file: ~/.config/opencode/opencode.json
    - No proxy/failover support (OpenCode handles internally)
  • docs: update v3.9.0 release notes with acknowledgments and improved macOS instructions
    - Add special thanks section for contributors @xunyu @deijing @su-fen
    - Update macOS tip: replace xattr command with System Settings GUI guidance
    - Reformat markdown tables with aligned columns
    - Move Linux section after Homebrew section
  • docs: enhance download section with detailed installation guide for v3.9.0
    - Convert system requirements to table format with architecture info
    - Add Windows/macOS file descriptions with recommended options
    - Replace Linux section with comprehensive distro-based table
    - Include complete installation commands for deb/rpm/AppImage/flatpak
    - Add helpful tips for macOS Gatekeeper and AppImage usage
  • docs: add download options for each system version in 3.9.0 release note (#547)
    * docs: add download options for each system version in 3.9.0 release note.
    
    * docs: add download options for each system version in 3.9.0 release note.
  • chore(release): prepare v3.9.0 stable release
    - Bump version from 3.9.0-3 to 3.9.0 across all config files
    - Add comprehensive release notes in English, Chinese, and Japanese
    - Update CHANGELOG with v3.9.0 stable and v3.9.0-2 entries
    - Update README badges and release note links to v3.9.0
  • chore: bump version to 3.9.0-beta.1
    - Update version in package.json, Cargo.toml, tauri.conf.json
    - Add CHANGELOG entry for v3.9.0-beta.1 with:
      - Local Proxy Server feature
      - Auto Failover with circuit breaker
      - Skills multi-app support
      - Provider icon colors
      - 25+ bug fixes
    - Add proxy feature guide documentation (Chinese)
  • docs: add v3.8.0 release documentation and Japanese README
    - Add CHANGELOG entry for v3.8.0
    - Update README.md and README_ZH.md with v3.8.0 features
    - Add Japanese README (README_JA.md)
    - Add release notes in English, Chinese, and Japanese
  • docs: add v3.7.1 release documentation
    Add release notes for v3.7.1 maintenance release, with v3.7.1 updates at top and complete v3.7.0 documentation below.
    
    **v3.7.1 Updates**:
    - Bug Fixes: Skills installation, Gemini config persistence, dialog overlay protection
    - New Features: Gemini config directory support, ArchLinux installation
    - Improvements: Skills error i18n enhancement (28+ keys), code formatting
    
    **v3.7.0 Complete Documentation**:
    - Six major features (Gemini CLI, MCP v3.7.0, Skills, Prompts, Deep Link, Conflict Detection)
    - Technical statistics (152 files, +18,104 / -3,732 lines)
    - Strategic positioning shift: Provider Switcher → AI CLI Management Platform
    
    Files:
    - docs/release-note-v3.7.1-zh.md (Chinese)
    - docs/release-note-v3.7.1-en.md (English)
  • docs: add v3.7.0 release documentation
    - Update CHANGELOG.md with v3.7.0 entry covering six major features
    - Add English release notes (docs/release-note-v3.7.0-en.md)
    - Add Chinese release notes (docs/release-note-v3.7.0-zh.md)
    
    Major features documented:
    - Gemini CLI integration (third app support)
    - MCP v3.7.0 unified architecture
    - Claude Skills management system (~2,000 lines)
    - Prompts management system (~1,300 lines)
    - Deep link protocol (ccswitch://)
    - Environment variable conflict detection
  • docs: add Codex MCP raw TOML refactor plan
    Add comprehensive implementation plan for v3.7.0 refactor that
    separates Codex MCP configuration from unified MCP structure.
    
    Key design decisions:
    - Codex MCP stored as raw TOML string in codexMcp.rawToml
    - Unified MCP (mcp.servers) only supports Claude/Gemini
    - Complete isolation: no apps.codex in unified structure
    - Migration clears mcp.codex.servers to prevent pollution
    
    Architecture improvements:
    - Single responsibility: each data source has one purpose
    - No priority conflicts: completely independent data paths
    - Simplified switching logic: no conditional branches
    - UI constraints: Tab1 limited to claude/gemini only
    
    Implementation phases:
    - Phase 0: Setup (0.5d)
    - Phase 1: Backend foundation (1.5d)
    - Phase 2: Command layer (1d)
    - Phase 3: Switching logic (1d)
    - Phase 4: Frontend API (0.5d)
    - Phase 5: UI implementation (2d)
    - Phase 6: Enhancements (1d, optional)
    - Phase 7: Testing & docs (1d)
    
    Total: 8.5 days (MVP: 7 days)
    
    Addresses TOML-JSON conversion data loss issue by preserving
    raw TOML format for Codex while maintaining structured approach
    for Claude/Gemini.
  • docs: add comprehensive v3.7.0 unified MCP refactor plan
    ## Document Overview
    Created detailed refactoring plan document covering:
    - Project goals and architecture changes
    - Data structure migration strategy (v3.6.x → v3.7.0)
    - Complete development progress tracking
    - Frontend remaining tasks roadmap
    - Testing plan and delivery checklist
    
    ## Completed Work (Documented)
     Phase 1: Backend data structure migration
      - McpApps, McpServer, McpRoot definitions
      - Automatic migration logic
      - Integration into load() method
    
     Phase 2: Backend services refactor
      - Complete McpService rewrite
      - Single-server sync functions
      - New Tauri commands
      - Backward compatibility layer
      - All compilation errors fixed
    
     Phase 3 (Partial): Frontend types and API
      - Updated TypeScript types (McpApps, McpServer)
      - New API methods (getAllServers, toggleApp, etc.)
    
    ## Remaining Work (Documented)
    📝 React Query hooks (useMcp.ts)
    📝 UnifiedMcpPanel component
    📝 i18n translations
    📝 Main app integration
    📝 Sub-components (table, form, import dialog)
    
    ## Key Highlights
    - Detailed UI wireframes and component structure
    - Step-by-step migration flow documentation
    - Risk assessment and mitigation strategies
    - Technical insights and architecture benefits
    
    Related: v3.7.0 unified MCP management
  • chore(release): prepare for v3.6.1 release
    - Bump version to 3.6.1 across all config files
      - package.json, Cargo.toml, tauri.conf.json
      - README.md and README_ZH.md version badges
      - Auto-updated Cargo.lock
    - Add release notes documentation
      - docs/release-note-v3.6.0-en.md (archive)
      - docs/release-note-v3.6.1-zh.md (cumulative format)
      - docs/release-note-v3.6.1-en.md (cumulative format)
    - Enlarge PackyCode sponsor logo by 50% (100px → 150px)
    - Update roadmap checklist (homebrew support marked as done)
  • docs: add v3.6.0 release notes and update READMEs with missing features
    **Release Notes**
    - Create Chinese v3.6.0 release notes in docs/ folder
    
    **README Updates**
    Add documentation for three missing v3.6.0 features:
    
    1. Claude Configuration Data Structure Enhancements
       - Granular model configuration: migrated from dual-key to quad-key system
       - New fields: ANTHROPIC_DEFAULT_HAIKU_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL,
         ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_MODEL
       - Replaces legacy ANTHROPIC_SMALL_FAST_MODEL with automatic migration
       - Backend normalizes old configs with smart fallback chain
       - UI expanded from 2 to 4 model input fields
    
    2. Updated Provider Models
       - Kimi: updated to latest kimi-k2-thinking model (from k1 series)
       - Removed legacy KimiModelSelector component
    
    3. Custom Configuration Directory (Cloud Sync Support)
       - Customize CC Switch's configuration storage location
       - Point to cloud sync folders (Dropbox, OneDrive, iCloud, etc.)
         to enable automatic config synchronization across devices
       - Managed via Tauri Store for better isolation
    
    **Files Changed**
    - README.md & README_ZH.md: added feature documentation
    - docs/release-note-v3.6.0-zh.md: comprehensive Chinese release notes
  • refactor(types): rename AppType to AppId for semantic clarity
    Rename `AppType` to `AppId` across the entire frontend codebase to better
    reflect its purpose as an application identifier rather than a type category.
    This aligns frontend naming with backend command parameter conventions.
    
    Changes:
    - Rename type `AppType` to `AppId` in src/lib/api/types.ts
    - Remove `AppType` export from src/lib/api/index.ts
    - Update all component props from `appType` to `appId` (43 files)
    - Update all variable names from `appType` to `appId`
    - Synchronize documentation (CHANGELOG, refactoring plans)
    - Update test files and MSW mocks
    
    BREAKING CHANGE: `AppType` type is no longer exported. Use `AppId` instead.
    All component props have been renamed from `appType` to `appId`.
  • refactor(api): unify AppType parsing with FromStr trait
    BREAKING CHANGE: Remove support for legacy app_type/appType parameters.
    All Tauri commands now accept only the 'app' parameter (values: "claude" or "codex").
    Invalid app values will return localized error messages with allowed values.
    
    This commit addresses code duplication and improves error handling:
    
    - Consolidate AppType parsing into FromStr trait implementation
      * Eliminates duplicate parse_app() functions across 3 command modules
      * Provides single source of truth for app type validation
      * Enables idiomatic Rust .parse::<AppType>() syntax
    
    - Enhance error messages with localization
      * Return bilingual error messages (Chinese + English)
      * Include list of allowed values in error responses
      * Use structured AppError::localized for better categorization
    
    - Add input normalization
      * Case-insensitive matching ("CLAUDE" → AppType::Claude)
      * Automatic whitespace trimming (" codex \n" → AppType::Codex)
      * Improves API robustness against user input variations
    
    - Introduce comprehensive unit tests
      * Test valid inputs with case variations
      * Test whitespace handling
      * Verify error message content and localization
      * 100% coverage of from_str logic
    
    - Update documentation
      * Add CHANGELOG entry marking breaking change
      * Update README with accurate architecture description
      * Revise REFACTORING_MASTER_PLAN with migration examples
      * Remove all legacy app_type/appType references
    
    Code Quality Metrics:
    - Lines removed: 27 (duplicate code)
    - Lines added: 52 (including tests and docs)
    - Code duplication: 3 → 0 instances
    - Test coverage: 0% → 100% for AppType parsing
  • refactor(backend): extract config and speedtest services (phase 4)
    This commit continues the backend refactoring initiative by extracting
    configuration management and API speedtest logic into dedicated service
    layers, completing phase 4 of the architectural improvement plan.
    
    ## Changes
    
    ### New Service Layers
    - **ConfigService** (`services/config.rs`): Consolidates all config
      import/export, backup management, and live sync operations
      - `create_backup()`: Creates timestamped backups with auto-cleanup
      - `export_config_to_path()`: Exports config to specified path
      - `load_config_for_import()`: Loads and validates imported config
      - `import_config_from_path()`: Full import with state update
      - `sync_current_providers_to_live()`: Syncs current providers to live files
      - Private helpers for Claude/Codex-specific sync logic
    
    - **SpeedtestService** (`services/speedtest.rs`): Encapsulates endpoint
      latency testing with proper validation and error handling
      - `test_endpoints()`: Tests multiple URLs concurrently
      - URL validation now unified in service layer
      - Includes 3 unit tests for edge cases (empty list, invalid URLs, timeout clamping)
    
    ### Command Layer Refactoring
    - Move all import/export commands to `commands/import_export.rs`
    - Commands become thin wrappers: parse params → call service → return JSON
    - Maintain `spawn_blocking` for I/O operations (phase 5 optimization)
    - Lock acquisition happens after I/O completes (minimize contention)
    
    ### File Organization
    - Delete: `import_export.rs`, `speedtest.rs` (root-level modules)
    - Create: `commands/import_export.rs`, `services/config.rs`, `services/speedtest.rs`
    - Update: Module declarations in `lib.rs`, `commands/mod.rs`, `services/mod.rs`
    
    ### Test Updates
    - Update 20 integration tests in `import_export_sync.rs` to use `ConfigService` APIs
    - All existing test cases pass without modification to test logic
    - Add 3 new unit tests for `SpeedtestService`:
      - `sanitize_timeout_clamps_values`: Boundary value testing
      - `test_endpoints_handles_empty_list`: Empty input handling
      - `test_endpoints_reports_invalid_url`: Invalid URL error reporting
    
    ## Benefits
    
    1. **Improved Testability**: Service methods are `pub fn`, easily callable
       from tests without Tauri runtime
    2. **Better Separation of Concerns**: Business logic isolated from
       command/transport layer
    3. **Enhanced Maintainability**: Related operations grouped in cohesive
       service structs
    4. **Consistent Error Handling**: Services return `Result<T, AppError>`,
       commands convert to `Result<T, String>`
    5. **Performance**: I/O operations run in `spawn_blocking`, locks released
       before file operations
    
    ## Testing
    
    -  All 43 tests passing (7 unit + 36 integration)
    -  `cargo fmt --check` passes
    -  `cargo clippy -- -D warnings` passes (zero warnings)
    
    ## Documentation
    
    Updated `BACKEND_REFACTOR_PLAN.md` to reflect completion of config and
    speedtest service extraction, marking phase 4 substantially complete.
    
    Co-authored-by: Claude Code <code@anthropic.com>
  • refactor(backend): extract MCP service layer with snapshot isolation
    Extract all MCP business logic from command layer into `services/mcp.rs`,
    implementing snapshot isolation pattern to optimize lock granularity after
    RwLock migration in Phase 5.
    
    ## Key Changes
    
    ### Service Layer (`services/mcp.rs`)
    - Add `McpService` with 7 methods: `get_servers`, `upsert_server`,
      `delete_server`, `set_enabled`, `sync_enabled`, `import_from_claude`,
      `import_from_codex`
    - Implement snapshot isolation: acquire write lock only for in-memory
      modifications, clone config snapshot, release lock, then perform file I/O
      with snapshot
    - Use conditional cloning: only clone config when sync is actually needed
      (e.g., when `enabled` flag is true or `sync_other_side` is requested)
    
    ### Command Layer (`commands/mcp.rs`)
    - Reduce to thin wrappers: parse parameters and delegate to `McpService`
    - Remove all `*_internal` and `*_test_hook` functions (-94 lines)
    - Each command now 5-10 lines (parameter parsing + service call + error mapping)
    
    ### Core Logic Refactoring (`mcp.rs`)
    - Rename `set_enabled_and_sync_for` → `set_enabled_flag_for`
    - Remove file sync logic from low-level function, move sync responsibility
      to service layer for better separation of concerns
    
    ### Test Adaptation (`tests/mcp_commands.rs`)
    - Replace test hooks with direct `McpService` calls
    - All 5 MCP integration tests pass
    
    ### Additional Fixes
    - Add `Default` impl for `AppState` (clippy suggestion)
    - Remove unnecessary auto-deref in `commands/provider.rs` and `lib.rs`
    - Update Phase 4/5 progress in `BACKEND_REFACTOR_PLAN.md`
    
    ## Performance Impact
    
    **Before**: Write lock held during file I/O (~10ms), blocking all readers
    **After**: Write lock held only for memory ops (~100μs), file I/O lock-free
    
    Estimated throughput improvement: ~2x in high-concurrency read scenarios
    
    ## Testing
    
    -  All tests pass: 5 MCP commands + 7 provider service tests
    -  Zero clippy warnings with `-D warnings`
    -  No behavioral changes, maintains original save semantics
    
    Part of Phase 4 (Service Layer Abstraction) of backend refactoring roadmap.
  • refactor(backend): phase 5 - optimize concurrency with RwLock and async IO
    Replace Mutex with RwLock for AppState.config to enable concurrent reads,
    improving performance for tray menu building and query operations that
    previously blocked each other unnecessarily.
    
    Key changes:
    - Migrate AppState.config from Mutex<MultiAppConfig> to RwLock<MultiAppConfig>
    - Distinguish read-only operations (read()) from mutations (write()) across
      all command handlers and service layers
    - Offload blocking file I/O in import/export commands to spawn_blocking threads,
      minimizing lock hold time and preventing main thread blocking
    - Extract load_config_for_import() to separate I/O logic from state updates
    - Update all integration tests to use RwLock semantics
    
    Performance impact:
    - Concurrent reads: Multiple threads can now query config simultaneously
      (tray menu, provider list, MCP config)
    - Reduced contention: Write locks only acquired during actual mutations
    - Non-blocking I/O: Config import/export no longer freezes UI thread
    
    All existing tests pass with new locking semantics.
  • refactor(backend): phase 4 - add test hooks and extend service layer
    - Extract internal functions in commands/mcp.rs and commands/provider.rs
      to enable unit testing without Tauri context
    - Add test hooks: set_mcp_enabled_test_hook, import_mcp_from_claude_test_hook,
      import_mcp_from_codex_test_hook, import_default_config_test_hook
    - Migrate error types from String to AppError for precise error matching in tests
    - Extend ProviderService with delete() method to unify Codex/Claude cleanup logic
    - Add comprehensive test coverage:
      - tests/mcp_commands.rs: command-level tests for MCP operations
      - tests/provider_service.rs: service-level tests for switch/delete operations
    - Run cargo fmt to fix formatting issues (EOF newlines)
    - Update BACKEND_REFACTOR_PLAN.md to mark phase 3 complete
  • 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
  • refactor(backend): phase 3 - unify error handling and fix backup timestamp bug
    Key improvements:
    - Extract switch_provider_internal() returning AppError for better testability
    - Fix backup mtime inheritance: use read+write instead of fs::copy to ensure latest backup survives cleanup
    - Add 15+ integration tests covering provider commands, atomic writes, and rollback scenarios
    - Expose write_codex_live_atomic, AppState, and test hooks in public API
    - Extract tests/support.rs with isolated HOME and mutex utilities
    
    Test coverage:
    - Provider switching with live config backfill and MCP sync
    - Codex atomic write success and failure rollback
    - Backup retention policy with proper mtime ordering
    - Negative cases: missing auth field, invalid provider ID
  • refactor(backend): phase 3 - expand integration tests for Codex and MCP sync
    Expand test suite from 3 to 11 integration tests, adding comprehensive coverage
    for Codex dual-file atomicity and bidirectional MCP synchronization:
    
    New Codex sync tests:
    - sync_codex_provider_writes_auth_and_config: validates atomic write of auth.json
      and config.toml, plus SSOT backfill of latest toml content
    - sync_enabled_to_codex_writes_enabled_servers: MCP projection to config.toml
    - sync_enabled_to_codex_removes_servers_when_none_enabled: cleanup when all disabled
    - sync_enabled_to_codex_returns_error_on_invalid_toml: error handling for malformed TOML
    
    New Codex MCP import tests:
    - import_from_codex_adds_servers_from_mcp_servers_table: imports new servers from live config
    - import_from_codex_merges_into_existing_entries: smart merge preserving SSOT server configs
    
    New Claude MCP tests:
    - sync_claude_enabled_mcp_projects_to_user_config: enabled/disabled filtering for .claude.json
    - import_from_claude_merges_into_config: intelligent merge preserving existing configurations
    
    Expand lib.rs API exports:
    - Codex paths: get_codex_auth_path, get_codex_config_path
    - Claude MCP: get_claude_mcp_path
    - MCP sync: sync_enabled_to_claude, sync_enabled_to_codex
    - MCP import: import_from_claude, import_from_codex
    - Error type: AppError (for test assertions)
    
    Test infrastructure improvements:
    - Enhanced reset_test_fs() to clean .claude.json
    - All tests use isolated HOME directory with sequential execution via mutex
    
    Test results: 11/11 passed
    Files changed: 3 (+394/-6 lines)
    
    Next steps: Command layer integration tests and error recovery scenarios
  • refactor(backend): phase 3 - add integration tests for config sync (partial)
    Add integration test suite with isolated test environment:
    - New test file: tests/import_export_sync.rs (149 lines, 3 test cases)
      * sync_claude_provider_writes_live_settings: validates SSOT sync to live settings
      * create_backup_skips_missing_file: edge case handling for missing config
      * create_backup_generates_snapshot_file: verifies backup snapshot creation
    - Test infrastructure:
      * OnceLock-based isolated HOME directory in temp folder
      * Mutex guard to ensure sequential test execution (avoid file system race)
      * Automatic cleanup between test runs
    
    Export core APIs for testing (lib.rs):
    - AppType, MultiAppConfig, Provider (data structures)
    - get_claude_settings_path, read_json_file (config utilities)
    - create_backup, sync_current_providers_to_live (sync operations)
    - update_settings, AppSettings (settings management)
    
    Adjust visibility:
    - import_export::sync_current_providers_to_live: fn -> pub fn
    
    Update documentation:
    - Mark Phase 3 as in-progress (🚧) in BACKEND_REFACTOR_PLAN.md
    - Document current test coverage scope and pending scenarios
    
    Test results: 7/7 passed (4 unit + 3 integration)
    Build time: 0.16s
    
    Next steps:
    - Add Codex sync tests (auth.json + config.toml atomic writes)
    - Add MCP sync integration tests
    - Add end-to-end provider switching tests
  • refactor(backend): phase 2 - split commands.rs by domain (100%)
    Split monolithic commands.rs (1525 lines) into 7 domain-focused modules
    to improve maintainability and readability while preserving the external API.
    
    ## Changes
    
    ### Module Structure
    
    Created `commands/` directory with domain-based organization:
    
    - **provider.rs** (946 lines, 15 commands)
      - Provider CRUD operations (get, add, update, delete, switch)
      - Usage query integration
      - Endpoint speed testing and custom endpoint management
      - Sort order management
      - Largest file but highly cohesive (all provider-related)
    
    - **mcp.rs** (235 lines, 13 commands)
      - Claude MCP management (~/.claude.json)
      - SSOT MCP config management (config.json)
      - Sync operations (Claude ↔ Codex)
      - Import/export functionality
    
    - **config.rs** (153 lines, 8 commands)
      - Config path queries (Claude/Codex)
      - Directory operations (open, pick)
      - Config status checks
      - Parameter compatibility layer (app_type/app/appType)
    
    - **settings.rs** (40 lines, 5 commands)
      - App settings management
      - App restart functionality
      - app_config_dir override (Store integration)
    
    - **plugin.rs** (36 lines, 4 commands)
      - Claude plugin management (~/.claude/config.json)
      - Plugin status and config operations
    
    - **misc.rs** (45 lines, 3 commands)
      - External link handling
      - Update checks
      - Portable mode detection
    
    - **mod.rs** (15 lines)
      - Module exports via `pub use`
      - Preserves flat API structure
    
    ### API Preservation
    
    - Used `pub use` pattern to maintain external API
    - All commands still accessible as `commands::function_name`
    - Zero breaking changes for frontend code
    - lib.rs invoke_handler unchanged (48 commands registered)
    
    ## Statistics
    
    - Files: 1 → 7 (modular organization)
    - Lines: 1525 → 1470 (net -55 lines, -3.6%)
    - Commands: 48 → 48 (all preserved)
    - Average file size: 210 lines (excluding provider.rs)
    - Compilation:  Success (6.92s, 0 warnings)
    - Tests:  4/4 passed
    
    ## Benefits
    
    - **Maintainability**: Easier to locate and modify domain-specific code
    - **Readability**: Smaller files (~200 lines) vs monolithic 1500+ lines
    - **Testability**: Can unit test individual modules in isolation
    - **Scalability**: Clear pattern for adding new command groups
    - **Zero Risk**: No API changes, all tests passing
    
    ## Design Decisions
    
    1. **Domain-based split**: Organized by business domain (provider, mcp, config)
       rather than technical layers (crud, query, sync)
    
    2. **Preserved provider.rs size**: Kept at 946 lines to maintain high cohesion
       (all provider-related operations together). Can be further split in Phase 2.1
       if needed.
    
    3. **Parameter compatibility**: Retained multiple parameter names (app_type, app,
       appType) for backward compatibility with different frontend call styles
    
    ## Phase 2 Status:  100% Complete
    
    Ready for Phase 3: Adding integration tests.
    
    Co-authored-by: Claude <noreply@anthropic.com>
  • refactor(backend): phase 1 - unified error handling with thiserror
    Introduce AppError enum to replace Result<T, String> pattern across
    the codebase, improving error context preservation and type safety.
    
    ## Changes
    
    ### Core Infrastructure
    - Add src/error.rs with AppError enum using thiserror
    - Add thiserror dependency to Cargo.toml
    - Implement helper functions: io(), json(), toml() for ergonomic error creation
    - Implement From<PoisonError> for automatic lock error conversion
    - Implement From<AppError> for String to maintain Tauri command compatibility
    
    ### Module Migrations (60% complete)
    - config.rs: Full migration to AppError
      - read_json_file, write_json_file, atomic_write
      - archive_file, copy_file, delete_file
    - claude_mcp.rs: Full migration to AppError
      - get_mcp_status, read_mcp_json, upsert_mcp_server
      - delete_mcp_server, validate_command_in_path
      - set_mcp_servers_map
    - codex_config.rs: Full migration to AppError
      - write_codex_live_atomic with rollback support
      - read_and_validate_codex_config_text
      - validate_config_toml
    - app_config.rs: Partial migration
      - MultiAppConfig::load, MultiAppConfig::save
    - store.rs: Partial migration
      - AppState::save now returns Result<(), AppError>
    - commands.rs: Minimal changes
      - Use .map_err(Into::into) for compatibility
    - mcp.rs: Minimal changes
      - sync_enabled_to_claude uses Into::into conversion
    
    ### Documentation
    - Add docs/BACKEND_REFACTOR_PLAN.md with detailed refactoring roadmap
    
    ## Benefits
    - Type-safe error handling with preserved error chains
    - Better error messages with file paths and context
    - Reduced boilerplate code (118 Result<T, String> instances to migrate)
    - Automatic error conversion for seamless integration
    
    ## Testing
    - All existing tests pass (4/4)
    - Compilation successful with no warnings
    - Build time: 0.61s (no performance regression)
    
    ## Remaining Work
    - claude_plugin.rs (7 functions)
    - migration.rs, import_export.rs
    - Add unit tests for error.rs
    - Complete commands.rs migration after dependent modules
    
    Co-authored-by: Claude <claude@anthropic.com>
  • test: add frontend testing infrastructure with vitest
    - Introduce Vitest + React Testing Library + jsdom environment
    - Add useDragSort hook unit tests covering:
      * Sorting logic (sortIndex → createdAt → name)
      * Successful drag operation (API call + cache invalidation)
      * Failed drag operation (error toast display)
      * Edge case (no valid target, no API call)
    - Configure global test setup (i18n mock, auto cleanup)
    - Update TypeScript configs to include tests/ directory
    - Add test development plan documentation
    
    Test Coverage:
      ✓ Provider drag-and-drop sorting core logic
      ✓ React Query cache refresh
      ✓ Toast notification display
      ✓ Boundary condition handling
    
    Test Results: 4/4 passed (671ms)
    Next Steps: Sprint 2 - component tests with MSW mock layer
  • refactor: consolidate provider form components
    This commit completes Stage 2.5-2.6 of the refactoring plan by:
    
    - Consolidating 8 provider form files (1941+ lines) into a single
      unified ProviderForm component (353 lines), reducing code by ~82%
    - Implementing modern form management with react-hook-form and zod
    - Adding preset provider categorization with grouped select UI
    - Supporting dual-mode operation for both Claude and Codex configs
    - Removing redundant subcomponents:
      - ApiKeyInput.tsx (72 lines)
      - ClaudeConfigEditor.tsx (205 lines)
      - CodexConfigEditor.tsx (667 lines)
      - EndpointSpeedTest.tsx (636 lines)
      - KimiModelSelector.tsx (195 lines)
      - PresetSelector.tsx (119 lines)
    
    Key improvements:
    - Type-safe form values with ProviderFormValues extension
    - Automatic template value application for presets
    - Better internationalization coverage
    - Cleaner separation of concerns
    - Enhanced UX with categorized preset groups
    
    Updates AddProviderDialog and EditProviderDialog to pass appType prop
    and handle preset category metadata.
  • feat: complete stage 4 cleanup and code formatting
    This commit completes stage 4 of the refactoring plan, focusing on cleanup
    and optimization of the modernized codebase.
    
    ## Key Changes
    
    ### Code Cleanup
    - Remove legacy `src/lib/styles.ts` (no longer needed)
    - Remove old modal components (`ImportProgressModal.tsx`, `ProviderList.tsx`)
    - Streamline `src/lib/tauri-api.ts` from 712 lines to 17 lines (-97.6%)
      - Remove global `window.api` pollution
      - Keep only event listeners (`tauriEvents.onProviderSwitched`)
      - All API calls now use modular `@/lib/api/*` layer
    
    ### Type System
    - Clean up `src/vite-env.d.ts` (remove 156 lines of outdated types)
    - Remove obsolete global type declarations
    - All TypeScript checks pass with zero errors
    
    ### Code Formatting
    - Format all source files with Prettier (82 files)
    - Fix formatting issues in 15 files:
      - App.tsx and core components
      - MCP management components
      - Settings module components
      - Provider management components
      - UI components
    
    ### Documentation Updates
    - Update `REFACTORING_CHECKLIST.md` with stage 4 progress
    - Mark completed tasks in `REFACTORING_MASTER_PLAN.md`
    
    ## Impact
    
    **Code Reduction:**
    - Total: -1,753 lines, +384 lines (net -1,369 lines)
    - tauri-api.ts: 712 → 17 lines (-97.6%)
    - Removed styles.ts: -82 lines
    - Removed vite-env.d.ts declarations: -156 lines
    
    **Quality Improvements:**
    -  Zero TypeScript errors
    -  Zero TODO/FIXME comments
    -  100% Prettier compliant
    -  Zero `window.api` references
    -  Fully modular API layer
    
    ## Testing
    - [x] TypeScript compilation passes
    - [x] Code formatting validated
    - [x] No linting errors
    
    Stage 4 completion: 100%
    Ready for stage 5 (testing and bug fixes)