Fix LLM output parsing and ResizeObserver error suppression#47
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
User description
Summary
This PR implements comprehensive fixes for two critical issues:
🎯 Enhanced LLM Output Parsing
optionsarrays wasn't being parsed correctly🛡️ Complete ResizeObserver Error Suppression
🏗️ Architecture Improvements
Test Plan
npm run buildpasses without errorsTechnical Details
New Parsing Capabilities
Error Suppression Strategy
Architectural Enhancements
contentGeneration.system.zh.j2+nextStepJsonl.system.zh.j2title→content,description→describeconversiontypefieldBreaking Changes
None - fully backward compatible with existing functionality.
Performance Impact
🤖 Generated with Claude Code
PR Type
Bug fix, Enhancement, Tests, Documentation
Description
• Enhanced LLM Output Parsing: Implemented advanced multi-format parsing system supporting 4 different JSON structures including new
optionsarrays format, with automatic field mapping and type inheritance• Complete ResizeObserver Error Suppression: Multi-layer error handling system (HTML → App → Component → Console levels) to eliminate persistent development console errors
• Two-stage LLM Processing Architecture: Separated content generation and JSONL recommendation phases with specialized prompt templates for improved AI workflow
• Comprehensive Concurrent Testing Framework: New OpenRouter API testing capabilities with load testing, performance metrics, health checks, and visual interface
• Task Manager Optimization: Fixed circular dependencies, enhanced async handling, and improved performance with proper memoization
• API Error Handling Enhancement: User-friendly localized error messages for different HTTP status codes with network connectivity checks
• Code Quality Improvements: Extensive cleanup of unused imports, variables, and dependencies across multiple components and services
Diagram Walkthrough
File Walkthrough
13 files
testRunner.ts
New OpenRouter API concurrent testing frameworksrc/utils/testRunner.ts
• Added comprehensive test runner utility with predefined test
scenarios for OpenRouter API
• Implemented load testing capabilities
with concurrent request handling and performance metrics
• Added HTML,
JSON, and CSV report generation functionality with CLI interface
concurrentTestService.ts
New concurrent testing service for API performancesrc/services/concurrentTestService.ts
• Created new service for concurrent API testing with semaphore-based
concurrency control
• Implemented load testing, health checks, and
performance metrics calculation
• Added support for multiple model
testing with detailed performance analytics
useTaskManager.test.ts
Task manager test fixes and improvementssrc/hooks/tests/useTaskManager.test.ts
• Fixed test implementation with proper mock setup and incremental
UUID generation
• Improved test reliability by avoiding complex async
behavior in concurrent tests
• Enhanced test coverage with better
assertion patterns and cleanup
storage.test.ts
Storage test updates for new data structuressrc/utils/tests/storage.test.ts
• Updated test data structures to match new
PromptTestandChatConversationinterfaces• Fixed property name changes (
name→title,added required fields)
• Aligned test mocks with updated type
definitions
concurrentTestService.test.ts
Unit tests for concurrent testing servicesrc/services/concurrentTestService.test.ts
• Added unit tests for concurrent test service core functionality
•
Implemented tests for token estimation, metrics calculation, and
service initialization
• Created test coverage for singleton pattern
and basic service operations
jinjaTemplateEngine.test.ts
Template engine test variable naming fixessrc/services/jinjaTemplateEngine.test.ts
• Fixed variable naming conflicts in test cases to avoid shadowing
•
Renamed
resultvariables torenderResultfor clarity and uniqueness•
Improved test readability and eliminated potential variable conflicts
api-security.test.ts
API security test robustness improvementssrc/services/tests/api-security.test.ts
• Enhanced security test robustness with better type checking and
conditional assertions
• Improved test reliability by handling
different console call patterns
• Fixed potential test failures with
more defensive assertion logic
validation.test.ts
Validation test improvements for rate limitingsrc/utils/tests/validation.test.ts
• Refactored rate limiting tests to use array collection and batch
assertions
• Improved test reliability by separating result collection
from assertions
• Enhanced test clarity with cleaner assertion
patterns
performance.test.ts
Performance test reliability improvementssrc/tests/performance.test.ts
• Fixed optional chaining and assertion patterns in performance tests
• Improved test reliability with better null checking
• Enhanced test
robustness for context stats validation
useFormValidation.test.ts
Form validation test cleanupsrc/hooks/tests/useFormValidation.test.ts
• Removed unused variable declaration in form validation test
•
Cleaned up test code by removing unnecessary variable assignment
•
Minor test code optimization
ConcurrentTestPanel.tsx
OpenRouter concurrent testing panel implementationsrc/components/ConcurrentTestPanel.tsx
• Created comprehensive testing interface for OpenRouter API
concurrent capabilities
• Implemented load testing, health checks, and
performance monitoring features
• Added visual test configuration and
real-time results display
• Integrated with ConcurrentTestService for
automated testing workflows
NextStepChat.test.tsx
Test updates for concurrent chat functionalitysrc/components/NextStepChat.test.tsx
• Updated test cases to reflect new concurrent functionality
•
Modified placeholder text expectations for input fields
• Simplified
test assertions to focus on core chat functionality
• Removed complex
conversation menu testing logic
ErrorBoundary.test.tsx
Error boundary test type safety improvementssrc/components/tests/ErrorBoundary.test.tsx
• Fixed TypeScript type assertions for process.env modifications
•
Updated test environment variable handling for better type safety
•
Maintained existing test functionality while resolving type issues
•
Improved test reliability in different Node.js environments
8 files
promptTemplateV2.ts
Enhanced prompt templates for two-stage LLM processingsrc/services/promptTemplateV2.ts
• Added new template contexts
contentGenerationandnextStepJsonlfortwo-stage LLM processing
• Implemented separate prompts for content
analysis and JSONL recommendation generation
• Enhanced template
system to support multi-stage AI workflows with specialized prompts
contentSplitter.ts
Advanced multi-format LLM output parsing systemsrc/utils/contentSplitter.ts
• Enhanced LLM output parsing to support 4 different JSON structures
including nested arrays
• Added support for new
optionsarray formatand field name mapping (
title→content)• Implemented multi-format JSON
extraction from code blocks and direct JSON parsing
prompt.ts
Prompt context types for two-stage processingsrc/types/prompt.ts
• Extended
PromptContexttype to includecontentGenerationandnextStepJsonl• Added support for new two-stage processing contexts
•
Enhanced type definitions for multi-stage LLM workflows
nextStepChat.system.zh.j2
Enhanced JSON output constraints in prompt templatesrc/prompt/nextStepChat.system.zh.j2
• Added comprehensive JSON output constraints and formatting
requirements
• Enhanced prompt template with specific JSON escaping
and validation rules
• Improved JSONL generation guidelines with error
prevention measures
NextStepChat.tsx
Two-stage LLM processing and enhanced output parsingsrc/components/NextStepChat.tsx
• Implemented two-stage LLM processing: content generation followed by
JSONL recommendations
• Enhanced LLM output parsing to support
multiple JSON formats including new
optionsarrays• Added concurrent
option handling with independent processing states
• Replaced complex
task management system with simplified concurrent execution
App.tsx
Main app integration for concurrent testingsrc/App.tsx
• Added concurrent test panel toggle functionality to main application
• Integrated centralized error suppression initialization
• Added
conditional rendering for concurrent test vs chat interface
• Enhanced
error boundary handling for main interface components
SimpleOptionCard.tsx
Simplified option card for concurrent processingsrc/components/SimpleOptionCard.tsx
• Created simplified option card component for concurrent processing
•
Added processing state indicators and visual feedback
• Implemented
hover effects and disabled state handling
• Replaced complex task
management with straightforward UI states
AppHeader.tsx
Header integration for concurrent test togglesrc/components/Layout/AppHeader.tsx
• Added concurrent test panel toggle button to header
• Implemented
conditional styling for active test mode
• Removed unused imports and
simplified component structure
• Enhanced header functionality with
new navigation options
2 files
useTaskManager.ts
Task manager dependency fixes and optimizationsrc/hooks/useTaskManager.ts
• Fixed circular dependency issues by using refs for function
references
• Added
useMemofor config optimization and improveddependency management
• Enhanced task processing with proper async
handling and cleanup
useNotification.ts
Notification hook optimization and dependency fixessrc/hooks/useNotification.ts
• Added
useMemofor config optimization and movedremoveNotificationbefore
addNotification• Fixed dependency order to prevent potential
callback recreation issues
• Enhanced hook performance with proper
memoization
4 files
errorSuppression.ts
Complete ResizeObserver error suppression systemsrc/utils/errorSuppression.ts
• Implemented comprehensive ResizeObserver error suppression system
•
Added multi-layer error handling (console, window events, React
overlay)
• Created centralized error filtering with occurrence
counting and logging
api.ts
Enhanced API error handling with friendly messagessrc/services/api.ts
• Enhanced error handling with user-friendly error messages for
different HTTP status codes
• Added specific handling for 401, 429,
500+ errors with localized Chinese messages
• Improved error reporting
with network connectivity checks
index.html
HTML-level ResizeObserver error suppressionpublic/index.html
• Added comprehensive early ResizeObserver error suppression script
before React loads
• Implemented multi-layer error handling at HTML
level with development environment detection
• Enhanced error
suppression with proper event handling and prevention
index.tsx
Centralized error suppression initializationsrc/index.tsx
• Replaced manual error handling with centralized error suppression
system
• Simplified application initialization with modular error
management
• Removed redundant global error listeners in favor of
utility module
• Enhanced error handling consistency across the
application
6 files
usePerformanceOptimization.ts
Performance monitoring disabled by defaultsrc/hooks/usePerformanceOptimization.ts
• Disabled performance monitoring by default
(
enablePerformanceMonitoring: false)• Reduced overhead in production
by turning off automatic performance tracking
• Optimized default
configuration for better runtime performance
nextStepJsonl.system.zh.j2
JSONL recommendation generation prompt templatesrc/prompt/nextStepJsonl.system.zh.j2
• Created specialized Jinja2 template for JSONL recommendation
generation
• Added strict JSON output constraints and formatting
requirements
• Implemented template variables for customizable
recommendation types
• Included comprehensive error prevention for
JSON parsing issues
nextStepJsonl.system.en.j2
English JSONL recommendation prompt templatesrc/prompt/nextStepJsonl.system.en.j2
• Created English version of JSONL recommendation prompt template
•
Mirrored Chinese template structure with English translations
•
Maintained consistent JSON formatting constraints and requirements
•
Provided bilingual support for international usage
nextStepChat.system.en.j2
Enhanced English prompt with JSON constraintssrc/prompt/nextStepChat.system.en.j2
• Enhanced English prompt template with critical JSON output
constraints
• Added strict formatting requirements for JSONL
generation
• Implemented character escaping and validation rules
•
Improved error prevention for LLM output parsing
contentGeneration.system.zh.j2
Chinese content generation prompt templatesrc/prompt/contentGeneration.system.zh.j2
• Created Chinese content generation prompt template for first stage
processing
• Focused on content analysis and expansion without option
generation
• Implemented Jinja2 template variables for customizable
content goals
• Separated content generation from recommendation logic
contentGeneration.system.en.j2
English content generation prompt templatesrc/prompt/contentGeneration.system.en.j2
• Created English content generation prompt template
• Mirrored
Chinese template structure for consistent bilingual support
• Focused
on deep content analysis and comprehensive expansion
• Maintained
separation between content generation and recommendations
8 files
authService.ts
Auth service code cleanupsrc/services/authService.ts
• Removed unused
datavariable assignments in OAuth sign-in methods•
Cleaned up GitHub and Google authentication functions
• Minor code
cleanup for better maintainability
dataService.ts
Data service code cleanupsrc/services/dataService.ts
• Removed unused import statements and variable assignments
• Cleaned
up database service code by removing unused
datavariables• Minor
code optimization and cleanup
contentSplitter.test.ts
Content splitter test import cleanupsrc/utils/tests/contentSplitter.test.ts
• Removed unused import of
NextStepOptioninterface• Cleaned up test
imports for better maintainability
• Minor import optimization
contentSplitter.test.ts
Content splitter TDD test import cleanupsrc/utils/contentSplitter.test.ts
• Removed unused import of
NextStepOptioninterface• Cleaned up test
imports for consistency
• Minor import optimization
NextStepChat.tsx.backup
NextStepChat component backup preservationsrc/components/NextStepChat.tsx.backup
• Created backup of NextStepChat component with two-stage LLM
processing implementation
• Preserved original component logic with
content generation and JSONL recommendation stages
• Maintained
historical component state for reference
TaskQueuePanel.tsx
Task queue panel import cleanupsrc/components/TaskQueuePanel.tsx
• Removed unused
useEffectimport• Minor import cleanup for better
code maintainability
• Code optimization
MigrationPrompt.tsx
Migration prompt cleanup and optimizationsrc/components/Auth/MigrationPrompt.tsx
• Removed unused
clearLocalDataimport from data migration hook•
Cleaned up component dependencies for better maintainability
•
Maintained existing migration functionality without unused references
OutputPanel.tsx
Output panel prop cleanup and simplificationsrc/components/OutputPanel.tsx
• Removed unused
darkModeprop from component interface• Simplified
component props for better maintainability
• Maintained existing
output panel functionality without unused parameters
1 files
CONCURRENT_TEST_GUIDE.md
Concurrent testing documentation and usage guideCONCURRENT_TEST_GUIDE.md
• Added comprehensive documentation for concurrent testing
functionality
• Provided usage examples for visual interface, test
runner, and direct service calls
• Documented test scenarios,
performance metrics, and troubleshooting guides
• Included file
structure overview and integration instructions
1 files
package.json
Package dependencies and linting configuration updatespackage.json
• Added
lodashdependency for utility functions• Fixed
react-scriptsversion to stable 5.0.1
• Added comprehensive ESLint rule overrides
for testing and development
• Updated security overrides for
vulnerable packages
2 files
Summary by CodeRabbit
New Features
Improvements
Documentation
Chores