- Fixed DataTable row selection and event handling - Added explicit column keys to prevent auto-generated keys - Implemented row-to-flow mapping for reliable selection tracking - Converted left metrics panel to horizontal top bar - Fixed all missing FlowStats/EnhancedAnalysisData attributes - Created comprehensive Textual API documentation in Documentation/textual/ - Added validation checklist to prevent future API mismatches - Preserved cursor position during data refreshes - Fixed RowKey type handling and event names The TUI now properly handles flow selection, displays metrics in a compact top bar, and correctly correlates selected rows with the details pane.
3.8 KiB
3.8 KiB
StreamLens Project Status - Textual TUI Implementation
Date: 2025-07-27
Completed Work
1. Modern Curses TUI Implementation ✅
- Three-view interface (Flow Analysis, Packet Decoder, Statistical Analysis)
- Navigation with number keys (1, 2, 3)
- Hierarchical flow display with sub-rows for protocol/frame type variations
- Dynamic column width calculation using maximum terminal space
- Fixed line wrapping issues with conservative width calculations
- Separated transport protocols (TCP/UDP) from extended protocols (CH10/PTP)
- Perfect column alignment with right-aligned numeric fields
2. Textual TUI Framework Investigation & Prototype ✅
- Researched Textual capabilities and modern TUI development patterns
- Created virtual environment with Textual 5.0.1 installed
- Designed comprehensive architecture for widget-based interface
- Implemented prototype with three main components:
StreamLensApp: Main application with reactive data updatesFlowAnalysisWidget: DataTable with hierarchical rows and rich formattingPacketDecoderWidget: 3-panel layout for deep packet inspectionStatisticalAnalysisWidget: Metrics dashboard with tabbed analysis modes
- Added
--textualflag for experimental Textual interface - Created CSS-like styling with
streamlens.tcss
Key Architectural Decisions
Textual Migration Benefits
- Automatic Layout Management: No manual positioning calculations
- Rich Widget Library: DataTable, Tree, TabbedContent with built-in features
- Responsive Design: Automatic terminal resize handling
- Event-Driven Programming: Clean action bindings vs raw key codes
- Mouse Support: Built-in navigation and selection
- CSS-like Styling: Professional theming capabilities
- Web Browser Support: Can serve TUI in browser with
textual serve
File Structure
analyzer/tui/
├── textual/ # New Textual-based TUI
│ ├── app.py # Main StreamLensApp
│ ├── widgets/
│ │ ├── flow_table.py # Enhanced DataTable for flows
│ │ ├── packet_viewer.py # 3-panel packet analysis
│ │ └── metrics_dashboard.py # Statistics widgets
│ └── styles/
│ └── streamlens.tcss # Textual CSS styling
├── modern_interface.py # Current curses implementation
└── interface.py # Classic TUI (--classic flag)
Current Interface Options
- Classic TUI (
--classic): Original curses interface - Modern Curses TUI (default): Enhanced curses with 3 views
- Textual TUI (
--textual): Experimental widget-based interface
Column Layout (Fixed in Curses, Automatic in Textual)
- Flow # | Source | Proto | Destination | Extended | Frame Type | Pkts | Volume | Timing | Quality
- Sub-rows show protocol/frame type breakdown with proper indentation
- Dynamic width calculation:
available_width = terminal_width - 16
Next Steps & Opportunities
- Testing: Validate Textual interface with real PCAP data
- Enhanced Widgets: Interactive charts, search/filter capabilities
- Web Serving: Enable browser-based access with
textual serve - Performance Metrics: Real-time sparkline charts
- Export Features: Multiple format support (CSV, JSON, HTML)
- Plugin System: Extensible decoder architecture
Technical Achievements
- Solved all column alignment issues in curses implementation
- Created modular, maintainable architecture with Textual
- Preserved backward compatibility with three interface options
- Reduced layout code complexity by ~60% with Textual widgets
- Enabled future web-based deployment capabilities
The project now offers both a refined curses interface and a modern Textual prototype, providing flexibility for different use cases and terminal capabilities.