Skip to content

Fix terminal width detection on Linux#8

Open
xAlcahest wants to merge 1 commit into
slima4:mainfrom
xAlcahest:fix/linux-terminal-width-detection
Open

Fix terminal width detection on Linux#8
xAlcahest wants to merge 1 commit into
slima4:mainfrom
xAlcahest:fix/linux-terminal-width-detection

Conversation

@xAlcahest
Copy link
Copy Markdown

@xAlcahest xAlcahest commented May 13, 2026

Summary

get_terminal_cols() walks the process tree looking for a parent with a TTY, but on Linux the no-TTY marker is ?, not ?? like macOS. The walk stopped at the first process, tried to open /dev/?, failed silently, and fell back to 80 columns. This made fit_parts() drop most statusline components on every Linux system.

Changes

  • claude_tui_components/utils.py, added "?" to the TTY exclusion check so the parent-walk skips no-TTY processes on Linux

Fixes #7

Summary by CodeRabbit

  • Bug Fixes
    • Improved terminal dimension detection with more robust TTY validation and fallback behavior.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 790407e1-9eb6-4301-aa62-4df9d6a9896f

📥 Commits

Reviewing files that changed from the base of the PR and between 8608624 and b12bc87.

📒 Files selected for processing (1)
  • claude_tui_components/utils.py

📝 Walkthrough

Walkthrough

The change expands the TTY validation filter in get_terminal_cols() to treat "?" as an invalid TTY alongside "??" and empty string, preventing failed /dev/? device access on Linux and allowing proper terminal width detection fallback.

Changes

Terminal Column Detection TTY Validation

Layer / File(s) Summary
TTY filter condition expansion
claude_tui_components/utils.py
The TTY validity check at line 59 now rejects "?" alongside "??" and "", ensuring processes without a controlling terminal on Linux fall back to shutil.get_terminal_size().columns or 80 instead of attempting to open /dev/?.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A question mark once caused a mystical maze,
On Linux, the TTY in subtle ways,
Now filtered with care, the rightful three,
The rabbit hops on, with columns set free! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix terminal width detection on Linux' directly and specifically describes the main change in the PR—fixing get_terminal_cols() to correctly detect TTY on Linux.
Linked Issues check ✅ Passed The PR fully addresses issue #7 by adding '?' to the TTY exclusion check, enabling correct terminal width detection on Linux instead of falling back to 80 columns.
Out of Scope Changes check ✅ Passed The single-line change to utils.py directly addresses the linked issue with no unrelated modifications or scope creep.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

get_terminal_cols() falls back to 80 columns on Linux

1 participant