Commit Graph

662 Commits

Author SHA1 Message Date
Jason
c985db8f3d feat(mcp): implement unified MCP management for v3.7.0
BREAKING CHANGE: Migrate from app-specific MCP storage to unified structure

## Phase 1: Data Structure Migration
- Add McpApps struct with claude/codex/gemini boolean fields
- Add McpServer struct for unified server definition
- Add migration logic in MultiAppConfig::migrate_mcp_to_unified()
- Integrate automatic migration into MultiAppConfig::load()
- Support backward compatibility through Optional fields

## Phase 2: Backend Services Refactor
- Completely rewrite services/mcp.rs for unified management:
  * get_all_servers() - retrieve all MCP servers
  * upsert_server() - add/update unified server
  * delete_server() - remove server
  * toggle_app() - enable/disable server for specific app
  * sync_all_enabled() - sync to all live configs
- Add single-server sync functions to mcp.rs:
  * sync_single_server_to_claude/codex/gemini()
  * remove_server_from_claude/codex/gemini()
- Add read_mcp_servers_map() to claude_mcp.rs and gemini_mcp.rs
- Add new Tauri commands to commands/mcp.rs:
  * get_mcp_servers, upsert_mcp_server, delete_mcp_server
  * toggle_mcp_app, sync_all_mcp_servers
- Register new commands in lib.rs

## Migration Strategy
- Detects old structure (mcp.claude/codex/gemini.servers)
- Merges into unified mcp.servers with apps markers
- Handles conflicts by merging enabled apps
- Clears old structures after migration
- Saves migrated config automatically

## Known Issues
- Old commands still need compatibility layer (WIP)
- toml_edit type conversion needs fixing (WIP)
- Frontend not yet implemented (Phase 3 pending)

Related: v3.6.2 -> v3.7.0
2025-11-14 12:51:24 +08:00
Jason
c7b235bb98 fix(i18n): add missing Gemini MCP panel title and fix ternary logic
- Add mcp.geminiTitle to both zh.json and en.json
- Fix McpPanel title logic to handle all three apps (claude/codex/gemini)
- Previous logic would incorrectly display codexTitle for gemini
2025-11-14 10:35:55 +08:00
Jason
1616c63c0b feat(gemini): implement full MCP management functionality
- Add gemini_mcp.rs module for Gemini MCP file I/O operations
- Implement sync_enabled_to_gemini to export enabled MCPs to ~/.gemini/settings.json
- Implement import_from_gemini to import MCPs from Gemini config
- Add Gemini sync logic in services/mcp.rs (upsert_server, delete_server, set_enabled)
- Register Tauri commands for Gemini MCP sync and import
- Update frontend API calls and McpPanel to support Gemini

Fixes the issue where adding MCP servers in Gemini tab would not sync to ~/.gemini/settings.json
2025-11-14 10:02:27 +08:00
Jason
146b42fb68 feat(gemini): add config.json editor and common config functionality
Implements dual-editor pattern for Gemini providers, following the Codex architecture:
- Environment variables (.env format) editor
- Extended configuration (config.json) editor with common config support

New Components:
- GeminiConfigSections: Separate sections for env and config editing
- GeminiCommonConfigModal: Modal for editing common config snippets

New Hooks:
- useGeminiConfigState: Manages env/config separation and conversion
  - Converts between .env string format and JSON object
  - Validates JSON config structure
  - Extracts API Key and Base URL from env
- useGeminiCommonConfig: Handles common config snippets
  - Deep merge algorithm for combining configs
  - Remove common config logic for toggling off
  - localStorage persistence for snippets

Features:
- Format buttons for both env and config editors
- Common config toggle with deep merge/remove
- Error validation and display
- Auto-open modal on common config errors

Configuration Structure:
{
  "env": {
    "GOOGLE_GEMINI_BASE_URL": "https://...",
    "GEMINI_API_KEY": "sk-...",
    "GEMINI_MODEL": "gemini-2.5-pro"
  },
  "config": {
    "timeout": 30000,
    "maxRetries": 3
  }
}

This brings Gemini providers to feature parity with Claude and Codex.
2025-11-14 08:32:30 +08:00
Jason
0ea434a485 fix(i18n): deduplicate category labels by reusing providerForm keys
- Change ProviderForm to use providerForm.category* instead of providerPreset.category*
- Remove duplicate category keys from providerPreset namespace in both zh.json and en.json
- Fix naming inconsistency: use categoryAggregation (not categoryAggregator)
- Fixes issue where English UI would show Chinese defaultValue fallbacks

This ensures single source of truth for category labels and improves maintainability.
2025-11-14 08:31:09 +08:00
Jason
21fd7cc9fd feat: migrate Claude common config snippet from localStorage to config.json
Migrate the Claude common config snippet storage from browser localStorage
to the persistent config.json file for better cross-device sync and backup support.

**Backend Changes:**
- Add `claude_common_config_snippet` field to `MultiAppConfig` struct
- Add `get_claude_common_config_snippet` and `set_claude_common_config_snippet` Tauri commands
- Include JSON validation in the setter command

**Frontend Changes:**
- Create new `lib/api/config.ts` API module
- Refactor `useCommonConfigSnippet` hook to use config.json instead of localStorage
- Add automatic one-time migration from localStorage to config.json
- Add loading state during initialization

**Benefits:**
- Cross-device synchronization via backup/restore
- More reliable persistence than browser storage
- Centralized configuration management
- Seamless migration for existing users
2025-11-13 22:45:58 +08:00
Jason
434c64f38d fix(ui): prevent URL overflow in provider cards
Add max-width constraint to URL display to prevent long URLs from breaking card layout.
2025-11-13 17:14:49 +08:00
Jason
6d8e822f8d refactor(i18n): remove unnecessary translation for brand names
- Use hardcoded "Claude", "Codex", "Gemini" instead of i18n keys
- Brand names should not be translated across different locales
- Simplifies code by removing useTranslation hook from AppSwitcher
- Reduces maintenance overhead in translation files
2025-11-13 17:08:05 +08:00
Jason
2fae8c9275 fix(i18n): add internationalization support for app names
- Add i18n for Claude/Codex/Gemini app names in AppSwitcher
- Use useTranslation hook with existing translation keys
- Fix ASCII diagram alignment in README files
2025-11-13 16:37:58 +08:00
Jason
30c763ffe3 fix(prompt): improve i18n and error handling for auto-import
Address code review feedback for PR #214:

- Replace hardcoded Chinese strings with English in auto-imported prompts
  - Prompt name: "Auto-imported Prompt" instead of "初始提示词"
  - Description: "Automatically imported on first launch"
- Remove panic risk by replacing expect() with proper error propagation
- Use AppError::localized for bilingual error messages
- Extract get_base_dir_with_fallback() helper to eliminate code duplication
- Update test assertions to match new English strings
- Suppress false-positive dead_code warning on TempHome.dir field

All 5 tests passing with zero compiler warnings.
2025-11-13 15:43:37 +08:00
YoVinchen
e4d7999294 refactor(prompt): extract file path logic and implement auto-import on first launch (#214)
- Extract prompt file path logic to dedicated prompt_files module
- Refactor PromptService to use centralized path resolution
- Implement auto-import for existing prompt files on first startup
- Add comprehensive unit tests for auto-import functionality
2025-11-13 15:15:58 +08:00
YoVinchen
34f7139fda fix(usage-script): add input validation and boundary checks (#208)
- Backend: validate auto-query interval ≤ 1440 minutes (24 hours)
- Frontend: add number input sanitization and blur validation
- Add user-friendly error messages for invalid inputs
- Support auto-clamping to valid ranges with toast notifications
2025-11-13 11:28:48 +08:00
YoVinchen
a85f24f616 fix(gemini): relax validation when adding providers (#210)
Allow users to create Gemini provider configurations without API key
and fill it in later. Split validation into two modes:

- validate_gemini_settings: Basic structure check (used when adding)
- validate_gemini_settings_strict: Full validation (used when switching)

This fixes the error 'Gemini config missing required field: GEMINI_API_KEY'
when trying to add Gemini providers from presets like PackyCode or Google.

Changes:
- Add validate_gemini_settings_strict for switching validation
- Update write_gemini_live to use strict validation
- Add comprehensive tests for both validation modes
2025-11-13 11:28:28 +08:00
YoVinchen
b9743a463d feat(tray): add Gemini support to system tray menu (#209)
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
2025-11-12 23:38:43 +08:00
YoVinchen
2f02514a14 feat(gemini): add Google Official branding with Gemini icon (#211)
Update Google Gemini preset to match Claude Official styling:
- Rename 'Google' to 'Google Official'
- Add GeminiIcon support in preset selector
- Add custom theme with Google blue (#4285F4) background
- Update PresetTheme type to support 'gemini' icon type

Changes:
- Add GeminiPresetTheme interface
- Add theme config to Google Official preset
- Import and render GeminiIcon in ProviderPresetSelector
- Update PresetTheme icon type to include 'gemini'
2025-11-12 22:41:26 +08:00
Jason
75866044bd update readme 2025-11-12 21:52:47 +08:00
YoVinchen
155532ea8c feat(prompts+i18n): add prompt management and improve prompt editor i18n (#193)
* feat(prompts): add prompt management across Tauri service and React UI

- backend: add commands/prompt.rs, services/prompt.rs, register in commands/mod.rs and lib.rs, refine app_config.rs
- frontend: add PromptPanel, PromptFormModal, PromptListItem, MarkdownEditor, usePromptActions, integrate in App.tsx
- api: add src/lib/api/prompts.ts
- i18n: update src/i18n/locales/{en,zh}.json
- build: update package.json and pnpm-lock.yaml

* feat(i18n): improve i18n for prompts and Markdown editor

- update src/i18n/locales/{en,zh}.json keys and strings
- apply i18n in PromptFormModal, PromptPanel, and MarkdownEditor
- align prompt text with src-tauri/src/services/prompt.rs

* feat(prompts): add enable/disable toggle and simplify panel UI

- Add PromptToggle component and integrate in prompt list items
- Implement toggleEnabled with optimistic update; enable via API, disable via upsert with enabled=false;
  reload after success
- Simplify PromptPanel: remove file import and current-file preview to keep CRUD flow focused
- Tweak header controls style (use mcp variant) and minor copy: rename “Prompt Management” to “Prompts”
- i18n: add disableSuccess/disableFailed messages
- Backend (Tauri): prevent duplicate backups when importing original prompt content

* style: unify code formatting with trailing commas

* feat(prompts): add Gemini filename support to PromptFormModal

Update filename mapping to use Record<AppId, string> pattern, supporting
GEMINI.md alongside CLAUDE.md and AGENTS.md.

* fix(prompts): sync enabled prompt to file when updating

When updating a prompt that is currently enabled, automatically sync
the updated content to the corresponding live file (CLAUDE.md/AGENTS.md/GEMINI.md).

This ensures the active prompt file always reflects the latest content
when editing enabled prompts.
2025-11-12 16:41:41 +08:00
YoVinchen
346f916048 refactor(endpoint): separate edit and create mode endpoint management (#192)
Optimize custom endpoint management logic to distinguish between edit and create modes:
- Edit mode: endpoints are read/written directly to backend via API
- Create mode: use draftCustomEndpoints to stage, save on submit
- Remove duplicate endpoint loading in useSpeedTestEndpoints
- Add isSaving state and initialCustomUrls tracking
2025-11-12 11:02:43 +08:00
YoVinchen
8a05e7bd3d 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>
2025-11-12 10:47:34 +08:00
Jason
32a2ba5ef6 chore(release): prepare for v3.6.2 release v3.6.2 2025-11-11 23:57:21 +08:00
Jason
4502b2f973 feat(presets): add Kimi For Coding and BaiLing provider presets
Add two new Chinese official provider presets:
- Kimi For Coding: AI coding assistant from Kimi
- BaiLing: Claude-compatible API from AliPay TBox
2025-11-11 23:50:52 +08:00
Jason
6cb930b4ec docs: add TypeScript Trending badge and improve contributing tone
- Add 🔥 TypeScript Trending badge celebrating daily/weekly/monthly rankings
- Refine contributing guidelines with friendlier, more welcoming language
- Replace directive tone with collaborative suggestions for feature PRs
2025-11-11 11:03:26 +08:00
Jason
9a5c8c0e57 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)
v3.6.1
2025-11-10 21:21:27 +08:00
Jason
b1abdf95aa feat(sponsor): add PackyCode as official partner
- Add PackyCode to sponsor section in README (both EN/ZH)
- Add PackyCode logo to assets/partners/logos/
- Mark PackyCode as partner in provider presets (Claude & Codex)
- Add promotion message to i18n files with 10% discount info
2025-11-10 18:44:19 +08:00
Jason
be155c857e refactor(usage-script): replace native checkbox with Switch component
Upgrade the enable toggle from native checkbox to shadcn/ui Switch component
for better UX and UI consistency with settings page.

**Improvements**:
1. Use modern toggle UI (Switch) instead of traditional checkbox
2. Adopt the same layout pattern as settings page (ToggleRow style)
3. Add bordered container with proper spacing for better visual hierarchy
4. Maintain full accessibility support (aria-label)

**Layout changes**:
- Before: Simple label + checkbox horizontal layout
- After: Bordered container, label on left, Switch on right, vertically centered
2025-11-10 16:01:28 +08:00
Jason
9d6f101006 fix(usage-script): replace FormLabel with Label to fix white screen crash
FormLabel component requires FormField context and throws error when used
standalone, causing the entire component to crash with a white screen.

Root cause:
- FormLabel internally calls useFormField() hook
- useFormField() requires FormFieldContext (must be within <FormField>)
- Without context, it throws: "useFormField should be used within <FormField>"
- Uncaught error crashes React rendering tree

Solution:
- Replace FormLabel with standalone Label component
- Label component from @/components/ui/label doesn't depend on form context
- Maintains same styling (text-sm font-medium) without requiring context

This fixes the white screen issue when clicking the usage panel.
2025-11-10 15:51:18 +08:00
Jason
2a56a0d889 style(usage-script): unify form input styles with shadcn/ui components
Replace native HTML input elements with shadcn/ui Input and FormLabel
components to ensure consistent styling across the application.

Changes:
- Import Input, FormLabel, Eye, and EyeOff components
- Replace all credential input fields with Input component
- Add show/hide toggle buttons for password fields (API Key, Access Token)
- Replace label/span elements with FormLabel component
- Update timeout and auto-query interval inputs to use Input component
- Improve spacing consistency (space-y-4 for credential config)
- Add proper id attributes for accessibility
- Use muted-foreground for hint text

The form now matches the styling of provider configuration forms
throughout the application.
2025-11-10 15:42:36 +08:00
Jason
7096957b40 feat(usage-query): decouple credentials from provider config
Add independent credential fields for usage query to support different
query endpoints and authentication methods.

Changes:
- Add `apiKey` and `baseUrl` fields to UsageScript struct
- Remove dependency on provider config credentials in query_usage
- Update test_usage_script to accept independent credential parameters
- Add credential input fields in UsageScriptModal based on template:
  * General: apiKey + baseUrl
  * NewAPI: baseUrl + accessToken + userId
  * Custom: no additional fields (full freedom)
- Auto-clear irrelevant fields when switching templates
- Add i18n text for "credentialsConfig"

Benefits:
- Query API can use different endpoint/key than provider config
- Better separation of concerns
- More flexible for various usage query scenarios
2025-11-10 15:28:09 +08:00
Jason
23d06515ad fix(toml): normalize CJK quotes to prevent parsing errors
Add quote normalization to handle Chinese/fullwidth quotes automatically
converted by IME. This fixes TOML parsing failures when users input
configuration with non-ASCII quotes (" " ' ' etc.).

Changes:
- Add textNormalization utility for quote normalization
- Apply normalization in TOML input handlers (MCP form, Codex config)
- Disable browser auto-correction in Textarea component
- Add defensive normalization in TOML parsing layer
2025-11-10 14:35:55 +08:00
Jason
3210202132 fix(mcp): preserve custom fields in Codex TOML config editor
Fixed an issue where custom/extension fields (e.g., timeout_ms, retry_count)
were silently dropped when editing Codex MCP server configurations in TOML format.

Root cause: The TOML parser functions only extracted known fields (type, command,
args, env, cwd, url, headers), discarding any additional fields during normalization.

Changes:
- mcpServerToToml: Now uses spread operator to copy all fields before stringification
- normalizeServerConfig: Added logic to preserve unknown fields after processing known ones
- Both stdio and http server types now retain custom configuration fields

This fix enables forward compatibility with future MCP protocol extensions and
allows users to add custom configurations without code changes.
2025-11-10 12:03:15 +08:00
Jason
7b52c44a9d feat(schema): add common JSON/TOML validators and enforce MCP conditional fields
- Add src/lib/schemas/common.ts with jsonConfigSchema and tomlConfigSchema
- Enhance src/lib/schemas/mcp.ts to require command for stdio and url for http via superRefine
- Keep ProviderForm as-is; future steps will wire new schemas into RHF flows
- Verified: pnpm typecheck passes
2025-11-09 20:42:43 +08:00
Jason
772081312e feat(ui): enhance provider switch error notification with copy action
- Split error message into title and description for better UX
- Add one-click copy button to easily share error details
- Extend toast duration to 6s for improved readability
- Use extractErrorMessage utility for consistent error handling
- Add i18n keys: common.copy, notifications.switchFailedTitle

This improves debugging experience when provider switching fails,
allowing users to quickly copy and share error messages.
2025-11-09 17:56:02 +08:00
Jason
cfcd7b892a fix(tray): replace unwrap with safe pattern matching in menu handler
Replace unwrap() calls with safe pattern matching to prevent panics
when handling invalid tray menu item IDs. Now logs errors and returns
gracefully instead of crashing the application.
2025-11-08 22:55:53 +08:00
Jason
3da787b9af fix(provider): set category to custom for imported default config
Ensure that when importing default configuration from live files,
the created provider is properly marked with category "custom" for
correct UI display and filtering.
2025-11-08 22:45:53 +08:00
Jason
9370054911 fix(error-handling): isolate tray menu update failures from main operations
Previously, if updateTrayMenu() failed after a successful main operation
(like sorting, adding, or updating providers), the entire operation would
appear to fail with a misleading error message, even though the core
functionality had already succeeded.

This resulted in false negative feedback where:
- Backend data was successfully updated
- Frontend UI was successfully refreshed
- Tray menu failed to update
- User saw "operation failed" message (incorrect)

Changes:
- Wrap updateTrayMenu() calls in nested try-catch blocks
- Log tray menu failures separately with descriptive messages
- Ensure main operation success is reported accurately
- Prevent tray menu failures from triggering main operation error handlers

Files modified:
- src/hooks/useDragSort.ts (drag-and-drop sorting)
- src/lib/query/mutations.ts (add/delete/switch mutations)
- src/hooks/useProviderActions.ts (update provider)

This fixes the bug introduced in PR #179 and prevents similar issues
across all provider operations.
2025-11-08 22:07:12 +08:00
ZyphrZero
5b3b211c9a fix(ui): sync tray menu order after drag-and-drop sorting (#179)
The drag-and-drop sorting feature introduced in PR #126 (9eb991d) was
updating the provider sort order in the backend and frontend, but failed
to update the tray menu to reflect the new order.

Changes:
- Add updateTrayMenu() call after successful sort order update
- Ensures tray menu items are immediately reordered to match the UI

This fixes the issue where dragging providers in the main window would
not update their order in the system tray menu.

Fixes: 9eb991d (feat(ui): add drag-and-drop sorting for provider list)
2025-11-08 21:45:43 +08:00
Jason
fb02881684 fix(forms): populate base URL for all non-official provider categories
The base URL field was not populating when editing providers with
categories like cn_official or aggregator. The issue was caused by
inconsistent conditional logic: the input field was shown for all
non-official categories, but the value extraction only worked for
third_party and custom categories.

Changed the category check from allowlist (third_party, custom) to
denylist (official) to match the UI display logic. Now ANTHROPIC_BASE_URL
correctly populates for all provider categories except official.
2025-11-08 21:25:41 +08:00
Jason
34b8aa1008 fix(ui): remove misleading model placeholders from input fields
Clear placeholder values for model input fields to avoid suggesting specific model names that may not be applicable to all providers. This prevents user confusion when configuring different Claude providers.
2025-11-08 08:50:15 +08:00
Jason
52a7f9d313 feat(usage): enable background query for usage polling
- Add `refetchIntervalInBackground: true` to usage query configuration
- Allows usage queries to continue running when app window is minimized or unfocused
- Existing safety mechanisms remain in place (timeout limits, minimum interval, no retry)
- Users have full control through autoQueryInterval setting
2025-11-08 00:02:28 +08:00
Jason
b617879035 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
2025-11-07 22:05:33 +08:00
Jason
8d77866160 Release v3.6.0: Major architecture refactoring and feature enhancements
New Features:
- Provider duplication and manual sorting via drag-and-drop
- Custom endpoint management for aggregator providers
- Usage query with auto-refresh interval and test script API
- Config editor improvements (JSON format button, real-time TOML validation)
- Auto-sync on directory change for WSL environment support
- Load live config when editing active provider to protect manual modifications
- New provider presets: DMXAPI, Azure Codex, AnyRouter, AiHubMix, MiniMax
- Partner promotion mechanism (Zhipu GLM Z.ai)

Architecture Improvements:
- Backend: 5-phase refactoring (error handling → command split → services → concurrency)
- Frontend: 4-stage refactoring (tests → hooks → components → cleanup)
- Testing: 100% hooks unit test coverage, integration tests for critical flows

Documentation:
- Complete README rewrite with detailed architecture overview
- Separate Chinese (README_ZH.md) and English (README.md) versions
- Comprehensive v3.6.0 changelog with categorized changes
- New bilingual screenshots and partner banners

Bug Fixes:
- Fixed configuration sync issues (apiKeyUrl priority, MCP sync, import sync)
- Fixed usage query interval timing and refresh button animation
- Fixed UI issues (edit mode alignment, language switch state)
- Fixed endpoint speed test and provider duplicate insertion position
- Force exit on config error to prevent silent fallback

Technical Details:
- Updated to Tauri 2.8.x, TailwindCSS 4.x, TanStack Query v5.90.x
- Removed legacy v1 migration logic for better startup performance
- Standardized command parameters (unified to camelCase `app`)
- Result pattern for graceful error handling
v3.6.0
2025-11-07 16:27:51 +08:00
Jason
7305b1124b fix(forms): show endpoint input for all non-official providers
Previously, endpoint URL input was only shown for aggregator, third_party,
and custom categories. This excluded cn_official providers from managing
custom endpoints.

Changed logic to show endpoint input for all categories except official,
which fixes the issue and simplifies the condition.
2025-11-07 11:25:55 +08:00
Jason
dc79c31148 refactor(settings): improve directory configuration UI layout
- Rebrand "CC-Switch" to "CC Switch" across all UI text
- Separate CC Switch config directory into standalone section at top
- Update description to highlight cloud sync capability
- Remove redundant descriptions for Claude/Codex directory inputs
- Improve Chinese grammar for WSL configuration description
2025-11-06 23:05:25 +08:00
Jason
03e15916dd chore: apply cargo fmt before release
- Format code in app_config.rs to comply with rustfmt rules
- Remove extra blank line in config.rs
- Format test code in app_config_load.rs for consistency
2025-11-06 16:32:45 +08:00
Jason
69c0a09604 refactor(cleanup): remove dead code and optimize Option checks
- Remove 5 unused functions that were left over from migration refactoring:
  - get_archive_root, ensure_unique_path, archive_file (config.rs)
  - read_config_text_from_path, read_and_validate_config_from_path (codex_config.rs)
- Simplify is_v1 check using is_some_and instead of map_or for better readability
- Remove outdated comments about removed functions

This eliminates all dead_code warnings and improves code maintainability.
2025-11-06 16:22:05 +08:00
Jason
4e23250755 feat: add Z.ai GLM partner and fix apiKeyUrl priority
- Add Z.ai GLM as official partner with promotion support
- Fix apiKeyUrl not being prioritized for cn_official and aggregator categories
- Now apiKeyUrl (with promotion parameters) takes precedence over websiteUrl for cn_official, aggregator, and third_party categories
2025-11-06 16:04:10 +08:00
Jason
5f78e58ffc feat: add partner promotion feature for Zhipu GLM
- Add isPartner and partnerPromotionKey fields to Provider and ProviderPreset types
- Display gold star badge on partner presets in selector
- Show promotional message in API Key section for partners
- Configure Zhipu GLM as official partner with 10% discount promotion
- Support both Claude and Codex provider presets
- Add i18n support for partner promotion messages (zh/en)
2025-11-06 15:22:38 +08:00
Jason
e4416c9da8 docs(changelog): document breaking changes in [Unreleased]
Add comprehensive documentation for three breaking changes:
1. Runtime auto-migration from v1 to v2 config format removed
2. Legacy v1 copy file migration logic removed
3. Tauri commands now only accept 'app' parameter

Also document improvements and new tests added in recent commits.
2025-11-06 12:30:45 +08:00
Jason
6f05a91226 refactor(migration): remove legacy v1 copy file migration logic
Remove the entire migration module (435 lines) that was used for
one-time migration from v3.1.0 to v3.2.0. This cleans up technical
debt and improves startup performance.

Changes:
- Delete src-tauri/src/migration.rs (copy file scanning and merging)
- Remove migration module reference from lib.rs
- Simplify startup logic to only ensure config structure exists
- Remove automatic deduplication and archiving logic

BREAKING CHANGE: Users upgrading from v3.1.0 must first upgrade to
v3.2.x to automatically migrate their configurations.
2025-11-06 12:22:48 +08:00
Jason
db80e96786 refactor(config): remove v1 auto-migration and improve error handling
BREAKING CHANGE: Runtime auto-migration from v1 to v2 config format has been removed.

Changes:
- Remove automatic v1→v2 migration logic from MultiAppConfig::load()
- Improve v1 detection using structural analysis (checks for 'apps' key absence)
- Return clear error with migration instructions when v1 config is detected
- Add comprehensive tests for config loading edge cases
- Fix false positive detection when v1 config contains 'version' or 'mcp' fields

Migration path for users:
1. Install v3.2.x to perform one-time auto-migration, OR
2. Manually edit ~/.cc-switch/config.json to v2 format

Rationale:
- Separates concerns: load() should be read-only, not perform side effects
- Fail-fast principle: unsupported formats should error immediately
- Simplifies code maintenance by removing migration logic from hot path

Tests added:
- load_v1_config_returns_error_and_does_not_write
- load_v1_with_extra_version_still_treated_as_v1
- load_invalid_json_returns_parse_error_and_does_not_write
- load_valid_v2_config_succeeds
2025-11-06 09:18:21 +08:00