204 Commits

Author SHA1 Message Date
9df6106bf5 Fix service start/stop toggle and nixos-rebuild permissions
- Implement proper service status checking for start/stop toggle
- Space key now checks current service status and toggles appropriately
- Active services get stopped, inactive services get started
- Fix nixos-rebuild sudo permissions (remove invalid package reference)
- Use only /run/current-system/sw/bin/nixos-rebuild path
2025-10-23 23:19:43 +02:00
967244064f Fix command execution permissions and eliminate backup error spam
- Add sudo permissions for systemctl and nixos-rebuild commands
- Use sudo in agent command execution for proper privileges
- Fix backup collector to handle missing status files gracefully
- Eliminate backup error spam when no backup system is configured
2025-10-23 23:07:52 +02:00
99da289183 Implement remote command execution and visual feedback for service control
This implements the core functionality for executing remote commands through
the dashboard and providing real-time visual feedback to users.

Key Features:
- Remote service control (start/stop/restart) via existing keyboard shortcuts
- System rebuild command with maintenance mode integration
- Real-time visual feedback with service status transitions
- ZMQ command protocol extension for service and system operations

Implementation Details:
- Extended AgentCommand enum with ServiceControl and SystemRebuild variants
- Added agent-side handlers for systemctl and nixos-rebuild execution
- Implemented command status tracking system for visual feedback
- Enhanced services widget to show progress states ( restarting)
- Integrated command execution with existing keyboard navigation

Keyboard Controls:
- Services Panel: Space (start/stop), R (restart)
- System Panel: R (nixos-rebuild switch)
- Backup Panel: B (trigger backup)

Technical Architecture:
- Command flow: UI → Dashboard → ZMQ → Agent → systemctl/nixos-rebuild
- Status tracking: InProgress/Success/Failed states with visual indicators
- Maintenance mode: Automatic /tmp/cm-maintenance file management
- Service feedback: Icon transitions (● →  → ● with status text)
2025-10-23 22:55:44 +02:00
b0b1ea04a1 Update CLAUDE.md with completed keyboard navigation and service selection features
- Mark keyboard navigation and service management as completed
- Document all implemented navigation controls and features
- Update current status to reflect working build display
- Replace old future priorities with actual service management tasks
- Add focus-aware selection and visual feedback documentation
2025-10-23 22:04:15 +02:00
b8afd15417 Fix service selection highlighting: preserve status icon colors and focus-aware display
Status Icon Color Preservation:
- Preserve original status icon colors (green ● for active, red ● for failed)
- Apply selection highlighting only to service text, not status icons
- Maintain visual health indicators while showing selection state

Focus-Aware Selection Display:
- Only show selection highlighting when Services panel is focused
- Hide selection bar when user switches to System or Backup panels
- Provides clean UI when not actively managing services

Selection Visual Behavior:
- Status icon: Original color (green/red/yellow) with blue background
- Service text: Blue background with black text for clear selection indication
- Unfocused state: All services display normally without selection artifacts

This creates optimal UX where status health information is always visible
and selection highlighting only appears when relevant for user interaction.
2025-10-23 21:56:43 +02:00
61287380d3 Improve service selection: preserve status colors and skip sub-services
Selection Behavior Improvements:
- Limit selection to parent services only (docker, nginx, postgresql, etc.)
- Skip sub-services in navigation (no longer select nginx sub-sites)
- Up/Down arrows now move between actionable services only

Visual Enhancement:
- Preserve original status colors in selection highlighting
- Selected services show blue background with status foreground colors
- Green text for active services, red for failed, even when selected
- Maintains visual health status information during selection

Selection Logic:
- Add parent service index mapping for accurate selection tracking
- Only count parent services in total service count
- Calculate proper parent service index from display line position
- Ensure selection highlights only apply to parent services

This creates a cleaner UX where users only select services they can
actually control (start/stop/restart) while maintaining visual health
status indicators through preserved status colors.
2025-10-23 21:46:50 +02:00
999e7b5db5 Fix service selection cursor highlighting and bounds checking
Visual Highlighting Fixes:
- Apply selection highlighting to individual text spans instead of entire paragraph
- Eliminates highlighting of empty space below services on single-service hosts
- Selection now only highlights actual service text content

Selection Logic Improvements:
- Add proper bounds checking in select_next() to prevent invalid selections
- Automatically clamp selection index when services are updated
- Add debug logging to track selection state and movement

Bounds Safety:
- Ensure selection index stays valid when service lists change
- Prevent out-of-bounds access during service updates
- Reset selection to last valid index when services are removed

This fixes the issues where:
1. Single service hosts showed empty space highlighting
2. Multi-service hosts had no visible selection cursor
3. Selection could become invalid when services changed
2025-10-23 21:37:10 +02:00
c851590aaa Implement service selection cursor and improve panel navigation
Service Selection Features:
- Add selection cursor for Services panel with visual highlighting
- Up/Down arrows move service selection instead of scrolling
- Track selected service for future action implementation
- Selection state maintained per host

Panel Navigation Improvements:
- Fix panel switching to only cycle through visible panels
- Dynamic panel list based on backup data availability
- Smart recovery when focused panel becomes invisible
- No more navigation to hidden backup panel

Backup Panel Scrolling Fix:
- Fix backup panel scroll to show actual repository content
- Replace static overflow indicator with proper scroll behavior
- Add scroll position indicators (above/below)
- Show all repositories when scrolling instead of truncated list

Navigation now works correctly with actual UI layout and
provides proper service selection for future action implementation.
2025-10-23 21:21:25 +02:00
6b18cdf562 Fix keyboard navigation and panel scrolling issues
- Remove Network panel from navigation cycle
- Fix system panel scrolling to work in both directions
- Add complete scroll support to Services and Backup panels
- Update panel cycling to System → Services → Backup only
- Enhance scroll indicators with proper bounds checking
- Clean up unused Network panel code and references

Resolves issues with non-functional up/down scrolling and
mystery network panel appearing during navigation.
2025-10-23 21:01:11 +02:00
1b46aa2f13 Fix keybinding handling in main event loop
The new keybindings (Shift+Tab, Up, Down, BackTab) weren't working because
the main app.rs event loop was only passing specific keys to the TUI app.
Added handling for:
- KeyCode::BackTab (Shift+Tab panel switching)
- KeyCode::Up (scroll up in focused panel)
- KeyCode::Down (scroll down in focused panel)

Now all keyboard navigation features work correctly.
2025-10-23 20:41:48 +02:00
8cb5650fbb Implement complete keyboard navigation and UI enhancement
Phase 1 - Panel Navigation:
- Add PanelType enum and panel focus state management
- Implement Shift+Tab cycling between panels (System → Services → Backup → Network)
- Add visual focus indicators with blue borders for focused panels
- Preserve existing Tab behavior for host switching

Phase 2 - Dynamic Statusbar:
- Add bottom statusbar with context-aware shortcuts
- Display different shortcuts based on focused panel
- Global shortcuts: Tab, Shift+Tab, Up/Down arrows, Q
- Panel-specific shortcuts: R (Rebuild), Space/R (Services), B (Backup), N (Network)

Phase 3 - Scrolling Support:
- Add scroll state management per host and panel type
- Implement Up/Down arrow key scrolling within focused panels
- Smart scrolling that activates only when content exceeds panel height
- Scroll bounds checking to prevent over-scrolling

Complete keyboard navigation experience with visual feedback and contextual help.
2025-10-23 20:34:45 +02:00
51375e8020 Change tree symbols to blue color across all panels
- Add Typography::tree() style using blue Theme::highlight() color
- Update system, backup, and services widgets to use consistent blue tree styling
- Centralizes tree color management in theme module for easy maintenance
2025-10-23 20:16:10 +02:00
65479c14af Add overflow handling to system and backup widgets
Restore "... and X more" indicators when panel content doesn't fit:
- System widget: Shows overflow for storage pools when area is too small
- Backup widget: Shows overflow for repository list when area is too small
- Maintains consistent formatting with existing services widget overflow
2025-10-23 20:12:01 +02:00
ecee256f91 Change tree symbols to use secondary text color
Update all tree symbols (└─, ├─) in system and backup widgets to use
Typography::secondary() style instead of raw text for consistent
text coloring throughout the interface.
2025-10-23 20:02:49 +02:00
b391448d33 Update backup widget layout and fix system widget Single label
Backup widget:
- Restructure to match new layout specification
- Add section headers: Latest backup, Disk, Repos
- Show timestamp with status icon and duration as sub-item
- Display disk info with product name, S/N, and usage in tree structure
- List repositories with archive count and size
- Remove old render methods and unused imports

System widget:
- Hide (Single) storage type label for cleaner display
2025-10-23 19:53:00 +02:00
997b30a9c0 Update system widget layout with section headers
- Add section headers: CPU, RAM, Storage as plain titles
- Remove status icons from section headers
- Keep status icons only on data lines (Load, Usage, /tmp, filesystems)
- Restore (Single) label for all storage types
- Improve visual hierarchy with clear section separation
2025-10-23 19:34:27 +02:00
d193b90ba1 Fix device detection to properly parse lsblk output
- Handle lsblk tree symbols (├─, └─) in device parsing
- Extract base device names from partitions (nvme0n1p2 -> nvme0n1)
- Support both NVMe and traditional device naming schemes
- Fixes missing device lines in storage display
2025-10-23 19:16:33 +02:00
ad298ac70c Fix device detection, tree indentation, and hide Single storage type
- Replace findmnt with lsblk for efficient device name detection
- Fix tree indentation to align consistently with status icon text
- Hide '(Single)' label for single disk storage pools
- Device detection returns actual names (nvme0n1, sda) not UUID paths
2025-10-23 19:06:52 +02:00
9f34c67bfa Fix debug log reference to removed underlying_devices field 2025-10-23 18:56:16 +02:00
5134c5320a Fix disk collector to use dynamic device detection
- Remove underlying_devices field from FilesystemConfig
- Add device detection at startup using findmnt command
- Store detected devices in HashMap for reuse during collection
- Keep all existing functionality (StoragePool, DriveInfo, SMART data)
- Detect devices only once at initialization, not every collection cycle
- Fixes agent startup failure due to missing underlying_devices config
2025-10-23 18:50:40 +02:00
7f5949b818 Update system widget layout to new specification
- Remove Active users line from NixOS section
- Add status icons to CPU and RAM sections
- Restructure layout with proper tree symbols and spacing
- Add empty lines between sections for better readability
- Remove Storage header, show each filesystem as top-level item
- Fix tree indentation to match specification
- CPU shows load averages with frequency as sub-item
- RAM shows usage with /tmp as sub-item with status icon
2025-10-23 18:35:17 +02:00
473f89fb57 Display mount points instead of pool names in storage section
- Add mount_point field to StoragePool struct
- Create mapping from pool names to mount points
- Update display to show user-friendly mount points (/, /mnt/steampool)
- Keep device detection for SMART data (temperature, wear)
- Resolves disk name confusion on different hosts
2025-10-23 18:19:14 +02:00
d0ce1726e8 Clean up UI code and improve agent hash display
- Remove unused imports and debug logging
- Change agent display from 'Agent Hash: full' to 'Agent: short8'
- Fix unused variable warnings
2025-10-23 17:54:06 +02:00
c5ec529210 Add agent hash display to system panel
Implement agent version tracking to diagnose deployment issues:
- Add get_agent_hash() method to extract Nix store hash from executable path
- Collect system_agent_hash metric in NixOS collector
- Display "Agent Hash" in system panel under NixOS section
- Update metric filtering to include agent hash

This helps identify which version of the agent is actually running
when troubleshooting deployment or metric collection issues.
2025-10-23 17:33:45 +02:00
4193a97737 Add comment to clarify NixOS build display fix 2025-10-23 17:13:35 +02:00
ef9c5b6cf1 Fix NixOS build version display in dashboard
Update metric filtering to use exact metric names instead of prefix matching.
This resolves the issue where build version showed 'unknown' despite agent
correctly collecting the metric.
2025-10-23 15:56:31 +02:00
84e21dc79a Update CLAUDE.md with current system panel implementation status 2025-10-23 15:47:17 +02:00
1e5f8d6111 Update TODO.md to reflect implemented NixOS build display format 2025-10-23 15:12:18 +02:00
3b1bda741b Remove codename from NixOS build display
- Strip codename part (e.g., '(Warbler)') from nixos-version output
- Display clean version format: '25.05.20251004.3bcc93c'
- Simplify parsing to use raw nixos-version output as requested
2025-10-23 14:55:18 +02:00
64af24dc40 Update NixOS display format to show build hash and timestamp
- Change from showing version to build format: 'hash dd/mm/yy H:M:S'
- Parse nixos-version output to extract short hash and format date
- Update system widget to display 'Build:' instead of 'Version:'
- Remove version/build_date fields in favor of single build string
- Follow TODO.md specification for NixOS section layout
2025-10-23 14:48:25 +02:00
df036e90dc Add missing tmpfs metric handling to system widget
- Add memory_tmp_usage_percent, memory_tmp_used_gb, memory_tmp_total_gb metric parsing
- Fix tmpfs display showing as —% —GB/—GB in dashboard
- System widget now properly receives and displays tmpfs metrics from memory collector
2025-10-23 14:33:50 +02:00
9e80d6b654 Remove hardcoded /tmp autodetection and implement proper tmpfs monitoring
- Remove /tmp autodetection from disk collector (57 lines removed)
- Add tmpfs monitoring to memory collector with get_tmpfs_metrics() method
- Generate memory_tmp_* metrics for proper RAM-based tmpfs monitoring
- Fix type annotations in tmpfs parsing for compilation
- System widget now correctly displays tmpfs usage in RAM section
2025-10-23 14:26:15 +02:00
39fc9cd22f Implement unified system widget with NixOS info, CPU, RAM, and Storage
- Create NixOS collector for version and active users detection
- Add SystemWidget combining all system information in TODO.md layout
- Replace separate CPU/Memory widgets with unified system display
- Add tree structure for storage with drive temperature/wear info
- Support NixOS version, active users, load averages, memory usage
- Follow exact decimal formatting from specification
2025-10-23 14:01:14 +02:00
c99e0bd8ee Remove hardcoded discovery interval in systemd collector
- Use config.interval_seconds instead of hardcoded 300 seconds
- Discovery now happens every 10 seconds (configurable) instead of 5 minutes
- Follows configuration-driven architecture requirements
2025-10-23 13:20:48 +02:00
0f12438ab4 Fix RwLock deadlock in systemd collector Phase 4
- Restructure get_monitored_services to avoid nested write locks
- Split discover_services into discover_services_internal that returns data
- Update state in separate scope to prevent deadlock
- Fix borrow checker errors with clone() for status cache
2025-10-23 13:12:53 +02:00
7607e971b8 Add debug logging to diagnose Phase 4 service discovery issue
Add detailed debug logging to track:
- Service discovery start
- Individual service parsing
- Final service count and list
- Empty results indication

This will help identify why cmbox disappeared from dashboard.
2025-10-23 12:57:10 +02:00
da6f3c3855 Phase 4: Cache service status from discovery to eliminate per-service calls
Major performance optimization:
- Parse and cache service status during discovery from systemctl list-units
- Eliminate per-service systemctl is-active and show calls
- Reduce systemctl calls from 1+2N to just 1 call total
- For 10 services: 21 calls → 1 call (95% reduction)
- Add fallback to systemctl for cache misses

This completes the major systemctl call reduction goal from TODO.md.
2025-10-23 12:51:17 +02:00
174b27f31a Phase 3: Add wildcard support for service pattern matching
Implement glob pattern matching for service filters:
- nginx* matches nginx, nginx-config-reload, etc.
- *backup matches any service ending with 'backup'
- docker*prune matches docker-weekly-prune, etc.
- Exact matches still work as before (backward compatible)

Addresses TODO.md requirement for '*' filtering support.
2025-10-23 12:37:16 +02:00
dc11538ae9 Phase 2b: Optimize to single systemctl command
Reduce from 2 systemctl commands to 1 by using only:
systemctl list-units --type=service --all

This captures all services (active, inactive, failed) in one call,
eliminating the redundant list-unit-files command.
Achieves the TODO.md goal of reducing systemctl calls.
2025-10-23 12:34:54 +02:00
9133e18090 Phase 2: Remove user service collection logic
Remove all sudo -u systemctl commands and user service processing.
Now only collects system services via systemctl list-units/list-unit-files.
Eliminates user service discovery completely as planned in TODO.md.
2025-10-23 12:32:19 +02:00
616fad2c5d Phase 1: Implement exact name filtering for service matching
Change service matching logic from contains-based to exact equality.
Services now match only if service_name == pattern exactly.
This is the first step in the systemd collector optimization plan.
2025-10-23 12:22:26 +02:00
7bb5c1cf84 Updated documentation 2025-10-23 12:21:18 +02:00
245e546f18 Updated documentation 2025-10-23 12:12:33 +02:00
14aae90954 Fix storage display and improve UI formatting
- Fix duplicate storage pool issue by clearing cache on agent startup
- Change storage pool header text to normal color for better readability
- Improve services panel tree icons with proper └─ symbols for last items
- Ensure fresh metrics data on each agent restart
2025-10-22 23:02:16 +02:00
52d630a2e5 Remove legacy indexed disk metrics parsing
Eliminate duplicate storage entries by removing old disk_count dependency.
Dashboard now uses pure auto-discovery of disk_{pool}_usage_percent metrics.
Fixes multiple storage instances (Storage 0, Storage 1, Storage root)
showing only proper tree structure format.
2025-10-22 21:27:11 +02:00
b1f294cf2f Implement storage widget tree structure with themed status icons
Add proper hierarchical tree display for storage pools and drives:
- Pool headers with status icons and type indication (Single/multi-drive)
- Individual drive lines with ├─ tree symbols and health status
- Usage summary with └─ end symbol and capacity status
- T: and W: prefixes for temperature and wear level metrics
- Themed status icons using StatusIcons::get_icon() with proper colors
- 2-space indentation for clean tree structure appearance

Replace flat storage display with beautiful tree format:
● Storage steampool (multi-drive):
  ├─ ● sdb T:35°C W:12%
  ├─ ● sdc T:38°C W:8%
  └─ ● 78.1% 1250.3GB/1600.0GB

Uses agent-calculated status from NixOS-configured thresholds.
Update CLAUDE.md with complete implementation specification.
2025-10-22 21:17:33 +02:00
1591565b1b Update storage widget for enhanced disk collector metrics
Restructure storage display to handle new individual metrics architecture:
- Parse disk_{pool}_* metrics instead of indexed disk_{index}_* format
- Support individual drive metrics disk_{pool}_{drive}_health/temperature/wear
- Display tree structure: "Storage {pool} ({type}): drive details"
- Show pool usage summary with individual drive health/temp/wear status
- Auto-discover storage pools and drives from metric patterns
- Maintain proper status aggregation from individual metrics

The dashboard now correctly displays the new enhanced disk collector output
with storage pools containing multiple drives and their individual metrics.
2025-10-22 20:40:24 +02:00
08d3454683 Enhance disk collector with individual drive health monitoring
- Add StoragePool and DriveInfo structures for grouping drives by mount point
- Implement SMART data collection for individual drives (health, temperature, wear)
- Support for ext4, zfs, xfs, mergerfs, btrfs filesystem types
- Generate individual drive metrics: disk_[pool]_[drive]_health/temperature/wear
- Add storage_type and underlying_devices to filesystem configuration
- Move hardcoded service directory mappings to NixOS configuration
- Move hardcoded host-to-user mapping to NixOS configuration
- Remove all unused code and fix compilation warnings
- Clean implementation with zero warnings and no dead code

Individual drives now show health status per storage pool:
Storage root (ext4): nvme0n1 PASSED 42°C 5% wear
Storage steampool (mergerfs): sda/sdb/sdc with individual health data
2025-10-22 19:59:25 +02:00
a6c2983f65 Add automatic config file detection for dashboard TUI
- Dashboard now automatically looks for /etc/cm-dashboard/dashboard.toml
- No need to specify --config flag when using standard NixOS deployment
- Fallback to manual config path if default not found
- Update help text to reflect optional config parameter
- Simplifies dashboard usage - just run 'cm-dashboard' without arguments
2025-10-21 22:11:35 +02:00
3d2b37b26c Remove hardcoded defaults and migrate dashboard config to NixOS
- Remove all unused configuration options from dashboard config module
- Eliminate hardcoded defaults - dashboard now requires config file like agent
- Keep only actually used config: zmq.subscriber_ports and hosts.predefined_hosts
- Remove unused get_host_metrics function from metric store
- Clean up missing module imports (hosts, utils)
- Make dashboard fail fast if no configuration provided
- Align dashboard config approach with agent configuration pattern
2025-10-21 21:54:23 +02:00