mirror of
https://github.com/taskgenius/taskgenius-plugin.git
synced 2026-07-22 06:40:25 +00:00
- Change performSearch visibility from private to public - Allow setting.ts to trigger search when navigating from URI
2.9 KiB
2.9 KiB
Worker Processing Control Implementation
Overview
Implemented complete control for background worker processing in Task Genius plugin, allowing users to enable/disable worker threads for file parsing performance optimization.
Changes Made
1. Settings UI Integration (IndexSettingsTab.ts)
- Updated the "Enable worker processing" toggle to use the new
fileSource.performance.enableWorkerProcessingsetting path - Added backward compatibility with legacy
fileParsingConfig.enableWorkerProcessingsetting - Ensures proper initialization of setting structure when needed
2. WorkerOrchestrator Enhancement (WorkerOrchestrator.ts)
- Added
enableWorkerProcessingconfiguration option to constructor - Implemented
setWorkerProcessingEnabled()method for dynamic control - Added
isWorkerProcessingEnabled()status check method - Enhanced
getMetrics()to provide comprehensive performance statistics - Circuit breaker automatically resets when re-enabling workers
3. DataflowOrchestrator Integration (Orchestrator.ts)
- Reads worker processing setting from both new and legacy paths
- Passes configuration to WorkerOrchestrator during initialization
- Added
updateSettings()method to propagate setting changes - Added
getWorkerStatus()for monitoring worker state and metrics
4. Settings Update Flow (setting.ts)
- Modified
applySettingsUpdate()to calldataflowOrchestrator.updateSettings() - Ensures worker processing changes take effect immediately without restart
5. FileSource Management (FileSource.ts)
- Added
cleanup()method for proper resource cleanup - Added
updateConfig()alias for configuration updates - Properly handles initialization and cleanup based on settings
How It Works
- User toggles setting: User changes "Enable worker processing" in Index Settings
- Setting saved: New value stored in
fileSource.performance.enableWorkerProcessing - Update propagated:
applySettingsUpdate()callsdataflowOrchestrator.updateSettings() - Worker control:
WorkerOrchestrator.setWorkerProcessingEnabled()updates worker state - Processing mode: Tasks are processed either by workers or main thread based on setting
Benefits
- Performance Control: Users can disable workers if experiencing issues
- Dynamic Updates: Changes take effect immediately without plugin restart
- Backward Compatibility: Works with both old and new setting paths
- Circuit Breaker: Automatic recovery when re-enabling workers
- Monitoring: Comprehensive metrics for debugging and optimization
Testing
Created comprehensive test suite (worker-processing-control.test.ts) that verifies:
- Default enabled state
- Configuration respect on initialization
- Dynamic enabling/disabling
- Circuit breaker reset behavior
- Metrics availability
- Settings path fallback logic
All tests pass successfully, confirming proper implementation.