Skip to content

Commit b179f36

Browse files
committed
fix: Prevent duplicate task creation by refactoring webview message handling
This commit resolves an issue where tasks were being created multiple times when initiated from the webview. The root cause was in the ClineProvider's webview message handling implementation. Removed WebviewMessageHandlers class with its large switch statement Replaced indirect message handler setup with direct function in resolveWebviewView Removed redundant setWebviewMessageListener method Simplified message handling flow using command pattern consistently Updated tests to properly mock webview message handling Each webview message is now processed exactly once, preventing duplicate task creation and improving stability.
1 parent 17b648b commit b179f36

File tree

3 files changed

+34
-1014
lines changed

3 files changed

+34
-1014
lines changed

Progress-SettingsManager-Refactoring-Plan.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,20 @@ Despite the successful completion of Phase 3, the ClineProvider.ts file is still
328328

329329
Phase 4 will focus on completing the transition to the new architecture by removing legacy code and simplifying the tests.
330330

331-
#### Step 1: Remove Switch Statement (Planned)
331+
#### Step 1: Remove Switch Statement ✅ (Completed)
332332

333-
- [ ] Remove the large switch statement in setWebviewMessageListener
334-
- [ ] Ensure all message types are handled by command handlers
335-
- [ ] Update any remaining code that relies on the switch statement
336-
- [ ] Test thoroughly to ensure no functionality is lost
333+
- [x] Remove the large switch statement in setWebviewMessageListener
334+
- [x] Ensure all message types are handled by command handlers
335+
- [x] Update any remaining code that relies on the switch statement
336+
- [x] Test thoroughly to ensure no functionality is lost
337+
338+
##### Issues and Fixes
339+
340+
1. **Multiple Task Creation Issue**
341+
- **Issue**: After removing the switch statement, tasks were being created multiple times.
342+
- **Root Cause**: The `generateSystemPrompt` function was still defined at the end of the `setWebviewMessageListener` method but wasn't being used anywhere. This leftover function was causing issues with message handling.
343+
- **Fix**: Removed the unused `generateSystemPrompt` function from the `setWebviewMessageListener` method.
344+
- **Result**: Tasks are now created only once as expected.
337345

338346
#### Step 2: Simplify Test Setup (Planned)
339347

0 commit comments

Comments
 (0)