mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-25 13:45:03 +08:00
d30562954a
* feat(components): add reusable full-screen panel components
Add new full-screen panel components to support the UI refactoring:
- FullScreenPanel: Reusable full-screen layout component with header,
content area, and optional footer. Provides consistent layout for
settings, prompts, and other full-screen views.
- PromptFormPanel: Dedicated panel for creating and editing prompts
with markdown preview support. Features real-time validation and
integrated save/cancel actions.
- AgentsPanel: Panel component for managing agent configurations.
Provides a consistent interface for agent CRUD operations.
- RepoManagerPanel: Full-featured repository manager panel for Skills.
Supports repository listing, addition, deletion, and configuration
management with integrated validation.
These components establish the foundation for the upcoming settings
page migration from dialog-based to full-screen layout.
* refactor(settings): migrate from dialog to full-screen page layout
Complete migration of settings from modal dialog to dedicated full-screen
page, improving UX and providing more space for configuration options.
Changes:
- Remove SettingsDialog component (legacy modal-based interface)
- Add SettingsPage component with full-screen layout using FullScreenPanel
- Refactor App.tsx routing to support dedicated settings page
* Add settings route handler
* Update navigation logic from dialog-based to page-based
* Integrate with existing app switcher and provider management
- Update ImportExportSection to work with new page layout
* Improve spacing and layout for better readability
* Enhanced error handling and user feedback
* Better integration with page-level actions
- Enhance useSettings hook to support page-based workflow
* Add navigation state management
* Improve settings persistence logic
* Better error boundary handling
Benefits:
- More intuitive navigation with dedicated settings page
- Better use of screen space for complex configurations
- Improved accessibility with clearer visual hierarchy
- Consistent with modern desktop application patterns
- Easier to extend with new settings sections
This change is part of the larger UI refactoring initiative to modernize
the application interface and improve user experience.
* refactor(forms): simplify and modernize form components
Comprehensive refactoring of form components to reduce complexity,
improve maintainability, and enhance user experience.
Provider Forms:
- CodexCommonConfigModal & CodexConfigSections
* Simplified state management with reduced boilerplate
* Improved field validation and error handling
* Better layout with consistent spacing
* Enhanced model selection with visual indicators
- GeminiCommonConfigModal & GeminiConfigSections
* Streamlined authentication flow (OAuth vs API Key)
* Cleaner form layout with better grouping
* Improved validation feedback
* Better integration with parent components
- CommonConfigEditor
* Reduced from 178 to 68 lines (-62% complexity)
* Extracted reusable form patterns
* Improved JSON editing with syntax validation
* Better error messages and recovery options
- EndpointSpeedTest
* Complete rewrite for better UX
* Real-time testing progress indicators
* Enhanced error handling with retry logic
* Visual feedback for test results (color-coded latency)
MCP & Prompts:
- McpFormModal
* Simplified from 581 to ~360 lines
* Better stdio/http server type handling
* Improved form validation
* Enhanced multi-app selection (Claude/Codex/Gemini)
- PromptPanel
* Cleaner integration with PromptFormPanel
* Improved list/grid view switching
* Better state management for editing workflows
* Enhanced delete confirmation with safety checks
Code Quality Improvements:
- Reduced total lines by ~251 lines (-24% code reduction)
- Eliminated duplicate validation logic
- Improved TypeScript type safety
- Better component composition and separation of concerns
- Enhanced accessibility with proper ARIA labels
These changes make forms more intuitive, responsive, and easier to
maintain while reducing bundle size and improving runtime performance.
* style(ui): modernize component layouts and visual design
Update UI components with improved layouts, visual hierarchy, and
modern design patterns for better user experience.
Navigation & Brand Components:
- AppSwitcher
* Enhanced visual design with better spacing
* Improved active state indicators
* Smoother transitions and hover effects
* Better mobile responsiveness
- BrandIcons
* Optimized icon rendering performance
* Added support for more provider icons
* Improved SVG handling and fallbacks
* Better scaling across different screen sizes
Editor Components:
- JsonEditor
* Enhanced syntax highlighting
* Better error visualization
* Improved code formatting options
* Added line numbers and code folding support
- UsageScriptModal
* Complete layout overhaul (1239 lines refactored)
* Better script editor integration
* Improved template selection UI
* Enhanced preview and testing panels
* Better error feedback and validation
Provider Components:
- ProviderCard
* Redesigned card layout with modern aesthetics
* Better information density and readability
* Improved action buttons placement
* Enhanced status indicators (active/inactive)
- ProviderList
* Better grid/list view layouts
* Improved drag-and-drop visual feedback
* Enhanced sorting indicators
- ProviderActions
* Streamlined action menu
* Better icon consistency
* Improved tooltips and accessibility
Usage & Footer:
- UsageFooter
* Redesigned footer layout
* Better quota visualization
* Improved refresh controls
* Enhanced error states
Design System Updates:
- dialog.tsx (shadcn/ui component)
* Updated to latest design tokens
* Better overlay animations
* Improved focus management
- index.css
* Added 65 lines of global utility classes
* New animation keyframes
* Enhanced color variables for dark mode
* Improved typography scale
- tailwind.config.js
* Extended theme with new design tokens
* Added custom animations and transitions
* New spacing and sizing utilities
* Enhanced color palette
Visual Improvements:
- Consistent border radius across components
- Unified shadow system for depth perception
- Better color contrast for accessibility (WCAG AA)
- Smoother animations and transitions
- Improved dark mode support
These changes create a more polished, modern interface while
maintaining consistency with the application's design language.
* chore: update dialogs, i18n and improve component integration
Various functional updates and improvements across provider dialogs,
MCP panel, skills page, and internationalization.
Provider Dialogs:
- AddProviderDialog
* Simplified form state management
* Improved preset selection workflow
* Better validation error messages
* Enhanced template variable handling
- EditProviderDialog
* Streamlined edit flow with better state synchronization
* Improved handling of live config backfilling
* Better error recovery for failed updates
* Enhanced integration with parent components
MCP & Skills:
- UnifiedMcpPanel
* Reduced complexity from 140+ to ~95 lines
* Improved multi-app server management
* Better server type detection (stdio/http)
* Enhanced server status indicators
* Cleaner integration with MCP form modal
- SkillsPage
* Simplified navigation and state management
* Better integration with RepoManagerPanel
* Improved error handling for repository operations
* Enhanced loading states
- SkillCard
* Minor layout adjustments
* Better action button placement
Environment & Configuration:
- EnvWarningBanner
* Improved conflict detection messages
* Better visual hierarchy for warnings
* Enhanced dismissal behavior
- tauri.conf.json
* Updated build configuration
* Added new window management options
Internationalization:
- en.json & zh.json
* Added 17 new translation keys for new features
* Updated existing keys for better clarity
* Added translations for new settings page
* Improved consistency across UI text
Code Cleanup:
- mutations.ts
* Removed 14 lines of unused mutation definitions
* Cleaned up deprecated query invalidation logic
* Better type safety for mutation parameters
Overall Impact:
- Reduced total lines by 51 (-10% in affected files)
- Improved component integration and data flow
- Better error handling and user feedback
- Enhanced i18n coverage for new features
These changes improve the overall polish and integration of various
components while removing technical debt and unused code.
* feat(backend): add auto-launch functionality
Implement system auto-launch feature to allow CC-Switch to start
automatically on system boot, improving user convenience.
Backend Implementation:
- auto_launch.rs: New module for auto-launch management
* Cross-platform support using auto-launch crate
* Enable/disable auto-launch with system integration
* Proper error handling for permission issues
* Platform-specific implementations (macOS/Windows/Linux)
Command Layer:
- Add get_auto_launch command to check current status
- Add set_auto_launch command to toggle auto-start
- Integrate commands with settings API
Settings Integration:
- Extend Settings struct with auto_launch field
- Persist auto-launch preference in settings store
- Automatic state synchronization on app startup
Dependencies:
- Add auto-launch ^0.5.0 to Cargo.toml
- Update Cargo.lock with new dependency tree
Technical Details:
- Uses platform-specific auto-launch mechanisms:
* macOS: Login Items via LaunchServices
* Windows: Registry Run key
* Linux: XDG autostart desktop files
- Handles edge cases like permission denials gracefully
- Maintains settings consistency across app restarts
This feature enables users to have CC-Switch readily available
after system boot without manual intervention, particularly useful
for users who frequently switch between API providers.
* refactor(settings): enhance settings page with auto-launch integration
Complete refactoring of settings page architecture to integrate auto-launch
feature and improve overall settings management workflow.
SettingsPage Component:
- Integrate auto-launch toggle with WindowSettings section
- Improve layout and spacing for better visual hierarchy
- Enhanced error handling for settings operations
- Better loading states during settings updates
- Improved accessibility with proper ARIA labels
WindowSettings Component:
- Add auto-launch switch with real-time status
- Integrate with backend auto-launch commands
- Proper error feedback for permission issues
- Visual indicators for current auto-launch state
- Tooltip guidance for auto-launch functionality
useSettings Hook (Major Refactoring):
- Complete rewrite reducing complexity by ~30%
- Better separation of concerns with dedicated handlers
- Improved state management using React Query
- Enhanced auto-launch state synchronization
* Fetch auto-launch status on mount
* Real-time updates on toggle
* Proper error recovery
- Optimized re-renders with better memoization
- Cleaner API for component integration
- Better TypeScript type safety
Settings API:
- Add getAutoLaunch() method
- Add setAutoLaunch(enabled: boolean) method
- Type-safe Tauri command invocations
- Proper error propagation to UI layer
Architecture Improvements:
- Reduced hook complexity from 197 to ~140 effective lines
- Eliminated redundant state management logic
- Better error boundaries and fallback handling
- Improved testability with clearer separation
User Experience Enhancements:
- Instant visual feedback on auto-launch toggle
- Clear error messages for permission issues
- Loading indicators during async operations
- Consistent behavior across all platforms
This refactoring provides a solid foundation for future settings
additions while maintaining code quality and user experience.
* refactor(ui): optimize FullScreenPanel, Dialog and App routing
Comprehensive refactoring of core UI components to improve code quality,
maintainability, and user experience.
FullScreenPanel Component:
- Enhanced props interface with better TypeScript types
- Improved layout flexibility with customizable padding
- Better header/footer composition patterns
- Enhanced scroll behavior for long content
- Added support for custom actions in header
- Improved responsive design for different screen sizes
- Better integration with parent components
- Cleaner prop drilling with context where appropriate
Dialog Component (shadcn/ui):
- Updated to latest component patterns
- Improved animation timing and easing
- Better focus trap management
- Enhanced overlay styling with backdrop blur
- Improved accessibility (ARIA labels, keyboard navigation)
- Better close button positioning and styling
- Enhanced mobile responsiveness
- Cleaner composition with DialogHeader/Footer
App Component Routing:
- Refactored routing logic for better clarity
- Improved state management for navigation
- Better integration with settings page
- Enhanced error boundary handling
- Cleaner separation of layout concerns
- Improved provider context propagation
- Better handling of deep links
- Optimized re-renders with React.memo where appropriate
Code Quality Improvements:
- Reduced prop drilling with better component composition
- Improved TypeScript type safety
- Better separation of concerns
- Enhanced code readability with clearer naming
- Eliminated redundant logic
Performance Optimizations:
- Reduced unnecessary re-renders
- Better memoization of callbacks
- Optimized component tree structure
- Improved event handler efficiency
User Experience:
- Smoother transitions and animations
- Better visual feedback for interactions
- Improved loading states
- More consistent behavior across features
These changes create a more maintainable and performant foundation
for the application's UI layer while improving the overall user
experience with smoother interactions and better visual polish.
* refactor(features): modernize Skills, Prompts and Agents components
Major refactoring of feature components to improve code quality,
user experience, and maintainability.
SkillsPage Component (299 lines refactored):
- Complete rewrite of layout and state management
- Better integration with RepoManagerPanel
- Improved navigation between list and detail views
- Enhanced error handling with user-friendly messages
- Better loading states with skeleton screens
- Optimized re-renders with proper memoization
- Cleaner separation between list and form views
- Improved skill card interactions
- Better responsive design for different screen sizes
RepoManagerPanel Component (370 lines refactored):
- Streamlined repository management workflow
- Enhanced form validation with real-time feedback
- Improved repository list with better visual hierarchy
- Better handling of git operations (clone, pull, delete)
- Enhanced error recovery for network issues
- Cleaner state management reducing complexity
- Improved TypeScript type safety
- Better integration with Skills backend API
- Enhanced loading indicators for async operations
PromptPanel Component (249 lines refactored):
- Modernized layout with FullScreenPanel integration
- Better separation between list and edit modes
- Improved prompt card design with better readability
- Enhanced search and filter functionality
- Cleaner state management for editing workflow
- Better integration with PromptFormPanel
- Improved delete confirmation with safety checks
- Enhanced keyboard navigation support
PromptFormPanel Component (238 lines refactored):
- Streamlined form layout and validation
- Better markdown editor integration
- Real-time preview with syntax highlighting
- Improved validation error display
- Enhanced save/cancel workflow
- Better handling of large prompt content
- Cleaner form state management
- Improved accessibility features
AgentsPanel Component (33 lines modified):
- Minor layout adjustments for consistency
- Better integration with FullScreenPanel
- Improved placeholder states
- Enhanced error boundaries
Type Definitions (types.ts):
- Added 10 new type definitions
- Better type safety for Skills/Prompts/Agents
- Enhanced interfaces for repository management
- Improved typing for form validations
Architecture Improvements:
- Reduced component coupling
- Better prop interfaces with explicit types
- Improved error boundaries
- Enhanced code reusability
- Better testing surface
User Experience Enhancements:
- Smoother transitions between views
- Better visual feedback for actions
- Improved error messages
- Enhanced loading states
- More intuitive navigation flows
- Better responsive layouts
Code Quality:
- Net reduction of 29 lines while adding features
- Improved code organization
- Better naming conventions
- Enhanced documentation
- Cleaner control flow
These changes significantly improve the maintainability and user
experience of core feature components while establishing consistent
patterns for future development.
* style(ui): refine component layouts and improve visual consistency
Comprehensive UI polish across multiple components to enhance visual
design, improve user experience, and maintain consistency.
UsageScriptModal Component (1302 lines refactored):
- Complete layout overhaul for better usability
- Improved script editor with syntax highlighting
- Better template selection interface
- Enhanced test/preview panels with clearer separation
- Improved error feedback and validation messages
- Better modal sizing and responsiveness
- Cleaner tab navigation between sections
- Enhanced code formatting and readability
- Improved loading states for async operations
- Better integration with parent components
MCP Components:
- McpFormModal (42 lines):
* Streamlined form layout
* Better server type selection (stdio/http)
* Improved field grouping and labels
* Enhanced validation feedback
- UnifiedMcpPanel (14 lines):
* Minor layout adjustments
* Better list item spacing
* Improved server status indicators
* Enhanced action button placement
Provider Components:
- ProviderCard (11 lines):
* Refined card layout and spacing
* Better visual hierarchy
* Improved badge placement
* Enhanced hover effects
- ProviderList (5 lines):
* Minor grid layout adjustments
* Better drag-and-drop visual feedback
- GeminiConfigSections (4 lines):
* Field label alignment
* Improved spacing consistency
Editor & Footer Components:
- JsonEditor (13 lines):
* Better editor height management
* Improved error display
* Enhanced syntax highlighting
- UsageFooter (10 lines):
* Refined footer layout
* Better quota display
* Improved refresh button placement
Settings & Environment:
- ImportExportSection (24 lines):
* Better button layout
* Improved action grouping
* Enhanced visual feedback
- EnvWarningBanner (4 lines):
* Refined alert styling
* Better dismiss button placement
Global Styles (index.css):
- Added 11 lines of utility classes
- Improved transition timing
- Better focus indicators
- Enhanced scrollbar styling
- Refined spacing utilities
Design Improvements:
- Consistent spacing using design tokens
- Unified color palette application
- Better typography hierarchy
- Improved shadow system for depth
- Enhanced interactive states (hover, active, focus)
- Better border radius consistency
- Refined animation timings
Accessibility:
- Improved focus indicators
- Better keyboard navigation
- Enhanced screen reader support
- Improved color contrast ratios
Code Quality:
- Net increase of 68 lines due to UsageScriptModal improvements
- Better component organization
- Cleaner style application
- Reduced style duplication
These visual refinements create a more polished and professional
interface while maintaining excellent usability and accessibility
standards across all components.
* chore(i18n): add auto-launch translation keys
Add translation keys for new auto-launch feature to support
multi-language interface.
Translation Keys Added:
- autoLaunch: Label for auto-launch toggle
- autoLaunchDescription: Explanation of auto-launch functionality
- autoLaunchEnabled: Status message when enabled
Languages Updated:
- Chinese (zh.json): 简体中文翻译
- English (en.json): English translations
The translations maintain consistency with existing terminology
and provide clear, user-friendly descriptions of the auto-launch
feature across both supported languages.
* test: update test suites to match component refactoring
Comprehensive test updates to align with recent component refactoring
and new auto-launch functionality.
Component Tests:
- AddProviderDialog.test.tsx (10 lines):
* Updated test cases for new dialog behavior
* Enhanced mock data for preset selection
* Improved assertions for validation
- ImportExportSection.test.tsx (16 lines):
* Updated for new settings page integration
* Enhanced test coverage for error scenarios
* Better mock state management
- McpFormModal.test.tsx (60 lines):
* Extensive updates for form refactoring
* New test cases for multi-app selection
* Enhanced validation testing
* Better coverage of stdio/http server types
- ProviderList.test.tsx (11 lines):
* Updated for new card layout
* Enhanced drag-and-drop testing
- SettingsDialog.test.tsx (96 lines):
* Major updates for SettingsPage migration
* New test cases for auto-launch functionality
* Enhanced integration test coverage
* Better async operation testing
Hook Tests:
- useDirectorySettings.test.tsx (32 lines):
* Updated for refactored hook logic
* Enhanced test coverage for edge cases
- useDragSort.test.tsx (36 lines):
* Simplified test cases
* Better mock implementation
* Improved assertions
- useImportExport tests (16 lines total):
* Updated for new error handling
* Enhanced test coverage
- useMcpValidation.test.tsx (23 lines):
* Updated validation test cases
* Better coverage of error scenarios
- useProviderActions.test.tsx (48 lines):
* Extensive updates for hook refactoring
* New test cases for provider operations
* Enhanced mock data
- useSettings.test.tsx (12 lines):
* New test cases for auto-launch
* Enhanced settings state testing
* Better async operation coverage
Integration Tests:
- App.test.tsx (41 lines):
* Updated for new routing logic
* Enhanced navigation testing
* Better component integration coverage
- SettingsDialog.test.tsx (88 lines):
* Complete rewrite for SettingsPage
* New integration test scenarios
* Enhanced user workflow testing
Mock Infrastructure:
- handlers.ts (117 lines):
* Major updates for MSW handlers
* New handlers for auto-launch commands
* Enhanced error simulation
* Better request/response mocking
- state.ts (37 lines):
* Updated mock state structure
* New state for auto-launch
* Enhanced state reset functionality
- tauriMocks.ts (10 lines):
* Updated mock implementations
* Better type safety
- server.ts & testQueryClient.ts:
* Minor cleanup (2 lines removed)
Test Infrastructure Improvements:
- Better test isolation
- Enhanced mock data consistency
- Improved async operation testing
- Better error scenario coverage
- Enhanced integration test patterns
Coverage Improvements:
- Net increase of 195 lines of test code
- Better coverage of edge cases
- Enhanced error path testing
- Improved integration test scenarios
- Better mock infrastructure
All tests now pass with the refactored components while maintaining
comprehensive coverage of functionality and edge cases.
* style(ui): improve window dragging and provider card styles
* fix(skills): resolve third-party skills installation failure
- Add skills_path field to Skill struct
- Use skills_path to construct correct source path during installation
- Fix installation for repos with custom skill subdirectories
* feat(icon): add icon type system and intelligent inference logic
Introduce a new icon system for provider customization:
- Add IconMetadata and IconPreset interfaces in src/types/icon.ts
- Define structure for icon name, display name, category, keywords
- Support default color configuration per icon
- Implement smart icon inference in src/config/iconInference.ts
- Create iconMappings for 25+ AI providers and cloud platforms
- Include Claude, DeepSeek, Qwen, Kimi, Google, AWS, Azure, etc.
- inferIconForPreset(): match provider name to icon config
- addIconsToPresets(): batch apply icons to preset arrays
- Support fuzzy matching for flexible name recognition
This foundation enables automatic icon assignment when users add
providers, improving visual identification in the provider list.
* feat(ui): add icon picker, color picker and provider icon components
Implement comprehensive icon selection system for provider customization:
## New Components
### ProviderIcon (src/components/ProviderIcon.tsx)
- Render SVG icons by name with automatic fallback
- Display provider initials when icon not found
- Support custom sizing via size prop
- Use dangerouslySetInnerHTML for inline SVG rendering
### IconPicker (src/components/IconPicker.tsx)
- Grid-based icon selection with visual preview
- Real-time search filtering by name and keywords
- Integration with icon metadata for display names
- Responsive grid layout (6-10 columns based on screen)
### ColorPicker (src/components/ColorPicker.tsx)
- 12 preset colors for quick selection
- Native color input for custom color picking
- Hex input field for precise color entry
- Visual feedback for selected color state
## Icon Assets (src/icons/extracted/)
- 38 high-quality SVG icons for AI providers and platforms
- Includes: OpenAI, Claude, DeepSeek, Qwen, Kimi, Gemini, etc.
- Cloud platforms: AWS, Azure, Google Cloud, Cloudflare
- Auto-generated index.ts with getIcon/hasIcon helpers
- Metadata system with searchable keywords per icon
## Build Scripts
- scripts/extract-icons.js: Extract icons from simple-icons
- scripts/generate-icon-index.js: Generate TypeScript index file
* feat(provider): integrate icon system into provider UI components
Add icon customization support to provider management interface:
## Type System Updates
### Provider Interface (src/types.ts)
- Add optional `icon` field for icon name (e.g., "openai", "anthropic")
- Add optional `iconColor` field for hex color (e.g., "#00A67E")
### Form Schema (src/lib/schemas/provider.ts)
- Extend providerSchema with icon and iconColor optional fields
- Maintain backward compatibility with existing providers
## UI Components
### ProviderCard (src/components/providers/ProviderCard.tsx)
- Display ProviderIcon alongside provider name
- Add icon container with hover animation effect
- Adjust layout spacing for icon placement
- Update translate offsets for action buttons
### BasicFormFields (src/components/providers/forms/BasicFormFields.tsx)
- Add icon preview section showing current selection
- Implement fullscreen icon picker dialog
- Auto-apply default color from icon metadata on selection
- Display provider name and icon status in preview
### AddProviderDialog & EditProviderDialog
- Pass icon fields through form submission
- Preserve icon data during provider updates
This enables users to visually distinguish providers in the list
with custom icons, improving UX for multi-provider setups.
* feat(backend): add icon fields to Provider model and default mappings
Extend Rust backend to support provider icon customization:
## Provider Model (src-tauri/src/provider.rs)
- Add `icon: Option<String>` field for icon name
- Add `icon_color: Option<String>` field for hex color
- Use serde rename `iconColor` for frontend compatibility
- Apply skip_serializing_if for clean JSON output
- Update Provider::new() to initialize icon fields as None
## Provider Defaults (src-tauri/src/provider_defaults.rs) [NEW]
- Define ProviderIcon struct with name and color fields
- Create DEFAULT_PROVIDER_ICONS static HashMap with 23 providers:
- AI providers: OpenAI, Anthropic, Claude, Google, Gemini,
DeepSeek, Kimi, Moonshot, Zhipu, MiniMax, Baidu, Alibaba,
Tencent, Meta, Microsoft, Cohere, Perplexity, Mistral, HuggingFace
- Cloud platforms: AWS, Azure, Huawei, Cloudflare
- Implement infer_provider_icon() with exact and fuzzy matching
- Add unit tests for matching logic (exact, fuzzy, case-insensitive)
## Deep Link Support (src-tauri/src/deeplink.rs)
- Initialize icon fields when creating Provider from deep link import
## Module Registration (src-tauri/src/lib.rs)
- Register provider_defaults module
## Dependencies (Cargo.toml)
- Add once_cell for lazy static initialization
This backend support enables icon persistence and future features
like auto-icon inference during provider creation.
* chore(i18n): add translations for icon picker and provider icon
Add Chinese and English translations for icon customization feature:
## Icon Picker (iconPicker)
- search: "Search Icons" / "搜索图标"
- searchPlaceholder: "Enter icon name..." / "输入图标名称..."
- noResults: "No matching icons found" / "未找到匹配的图标"
- category.aiProvider: "AI Providers" / "AI 服务商"
- category.cloud: "Cloud Platforms" / "云平台"
- category.tool: "Dev Tools" / "开发工具"
- category.other: "Other" / "其他"
## Provider Icon (providerIcon)
- label: "Icon" / "图标"
- colorLabel: "Icon Color" / "图标颜色"
- selectIcon: "Select Icon" / "选择图标"
- preview: "Preview" / "预览"
These translations support the new icon picker UI components
and provider form icon selection interface.
* style(ui): refine header layout and AppSwitcher color scheme
Improve application header and component styling:
## App.tsx Header Layout
- Wrap title and settings button in flex container with gap
- Add vertical divider between title and settings icon
- Apply responsive padding (pl-1 sm:pl-2)
- Reformat JSX for better readability (prettier)
- Fix string template formatting in className
## AppSwitcher Color Update
- Change Claude tab gradient from orange/amber to teal/emerald/green
- Update shadow color to match new teal theme
- Change hover color from orange-500 to teal-500
- Align visual style with emerald/teal brand colors
## Dialog Component Cleanup
- Remove default close button (X icon) from DialogContent
- Allow parent components to control close button placement
- Remove unused lucide-react X import
## index.css Header Border
- Add top border (2px solid) to glass-header
- Apply to both light and dark mode variants
- Improve visual separation of header area
These changes enhance visual consistency and modernize the UI
appearance with a cohesive teal color scheme.
* chore(deps): add icon library and update preset configurations
Add dependencies and utility scripts for icon system:
## Dependencies (package.json)
- Add @lobehub/icons-static-svg@1.73.0
- High-quality SVG icon library for AI providers
- Source for extracted icons in src/icons/extracted/
- Update pnpm-lock.yaml accordingly
## Provider Preset Updates (src/config/claudeProviderPresets.ts)
- Add optional `icon` and `iconColor` fields to ProviderPreset interface
- Apply to Anthropic Official preset as example:
- icon: "anthropic"
- iconColor: "#D4915D"
- Future presets can include default icon configurations
## Utility Script (scripts/filter-icons.js) [NEW]
- Helper script for filtering and managing icon assets
- Supports icon discovery and validation workflow
- Complements extract-icons.js and generate-icon-index.js
This completes the icon system infrastructure, providing all
necessary tools and dependencies for icon customization.
* refactor(ui): simplify AppSwitcher styles and migrate to local SVG icons
- Replace complex gradient animations with clean, minimal tab design
- Migrate from @lobehub/icons CDN to local SVG assets for better reliability
- Fix clippy warning in error.rs (use inline format args)
- Improve code formatting in skill service and commands
- Reduce CSS complexity in AppSwitcher component (removed blur effects and gradients)
- Update BrandIcons to use imported local SVG files instead of dynamic image loading
This improves performance, reduces external dependencies, and provides a cleaner UI experience.
* style(ui): hide scrollbars across all browsers and optimize form layout
- Hide scrollbars globally with cross-browser support:
* WebKit browsers (Chrome, Safari, Edge): ::-webkit-scrollbar { display: none }
* Firefox: scrollbar-width: none
* IE 10+: -ms-overflow-style: none
- Remove custom scrollbar styling (width, colors, hover states)
- Reorganize BasicFormFields layout:
* Move icon picker to top center as a clickable preview (80x80)
* Change name and notes fields to horizontal grid layout (md:grid-cols-2)
* Remove icon preview section from bottom
* Improve visual hierarchy and space efficiency
This provides a cleaner, more modern UI with hidden scrollbars while maintaining full scroll functionality.
* refactor(layout): standardize max-width to 60rem and optimize padding structure
- Unify container max-width across components:
* Replace max-w-4xl with max-w-[60rem] in App.tsx provider list
* Replace max-w-5xl with max-w-[60rem] in PromptPanel
* Move padding from header element to inner container for consistent spacing
- Optimize padding hierarchy:
* Remove px-6 from header element, add to inner header container
* Remove px-6 from main element, keep it only in provider list container
* Consolidate PromptPanel padding: move px-6 from nested divs to outer container
* Remove redundant pl-1 sm:pl-2 from logo/title area
- Benefits:
* Consistent 60rem max-width provides better readability on wide screens
* Simplified padding structure reduces CSS complexity
* Cleaner responsive behavior with unified spacing rules
This creates a more maintainable and visually consistent layout system.
* refactor(ui): unify layout system with 60rem max-width and consistent spacing
- Standardize container max-width across all panels:
* Replace max-w-4xl and max-w-5xl with unified max-w-[60rem]
* Apply to SettingsPage, UnifiedMcpPanel, SkillsPage, and FullScreenPanel
* Ensures consistent reading width and visual balance on wide screens
- Optimize padding hierarchy and structure:
* Move px-6 from parent elements to content containers
* FullScreenPanel: Add max-w-[60rem] wrapper to header, content, and footer
* Add border separators (border-t/border-b) to header and footer sections
* Consolidate nested padding in MCP, Skills, and Prompts panels
* Remove redundant padding layers for cleaner CSS
- Simplify component styling:
* MCP list items: Replace card-based layout with modern group-based design
* Remove unnecessary wrapper divs and flatten DOM structure
* Update card hover effects with smooth transitions
* Simplify icon selection dialog (remove description text in BasicFormFields)
- Benefits:
* Consistent 60rem max-width provides optimal readability
* Unified spacing rules reduce maintenance complexity
* Cleaner component hierarchy improves performance
* Better responsive behavior across different screen sizes
* More cohesive visual design language throughout the app
This creates a maintainable, scalable design system foundation.
* feat(deeplink): add Claude model fields support and enhance import dialog
- Add Claude-specific model field support in deeplink import:
* Support model (ANTHROPIC_MODEL) - general default model
* Support haikuModel (ANTHROPIC_DEFAULT_HAIKU_MODEL)
* Support sonnetModel (ANTHROPIC_DEFAULT_SONNET_MODEL)
* Support opusModel (ANTHROPIC_DEFAULT_OPUS_MODEL)
* Backend: Update DeepLinkImportRequest struct to include optional model fields
* Frontend: Add TypeScript type definitions for new model parameters
- Enhance deeplink demo page (deplink.html):
* Add 5 new Claude configuration examples showcasing different model setups
* Add parameter documentation with required/optional tags
* Include basic config (no models), single model, complete 4-model, partial models, and third-party provider examples
* Improve visual design with param-list component and color-coded badges
* Add detailed descriptions for each configuration scenario
- Redesign DeepLinkImportDialog layout:
* Switch from 3-column to compact 2-column grid layout
* Reduce dialog width from 500px to 650px for better content display
* Add dedicated section for Claude model configurations with blue highlight box
* Use uppercase labels and smaller text for more information density
* Add truncation and tooltips for long URLs
* Improve visual hierarchy with spacing and grouping
* Increase z-index to 9999 to ensure dialog appears on top
- Minor UI refinements:
* Update App.tsx layout adjustments
* Optimize McpFormModal styling
* Refine ProviderCard and BasicFormFields components
This enables users to import Claude providers with precise model configurations via deeplink.
* feat(deeplink): add config file support for deeplink import
Support importing provider configuration from embedded or remote config files.
- Add base64 dependency for config content encoding
- Support config, configFormat, and configUrl parameters
- Make homepage/endpoint/apiKey optional when config is provided
- Add config parsing and merging logic
* feat(deeplink): enhance dialog with config file preview
Add config file parsing and preview in deep link import dialog.
- Support Base64 encoded config display
- Add config file source indicator (embedded/remote)
- Parse and display config fields by app type (Claude/Codex/Gemini)
- Mask sensitive values in config preview
- Improve dialog layout and content organization
* refactor(ui): unify dialog styles and improve layout consistency
Standardize dialog and panel components across the application.
- Update dialog background to use semantic color tokens
- Adjust FullScreenPanel max-width to 56rem for better alignment
- Add drag region and prevent body scroll in full-screen panels
- Optimize button sizes and spacing in panel headers
- Apply consistent styling to all dialog-based components
* i18n: add deeplink config preview translations
Add missing translation keys for config file preview feature.
- Add configSource, configEmbedded, configRemote labels
- Add configDetails and configUrl display strings
- Support both Chinese and English versions
* feat(deeplink): enhance test page with v3.8 config file examples
Improve deeplink test page with comprehensive config file import examples.
- Add version badge for v3.8 features
- Add copy-to-clipboard functionality for all deep links
- Add Claude config file import examples (embedded/remote)
- Add Codex config file import examples (auth.json + config.toml)
- Add Gemini config file import examples (.env format)
- Add config generator tool for easy testing
- Update UI with better styling and layout
* feat(settings): add autoSaveSettings for lightweight auto-save
Add optimized auto-save function for General tab settings.
- Add autoSaveSettings method for non-destructive auto-save
- Only trigger system APIs when values actually change
- Avoid unnecessary auto-launch and plugin config updates
- Update tests to cover new functionality
* refactor(settings): simplify settings page layout and auto-save
Reorganize settings page structure and integrate autoSaveSettings.
- Move save button inline within Advanced tab content
- Remove sticky footer for cleaner layout
- Use autoSaveSettings for General tab settings
- Simplify dialog close behavior
- Refactor ImportExportSection layout
* style(providers): optimize card layout and action button sizes
Improve provider card visual density and action buttons.
- Reduce icon button sizes for compact layout
- Adjust drag handle and icon sizes
- Tighten spacing between action buttons
- Update hover translate values for better alignment
* refactor(mcp): improve form modal layout with adaptive height editor
Restructure MCP form modal for better space utilization.
- Split form into upper form fields and lower JSON editor sections
- Add full-height mode support for JsonEditor component
- Use flex layout for editor to fill available space
- Update PromptFormPanel to use full-height editor
- Fix locale text formatting
* style: unify list item styles with semantic colors
Apply consistent styling to list items across components.
- Replace hardcoded colors with semantic tokens in MCP and Prompt list items
- Add glass effect container to EndpointSpeedTest panel
- Format code for better readability
* style: format template literals for better readability
Improve code formatting for conditional className expressions.
- Break long template literals across multiple lines
- Maintain consistent formatting in MCP form and endpoint test components
* feat(deeplink): add config merge command for preview
Expose config merging functionality to frontend for preview.
- Add merge_deeplink_config Tauri command
- Make parse_and_merge_config public for reuse
- Enable frontend to display complete config before import
* feat(deeplink): merge and display config in import dialog
Enhance import dialog to fetch and display complete config.
- Call mergeDeeplinkConfig API when config is present
- Add UTF-8 base64 decoding support for config content
- Add scrollable content area with custom scrollbar styling
- Show complete configuration before user confirms import
* i18n: add config merge error message
Add translation for config file merge error handling.
* style(deeplink): format test page HTML for better readability
Improve HTML formatting in deeplink test page.
- Format multiline attributes for better readability
- Add consistent indentation to nested elements
- Break long lines in buttons and links
* refactor(usage): improve footer layout with two-row design
Reorganize usage footer for better readability and space efficiency.
- Split into two rows: update time + refresh button (row 1), usage stats (row 2)
- Move refresh button to top row next to update time
- Remove card background for cleaner look
- Add fallback text when never updated
- Improve spacing and alignment
- Format template literals for consistency
* feat(database): add SQLite database infrastructure
- Add rusqlite dependency (v0.32.1) and r2d2 connection pooling
- Implement Database module with CRUD operations for providers, MCP servers, prompts, and skills
- Add schema initialization with proper indexes
- Include data migration utilities from JSON config to SQLite
- Support timestamp tracking (created_at, updated_at)
* refactor(core): integrate SQLite database into application core
- Initialize database on app startup with migration from JSON config
- Update AppState to include Database instance alongside MultiAppConfig
- Simplify store module by removing unused session management code
- Add database initialization to app setup flow
- Support both database and legacy config during transition
* refactor(services): migrate service layer to use SQLite database
- Refactor ProviderService to use database queries instead of in-memory config
- Update McpService to fetch and store MCP servers in database
- Migrate PromptService to database-backed storage
- Simplify ConfigService by removing complex transaction logic
- Remove 648 lines of redundant code through database abstraction
* refactor(commands): update command layer to use database API
- Update config commands to query database for providers and settings
- Modify provider commands to pass database handle to services
- Update MCP commands to use database-backed operations
- Refactor prompt and skill commands to leverage database storage
- Simplify import/export commands with database integration
* refactor(backend): update supporting modules for database compatibility
- Add DatabaseError variant to AppError enum
- Update provider module to support database-backed operations
- Modify codex_config to work with new database structure
- Ensure error handling covers database operations
* refactor(frontend): update UI components for database migration
- Update UsageFooter component to handle new data structure
- Modify SkillsPage to work with database-backed skills management
- Ensure frontend compatibility with refactored backend
* feat(skills): add search functionality to Skills page
- Add search input with Search icon in SkillsPage component
- Implement useMemo-based filtering by skill name, description, and directory
- Display search results count when filtering is active
- Show "no results" message when no skills match the search query
- Add i18n translations for search UI (zh/en)
- Maintain responsive layout and consistent styling with existing UI
* refactor(backend): replace unsafe unwrap calls with proper error handling
- Add to_json_string helper for safe JSON serialization
- Add lock_conn macro for safe Mutex locking
- Replace 41 unwrap() calls with proper error handling:
- database.rs: JSON serialization and Mutex operations (31 fixes)
- lib.rs: macOS NSWindow and tray icon handling (3 fixes)
- services/provider.rs: Claude model normalization (1 fix)
- services/prompt.rs: timestamp generation (3 fixes)
- services/skill.rs: directory name extraction (2 fixes)
- mcp.rs: HashMap initialization and type conversions (5 fixes)
- app_config.rs: timestamp fallback (1 fix)
This improves application stability and prevents potential panics.
* feat(init): implement automatic data import on first launch
Add comprehensive first-launch data import system:
Database layer:
- Add is_empty_for_first_import() to detect empty database
- Add init_default_skill_repos() to initialize 3 default skill repositories
Services layer:
- Implement McpService::import_from_claude/codex/gemini()
to import MCP servers from existing config files
- Implement PromptService::import_from_file_on_first_launch()
to import prompt files (CLAUDE.md, AGENTS.md, GEMINI.md)
Startup flow (lib.rs):
- Check if database is empty on startup
- Import existing configurations if detected:
1. Initialize default skill repositories
2. Import provider configurations from live settings
3. Import MCP servers from config files
4. Import prompt files
- All imports are fault-tolerant and logged
This ensures seamless migration from file-based configs to database.
* fix(skills): auto-sync locally installed skills to database
Add automatic synchronization in get_skills command:
- Detect locally installed skills in ~/.claude/skills/
- Auto-add to database if not already tracked
- Ensures existing skills are recognized on first launch
This fixes the issue where user's existing skills were not
imported into the database on initial application run.
* docs(frontend): add code comments and improve formatting
- Add explanatory comment in EditProviderDialog about config assembly
- Improve import formatting in SkillsPage for better readability
* feat(deeplink): display all four Claude model fields in import dialog
- Show haiku/sonnet/opus/multiModel fields conditionally for Claude
- Maintain single model field display for Codex and Gemini
- Add i18n translations for new model field labels (zh/en)
* feat(backend): add database SQL export/import with backup
- Enable rusqlite backup feature for SQL dump support
- Implement export_sql to generate SQLite-compatible SQL dumps
- Implement import_sql with automatic backup before import
- Add snapshot_to_memory to avoid long-held database locks
- Add backup rotation to retain latest 10 backups
- Support atomic import with rollback on failure
* refactor(backend): migrate import/export to use SQL backup
- Reimplement export_config_to_file to use database.export_sql
- Reimplement import_config_from_file to use database.import_sql
- Add sync_current_from_db to sync live configs after import
- Add settings database binding on app initialization
- Remove deprecated JSON-based config import logic
* refactor(backend): migrate settings storage to database
- Add bind_db function to initialize database-backed settings
- Implement load_initial_settings with database fallback
- Replace direct file save with settings store management
- Add SETTINGS_DB static for database binding
- Maintain backward compatibility with file-based settings
- Keep settings.json for legacy migration support
* feat(frontend): update import/export UI for SQL backup
- Change default export filename from .json to .sql
- Update file format to timestamp format (YYYYMMDD_HHMMSS)
- Update error messages to reference SQL files
- Align with backend SQL export/import implementation
* feat(i18n): update translations for SQL backup feature
- Update Chinese translations for SQL import/export
- Update English translations for SQL import/export
- Change terminology from 'config file' to 'SQL backup'
- Update error messages and UI hints
* fix(backend): remove unnecessary dereference in backup operation
- Simplify Backup::new call by removing redundant dereference
- MutexGuard already implements DerefMut
864 lines
29 KiB
Rust
864 lines
29 KiB
Rust
use serde::{Deserialize, Serialize};
|
||
use std::collections::HashMap;
|
||
use std::str::FromStr;
|
||
|
||
use crate::services::skill::SkillStore;
|
||
|
||
/// MCP 服务器应用状态(标记应用到哪些客户端)
|
||
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
|
||
pub struct McpApps {
|
||
#[serde(default)]
|
||
pub claude: bool,
|
||
#[serde(default)]
|
||
pub codex: bool,
|
||
#[serde(default)]
|
||
pub gemini: bool,
|
||
}
|
||
|
||
impl McpApps {
|
||
/// 检查指定应用是否启用
|
||
pub fn is_enabled_for(&self, app: &AppType) -> bool {
|
||
match app {
|
||
AppType::Claude => self.claude,
|
||
AppType::Codex => self.codex,
|
||
AppType::Gemini => self.gemini,
|
||
}
|
||
}
|
||
|
||
/// 设置指定应用的启用状态
|
||
pub fn set_enabled_for(&mut self, app: &AppType, enabled: bool) {
|
||
match app {
|
||
AppType::Claude => self.claude = enabled,
|
||
AppType::Codex => self.codex = enabled,
|
||
AppType::Gemini => self.gemini = enabled,
|
||
}
|
||
}
|
||
|
||
/// 获取所有启用的应用列表
|
||
pub fn enabled_apps(&self) -> Vec<AppType> {
|
||
let mut apps = Vec::new();
|
||
if self.claude {
|
||
apps.push(AppType::Claude);
|
||
}
|
||
if self.codex {
|
||
apps.push(AppType::Codex);
|
||
}
|
||
if self.gemini {
|
||
apps.push(AppType::Gemini);
|
||
}
|
||
apps
|
||
}
|
||
|
||
/// 检查是否所有应用都未启用
|
||
pub fn is_empty(&self) -> bool {
|
||
!self.claude && !self.codex && !self.gemini
|
||
}
|
||
}
|
||
|
||
/// MCP 服务器定义(v3.7.0 统一结构)
|
||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
pub struct McpServer {
|
||
pub id: String,
|
||
pub name: String,
|
||
pub server: serde_json::Value,
|
||
pub apps: McpApps,
|
||
#[serde(skip_serializing_if = "Option::is_none")]
|
||
pub description: Option<String>,
|
||
#[serde(skip_serializing_if = "Option::is_none")]
|
||
pub homepage: Option<String>,
|
||
#[serde(skip_serializing_if = "Option::is_none")]
|
||
pub docs: Option<String>,
|
||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||
pub tags: Vec<String>,
|
||
}
|
||
|
||
/// MCP 配置:单客户端维度(v3.6.x 及以前,保留用于向后兼容)
|
||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||
pub struct McpConfig {
|
||
/// 以 id 为键的服务器定义(宽松 JSON 对象,包含 enabled/source 等 UI 辅助字段)
|
||
#[serde(default)]
|
||
pub servers: HashMap<String, serde_json::Value>,
|
||
}
|
||
|
||
impl McpConfig {
|
||
/// 检查配置是否为空
|
||
pub fn is_empty(&self) -> bool {
|
||
self.servers.is_empty()
|
||
}
|
||
}
|
||
|
||
/// MCP 根配置(v3.7.0 新旧结构并存)
|
||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
pub struct McpRoot {
|
||
/// 统一的 MCP 服务器存储(v3.7.0+)
|
||
#[serde(skip_serializing_if = "Option::is_none")]
|
||
pub servers: Option<HashMap<String, McpServer>>,
|
||
|
||
/// 旧的分应用存储(v3.6.x 及以前,保留用于迁移)
|
||
#[serde(default, skip_serializing_if = "McpConfig::is_empty")]
|
||
pub claude: McpConfig,
|
||
#[serde(default, skip_serializing_if = "McpConfig::is_empty")]
|
||
pub codex: McpConfig,
|
||
#[serde(default, skip_serializing_if = "McpConfig::is_empty")]
|
||
pub gemini: McpConfig,
|
||
}
|
||
|
||
impl Default for McpRoot {
|
||
fn default() -> Self {
|
||
Self {
|
||
// v3.7.0+ 默认使用新的统一结构(空 HashMap)
|
||
servers: Some(HashMap::new()),
|
||
// 旧结构保持空,仅用于反序列化旧配置时的迁移
|
||
claude: McpConfig::default(),
|
||
codex: McpConfig::default(),
|
||
gemini: McpConfig::default(),
|
||
}
|
||
}
|
||
}
|
||
|
||
/// Prompt 配置:单客户端维度
|
||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||
pub struct PromptConfig {
|
||
#[serde(default)]
|
||
pub prompts: HashMap<String, crate::prompt::Prompt>,
|
||
}
|
||
|
||
/// Prompt 根:按客户端分开维护
|
||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||
pub struct PromptRoot {
|
||
#[serde(default)]
|
||
pub claude: PromptConfig,
|
||
#[serde(default)]
|
||
pub codex: PromptConfig,
|
||
#[serde(default)]
|
||
pub gemini: PromptConfig,
|
||
}
|
||
|
||
use crate::config::{copy_file, get_app_config_dir, get_app_config_path, write_json_file};
|
||
use crate::error::AppError;
|
||
use crate::prompt_files::prompt_file_path;
|
||
use crate::provider::ProviderManager;
|
||
|
||
/// 应用类型
|
||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||
#[serde(rename_all = "lowercase")]
|
||
pub enum AppType {
|
||
Claude,
|
||
Codex,
|
||
Gemini, // 新增
|
||
}
|
||
|
||
impl AppType {
|
||
pub fn as_str(&self) -> &str {
|
||
match self {
|
||
AppType::Claude => "claude",
|
||
AppType::Codex => "codex",
|
||
AppType::Gemini => "gemini", // 新增
|
||
}
|
||
}
|
||
}
|
||
|
||
impl FromStr for AppType {
|
||
type Err = AppError;
|
||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||
let normalized = s.trim().to_lowercase();
|
||
match normalized.as_str() {
|
||
"claude" => Ok(AppType::Claude),
|
||
"codex" => Ok(AppType::Codex),
|
||
"gemini" => Ok(AppType::Gemini), // 新增
|
||
other => Err(AppError::localized(
|
||
"unsupported_app",
|
||
format!("不支持的应用标识: '{other}'。可选值: claude, codex, gemini。"),
|
||
format!("Unsupported app id: '{other}'. Allowed: claude, codex, gemini."),
|
||
)),
|
||
}
|
||
}
|
||
}
|
||
|
||
/// 通用配置片段(按应用分治)
|
||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||
pub struct CommonConfigSnippets {
|
||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||
pub claude: Option<String>,
|
||
|
||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||
pub codex: Option<String>,
|
||
|
||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||
pub gemini: Option<String>,
|
||
}
|
||
|
||
impl CommonConfigSnippets {
|
||
/// 获取指定应用的通用配置片段
|
||
pub fn get(&self, app: &AppType) -> Option<&String> {
|
||
match app {
|
||
AppType::Claude => self.claude.as_ref(),
|
||
AppType::Codex => self.codex.as_ref(),
|
||
AppType::Gemini => self.gemini.as_ref(),
|
||
}
|
||
}
|
||
|
||
/// 设置指定应用的通用配置片段
|
||
pub fn set(&mut self, app: &AppType, snippet: Option<String>) {
|
||
match app {
|
||
AppType::Claude => self.claude = snippet,
|
||
AppType::Codex => self.codex = snippet,
|
||
AppType::Gemini => self.gemini = snippet,
|
||
}
|
||
}
|
||
}
|
||
|
||
/// 多应用配置结构(向后兼容)
|
||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
pub struct MultiAppConfig {
|
||
#[serde(default = "default_version")]
|
||
pub version: u32,
|
||
/// 应用管理器(claude/codex)
|
||
#[serde(flatten)]
|
||
pub apps: HashMap<String, ProviderManager>,
|
||
/// MCP 配置(按客户端分治)
|
||
#[serde(default)]
|
||
pub mcp: McpRoot,
|
||
/// Prompt 配置(按客户端分治)
|
||
#[serde(default)]
|
||
pub prompts: PromptRoot,
|
||
/// Claude Skills 配置
|
||
#[serde(default)]
|
||
pub skills: SkillStore,
|
||
/// 通用配置片段(按应用分治)
|
||
#[serde(default)]
|
||
pub common_config_snippets: CommonConfigSnippets,
|
||
/// Claude 通用配置片段(旧字段,用于向后兼容迁移)
|
||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||
pub claude_common_config_snippet: Option<String>,
|
||
}
|
||
|
||
fn default_version() -> u32 {
|
||
2
|
||
}
|
||
|
||
impl Default for MultiAppConfig {
|
||
fn default() -> Self {
|
||
let mut apps = HashMap::new();
|
||
apps.insert("claude".to_string(), ProviderManager::default());
|
||
apps.insert("codex".to_string(), ProviderManager::default());
|
||
apps.insert("gemini".to_string(), ProviderManager::default()); // 新增
|
||
|
||
Self {
|
||
version: 2,
|
||
apps,
|
||
mcp: McpRoot::default(),
|
||
prompts: PromptRoot::default(),
|
||
skills: SkillStore::default(),
|
||
common_config_snippets: CommonConfigSnippets::default(),
|
||
claude_common_config_snippet: None,
|
||
}
|
||
}
|
||
}
|
||
|
||
impl MultiAppConfig {
|
||
/// 从文件加载配置(仅支持 v2 结构)
|
||
pub fn load() -> Result<Self, AppError> {
|
||
let config_path = get_app_config_path();
|
||
|
||
if !config_path.exists() {
|
||
log::info!("配置文件不存在,创建新的多应用配置并自动导入提示词");
|
||
// 使用新的方法,支持自动导入提示词
|
||
let config = Self::default_with_auto_import()?;
|
||
// 立即保存到磁盘
|
||
config.save()?;
|
||
return Ok(config);
|
||
}
|
||
|
||
// 尝试读取文件
|
||
let content =
|
||
std::fs::read_to_string(&config_path).map_err(|e| AppError::io(&config_path, e))?;
|
||
|
||
// 先解析为 Value,以便严格判定是否为 v1 结构;
|
||
// 满足:顶层同时包含 providers(object) + current(string),且不包含 version/apps/mcp 关键键,即视为 v1
|
||
let value: serde_json::Value =
|
||
serde_json::from_str(&content).map_err(|e| AppError::json(&config_path, e))?;
|
||
let is_v1 = value.as_object().is_some_and(|map| {
|
||
let has_providers = map.get("providers").map(|v| v.is_object()).unwrap_or(false);
|
||
let has_current = map.get("current").map(|v| v.is_string()).unwrap_or(false);
|
||
// v1 的充分必要条件:有 providers 和 current,且 apps 不存在(version/mcp 可能存在但不作为 v2 判据)
|
||
let has_apps = map.contains_key("apps");
|
||
has_providers && has_current && !has_apps
|
||
});
|
||
if is_v1 {
|
||
return Err(AppError::localized(
|
||
"config.unsupported_v1",
|
||
"检测到旧版 v1 配置格式。当前版本已不再支持运行时自动迁移。\n\n解决方案:\n1. 安装 v3.2.x 版本进行一次性自动迁移\n2. 或手动编辑 ~/.cc-switch/config.json,将顶层结构调整为:\n {\"version\": 2, \"claude\": {...}, \"codex\": {...}, \"mcp\": {...}}\n\n",
|
||
"Detected legacy v1 config. Runtime auto-migration is no longer supported.\n\nSolutions:\n1. Install v3.2.x for one-time auto-migration\n2. Or manually edit ~/.cc-switch/config.json to adjust the top-level structure:\n {\"version\": 2, \"claude\": {...}, \"codex\": {...}, \"mcp\": {...}}\n\n",
|
||
));
|
||
}
|
||
|
||
let has_skills_in_config = value
|
||
.as_object()
|
||
.is_some_and(|map| map.contains_key("skills"));
|
||
|
||
// 解析 v2 结构
|
||
let mut config: Self =
|
||
serde_json::from_value(value).map_err(|e| AppError::json(&config_path, e))?;
|
||
let mut updated = false;
|
||
|
||
if !has_skills_in_config {
|
||
let skills_path = get_app_config_dir().join("skills.json");
|
||
if skills_path.exists() {
|
||
match std::fs::read_to_string(&skills_path) {
|
||
Ok(content) => match serde_json::from_str::<SkillStore>(&content) {
|
||
Ok(store) => {
|
||
config.skills = store;
|
||
updated = true;
|
||
log::info!("已从旧版 skills.json 导入 Claude Skills 配置");
|
||
}
|
||
Err(e) => {
|
||
log::warn!("解析旧版 skills.json 失败: {e}");
|
||
}
|
||
},
|
||
Err(e) => {
|
||
log::warn!("读取旧版 skills.json 失败: {e}");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// 确保 gemini 应用存在(兼容旧配置文件)
|
||
if !config.apps.contains_key("gemini") {
|
||
config
|
||
.apps
|
||
.insert("gemini".to_string(), ProviderManager::default());
|
||
updated = true;
|
||
}
|
||
|
||
// 执行 MCP 迁移(v3.6.x → v3.7.0)
|
||
let migrated = config.migrate_mcp_to_unified()?;
|
||
if migrated {
|
||
log::info!("MCP 配置已迁移到 v3.7.0 统一结构,保存配置...");
|
||
updated = true;
|
||
}
|
||
|
||
// 对于已经存在的配置文件,如果此前版本还没有 Prompt 功能,
|
||
// 且 prompts 仍然是空的,则尝试自动导入现有提示词文件。
|
||
let imported_prompts = config.maybe_auto_import_prompts_for_existing_config()?;
|
||
if imported_prompts {
|
||
updated = true;
|
||
}
|
||
|
||
// 迁移通用配置片段:claude_common_config_snippet → common_config_snippets.claude
|
||
if let Some(old_claude_snippet) = config.claude_common_config_snippet.take() {
|
||
log::info!(
|
||
"迁移通用配置:claude_common_config_snippet → common_config_snippets.claude"
|
||
);
|
||
config.common_config_snippets.claude = Some(old_claude_snippet);
|
||
updated = true;
|
||
}
|
||
|
||
if updated {
|
||
log::info!("配置结构已更新(包括 MCP 迁移或 Prompt 自动导入),保存配置...");
|
||
config.save()?;
|
||
}
|
||
|
||
Ok(config)
|
||
}
|
||
|
||
/// 保存配置到文件
|
||
pub fn save(&self) -> Result<(), AppError> {
|
||
let config_path = get_app_config_path();
|
||
// 先备份旧版(若存在)到 ~/.cc-switch/config.json.bak,再写入新内容
|
||
if config_path.exists() {
|
||
let backup_path = get_app_config_dir().join("config.json.bak");
|
||
if let Err(e) = copy_file(&config_path, &backup_path) {
|
||
log::warn!("备份 config.json 到 .bak 失败: {e}");
|
||
}
|
||
}
|
||
|
||
write_json_file(&config_path, self)?;
|
||
Ok(())
|
||
}
|
||
|
||
/// 获取指定应用的管理器
|
||
pub fn get_manager(&self, app: &AppType) -> Option<&ProviderManager> {
|
||
self.apps.get(app.as_str())
|
||
}
|
||
|
||
/// 获取指定应用的管理器(可变引用)
|
||
pub fn get_manager_mut(&mut self, app: &AppType) -> Option<&mut ProviderManager> {
|
||
self.apps.get_mut(app.as_str())
|
||
}
|
||
|
||
/// 确保应用存在
|
||
pub fn ensure_app(&mut self, app: &AppType) {
|
||
if !self.apps.contains_key(app.as_str()) {
|
||
self.apps
|
||
.insert(app.as_str().to_string(), ProviderManager::default());
|
||
}
|
||
}
|
||
|
||
/// 获取指定客户端的 MCP 配置(不可变引用)
|
||
pub fn mcp_for(&self, app: &AppType) -> &McpConfig {
|
||
match app {
|
||
AppType::Claude => &self.mcp.claude,
|
||
AppType::Codex => &self.mcp.codex,
|
||
AppType::Gemini => &self.mcp.gemini,
|
||
}
|
||
}
|
||
|
||
/// 获取指定客户端的 MCP 配置(可变引用)
|
||
pub fn mcp_for_mut(&mut self, app: &AppType) -> &mut McpConfig {
|
||
match app {
|
||
AppType::Claude => &mut self.mcp.claude,
|
||
AppType::Codex => &mut self.mcp.codex,
|
||
AppType::Gemini => &mut self.mcp.gemini,
|
||
}
|
||
}
|
||
|
||
/// 创建默认配置并自动导入已存在的提示词文件
|
||
fn default_with_auto_import() -> Result<Self, AppError> {
|
||
log::info!("首次启动,创建默认配置并检测提示词文件");
|
||
|
||
let mut config = Self::default();
|
||
|
||
// 为每个应用尝试自动导入提示词
|
||
Self::auto_import_prompt_if_exists(&mut config, AppType::Claude)?;
|
||
Self::auto_import_prompt_if_exists(&mut config, AppType::Codex)?;
|
||
Self::auto_import_prompt_if_exists(&mut config, AppType::Gemini)?;
|
||
|
||
Ok(config)
|
||
}
|
||
|
||
/// 已存在配置文件时的 Prompt 自动导入逻辑
|
||
///
|
||
/// 适用于「老版本已经生成过 config.json,但当时还没有 Prompt 功能」的升级场景。
|
||
/// 判定规则:
|
||
/// - 仅当所有应用的 prompts 都为空时才尝试导入(避免打扰已经在使用 Prompt 功能的用户)
|
||
/// - 每个应用最多导入一次,对应各自的提示词文件(如 CLAUDE.md/AGENTS.md/GEMINI.md)
|
||
///
|
||
/// 返回值:
|
||
/// - Ok(true) 表示至少有一个应用成功导入了提示词
|
||
/// - Ok(false) 表示无需导入或未导入任何内容
|
||
fn maybe_auto_import_prompts_for_existing_config(&mut self) -> Result<bool, AppError> {
|
||
// 如果任一应用已经有提示词配置,说明用户已经在使用 Prompt 功能,避免再次自动导入
|
||
if !self.prompts.claude.prompts.is_empty()
|
||
|| !self.prompts.codex.prompts.is_empty()
|
||
|| !self.prompts.gemini.prompts.is_empty()
|
||
{
|
||
return Ok(false);
|
||
}
|
||
|
||
log::info!("检测到已存在配置文件且 Prompt 列表为空,将尝试从现有提示词文件自动导入");
|
||
|
||
let mut imported = false;
|
||
for app in [AppType::Claude, AppType::Codex, AppType::Gemini] {
|
||
// 复用已有的单应用导入逻辑
|
||
if Self::auto_import_prompt_if_exists(self, app)? {
|
||
imported = true;
|
||
}
|
||
}
|
||
|
||
Ok(imported)
|
||
}
|
||
|
||
/// 检查并自动导入单个应用的提示词文件
|
||
///
|
||
/// 返回值:
|
||
/// - Ok(true) 表示成功导入了非空文件
|
||
/// - Ok(false) 表示未导入(文件不存在、内容为空或读取失败)
|
||
fn auto_import_prompt_if_exists(config: &mut Self, app: AppType) -> Result<bool, AppError> {
|
||
let file_path = prompt_file_path(&app)?;
|
||
|
||
// 检查文件是否存在
|
||
if !file_path.exists() {
|
||
log::debug!("提示词文件不存在,跳过自动导入: {file_path:?}");
|
||
return Ok(false);
|
||
}
|
||
|
||
// 读取文件内容
|
||
let content = match std::fs::read_to_string(&file_path) {
|
||
Ok(c) => c,
|
||
Err(e) => {
|
||
log::warn!("读取提示词文件失败: {file_path:?}, 错误: {e}");
|
||
return Ok(false); // 失败时不中断,继续处理其他应用
|
||
}
|
||
};
|
||
|
||
// 检查内容是否为空
|
||
if content.trim().is_empty() {
|
||
log::debug!("提示词文件内容为空,跳过导入: {file_path:?}");
|
||
return Ok(false);
|
||
}
|
||
|
||
log::info!("发现提示词文件,自动导入: {file_path:?}");
|
||
|
||
// 创建提示词对象
|
||
let timestamp = std::time::SystemTime::now()
|
||
.duration_since(std::time::UNIX_EPOCH)
|
||
.map(|d| d.as_secs() as i64)
|
||
.unwrap_or_else(|_| {
|
||
log::warn!("Failed to get system time, using 0 as timestamp");
|
||
0
|
||
});
|
||
|
||
let id = format!("auto-imported-{timestamp}");
|
||
let prompt = crate::prompt::Prompt {
|
||
id: id.clone(),
|
||
name: format!(
|
||
"Auto-imported Prompt {}",
|
||
chrono::Local::now().format("%Y-%m-%d %H:%M")
|
||
),
|
||
content,
|
||
description: Some("Automatically imported on first launch".to_string()),
|
||
enabled: true, // 自动启用
|
||
created_at: Some(timestamp),
|
||
updated_at: Some(timestamp),
|
||
};
|
||
|
||
// 插入到对应的应用配置中
|
||
let prompts = match app {
|
||
AppType::Claude => &mut config.prompts.claude.prompts,
|
||
AppType::Codex => &mut config.prompts.codex.prompts,
|
||
AppType::Gemini => &mut config.prompts.gemini.prompts,
|
||
};
|
||
|
||
prompts.insert(id, prompt);
|
||
|
||
log::info!("自动导入完成: {}", app.as_str());
|
||
Ok(true)
|
||
}
|
||
|
||
/// 将 v3.6.x 的分应用 MCP 结构迁移到 v3.7.0 的统一结构
|
||
///
|
||
/// 迁移策略:
|
||
/// 1. 检查是否已经迁移(mcp.servers 是否存在)
|
||
/// 2. 收集所有应用的 MCP,按 ID 去重合并
|
||
/// 3. 生成统一的 McpServer 结构,标记应用到哪些客户端
|
||
/// 4. 清空旧的分应用配置
|
||
pub fn migrate_mcp_to_unified(&mut self) -> Result<bool, AppError> {
|
||
// 检查是否已经是新结构
|
||
if self.mcp.servers.is_some() {
|
||
log::debug!("MCP 配置已是统一结构,跳过迁移");
|
||
return Ok(false);
|
||
}
|
||
|
||
log::info!("检测到旧版 MCP 配置格式,开始迁移到 v3.7.0 统一结构...");
|
||
|
||
let mut unified_servers: HashMap<String, McpServer> = HashMap::new();
|
||
let mut conflicts = Vec::new();
|
||
|
||
// 收集所有应用的 MCP
|
||
for app in [AppType::Claude, AppType::Codex, AppType::Gemini] {
|
||
let old_servers = match app {
|
||
AppType::Claude => &self.mcp.claude.servers,
|
||
AppType::Codex => &self.mcp.codex.servers,
|
||
AppType::Gemini => &self.mcp.gemini.servers,
|
||
};
|
||
|
||
for (id, entry) in old_servers {
|
||
let enabled = entry
|
||
.get("enabled")
|
||
.and_then(|v| v.as_bool())
|
||
.unwrap_or(true);
|
||
|
||
if let Some(existing) = unified_servers.get_mut(id) {
|
||
// 该 ID 已存在,合并 apps 字段
|
||
existing.apps.set_enabled_for(&app, enabled);
|
||
|
||
// 检测配置冲突(同 ID 但配置不同)
|
||
if existing.server != *entry.get("server").unwrap_or(&serde_json::json!({})) {
|
||
conflicts.push(format!(
|
||
"MCP '{id}' 在 {} 和之前的应用中配置不同,将使用首次遇到的配置",
|
||
app.as_str()
|
||
));
|
||
}
|
||
} else {
|
||
// 首次遇到该 MCP,创建新条目
|
||
let name = entry
|
||
.get("name")
|
||
.and_then(|v| v.as_str())
|
||
.unwrap_or(id)
|
||
.to_string();
|
||
|
||
let server = entry
|
||
.get("server")
|
||
.cloned()
|
||
.unwrap_or(serde_json::json!({}));
|
||
|
||
let description = entry
|
||
.get("description")
|
||
.and_then(|v| v.as_str())
|
||
.map(|s| s.to_string());
|
||
|
||
let homepage = entry
|
||
.get("homepage")
|
||
.and_then(|v| v.as_str())
|
||
.map(|s| s.to_string());
|
||
|
||
let docs = entry
|
||
.get("docs")
|
||
.and_then(|v| v.as_str())
|
||
.map(|s| s.to_string());
|
||
|
||
let tags = entry
|
||
.get("tags")
|
||
.and_then(|v| v.as_array())
|
||
.map(|arr| {
|
||
arr.iter()
|
||
.filter_map(|v| v.as_str().map(|s| s.to_string()))
|
||
.collect()
|
||
})
|
||
.unwrap_or_default();
|
||
|
||
let mut apps = McpApps::default();
|
||
apps.set_enabled_for(&app, enabled);
|
||
|
||
unified_servers.insert(
|
||
id.clone(),
|
||
McpServer {
|
||
id: id.clone(),
|
||
name,
|
||
server,
|
||
apps,
|
||
description,
|
||
homepage,
|
||
docs,
|
||
tags,
|
||
},
|
||
);
|
||
}
|
||
}
|
||
}
|
||
|
||
// 记录冲突警告
|
||
if !conflicts.is_empty() {
|
||
log::warn!("MCP 迁移过程中检测到配置冲突:");
|
||
for conflict in &conflicts {
|
||
log::warn!(" - {conflict}");
|
||
}
|
||
}
|
||
|
||
log::info!(
|
||
"MCP 迁移完成,共迁移 {} 个服务器{}",
|
||
unified_servers.len(),
|
||
if !conflicts.is_empty() {
|
||
format!("(存在 {} 个冲突)", conflicts.len())
|
||
} else {
|
||
String::new()
|
||
}
|
||
);
|
||
|
||
// 替换为新结构
|
||
self.mcp.servers = Some(unified_servers);
|
||
|
||
// 清空旧的分应用配置
|
||
self.mcp.claude = McpConfig::default();
|
||
self.mcp.codex = McpConfig::default();
|
||
self.mcp.gemini = McpConfig::default();
|
||
|
||
Ok(true)
|
||
}
|
||
}
|
||
|
||
#[cfg(test)]
|
||
mod tests {
|
||
use super::*;
|
||
use serial_test::serial;
|
||
use std::env;
|
||
use std::fs;
|
||
use tempfile::TempDir;
|
||
|
||
struct TempHome {
|
||
#[allow(dead_code)] // 字段通过 Drop trait 管理临时目录生命周期
|
||
dir: TempDir,
|
||
original_home: Option<String>,
|
||
original_userprofile: Option<String>,
|
||
}
|
||
|
||
impl TempHome {
|
||
fn new() -> Self {
|
||
let dir = TempDir::new().expect("failed to create temp home");
|
||
let original_home = env::var("HOME").ok();
|
||
let original_userprofile = env::var("USERPROFILE").ok();
|
||
|
||
env::set_var("HOME", dir.path());
|
||
env::set_var("USERPROFILE", dir.path());
|
||
|
||
Self {
|
||
dir,
|
||
original_home,
|
||
original_userprofile,
|
||
}
|
||
}
|
||
}
|
||
|
||
impl Drop for TempHome {
|
||
fn drop(&mut self) {
|
||
match &self.original_home {
|
||
Some(value) => env::set_var("HOME", value),
|
||
None => env::remove_var("HOME"),
|
||
}
|
||
|
||
match &self.original_userprofile {
|
||
Some(value) => env::set_var("USERPROFILE", value),
|
||
None => env::remove_var("USERPROFILE"),
|
||
}
|
||
}
|
||
}
|
||
|
||
fn write_prompt_file(app: AppType, content: &str) {
|
||
let path = crate::prompt_files::prompt_file_path(&app).expect("prompt path");
|
||
if let Some(parent) = path.parent() {
|
||
fs::create_dir_all(parent).expect("create parent dir");
|
||
}
|
||
fs::write(path, content).expect("write prompt");
|
||
}
|
||
|
||
#[test]
|
||
#[serial]
|
||
fn auto_imports_existing_prompt_when_config_missing() {
|
||
let _home = TempHome::new();
|
||
write_prompt_file(AppType::Claude, "# hello");
|
||
|
||
let config = MultiAppConfig::load().expect("load config");
|
||
|
||
assert_eq!(config.prompts.claude.prompts.len(), 1);
|
||
let prompt = config
|
||
.prompts
|
||
.claude
|
||
.prompts
|
||
.values()
|
||
.next()
|
||
.expect("prompt exists");
|
||
assert!(prompt.enabled);
|
||
assert_eq!(prompt.content, "# hello");
|
||
|
||
let config_path = crate::config::get_app_config_path();
|
||
assert!(
|
||
config_path.exists(),
|
||
"auto import should persist config to disk"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
#[serial]
|
||
fn skips_empty_prompt_files_during_import() {
|
||
let _home = TempHome::new();
|
||
write_prompt_file(AppType::Claude, " \n ");
|
||
|
||
let config = MultiAppConfig::load().expect("load config");
|
||
assert!(
|
||
config.prompts.claude.prompts.is_empty(),
|
||
"empty files must be ignored"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
#[serial]
|
||
fn auto_import_happens_only_once() {
|
||
let _home = TempHome::new();
|
||
write_prompt_file(AppType::Claude, "first version");
|
||
|
||
let first = MultiAppConfig::load().expect("load config");
|
||
assert_eq!(first.prompts.claude.prompts.len(), 1);
|
||
let claude_prompt = first
|
||
.prompts
|
||
.claude
|
||
.prompts
|
||
.values()
|
||
.next()
|
||
.expect("prompt exists")
|
||
.content
|
||
.clone();
|
||
assert_eq!(claude_prompt, "first version");
|
||
|
||
// 覆盖文件内容,但保留 config.json
|
||
write_prompt_file(AppType::Claude, "second version");
|
||
let second = MultiAppConfig::load().expect("load config again");
|
||
|
||
assert_eq!(second.prompts.claude.prompts.len(), 1);
|
||
let prompt = second
|
||
.prompts
|
||
.claude
|
||
.prompts
|
||
.values()
|
||
.next()
|
||
.expect("prompt exists");
|
||
assert_eq!(
|
||
prompt.content, "first version",
|
||
"should not re-import when config already exists"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
#[serial]
|
||
fn auto_imports_gemini_prompt_on_first_launch() {
|
||
let _home = TempHome::new();
|
||
write_prompt_file(AppType::Gemini, "# Gemini Prompt\n\nTest content");
|
||
|
||
let config = MultiAppConfig::load().expect("load config");
|
||
|
||
assert_eq!(config.prompts.gemini.prompts.len(), 1);
|
||
let prompt = config
|
||
.prompts
|
||
.gemini
|
||
.prompts
|
||
.values()
|
||
.next()
|
||
.expect("gemini prompt exists");
|
||
assert!(prompt.enabled, "gemini prompt should be enabled");
|
||
assert_eq!(prompt.content, "# Gemini Prompt\n\nTest content");
|
||
assert_eq!(
|
||
prompt.description,
|
||
Some("Automatically imported on first launch".to_string())
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
#[serial]
|
||
fn auto_imports_all_three_apps_prompts() {
|
||
let _home = TempHome::new();
|
||
write_prompt_file(AppType::Claude, "# Claude prompt");
|
||
write_prompt_file(AppType::Codex, "# Codex prompt");
|
||
write_prompt_file(AppType::Gemini, "# Gemini prompt");
|
||
|
||
let config = MultiAppConfig::load().expect("load config");
|
||
|
||
// 验证所有三个应用的提示词都被导入
|
||
assert_eq!(config.prompts.claude.prompts.len(), 1);
|
||
assert_eq!(config.prompts.codex.prompts.len(), 1);
|
||
assert_eq!(config.prompts.gemini.prompts.len(), 1);
|
||
|
||
// 验证所有提示词都被启用
|
||
assert!(
|
||
config
|
||
.prompts
|
||
.claude
|
||
.prompts
|
||
.values()
|
||
.next()
|
||
.unwrap()
|
||
.enabled
|
||
);
|
||
assert!(
|
||
config
|
||
.prompts
|
||
.codex
|
||
.prompts
|
||
.values()
|
||
.next()
|
||
.unwrap()
|
||
.enabled
|
||
);
|
||
assert!(
|
||
config
|
||
.prompts
|
||
.gemini
|
||
.prompts
|
||
.values()
|
||
.next()
|
||
.unwrap()
|
||
.enabled
|
||
);
|
||
}
|
||
}
|