fix(tea): fall back to 80x24 when initial GetSize returns 0 (blank first frame under tmux)#1718
Open
Ricardo-M-L wants to merge 1 commit into
Open
Conversation
Program.Run reads the terminal size once at startup via term.GetSize and trusts the result, checking only the error. Some terminals — tmux is the common case, before the pty size is negotiated — return (0, 0) with no error. Run then resizes the renderer to 0x0 and the event loop, which only paints after a message, renders the first frame into a 0x0 viewport: the whole screen is blank until a real SIGWINCH (a resize or keypress) arrives. This looks like the program hung, and it happens regardless of the model's View() — even a width-agnostic view renders blank because the renderer viewport is 0. Fall back to a standard 80x24 for any zero dimension so the first frame paints; the genuine size still arrives via WindowSizeMsg a moment later and re-renders correctly. Adds fallbackZeroSize + a unit test.
Author
|
Gentle ping on this one 🙂 It's a small (+52/-1), self-contained fix with a unit test for a real tmux issue: Happy to adjust the fallback dimensions or take a different approach if you'd prefer. Thanks for taking a look when you get a chance! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Launching a Bubble Tea v2 program inside tmux (and some other pty setups) shows a blank screen until the first event — the user resizes the window or presses a key — at which point the UI finally paints. It looks like the program hung.
Root cause
Program.Runreads the terminal size once at startup and trusts the result, checking only the error:Under tmux the pty size often isn't negotiated yet at this instant, so
term.GetSizereturns(0, 0)witherr == nil.Runthen resizes the renderer to0x0. Because the event loop only paints after it receives a message, and the only startup message is the resultingWindowSizeMsg{0,0}, the first frame is clipped to a 0x0 viewport — blank — until a realSIGWINCHarrives.This is independent of the model's
View(): even a view that ignores width entirely renders blank, because the renderer viewport is0x0.Fix
Fall back to a standard
80x24for any zero dimension, mirroring what terminal apps conventionally do. The first frame then paints, and the genuine size replaces it viaWindowSizeMsga moment later.Adds
fallbackZeroSize(a small pure helper) plus a unit test. The startupGetSizepath itself is awkward to unit-test (it needs a real tty Fd), so the fallback logic is factored into a tested helper.Testing
go test .passes.