claude-code-webui
claude-code-webui copied to clipboard
Enhanced CollapsibleDetails component functionality
Summary
Enhance the existing CollapsibleDetails component to improve user experience with better interaction patterns, performance, and visual feedback for long message content.
Background
The current CollapsibleDetails component provides basic collapsible functionality but could benefit from:
- Better UX patterns for long content management
- Improved visual indicators and animations
- Performance optimizations for large content
- Enhanced accessibility features
- More flexible layout options
Current Implementation Analysis
Existing features:
- Basic expand/collapse functionality
- Keyboard accessibility (Enter/Space)
- Configurable color schemes
- Icon and badge support
Areas for improvement:
- Content preview/truncation options
- Smooth animations for expand/collapse
- Performance for very large content
- Better visual feedback for expandable state
- Content search within collapsed sections
Implementation Plan
1. Enhanced UX Patterns
interface EnhancedCollapsibleProps extends CollapsibleDetailsProps {
// Content management
maxPreviewLines?: number;
contentType?: 'text' | 'code' | 'json' | 'html';
// Visual enhancements
animationDuration?: number;
showContentPreview?: boolean;
// Advanced features
searchable?: boolean;
allowPartialExpansion?: boolean;
// Performance
virtualizedContent?: boolean;
lazyRender?: boolean;
}
2. Content Preview System
- Show first N lines of content when collapsed
- Smart truncation with "Show more/less" indicators
- Content type-aware previews (code vs text vs JSON)
- Visual fade-out effect for truncated content
3. Animation and Visual Feedback
- Smooth CSS transitions for expand/collapse
- Loading states for large content rendering
- Better visual indicators for collapsible state
- Hover effects and improved click targets
4. Performance Optimizations
- Lazy rendering for large content
- Virtual scrolling for extremely long content
- Content chunking for better memory management
- Debounced search functionality
5. Enhanced Accessibility
- Better screen reader announcements for state changes
- Keyboard navigation improvements
- Focus management during expand/collapse
- ARIA attributes for content state
Technical Details
Files to modify:
frontend/src/components/messages/CollapsibleDetails.tsx- Core enhancementsfrontend/src/components/messages/CollapsibleContent.tsx- New content rendererfrontend/src/hooks/useCollapsibleContent.ts- Content management logicfrontend/src/utils/contentUtils.ts- Content processing utilities
Dependencies:
- Existing React and TailwindCSS setup
- Optional: Framer Motion for advanced animations (evaluate if needed)
- Integration with existing theme system
Enhancement Priorities
Phase 1: Core UX Improvements
- Content preview system with smart truncation
- Smooth expand/collapse animations
- Better visual indicators and hover states
Phase 2: Performance and Accessibility
- Lazy rendering for large content
- Enhanced keyboard navigation
- Screen reader improvements
Phase 3: Advanced Features
- Content search within collapsed sections
- Partial expansion modes
- Content type-specific optimizations
Acceptance Criteria
Core Functionality
- [ ] Smooth animations for expand/collapse transitions
- [ ] Content preview system shows first N lines when collapsed
- [ ] Better visual indicators for collapsible state
- [ ] Improved hover and focus states
Performance
- [ ] Lazy rendering for content >1000 lines
- [ ] Smooth performance with large content blocks
- [ ] Memory efficient content management
- [ ] Fast expand/collapse even with large content
Accessibility
- [ ] Enhanced screen reader support with proper announcements
- [ ] Improved keyboard navigation (Tab, Enter, Space, Arrow keys)
- [ ] Focus management during state changes
- [ ] Proper ARIA attributes for dynamic content
Visual Design
- [ ] Consistent with existing design system
- [ ] Works seamlessly with light/dark themes
- [ ] Responsive design for mobile devices
- [ ] Content type-aware formatting (code vs text vs JSON)
Integration
- [ ] Backward compatible with existing CollapsibleDetails usage
- [ ] Works with all existing message types (System, Tool Result, etc.)
- [ ] Integrates with planned syntax highlighting (#246)
- [ ] Supports planned tool result enhancements (#245)
Examples
Enhanced Content Preview
🔍 Tool Result: Search completed ✅ Success
├─ Found 24 matches across 8 files
├─ Preview: src/components/App.tsx:45: const [isLoading, setIsLoading] = useState(false);
│ src/utils/api.ts:23: export const fetchData = async () => {
│ [22 more matches...]
└─ ▶ Click to expand full results
Smart Truncation
📄 File Content: package.json (247 lines)
├─ Preview: {
│ "name": "claude-code-webui",
│ "version": "0.1.47",
│ [244 more lines...]
└─ ▶ Show full content
Parent Issue
This is a sub-issue of #10 - Enhance frontend UI with Slack-like chat experience
Related Issues
- #245 - Tool Result message formatting (will use enhanced CollapsibleDetails)
- #246 - Code syntax highlighting (integration needed)
- #25 - Copy functionality (needs to work with collapsed/expanded content)
Labels
feature, ui/ux, frontend, enhancement, sub-issue