Commit Graph

7 Commits

  • fix(windows): restore default home dir resolution to prevent data loss
    v3.10.3 introduced HOME env priority on Windows for test isolation,
    which caused database path to change when HOME differs from USERPROFILE
    (common in Git/MSYS environments), making providers appear to disappear.
    
    Changes:
    - Use CC_SWITCH_TEST_HOME for test isolation instead of HOME
    - Add legacy fallback to detect v3.10.3 database location on Windows
    - Add logging for legacy path detection to aid debugging
  • fix: resolve test failures and clippy warnings
    - tests/App.test.tsx: remove outdated SettingsPage mock, use dynamic import
    - database/tests.rs: remove unused field, use struct init syntax
    - deeplink/tests.rs: use idiomatic assert!() instead of assert_eq!(true)
    - support.rs: add #[allow(dead_code)] for test utilities
    - usage_stats.rs: code formatting
  • fix(proxy): update live backup when hot-switching provider in proxy mode
    When proxy is active, switching providers only updated the database flags
    but not the live backup. This caused the wrong provider config to be
    restored when stopping the proxy.
    
    Added `update_live_backup_from_provider()` method to ProxyService that
    generates backup from provider's settings_config instead of reading from
    live files (which are already taken over by proxy).
  • fix(proxy): wait for server shutdown before exiting app
    The previous cleanup logic only sent a shutdown signal but didn't wait
    for the proxy server to actually stop. This caused a race condition
    where the app would exit before cleanup completed, leaving Live configs
    in an inconsistent state.
    
    Changes:
    - Add `server_handle` field to ProxyServer to track the spawned task
    - Modify `stop()` to wait for server task completion (5s timeout)
    - Add 100ms delay before process exit to ensure I/O flush
    - Export ProxyService and fix test files that were missing proxy_service field
  • test: migrate tests to SQLite database architecture
    This commit refactors all tests to work with the new database-based
    architecture, replacing the previous JSON config approach.
    
    Key changes:
    - Add Database export to lib.rs for test access
    - Create test helper functions in support.rs:
      - create_test_state(): Creates empty test state with fresh DB
      - create_test_state_with_config(): Migrates JSON config to DB
    - Fix environment isolation in provider_service tests:
      - provider_service_switch_missing_provider_returns_error
      - provider_service_switch_codex_missing_auth_returns_error
    - Replace ignored export tests with working alternatives:
      - export_sql_writes_to_target_path (tests Database::export_sql)
      - export_sql_returns_error_for_invalid_path (tests error handling)
    - Update error type matching to align with current implementation
    
    All tests now:
    - Use isolated test environments (test_mutex + reset_test_fs)
    - Access data via Database API instead of RwLock<MultiAppConfig>
    - Work with SQLite persistence layer
    - Pass without environment pollution or race conditions
    
    Fixes test compilation errors after database migration.
  • feat(gemini): add Gemini provider integration (#202)
    * feat(gemini): add Gemini provider integration
    
    - Add gemini_config.rs module for .env file parsing
    - Extend AppType enum to support Gemini
    - Implement GeminiConfigEditor and GeminiFormFields components
    - Add GeminiIcon with standardized 1024x1024 viewBox
    - Add Gemini provider presets configuration
    - Update i18n translations for Gemini support
    - Extend ProviderService and McpService for Gemini
    
    * fix(gemini): resolve TypeScript errors, add i18n support, and fix MCP logic
    
    **Critical Fixes:**
    - Fix TS2741 errors in tests/msw/state.ts by adding missing Gemini type definitions
    - Fix ProviderCard.extractApiUrl to support GOOGLE_GEMINI_BASE_URL display
    - Add missing apps.gemini i18n keys (zh/en) for proper app name display
    - Fix MCP service Gemini cross-app duplication logic to prevent self-copy
    
    **Technical Details:**
    - tests/msw/state.ts: Add gemini default providers, current ID, and MCP config
    - ProviderCard.tsx: Check both ANTHROPIC_BASE_URL and GOOGLE_GEMINI_BASE_URL
    - services/mcp.rs: Skip Gemini in sync_other_side logic with unreachable!() guards
    - Run pnpm format to auto-fix code style issues
    
    **Verification:**
    -  pnpm typecheck passes
    -  pnpm format completed
    
    * feat(gemini): enhance authentication and config parsing
    
    - Add strict and lenient .env parsing modes
    - Implement PackyCode partner authentication detection
    - Support Google OAuth official authentication
    - Auto-configure security.auth.selectedType for PackyCode
    - Add comprehensive test coverage for all auth types
    - Update i18n for OAuth hints and Gemini config
    
    ---------
    
    Co-authored-by: Jason <farion1231@gmail.com>
  • 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