Skip to content

Conversation

@danielaskdd
Copy link
Collaborator

WebUI Bugfix and Improvement

📋 Overview

This PR introduces significant improvements across multiple components of the LightRAG system, focusing on conversation handling, Chain of Thought (COT) processing, user interface enhancements, and theme switching stability.

1. Fix Conversation History Handling When history_turns is 0

  • Problem: WebUI was sending all conversation history even when history_turns was set to 0
  • Solution: Added proper validation to check history_turns > 0 before filtering
  • Impact: Prevents history message affecting RAG result for better query testing

2. Fix inline code display problem in query test page**

  • Added messageRole Prop: Enhanced CodeHighlight component with role-based styling
  • Cleaned Imports: Removed unused Element type import
  • Inline Detection: Replaced node-based detection with more reliable method
  • Theme Integration: Added theme-aware inline code styles
  • Performance: Updated dependency arrays in useMemo for better optimization

3. Replace Input with Auto-Resizing Textarea in query test page

  • New Component: Added dedicated Textarea component
  • Smart Resizing: Auto-resize between 40px-120px height
  • Enhanced UX:
    • Enter to submit
    • Shift+Enter for newline
  • State Management: Reset height after message submission

4. Fix Theme Switching Crashes and Optimize Graph Rendering

Critical Fixes:

  • Theme Isolation: Implemented theme switching isolation by hiding GraphSearch during transitions
  • Error Prevention: Fixed NotFoundGraphError during theme switching with defensive programming
  • Component Safety: Replaced problematic NodeById component with custom safe implementation
  • Comprehensive Error Handling: Added node/edge existence checks

Performance Optimizations:

  • Sigma Settings Memoization: Prevents unnecessary re-renders
  • Event Listener Cleanup: Removed redundant theme update logic
  • Memory Management: Simplified event listener management

5. Optimize COT (Chain of Thought) Handling Logic

Backend Enhancements:

  • Prevent Unclosed Thinking Tags: Added COT closure after stream completion
  • Exception Scenario Handling: Proper COT handling in error cases
  • Safety Check: Final safety check in finally block to ensure tag closure
  • Stream Completion: Ensures thinking tags are properly closed after streaming

Frontend Improvements:

  • Robust COT Parsing: Refactored to handle multiple think blocks reliably
  • Enhanced Error Handling: Better parsing of complex COT structures
  • Multiple Block Support: Improved handling of nested or sequential thinking blocks

6. Optimize Prompt Instruction for Citation Format

Backend Enhancements:

  • Enhanced citation format handling in prompt instructions
  • Improved consistency in citation generation
  • Better integration with existing prompt patterns

• Check history_turns > 0 before filtering
• Prevent sending all history converstion to backend when history_turns is 0
- Add COT closure after stream completion
- Handle COT in exception scenarios
- Add final safety check in finally block
- Prevent unclosed thinking tags
- Log COT closure failures
…tion

• Add messageRole prop to CodeHighlight
• Remove unused Element type import
• Replace node-based inline detection
• Add theme-aware inline code styles
• Update dependency arrays in useMemo
• Add new Textarea component
• Auto-resize between 40px-120px height
• Support Enter to submit, Shift+Enter for newline
• Add form autocomplete attributes
• Reset height after message submission
- Implement theme switching isolation to prevent component access during transitions by hidding GraphSearch
- Fix NotFoundGraphError during theme switching by adding defensive programming
- Replace problematic NodeById component with custom safe implementation
- Add comprehensive error handling and node/edge existence checks
- Optimize sigma settings with memoization to prevent unnecessary re-renders
- Remove redundant theme update logic and simplify event listener management
@danielaskdd danielaskdd merged commit aafed76 into HKUDS:main Sep 21, 2025
1 check passed
@danielaskdd danielaskdd deleted the fix-webui branch September 22, 2025 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant