Commit Graph

15 Commits

  • feat(usage): improve custom template system with variable hints and validation fixes (#628)
    * feat(usage): improve custom template with variables display and explicit type detection
    
    Combine two feature improvements:
    1. Display supported variables ({{baseUrl}}, {{apiKey}}) with actual values in custom template mode
    2. Add explicit templateType field for accurate template mode detection
    
    ## Changes
    
    ### Frontend
    - Display template variables with actual values extracted from provider settings
    - Add templateType field to UsageScript for explicit mode detection
    - Support template mode persistence across sessions
    
    ### Backend
    - Add template_type field to UsageScript struct
    - Improve validation logic based on explicit template type
    - Maintain backward compatibility with type inference
    
    ### I18n
    - Add "Supported Variables" section translation (zh/en/ja)
    
    ### Benefits
    - More accurate template mode detection (no more guessing)
    - Better user experience with variable hints
    - Clearer validation rules per template type
    
    * fix(usage): resolve custom template cache and validation issues
    
    Combine three bug fixes to make custom template mode work correctly:
    
    1. **Update cache after test**: Testing usage script successfully now updates the main list cache immediately
    2. **Fix same-origin check**: Custom template mode can now access different domains (SSRF protection still active)
    3. **Fix field naming**: Unified to use autoQueryInterval consistently between frontend and backend
    
    ## Problems Solved
    
    - Main provider list showing "Query failed" after successful test
    - Custom templates blocked by overly strict same-origin validation
    - Auto-query intervals not saved correctly due to inconsistent naming
    
    ## Changes
    
    ### Frontend (UsageScriptModal)
    - Import useQueryClient and update cache after successful test
    - Invalidate usage cache when saving script configuration
    - Use standardized autoQueryInterval field name
    
    ### Backend (usage_script.rs)
    - Allow custom template mode to bypass same-origin checks
    - Maintain SSRF protection for all modes
    
    ### Hooks (useProviderActions)
    - Invalidate usage query cache when saving script
    
    ## Impact
    
    Users can now use custom templates freely while security validations remain intact for general templates.
    
    * fix(usage): correct provider credential field names
    
    - Claude: support both ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN
    - Gemini: use GEMINI_API_KEY instead of GOOGLE_GEMINI_API_KEY
    - Codex: use OPENAI_API_KEY and parse base_url from TOML config string
    
    Addresses review feedback from PR #628
    
    * style: format code
    
    ---------
    
    Co-authored-by: Jason <farion1231@gmail.com>
  • Feature/global proxy (#596)
    * refactor(proxy): simplify logging for better readability
    
    - Delete 17 verbose debug logs from handlers, streaming, and response_processor
    - Convert excessive INFO logs to DEBUG level for internal processing details
    - Add 2 critical INFO logs in forwarder.rs for failover scenarios:
      - Log when switching to next provider after failure
      - Log when all providers have been exhausted
    - Fix clippy uninlined_format_args warning
    
    This reduces log noise while maintaining visibility into key user-facing decisions.
    
    * fix: replace unsafe unwrap() calls with proper error handling
    
    - database/dao/mcp.rs: Use map_err for serde_json serialization
    - database/dao/providers.rs: Use map_err for settings_config and meta serialization
    - commands/misc.rs: Use expect() for compile-time regex pattern
    - services/prompt.rs: Use unwrap_or_default() for SystemTime
    - deeplink/provider.rs: Replace unwrap() with is_none_or pattern for Option checks
    
    Reduces potential panic points from 26 to 1 (static regex init, safe).
    
    * refactor(proxy): simplify verbose logging output
    
    - Remove response JSON full output logging in response_processor
    - Remove per-request INFO logs in provider_router (failover status, provider selection)
    - Change model mapping log from INFO to DEBUG
    - Change usage logging failure from INFO to WARN
    - Remove redundant debug logs for circuit breaker operations
    
    Reduces log noise significantly while preserving important warnings and errors.
    
    * feat(proxy): add structured log codes for i18n support
    
    Add error code system to proxy module logs for multi-language support:
    
    - CB-001~006: Circuit breaker state transitions and triggers
    - SRV-001~004: Proxy server lifecycle events
    - FWD-001~002: Request forwarding and failover
    - FO-001~005: Failover switch operations
    - USG-001~002: Usage logging errors
    
    Log format: [CODE] Chinese message
    Frontend/log tools can map codes to any language.
    
    New file: src/proxy/log_codes.rs - centralized code definitions
    
    * chore: bump version to 3.9.1
    
    * style: format code with prettier and rustfmt
    
    * fix(ui): allow number inputs to be fully cleared before saving
    
    - Convert numeric state to string type for controlled inputs
    - Use isNaN() check instead of || fallback to allow 0 values
    - Apply fix to ProxyPanel, CircuitBreakerConfigPanel,
      AutoFailoverConfigPanel, and ModelTestConfigPanel
    
    * feat(pricing): support @ separator in model name matching
    
    - Refactor model name cleaning into chained method calls
    - Add @ to - replacement (e.g., gpt-5.2-codex@low → gpt-5.2-codex-low)
    - Add test case for @ separator matching
    
    * feat(proxy): add global proxy settings support
    
    Add ability to configure a global HTTP/HTTPS proxy for all outbound
    requests including provider API calls, speed tests, and stream checks.
    
    * fix(proxy): improve validation and error handling in proxy config panels
    
    - Add StopTimeout/StopFailed error types for proper stop() error reporting
    - Replace silent clamp with validation-and-block in config panels
    - Add listenAddress format validation in ProxyPanel
    - Use log_codes constants instead of hardcoded strings
    - Use once_cell::Lazy for regex precompilation
    
    * fix(proxy): harden error handling and input validation
    
    - Handle RwLock poisoning in settings.rs with unwrap_or_else
    - Add fallback for dirs::home_dir() in config modules
    - Normalize localhost to 127.0.0.1 in ProxyPanel
    - Format IPv6 addresses with brackets for valid URLs
    - Strict port validation with pure digit regex
    - Treat NaN as validation failure in config panels
    - Log warning on cost_multiplier parse failure
    - Align timeoutSeconds range to [0, 300] across all panels
    
    * feat(proxy): add local proxy auto-scan and fix hot-reload
    
    - Add scan_local_proxies command to detect common proxy ports
    - Fix SkillService not using updated proxy after hot-reload
    - Move global proxy settings to advanced tab
    - Add error handling for scan failures
    
    * fix(proxy): allow localhost input in proxy address field
    
    * fix(proxy): restore request timeout and fix proxy hot-reload issues
    
    - Add URL scheme validation in build_client (http/https/socks5/socks5h)
    - Restore per-request timeout for speedtest, stream_check, usage_script, forwarder
    - Fix set_global_proxy_url to validate before persisting to DB
    - Mask proxy credentials in all log outputs
    - Fix forwarder hot-reload by fetching client on each request
    
    * style: format code with prettier
    
    * fix(proxy): improve global proxy stability and error handling
    
    - Fix RwLock silent failures with explicit error propagation
    - Handle init() duplicate calls gracefully with warning log
    - Align fallback client config with build_client settings
    - Make scan_local_proxies async to avoid UI blocking
    - Add mixed mode support for Clash 7890 port (http+socks5)
    - Use multiple test targets for better proxy connectivity test
    - Clear invalid proxy config on init failure
    - Restore timeout constraints in usage_script
    - Fix mask_url output for URLs without port
    - Add structured error codes [GP-001 to GP-009]
    
    * feat(proxy): add username/password authentication support
    
    - Add separate username and password input fields
    - Implement password visibility toggle with eye icon
    - Add clear button to reset all proxy fields
    - Auto-extract auth info from saved URL and merge on save
    - Update i18n translations (zh/en/ja)
    
    * fix(proxy): fix double encoding issue in proxy auth and add debug logs
    
    - Remove encodeURIComponent in mergeAuth() since URL object's
      username/password setters already do percent-encoding automatically
    - Add GP-010 debug log for database read operations
    - Add GP-011 debug log to track incoming URL info (length, has_auth)
    - Fix username.trim() in fallback branch for consistent behavior
  • Fix/Resolve panic issues in proxy-related code (#560)
    * fix(proxy): change default port from 5000 to 15721
    
    Port 5000 conflicts with AirPlay Receiver on macOS 12+.
    Also adds error handling for proxy toggle and i18n placeholder updates.
    
    * fix(proxy): replace unwrap/expect with graceful error handling
    
    - Handle HTTP client initialization failure with no_proxy fallback
    - Fix potential panic on Unicode slicing in API key preview
    - Add proper error handling for response body builder
    - Handle edge case where SystemTime is before UNIX_EPOCH
    
    * fix(proxy): handle UTF-8 char boundary when truncating request body log
    
    Rust strings are UTF-8 encoded, slicing at a fixed byte index may cut
    in the middle of a multi-byte character (e.g., Chinese, emoji), causing
    a panic. Use is_char_boundary() to find the nearest safe cut point.
    
    * fix(proxy): improve robustness and prevent panics
    
    - Add reqwest socks feature to support SOCKS proxy environments
    - Fix UTF-8 safety in masked_key/masked_access_token (use chars() instead of byte slicing)
    - Fix UTF-8 boundary check in usage_script HTTP response truncation
    - Add defensive checks for JSON operations in proxy service
    - Remove verbose debug logs that could trigger panic-prone code paths
  • Feat/provider icon color (#385)
    * feat(ui): add color prop support to ProviderIcon component
    
    * feat(health): add stream check core functionality
    
    Add new stream-based health check module to replace model_test:
    - Add stream_check command layer with single and batch provider checks
    - Add stream_check DAO layer for config and log persistence
    - Add stream_check service layer with retry mechanism and health status evaluation
    - Add frontend HealthStatusIndicator component
    - Add frontend useStreamCheck hook
    
    This provides more comprehensive health checking capabilities.
    
    * refactor(health): replace model_test with stream_check
    
    Replace model_test module with stream_check across the codebase:
    - Remove model_test command and service modules
    - Update command registry in lib.rs to use stream_check commands
    - Update module exports in commands/mod.rs and services/mod.rs
    - Remove frontend useModelTest hook
    - Update stream_check command implementation
    
    This refactoring provides clearer naming and better separation of concerns.
    
    * refactor(db): clean up unused database tables and optimize schema
    
    Remove deprecated and unused database tables:
    - Remove proxy_usage table (replaced by proxy_request_logs)
    - Remove usage_daily_stats table (aggregation done on-the-fly)
    - Rename model_test_logs to stream_check_logs with updated schema
    - Remove related DAO methods for proxy_usage
    - Update usage_stats service to use proxy_request_logs only
    - Refactor usage_script to work with new schema
    
    This simplifies the database schema and removes redundant data storage.
    
    * refactor(ui): update frontend components for stream check
    
    Update frontend components to use stream check API:
    - Refactor ModelTestConfigPanel to use stream check config
    - Update API layer to use stream_check commands
    - Add HealthStatus type and StreamCheckResult interface
    - Update ProviderList to use new health check integration
    - Update AutoFailoverConfigPanel with stream check references
    - Improve UI layout and configuration options
    
    This completes the frontend migration from model_test to stream_check.
    
    * feat(health): add configurable test models and reasoning effort support
    
    Enhance stream check service with configurable test models:
    - Add claude_model, codex_model, gemini_model to StreamCheckConfig
    - Support reasoning effort syntax (model@level or model#level)
    - Parse and apply reasoning_effort for OpenAI-compatible models
    - Remove hardcoded model names from check functions
    - Add unit tests for model parsing logic
    - Remove obsolete model_test source files
    
    This allows users to customize which models are used for health checks.
  • fix(proxy): resolve 404 error and auto-setup proxy targets
    Issues fixed:
    1. Route prefix mismatch - Live config was set to use /claude, /codex,
       /gemini prefixes but server only had routes without prefixes
    2. Proxy targets not auto-configured - start_with_takeover only modified
       Live config but didn't set is_proxy_target=true for current providers
    
    Changes:
    - Add prefixed routes (/claude/v1/messages, /codex/v1/*, /gemini/v1beta/*)
      to server.rs for backward compatibility
    - Remove URL prefixes from takeover_live_configs() - server can route
      by API endpoint path alone (/v1/messages=Claude, /v1/chat/completions=Codex)
    - Add setup_proxy_targets() method that automatically sets current providers
      as proxy targets when starting proxy with takeover
    - Unify proxy toggle in SettingsPage to use takeover mode (same as main UI)
    - Fix error message extraction in useProxyStatus hooks
    - Fix provider switch logic to check both takeover flag AND proxy running state
  • Security fixes javascript executor and usage script (#151)
    * dependencies: url
    
    * fix: comprehensive security improvements for usage script execution
    
    🛡️ Security Fixes:
    - Implement robust SSRF protection with same-origin URL validation
    - Add precise IP address validation for IPv4/IPv6 private networks
    - Fix port comparison to handle default ports correctly (443/80)
    - Remove hardcoded domain whitelist, support custom domains flexibly
    - Add comprehensive input validation and hostname security checks
    
    🔧 Technical Improvements:
    - Replace string-based IP checks with proper IpAddr parsing
    - Use port_or_known_default() for accurate port validation
    - Add comprehensive unit tests covering edge cases
    - Implement CIDR-compliant private IP detection (RFC1918)
    - Fix IPv6 address validation to prevent false positives
    
    📊 Fixed Issues:
    - Prevent access to private IP addresses while allowing public services
    - Support Cloudflare (172.67.x.x) and other public 172.x.x.x ranges
    - Fix port matching between explicit (e.g., :443) and implicit (default) ports
    - Resolve IPv6 false positives for addresses containing ::1 substrings
    - Maintain backward compatibility with existing script usage patterns
    
     Testing:
    - Add comprehensive test suite for IP validation (IPv4/IPv6)
    - Add port comparison tests for various scenarios
    - Add edge case tests for CIDR boundaries
    - All tests passing, ensuring no regressions
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    Co-Authored-By: Claude <noreply@anthropic.com>
    
    * fix: add is_loopback_host for proper localhost validation
    
    * fix: use Database::memory() in tests
    
    ---------
    
    Co-authored-by: Claude <noreply@anthropic.com>
  • 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>
  • chore: unify code formatting and remove unused code
    - Apply cargo fmt to Rust code with multiline error handling
    - Apply Prettier formatting to TypeScript code with trailing commas
    - Unify #[allow(non_snake_case)] attribute formatting
    - Remove unused ProviderNotFound error variant from error.rs
    - Add vitest-report.json to .gitignore to exclude test artifacts
    - Optimize readability of error handling chains with vertical alignment
    
    All tests passing: 22 Rust tests + 126 frontend tests
  • refactor(i18n): complete error message internationalization and code cleanup
    Replaced all remaining hardcoded error types with AppError::localized for
    full bilingual support and simplified error handling logic.
    
    Backend changes:
    - usage_script.rs: Converted InvalidHttpMethod to localized error
    - provider.rs: Replaced all 7 ProviderNotFound instances with localized errors
      * Line 436: Delete provider validation
      * Line 625: Update provider metadata
      * Line 785: Test usage script provider lookup
      * Line 855: Query usage provider lookup
      * Line 924: Prepare Codex provider switch
      * Line 1011: Prepare Claude provider switch
      * Line 1272: Delete provider snapshot
    - provider.rs: Simplified error message formatting (removed 40+ lines)
      * Removed redundant string matching fallback logic
      * Now uses clean language-based selection for Localized errors
      * Falls back to default Display for other error types
    - error.rs: Removed unused error variants
      * Deleted InvalidHttpMethod (replaced with localized)
      * Deleted ProviderNotFound (replaced with localized)
    
    Code quality improvements:
    - Reduced complexity: 40+ lines of string matching removed
    - Better maintainability: Centralized error message handling
    - Type safety: All provider errors now use consistent localized format
    
    Impact:
    - 100% i18n coverage for provider and usage script error messages
    - Cleaner, more maintainable error handling code
    - No unused error variants remaining
  • feat(i18n): complete internationalization for usage query feature
    Fully internationalized the usage query feature to support both Chinese and English.
    
    Frontend changes:
    - Refactored UsageScriptModal to use i18n translation keys
    - Replaced hardcoded Chinese template names with constants
    - Implemented dynamic template generation with i18n support
    - Internationalized all labels, placeholders, and code comments
    - Added template name mapping for translation
    
    Backend changes:
    - Replaced all hardcoded Chinese error messages in usage_script.rs
    - Converted 33 error instances from AppError::Message to AppError::localized
    - Added bilingual error messages for runtime, parsing, HTTP, and validation errors
    
    Translation updates:
    - Added 11 new translation key pairs to zh.json and en.json
    - Covered template names, field labels, placeholders, and code comments
    
    Impact:
    - 100% i18n coverage for usage query functionality
    - All user-facing text and error messages now support language switching
    - Better user experience for English-speaking users
  • feat(usage): add support for access token and user ID in usage scripts
    Add optional accessToken and userId fields to usage query scripts,
    enabling queries to authenticated endpoints like /api/user/self.
    
    Changes:
    - Add accessToken and userId fields to UsageScript type (frontend & backend)
    - Extend script engine to support {{accessToken}} and {{userId}} placeholders
    - Update NewAPI preset template to use /api/user/self endpoint
    - Add UI inputs for access token and user ID in UsageScriptModal
    - Pass new parameters through service layer to script executor
    
    This allows users to query usage data from endpoints that require
    login credentials, providing more accurate balance information for
    services like NewAPI/OneAPI platforms.
  • refine(usage): enhance query robustness and error handling
    Backend improvements:
    - Add InvalidHttpMethod error enum for better error semantics
    - Clamp HTTP timeout to 2-30s to prevent config abuse
    - Strict HTTP method validation instead of silent fallback to GET
    
    Frontend improvements:
    - Add i18n support for usage query errors (en/zh)
    - Improve error handling with type-safe unknown instead of any
    - Optimize i18n import (direct import instead of dynamic)
    - Disable auto-retry for usage queries to avoid API stampede
    
    Additional changes:
    - Apply prettier formatting to affected files
    
    Files changed:
    - src-tauri/src/error.rs (+2)
    - src-tauri/src/usage_script.rs (+8 -2)
    - src/i18n/locales/{en,zh}.json (+4 -1 each)
    - src/lib/api/usage.ts (+21 -4)
    - src/lib/query/queries.ts (+1)
    - style: prettier formatting on 6 other files
  • 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): complete phase 1 - full AppError migration (100%)
    Finalized the backend error handling refactoring by migrating all remaining
    modules to use AppError, eliminating all temporary error conversions.
    
    ## Changes
    
    ### Fully Migrated Modules
    
    - **mcp.rs** (129 lines changed)
      - Migrated 13 functions from Result<T, String> to Result<T, AppError>
      - Added AppError::McpValidation for domain-specific validation errors
      - Functions: validate_server_spec, validate_mcp_entry, upsert_in_config_for,
        delete_in_config_for, set_enabled_and_sync_for, sync_enabled_to_claude,
        import_from_claude, import_from_codex, sync_enabled_to_codex
      - Removed all temporary error conversions
    
    - **usage_script.rs** (143 lines changed)
      - Migrated 4 functions: execute_usage_script, send_http_request,
        validate_result, validate_single_usage
      - Used AppError::Message for JS runtime errors
      - Used AppError::InvalidInput for script validation errors
      - Improved error construction with ok_or_else (lazy evaluation)
    
    - **lib.rs** (47 lines changed)
      - Migrated create_tray_menu() and switch_provider_internal()
      - Simplified PoisonError handling with AppError::from
      - Added error logging in update_tray_menu()
      - Improved error handling in menu update logic
    
    - **migration.rs** (10 lines changed)
      - Migrated migrate_copies_into_config()
      - Used AppError::io() helper for file operations
    
    - **speedtest.rs** (8 lines changed)
      - Migrated build_client() and test_endpoints()
      - Used AppError::Message for HTTP client errors
    
    - **app_store.rs** (14 lines changed)
      - Migrated set_app_config_dir_to_store() and migrate_app_config_dir_from_settings()
      - Used AppError::Message for Tauri Store errors
      - Used AppError::io() for file system operations
    
    ### Fixed Previous Temporary Solutions
    
    - **import_export.rs** (2 lines changed)
      - Removed AppError::Message wrapper for mcp::sync_enabled_to_codex
      - Now directly calls the AppError-returning function (no conversion needed)
    
    - **commands.rs** (6 lines changed)
      - Updated query_provider_usage() and test_api_endpoints()
      - Explicit .to_string() conversion for Tauri command interface
    
    ## New Error Types
    
    - **AppError::McpValidation**: Domain-specific error for MCP configuration validation
      - Separates MCP validation errors from generic Config errors
      - Follows domain-driven design principles
    
    ## Statistics
    
    - Files changed: 8
    - Lines changed: +237/-122 (net +115)
    - Compilation:  Success (7.13s, 0 warnings)
    - Tests:  4/4 passed
    
    ## Benefits
    
    - **100% Migration**: All modules now use AppError consistently
    - **Domain Errors**: Added McpValidation for better error categorization
    - **No Temporary Solutions**: Eliminated all AppError::Message conversions for internal calls
    - **Performance**: Used ok_or_else for lazy error construction
    - **Maintainability**: Removed ~60 instances of .map_err(|e| format!("...", e))
    - **Debugging**: Added error logging in critical paths (tray menu updates)
    
    ## Phase 1 Complete
    
    Total impact across 3 commits:
    - 25 files changed
    - +671/-302 lines (net +369)
    - 100% of codebase migrated from Result<T, String> to Result<T, AppError>
    - 0 compilation warnings
    - All tests passing
    
    Ready for Phase 2: Splitting commands.rs by domain.
    
    Co-authored-by: Claude <noreply@anthropic.com>
  • feat: add provider usage query with JavaScript scripting support (#101)
    * feat: add provider usage query functionality
    
    - Updated `Cargo.toml` to include `regex` and `rquickjs` dependencies for usage script execution.
    - Implemented `query_provider_usage` command in `commands.rs` to handle usage queries.
    - Created `UsageScript` and `UsageData` structs in `provider.rs` for managing usage script configurations and results.
    - Added `execute_usage_script` function in `usage_script.rs` to run user-defined scripts for querying usage.
    - Enhanced `ProviderList` component to include a button for configuring usage scripts and a modal for editing scripts.
    - Introduced `UsageFooter` component to display usage information and status.
    - Added `UsageScriptModal` for editing and testing usage scripts with preset templates.
    - Updated Tauri API to support querying provider usage.
    - Modified types in `types.ts` to include structures for usage scripts and results.
    
    * feat(usage): support multi-plan usage display for providers
    
    - 【Feature】
      - Update `UsageResult` to support an array of `UsageData` for displaying multiple usage plans per provider.
      - Refactor `query_provider_usage` command to parse both single `UsageData` objects (for backward compatibility) and arrays of `UsageData`.
      - Enhance `usage_script` validation to accept either a single usage object or an array of usage objects.
    - 【Frontend】
      - Redesign `UsageFooter` to iterate and display details for all available usage plans, introducing `UsagePlanItem` for individual plan rendering.
      - Improve usage display with color-coded remaining balance and clear plan information.
      - Update `UsageScriptModal` test notification to summarize all returned plans.
      - Remove redundant `isCurrent` prop from `UsageFooter` in `ProviderList`.
    - 【Build】
      - Change frontend development server port from `3000` to `3005` in `tauri.conf.json` and `vite.config.mts`.
    
    * feat(usage): enhance query flexibility and display
    - 【`src/types.ts`, `src-tauri/src/provider.rs`】Make `UsageData` fields optional and introduce `extra` and `invalidMessage` for more flexible reporting.
      - `expiresAt` replaced by generic `extra` field.
      - `isValid`, `remaining`, `unit` are now optional.
      - Added `invalidMessage` to provide specific reasons for invalid status.
    - 【`src-tauri/src/usage_script.rs`】Relax usage script result validation to accommodate optional fields in `UsageData`.
    - 【`src/components/UsageFooter.tsx`】Update UI to display `extra` field and `invalidMessage`, and conditionally render `remaining` and `unit` based on availability.
    - 【`src/components/UsageScriptModal.tsx`】
      - Add a new `NewAPI` preset template demonstrating advanced extractor logic for complex API responses.
      - Update script instructions to reflect optional fields and new variable syntax (`{{apiKey}}`).
      - Remove old "DeepSeek" and "OpenAI" templates.
      - Remove basic syntax check for `return` statement.
    - 【`.vscode/settings.json`】Add `dish-ai-commit.base.language` setting.
    - 【`src-tauri/src/commands.rs`】Adjust usage logging to handle optional `remaining` and `unit` fields.
    
    * chore(config): remove VS Code settings from version control
    
    - delete .vscode/settings.json to remove editor-specific configurations
    - add /.vscode to .gitignore to prevent tracking of local VS Code settings
    - ensure personalized editor preferences are not committed to the repository
    
    * fix(provider): preserve usage script during provider update
    
    - When updating a provider, the `usage_script` configuration within `ProviderMeta` was not explicitly merged.
    - This could lead to the accidental loss of `usage_script` settings if the incoming `provider` object in the update request did not contain this field.
    - Ensure `usage_script` is cloned from the existing provider's meta when merging `ProviderMeta` during an update.
    
    * refactor(provider): enforce base_url for usage scripts and update dev ports
    - 【Backend】
        - `src-tauri/src/commands.rs`: Made `ANTHROPIC_BASE_URL` a required field for Claude providers and `base_url` a required field in `config.toml` for Codex providers when extracting credentials for usage script execution. This improves error handling by explicitly failing if these critical URLs are missing or malformed.
    - 【Frontend】
        - `src/App.tsx`, `src/components/ProviderList.tsx`: Passed `appType` prop to `ProviderList` component to ensure `updateProvider` calls within `handleSaveUsageScript` correctly identify the application type.
    - 【Config】
        - `src-tauri/tauri.conf.json`, `vite.config.mts`: Updated development server ports from `3005` to `3000` to standardize local development environment.
    
    * refactor(usage): improve usage data fetching logic
    
    - Prevent redundant API calls by tracking last fetched parameters in `useEffect`.
    - Avoid concurrent API requests by adding a guard in `fetchUsage`.
    - Clear usage data and last fetch parameters when usage query is disabled.
    - Add `queryProviderUsage` API declaration to `window.api` interface.
    
    * fix(usage-script): ensure usage script updates and improve reactivity
    
    - correctly update `usage_script` from new provider meta during updates
    - replace full page reload with targeted provider data refresh after saving usage script settings
    - trigger usage data fetch or clear when `usageEnabled` status changes in `UsageFooter`
    - reduce logging verbosity for usage script execution in backend commands and script execution
    
    * style(usage-footer): adjust usage plan item layout
    
    - Decrease width of extra field column from 35% to 30%
    - Increase width of usage information column from 40% to 45%
    - Improve visual balance and readability of usage plan items