Skip to content

Conversation

Copy link

Copilot AI commented Nov 25, 2025

Implements enhancements from the PTUI dashboard roadmap: system resource monitoring, latency trend tracking, and integrated help.

Changes

New Dashboard Sections

  • System Resources: CPU/Memory/Disk usage with progress bars (requires optional psutil)
  • Help: Keyboard shortcuts reference and feature status; accessible via ? key

Latency Trend Indicators

Tracks service latency history and displays trend in Service Overview:

  • improving, degrading, stable
ONLINE  LiteLLM Gateway
  Latency: 12ms ↓   URL: http://localhost:4000

Configuration Constants

  • TREND_RECENT_SAMPLES, TREND_MIN_SAMPLES, TREND_IMPROVEMENT_THRESHOLD, TREND_DEGRADATION_THRESHOLD
  • PROGRESS_BAR_MAX_WIDTH
  • Uses non-blocking cpu_percent(interval=None) to avoid UI delay

Tests

  • 19 new unit tests for latency tracking, system resources, and constants
Original prompt

ptui enhancements


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: Camier <8348793+Camier@users.noreply.github.com>
@Camier Camier marked this pull request as ready for review November 25, 2025 05:28
Copilot AI review requested due to automatic review settings November 25, 2025 05:28
Copy link

Copilot AI left a comment

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 enhances the PTUI dashboard with three major features: system resource monitoring, latency trend tracking, and an integrated help section. The dashboard now provides better observability while maintaining its lightweight, terminal-based design with optional dependencies for enhanced functionality.

  • Added system resources panel showing CPU, memory, and disk usage with visual progress bars using psutil (optional)
  • Implemented latency history tracking that displays trend indicators (↓=improving, ↑=degrading, →=stable) alongside service latencies
  • Added Help section with keyboard shortcuts reference and feature availability status, accessible via '?' key

Reviewed changes

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

File Description
scripts/ptui_dashboard.py Adds latency tracking functions, system resource monitoring with psutil integration, help panel rendering, and '?' keyboard shortcut handler
tests/unit/test_ptui_dashboard.py Adds 17 new test cases covering latency tracking (recording, trends, edge cases), system resources (availability, value ranges), and new constants validation
docs/ptui-dashboard.md Updates documentation to reflect new features including system resources panel, latency trends, help section, and '?' keyboard shortcut

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 716 to 755
bar_width = min(30, width - 4)
filled = int((cpu_percent / 100) * bar_width)
bar = "█" * filled + "░" * (bar_width - filled)
safe_addstr(stdscr, y, left + 2, f"[{bar}]", width - 2, cpu_attr)
y += 1
safe_addstr(stdscr, y, left + 2, f"{cpu_count} cores available", width - 2, curses.A_DIM)
y += 2

# Memory Usage
memory_percent = resources.get("memory_percent", 0)
memory_used = resources.get("memory_used_gb", 0)
memory_total = resources.get("memory_total_gb", 0)
mem_attr = curses.color_pair(1) if memory_percent < 80 else curses.color_pair(2)
safe_addstr(
stdscr, y, left,
f"Memory: {memory_used:.1f}GB / {memory_total:.1f}GB ({memory_percent:.1f}%)",
width,
mem_attr | curses.A_BOLD,
)
y += 1
filled = int((memory_percent / 100) * bar_width)
bar = "█" * filled + "░" * (bar_width - filled)
safe_addstr(stdscr, y, left + 2, f"[{bar}]", width - 2, mem_attr)
y += 2

# Disk Usage
disk_percent = resources.get("disk_percent", 0)
disk_used = resources.get("disk_used_gb", 0)
disk_total = resources.get("disk_total_gb", 0)
disk_attr = curses.color_pair(1) if disk_percent < 90 else curses.color_pair(2)
safe_addstr(
stdscr, y, left,
f"Disk: {disk_used:.1f}GB / {disk_total:.1f}GB ({disk_percent:.1f}%)",
width,
disk_attr | curses.A_BOLD,
)
y += 1
filled = int((disk_percent / 100) * bar_width)
bar = "█" * filled + "░" * (bar_width - filled)
safe_addstr(stdscr, y, left + 2, f"[{bar}]", width - 2, disk_attr)
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

The variable bar_width is computed once at line 716 in the CPU section and then implicitly reused for memory (line 736) and disk (line 753) progress bars. This creates an implicit dependency that could break if the code is refactored. Consider either: (1) computing bar_width once before the CPU section, or (2) computing it separately for each progress bar to make the code more self-contained and maintainable.

Copilot uses AI. Check for mistakes.
…cpu_percent

Co-authored-by: Camier <8348793+Camier@users.noreply.github.com>
Copilot AI changed the title [WIP] Add enhancements to ptui functionality feat(ptui): Add system resources, latency trends, and help sections Nov 25, 2025
Copilot AI requested a review from Camier November 25, 2025 05:35
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.

2 participants