Skip to content

Enhance gitt help CLI output in small terminal size#389

Open
dataCenter430 wants to merge 2 commits intoentrius:testfrom
dataCenter430:feat/enhance-TUI-for-small-terminal-size
Open

Enhance gitt help CLI output in small terminal size#389
dataCenter430 wants to merge 2 commits intoentrius:testfrom
dataCenter430:feat/enhance-TUI-for-small-terminal-size

Conversation

@dataCenter430
Copy link
Copy Markdown

@dataCenter430 dataCenter430 commented Apr 11, 2026

Summary

The gitt --help output uses Rich-powered panels and ratio-based columns which break visually on narrow or split-pane terminals. This PR adds a plain-text fallback that activates automatically when the terminal is too narrow to render the box layout cleanly.

Root Cause

Two bugs combined to make the existing width-check ineffective:

  1. ctx.terminal_width is always None — Click does not populate this field on its own. The or 120 fallback meant the console was always created at 120 columns regardless of the real terminal width, so the width guard never fired.
  2. Threshold was 80 — even if detection had worked, 80 cols is the classic standard terminal width. The 4-column ratio layout (4:1:1:7) is already cramped at that size.

Changes (gittensor/cli/issue_commands/help.py)

Width detection fix

Replaced ctx.terminal_width or 120 with a _terminal_width(ctx) helper that falls back to shutil.get_terminal_size(), which correctly reads the OS terminal dimensions.

Threshold raised to 100

Terminals under 100 columns get plain text. The 4-column options panel needs real room; at 80 cols (standard terminal) it was always visually broken.

Plain-text rendering path

Three new helpers render help output without any Rich boxes when width is below the threshold:

Helper Output
_plain_usage Bare Usage: line
_plain_options Options: section, two-column aligned
_plain_section Commands: section, two-column aligned

_plain_options also handles long flag names gracefully: if a label would push the description off-screen, it uses a stacked layout (flag on its own line, description indented below) instead of an inline one. The label column is capped at half the usable terminal width.

Behaviour

Terminal width Output
≥ 100 cols Rich panels + boxes (unchanged)
60 – 99 cols Plain text, inline where it fits
≤ 59 cols Plain text, stacked for long flags

Testing

Verified manually at widths 40, 60, 79, 80, 99, 100, and 120 columns with both StyledCommand and StyledGroup help output. No regressions on the wide-terminal path.

Closes : #388

Screenshot

Before:

image

After:

image image

@dataCenter430 dataCenter430 force-pushed the feat/enhance-TUI-for-small-terminal-size branch 2 times, most recently from 263913c to 7683ad6 Compare April 12, 2026 00:12
@dataCenter430 dataCenter430 changed the title Feat/enhance t UI for small terminal size Enhance gitt help CLI output in small terminal size Apr 12, 2026
@dataCenter430
Copy link
Copy Markdown
Author

Hi, @anderdc
Would you review this PR and share me your thoughts, please?

@anderdc
Copy link
Copy Markdown
Collaborator

anderdc commented Apr 12, 2026

why would someone not just rerun the command and expand their terminal size? It seems you're adding unnecessary complexity for an issue that doesn't really matter?

@dataCenter430
Copy link
Copy Markdown
Author

Hi, @anderdc
Thanks for your consideration.
Fair point, but resizing isn't always possible:

  • SSH sessions and container shells (often fixed at 80 cols)
  • CI logs (GitHub Actions captures output at fixed width)
  • Split panes in tmux/VSCode — can't expand without shrinking another
  • Mobile terminals (Termux, Blink)

For a new user, broken box rendering on first gitt --help is a poor first impression.

The change is ~50 lines behind a single width < 100 guard — no new deps, no state, wide-terminal path unchanged. Tools like git, kubectl, cargo, and the af CLI in the screenshot all degrade gracefully on narrow terminals; we were the outlier.

Happy to tune the threshold if you'd prefer.

@wdeveloper16
Copy link
Copy Markdown

Good, I also think so, @dataCenter430
Thanks for your PR.

@syndrome4002-leo
Copy link
Copy Markdown

Good enhancement, @dataCenter430
It's so helpful for many cases.
cc: @anderdc

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.

Keep the plain text output for narrow terminal size

4 participants