fix: resolve code output to chat instead of files #1927
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🐛 Bug Fix
Fixes #1797 - Code outputs to chat instead of creating workspace files
📋 Summary
This PR delivers a comprehensive solution to the critical issue where certain AI models (particularly Claude 3.7 and DeepSeek) output code directly to the chat interface instead of creating files in the workspace. After extensive analysis and testing, I've implemented an enhanced message parser that intelligently detects code blocks and automatically wraps them in the proper artifact tags.
🎯 Problem Solved
Users reported that when using Claude 3.7, DeepSeek, and other models, generated code would appear as text in the chat instead of creating actual files. This disrupted the development workflow and made it impossible to work on larger projects effectively.
🏗️ Solution Architecture
Enhanced Message Parser
Created
EnhancedStreamingMessageParserthat extends the existing parser with intelligent code detection:Detection Patterns
The parser implements six sophisticated pattern detection strategies:
Explicit File Operations
Filename Comments
File Path Headers
Context Mentions
Component Detection
Config File Detection
🧪 Testing Results
Thoroughly tested with multiple scenarios:
📊 Performance Impact
🔧 Technical Implementation
Key Features:
Code Quality:
🎬 Demo
Before this fix:
After this fix:
📝 Changes
enhanced-message-parser.tswith intelligent detectionuseMessageParser.tsto use enhanced parser✅ Checklist
🚀 Impact
This fix significantly improves the developer experience by:
Users can now confidently use any AI model without worrying about code output inconsistencies.
Developed with extensive testing and attention to edge cases