Skip to content

refactor: major architecture refactoring and remote monitoring improvements#1

Merged
inureyes merged 16 commits into
mainfrom
refactor/cleanup-structure
Jul 8, 2025
Merged

refactor: major architecture refactoring and remote monitoring improvements#1
inureyes merged 16 commits into
mainfrom
refactor/cleanup-structure

Conversation

@inureyes

@inureyes inureyes commented Jul 8, 2025

Copy link
Copy Markdown
Member

Summary

This pull request represents a comprehensive refactoring of the all-smi codebase, transforming it from a monolithic structure to a modular, maintainable architecture while significantly enhancing remote monitoring capabilities and introducing advanced testing features.

Major Architectural Changes

Complete Modular Restructure

  • Before: Monolithic structure with tightly coupled components
  • After: Clean modular architecture with separated concerns
  • New Module Structure:
    • src/common/ - Shared utilities and configuration
    • src/metrics/ - Data aggregation and coordination
    • src/network/ - Remote monitoring and client functionality
    • src/ui/ - User interface components and rendering
    • src/view/ - Application orchestration and data flow
    • src/device/ - Hardware abstraction and platform detection
    • src/utils/ - Utility functions and helpers

Enhanced Rendering System

  • Refactored: Complete rendering logic overhaul for better performance
  • Improvements:
    • Modular device renderers for different hardware types
    • Optimized UI component separation
    • Better text rendering and formatting utilities
    • Enhanced dashboard with cleaner layout calculations

Responsive Event Handling

  • Enhancement: Significantly improved event handling responsiveness
  • Features:
    • Better mouse event capturing
    • More responsive keyboard interactions
    • Smoother tab navigation and scrolling
    • Fixed time series output issues

Remote Monitoring Enhancements

Advanced Connection Management

  • Real-time Updates: Dynamic tab and node view updates with disconnected node tracking
  • Connection Status: Comprehensive tracking of node connectivity states
  • Placeholder Logic: Smart tab naming for inaccessible nodes with automatic updates
  • Order Preservation: Maintains host order from configuration files

📈 Live Statistics Integration

  • Node Statistics: Live/Total node count display (e.g., "2/5 nodes")
  • Visual Indicators: Improved connection status visualization
  • Health Monitoring: Real-time cluster health overview

Testing and Development Features

Mock Server Capabilities

  • Failure Simulation: Advanced node failure simulation with --failure-nodes parameter
  • Realistic Testing: Configurable failure patterns for comprehensive testing
  • Disk Metrics: Consistent Prometheus-compatible disk terminology
  • Development Tools: Makefile for streamlined testing workflows

Code Quality Improvements

  • Warning Resolution: Comprehensive warning and lint fixes throughout codebase
  • Format Consistency: Standardized code formatting across all modules
  • Best Practices: Implementation of Rust best practices and patterns
  • Documentation: Enhanced inline documentation and comments

Technical Improvements

New Runner Architecture

  • Modular Design: Separated terminal management from UI logic
  • Better Abstraction: Clean separation between data collection and presentation
  • Improved Performance: More efficient resource utilization
  • Maintainability: Easier to extend and modify individual components

UI/UX Enhancements

  • Dashboard Improvements: Enhanced system overview with better layout
  • Device Rendering: Specialized renderers for different device types
  • Notification System: Improved notification management and display
  • Layout Optimization: Better space utilization and responsive design

🔗 Network Layer Improvements

  • Client Architecture: Robust HTTP client with connection pooling
  • Metrics Parsing: Enhanced Prometheus metrics parsing capabilities
  • Error Handling: Comprehensive error handling and recovery mechanisms
  • Performance: Optimized network requests and response handling

Documentation and Developer Experience

Documentation Updates

  • README: Updated with new architecture and usage examples
  • CLAUDE.md: Comprehensive development guidelines and architecture documentation
  • Makefile: Simplified testing and development workflows
  • Code Comments: Enhanced inline documentation throughout

Development Tools

  • Build System: Improved build configuration and feature flags
  • Testing: Enhanced testing capabilities with mock server improvements
  • Linting: Comprehensive clippy and formatting compliance
  • CI/CD Ready: Structure prepared for continuous integration workflows

Breaking Changes

Module Reorganization

  • File paths have changed due to modular restructuring
  • Import statements may need updates for external integrations
  • Configuration file structure remains backward compatible

API Changes

  • Internal API structure updated for better separation of concerns
  • Public CLI interface remains unchanged for user compatibility
  • Mock server parameters enhanced with new testing features

Migration Guide

For Users

  • No changes required - CLI interface remains identical
  • New features available through optional parameters
  • Enhanced functionality with existing workflows

For Developers

  • Update import statements to use new module structure
  • Review new architecture documentation in CLAUDE.md
  • Utilize new development tools and testing capabilities

Files Changed

Core Architecture

  • src/main.rs - Application entry point and orchestration
  • src/app_state.rs - Enhanced state management
  • src/common/* - New shared utilities module
  • src/metrics/* - New metrics coordination system
  • src/view/* - Refactored application logic

UI System

  • src/ui/* - Complete UI system overhaul
  • src/ui/dashboard.rs - Enhanced system dashboard
  • src/ui/device_renderers.rs - Specialized device rendering
  • src/ui/widgets.rs - Reusable UI components

Network & Remote Monitoring

  • src/network/client.rs - Advanced HTTP client
  • src/network/metrics_parser.rs - Enhanced metrics parsing
  • src/bin/all-smi-mock-server.rs - Enhanced mock server

Development Tools

  • Makefile - New development workflow automation
  • README.md - Updated documentation
  • Multiple test and configuration files

Test Plan

  • Verify modular architecture builds successfully
  • Confirm all existing functionality preserved
  • Test new remote monitoring features
  • Validate mock server enhancements
  • Verify responsive event handling
  • Test cross-platform compatibility
  • Confirm performance improvements
  • Validate documentation accuracy
  • Test development workflow tools
  • Verify no regressions in core functionality

Performance Impact

Improvements

  • Faster Rendering: Modular UI components reduce overhead
  • Better Memory Usage: Improved data structure organization
  • Network Efficiency: Enhanced connection management and pooling
  • Responsive UI: Significantly improved event handling performance

Metrics

  • Reduced compilation time due to modular structure
  • Lower memory footprint with optimized data structures
  • Faster startup time with streamlined initialization
  • Improved responsiveness in high-node-count scenarios

This refactoring establishes all-smi as a robust, maintainable, and extensible monitoring solution with enterprise-grade remote monitoring capabilities and comprehensive testing tools.

@inureyes inureyes added the type:enhancement New feature or request label Jul 8, 2025
@inureyes inureyes self-assigned this Jul 8, 2025
@inureyes inureyes changed the title refactor: rendering logic refactor: major architecture refactoring and remote monitoring improvements Jul 8, 2025
@inureyes inureyes requested a review from Copilot July 8, 2025 02:05
@inureyes inureyes marked this pull request as ready for review July 8, 2025 02:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the view layer into modular components, extracts terminal and data logic into dedicated modules, and updates the runner to orchestrate these new pieces.

  • Introduces UiLoop and TerminalManager for clean initialization and terminal cleanup.
  • Extracts data collection into DataCollector and decomposes the monolithic runner into runner.rs.
  • Splits UI rendering into submodules (layout, tabs, process_renderer, device_renderers, etc.) for maintainability.

Reviewed Changes

Copilot reviewed 43 out of 44 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/view/ui_loop.rs New asynchronous UI loop handling rendering and input
src/view/terminal_manager.rs Terminal initialization and cleanup via RAII
src/view/runner.rs Updated runner to use TerminalManager, DataCollector, and UiLoop
src/view/data_collector.rs New module for local and remote data collection logic
src/view/event_handler.rs Tab‐scrolling logic refined for left/right arrow handling
src/ui/layout.rs Layout calculation utilities extracted
src/ui/tabs.rs Tab drawing and visibility calculation
src/ui/process_renderer.rs Extracted process table rendering
src/ui/device_renderers.rs Extracted GPU/CPU/Memory/Storage rendering
src/utils/disk_filter.rs New disk filter module with tests
Comments suppressed due to low confidence (2)

src/view/data_collector.rs:22

  • This function drops port information, so hosts distinguished only by port will collide. Consider preserving the full host:port in the identifier or renaming to clarify that only the hostname is extracted.
fn extract_hostname_from_url(url: &str) -> String {

src/view/event_handler.rs:65

  • The call to size() is unqualified and size is not imported in this module, causing a compilation error. Add use crossterm::terminal::size; at the top.
            let (cols, _) = size().unwrap();


impl Default for TerminalManager {
fn default() -> Self {
Self::new().unwrap_or_else(|_| Self { initialized: false })

Copilot AI Jul 8, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Silently swallowing initialization errors may hide failures at runtime. Consider logging the error or returning a Result instead of defaulting to initialized: false.

Suggested change
Self::new().unwrap_or_else(|_| Self { initialized: false })
match Self::new() {
Ok(manager) => manager,
Err(e) => {
eprintln!("Failed to initialize TerminalManager: {}", e);
Self { initialized: false }
}
}

Copilot uses AI. Check for mistakes.
@inureyes inureyes merged commit 2166c19 into main Jul 8, 2025
3 checks passed
@inureyes inureyes added priority:high High priority issue status:done Completed feature labels Sep 10, 2025
@inureyes inureyes removed the feature label Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:high High priority issue status:done Completed type:enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants