Add mcp/opencode.rs with format conversion between CC Switch and OpenCode:
- stdio ↔ local type conversion
- command+args ↔ command array format
- env ↔ environment field mapping
- sse/http ↔ remote type conversion
Public API:
- sync_enabled_to_opencode: Batch sync all enabled servers
- sync_single_server_to_opencode: Sync individual server
- remove_server_from_opencode: Remove from live config
- import_from_opencode: Import servers from OpenCode config
Also fix test files to include new opencode field in McpApps struct.
All 4 unit tests pass for format conversion.
Add recursive directory scanning to discover SKILL.md files in nested
directories. When a SKILL.md is found, treat sibling directories as
functional folders rather than separate skills.
Add get_effective_current_provider() to validate local settings ID
against database, with automatic cleanup and fallback to DB is_current.
This fixes edge cases in multi-device cloud sync scenarios where local
settings may contain stale provider IDs:
- current(): now returns validated effective provider ID
- update(): correctly syncs live config when local ID differs from DB
- delete(): checks both local settings and DB to prevent deletion
- switch(): backfill logic now targets valid provider
- sync_current_to_live(): uses validated ID with auto-fallback
- tray menu: displays correct checkmark on startup
Also fixes test issues:
- Add missing test setup calls (mutex, reset_test_fs, ensure_test_home)
- Correct Gemini security settings path to ~/.gemini/settings.json
The switch function was missing two important features after the SQLite
migration:
1. Backfill mechanism: Before switching providers, read the current live
config and save it back to the current provider. This preserves any
manual edits users made to the live config file.
2. Gemini security flags: When switching to a Gemini provider, set the
appropriate security.auth.selectedType:
- PackyCode providers: "gemini-api-key"
- Google OAuth providers: "oauth-personal"
Also update tests to:
- Use the new unified MCP structure (mcp.servers) instead of the legacy
per-app structure (mcp.codex.servers)
- Expect backfill behavior (was incorrectly marked as "no backfill")
- Remove assertions for provider-specific file deletion (v3.7.0+ uses
SSOT, no longer creates per-provider config files)
This merge brings the SQLite migration system from feat/sqlite-migration branch:
## New Features
- Schema version control with SCHEMA_VERSION constant
- Automatic migration of missing columns for providers table
- Dry-run validation mode for schema compatibility checks
- JSON→SQLite migration feature gate (CC_SWITCH_ENABLE_JSON_DB_MIGRATION)
- Settings reload mechanism after imports
## Test Updates
- Updated tests to use SQLite database instead of config.json
- Removed obsolete import_config_from_path tests (replaced by db.import_sql)
- Fixed MCP tests to use unified McpServer structure (v3.7.0+)
- Updated provider switch tests to reflect no-backfill behavior
- Adjusted error type matching for new error variants
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.
Refactor tray menu system to support three applications (Claude/Codex/Gemini):
- Introduce generic TrayAppSection structure and TRAY_SECTIONS array
- Implement append_provider_section and handle_provider_tray_event helper functions
- Enhance Gemini provider service with .env config read/write support
- Implement Gemini LiveSnapshot for atomic operations and rollback
- Update README documentation to reflect Gemini tray quick switching feature
- 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