[PR #233] feat(tui): add keybinding g to swap host and GPU history graphs #232

Open
opened 2026-10-23 22:05:40 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/XuehaiPan/nvitop/pull/233
Author: @MengmaoR
Created: 10/22/2026
Status: 🔄 Open

Base: main ← Head: feat/swap-host-gpu-graphs


📝 Commits (1)

  • 9ec0372 feat(tui): add keybinding g to swap host and GPU history graphs

📊 Changes

3 files changed (+101 additions, -50 deletions)

View changed files

📝 nvitop/tui/screens/help.py (+10 -8)
📝 nvitop/tui/screens/main/__init__.py (+4 -0)
📝 nvitop/tui/screens/main/panels/host.py (+87 -42)

📄 Description

Issue Type

  • Improvement/feature implementation

Description

Add a reversible keybinding g on the main screen to swap the horizontal positions of the host (CPU / MEM / SWP) and GPU (MEM / UTL) history graphs in HostPanel:

  • Default (swap_graphs=False): Host CPU/MEM/SWP graphs are rendered in the left 77-column pane (x + 1), and GPU memory/utilization graphs are rendered in the right pane (x + 79) when terminal width >= 100.
  • Swapped (swap_graphs=True, toggled via g): GPU memory/utilization graphs are rendered in the left 77-column pane, and Host CPU/MEM/SWP graphs are moved to the right pane when terminal width >= 100. Pressing g again restores the default layout.
  • Narrow right pane adaptation (100 <= width < 113): When host graphs are placed in the right pane and its inner width is narrower than the full Load Average or MEM/SWP byte labels, the labels gracefully fall back to compact percentage strings so they never overflow the right border.
  • Help screen: Document g: swap host/GPU graphs in HelpScreen.

Motivation and Context

In HostPanel, the left 79-column box is fixed to host CPU/memory/swap history graphs while GPU memory and utilization history graphs are only drawn on the right when the terminal width is at least 100 columns.

When working in narrower terminals (79 <= width < 100, such as split panes or side-by-side terminal windows), the GPU history graphs are completely hidden and only the host CPU/memory graphs are visible. Even on wider terminals, users primarily monitoring GPU workloads may prefer having the wider 77-column history window dedicated to GPU metrics.

Adding the reversible g shortcut lets users freely toggle between host and GPU history graphs in 79–99 column terminals and swap their left/right placement in 100+ column terminals, without altering the 79-column frame grid, border connectors (╧ / ╪), or timebase ruler.

Testing

  • Passed ruff check, ruff format --check, codespell, mypy, and pylint (10.00/10).
  • Verified reversible toggling (g) and terminal resizing across narrow (80 columns), medium (100–112 columns), and wide (120+ columns) PTY sessions, as well as HelpScreen rendering (h / ?).

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/XuehaiPan/nvitop/pull/233 **Author:** [@MengmaoR](https://github.com/MengmaoR) **Created:** 10/22/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/swap-host-gpu-graphs` --- ### 📝 Commits (1) - [`9ec0372`](https://github.com/XuehaiPan/nvitop/commit/9ec0372c0ca8bcf46e5e8794bfa5887a4e510635) feat(tui): add keybinding `g` to swap host and GPU history graphs ### 📊 Changes **3 files changed** (+101 additions, -50 deletions) <details> <summary>View changed files</summary> 📝 `nvitop/tui/screens/help.py` (+10 -8) 📝 `nvitop/tui/screens/main/__init__.py` (+4 -0) 📝 `nvitop/tui/screens/main/panels/host.py` (+87 -42) </details> ### 📄 Description #### Issue Type - Improvement/feature implementation #### Description Add a reversible keybinding `g` on the main screen to swap the horizontal positions of the host (CPU / MEM / SWP) and GPU (MEM / UTL) history graphs in `HostPanel`: - **Default (`swap_graphs=False`)**: Host CPU/MEM/SWP graphs are rendered in the left 77-column pane (`x + 1`), and GPU memory/utilization graphs are rendered in the right pane (`x + 79`) when terminal width `>= 100`. - **Swapped (`swap_graphs=True`, toggled via `g`)**: GPU memory/utilization graphs are rendered in the left 77-column pane, and Host CPU/MEM/SWP graphs are moved to the right pane when terminal width `>= 100`. Pressing `g` again restores the default layout. - **Narrow right pane adaptation (`100 <= width < 113`)**: When host graphs are placed in the right pane and its inner width is narrower than the full `Load Average` or `MEM/SWP` byte labels, the labels gracefully fall back to compact percentage strings so they never overflow the right border. - **Help screen**: Document `g: swap host/GPU graphs` in `HelpScreen`. #### Motivation and Context In `HostPanel`, the left 79-column box is fixed to host CPU/memory/swap history graphs while GPU memory and utilization history graphs are only drawn on the right when the terminal width is at least 100 columns. When working in narrower terminals (`79 <= width < 100`, such as split panes or side-by-side terminal windows), the GPU history graphs are completely hidden and only the host CPU/memory graphs are visible. Even on wider terminals, users primarily monitoring GPU workloads may prefer having the wider 77-column history window dedicated to GPU metrics. Adding the reversible `g` shortcut lets users freely toggle between host and GPU history graphs in 79–99 column terminals and swap their left/right placement in 100+ column terminals, without altering the 79-column frame grid, border connectors (`╧` / `╪`), or timebase ruler. #### Testing - Passed `ruff check`, `ruff format --check`, `codespell`, `mypy`, and `pylint` (10.00/10). - Verified reversible toggling (`g`) and terminal resizing across narrow (`80` columns), medium (`100–112` columns), and wide (`120+` columns) PTY sessions, as well as `HelpScreen` rendering (`h` / `?`). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github-starred/nvitop#232
No description provided.