Repository navigation
fix(tty): fall back to default dimensions when terminal size is 0x0 - #1836
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1836 +/- ##
==========================================
+ Coverage 59.91% 60.21% +0.30%
==========================================
Files 25 25
Lines 1342 1365 +23
==========================================
+ Hits 804 822 +18
- Misses 449 452 +3
- Partials 89 91 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
andrinoff
left a comment
There was a problem hiding this comment.
Please, fix those and it is good to go!
| width, height = w, h | ||
| } | ||
|
|
||
| width, height = p.fallbackDimensions(width, height) |
There was a problem hiding this comment.
This fallback also runs when the output isn't a terminal at all, such as output to a buffer, a pipe, or a Wish/SSH session. Apps that used to receive a 0x0 size there will now get a made-up 80x24. Moving this line inside the if p.ttyOutput != nil block above would limit the fix to the actual bug
| cols = p.environ.Getenv("COLUMNS") | ||
| } | ||
| if cols == "" { | ||
| cols = os.Getenv("COLUMNS") |
There was a problem hiding this comment.
If the app passed its own environment with WithEnvironment, which is the usual Wish setup, this falls back to the server's own COLUMNS/LINES. Those belong to the wrong machine, so it should only read the program's environment and skip os.Getenv
| lines = p.environ.Getenv("LINES") | ||
| } | ||
| if lines == "" { | ||
| lines = os.Getenv("LINES") |
There was a problem hiding this comment.
If the app passed its own environment with WithEnvironment, which is the usual Wish setup, this falls back to the server's own COLUMNS/LINES. Those belong to the wrong machine, so it should only read the program's environment and skip os.Getenv
|
Updated per your review:
|
Problem
When running Bubble Tea v2 applications on serial consoles, headless setups, or terminals where window dimensions are not yet configured or reported as 0x0 (e.g. stty rows 0 cols 0), term.GetSize returns (0, 0, nil). Bubble Tea sets p.width = 0 and p.height = 0 and passes these dimensions to the renderer and model. Because the viewport height and width are 0, rendered output lines are clipped, resulting in a completely blank screen.
Root Cause
In Program.Run and Program.checkResize:
Solution
Fixes #1828