This module implements AI state management functionality, supporting switching between different AI tools (such as Cursor, Qoder, etc.) in the IDE. After subsequent phase optimizations, it now supports configuration-driven AI management with better extensibility and maintainability.
- Support for dynamically configured AI types (default: cursor, qoder, claudeCode)
- Extensible support for more AI types
- State persistence
- State change listener mechanism
- Automatic AI state adjustment when configuration changes
- Display current AI state in IDE bottom status bar
- Click status bar to pop up AI selection menu
- Real-time AI state display updates
Alt+Shift+S: Switch to next AI- Support for cycling through AI types
- Support for dynamically configured AI switching shortcuts (e.g., option+shift+1/2/3)
- Automatic shortcut conflict detection and resolution
- Status bar component displaying current AI
- Popup menu for AI selection
- Switch success prompt messages
src/main/kotlin/com/github/switch2ai/
├── state/
│ ├── AIStateManager.kt # AI State Manager (optimized)
│ └── AIStatePersistentComponent.kt # State Persistence Component
├── ui/
│ ├── AIStatusBarWidget.kt # Status Bar Component
│ └── AISelectionPopup.kt # AI Selection Popup
├── actions/
│ ├── SwitchAIAction.kt # AI Switch Action
│ ├── AbstractDynamicActionRegistry.kt # Abstract Dynamic Registry (new)
│ ├── DynamicActionRegistry.kt # Dynamic Action Registry (refactored)
│ └── DynamicSwitchAIActionRegistry.kt # Dynamic AI Switch Registry (new)
└── settings/
└── AppSettingsState.kt # Unified Configuration Management (optimized)
- Manages currently selected AI state
- Provides AI switching functionality
- Supports state change listening
- Validates AI type validity
- New: Dynamically obtains supported AI types from
AppSettingsState - New: Automatically adjusts AI state when configuration changes
- New: Supports configuration-driven AI management
- Implements state persistence
- Restores AI state after IDE restart
- Supports custom AI type extension
- Displays current AI state in status bar
- Supports click to switch AI
- Real-time display content updates
- Displays selectable AI list
- Supports mouse hover effects
- Click to select AI type
- Handles AI switching shortcuts
- Displays switch success messages
- Integrates with IDE menu system
- View "AI: cursor" display in IDE bottom status bar
- Click status bar component
- Select target AI from popup menu
- AI state updates immediately
- Press
Alt+Shift+S - AI automatically switches to next type
- Display switch success message
- Click
Tools→Switch AI - AI automatically switches to next type
- Display switch success message
- Use configured shortcuts (e.g., option+shift+1 to switch to cursor)
- Support for dynamically configured AI switching shortcuts
- Shortcuts automatically update when configuration changes
cursor: Cursor editor (default shortcut: option+shift+1)qoder: Qoder editor (default shortcut: option+shift+2)claudeCode: Claude editor (default shortcut: option+shift+3)
- Default AI: cursor
- Shortcut: Alt+Shift+S (cycle switch)
- Status bar display: enabled
- Configuration driven: supports dynamic configuration and shortcut customization
- Add new AI type in
AppSettingsStateconfiguration - Configure AI shortcuts and basic information
- System automatically registers new AI switch actions
- No core code modification required, fully configuration-driven
- Modify AI or action shortcut configuration in
AppSettingsState - System automatically detects shortcut conflicts and provides solutions
- Configuration changes take effect immediately (when shortcuts don't change)
- IDE restart prompt when shortcuts change
./gradlew test- AI state management functionality
- State switching logic
- Listener mechanism
- Edge case handling
- State Persistence: AI state automatically restores after IDE restart
- Extensibility: Supports adding new AI types without core code modification
- Performance: State change listeners use lightweight implementation with minimal performance impact
- Compatibility: Supports IntelliJ IDEA 2022.3 and above
- Configuration Driven: All AI and action configurations now managed through
AppSettingsState - Dynamic Updates: System automatically responds to configuration changes without manual restart
- Shortcut Conflicts: System automatically detects shortcut conflicts and provides solutions
- Implement AI state management functionality
- Support status bar display and shortcut switching
- State persistence
- Separate command execution into configuration module, information reading module, command execution module
- Implement module decoupling and independent testing
- Implement configuration-based dynamic action registration
- Support dynamic shortcut binding and conflict detection
- Add right-click menu support
- Architecture Optimization: Create abstract parent class for code reuse
- Unified Configuration: Unified configuration management through
AppSettingsState - Code Simplification: Significantly reduce code volume, improve maintainability
- Create
AbstractDynamicActionRegistry<T>abstract parent class - Implement code reuse and logic simplification
- Support generic design for easy extension
- Merge configuration management functionality into
AppSettingsState - Support real-time configuration updates and synchronization
- Implement automatic response to configuration changes
- Merge data classes to avoid duplicate definitions
- Reduce unnecessary object creation and type conversion
- Improve configuration change response speed
If you encounter problems during use, please:
- Check if IDE version is supported
- View IDE event logs
- Confirm plugin is correctly installed
- Submit Issue describing problem details