fix: send SIGWINCH to PTY when terminal element resizes#342
Merged
Conversation
The embedded terminal was hardcoded to 80x24. GPUI computes correct cols/rows from element bounds in prepaint() but never sent them to the PTY. Store the PTY master handle in Terminal (via Arc<Mutex<>>), add ResizeHandle that bundles the refs needed for resize operations, and call resize_if_changed() from prepaint() when dimensions change. This sends SIGWINCH to the child process and reflows the terminal grid so programs like vim/htop respond to window resize correctly. Closes #310
Owner
Author
PR Review SummaryCritical Issues (1 found)
Important Issues (2 found)
Suggestions (3 found)
Strengths
Type Design (7.5/10)
Verdict: NEEDS FIXESTwo error handling issues violate the project's "No Silent Failures" principle:
Core implementation is solid. Fixes are straightforward and don't require architectural changes. Recommended Actions
|
- Replace .expect() on current_size lock with map_err + early return to prevent UI crash on lock poison - Replace silent if-let-Ok on pty_master lock with explicit error logging and propagation - Make resize_if_changed() return Result<(), TerminalError>, using the previously-unused PtyResize error variant - Handle Result in TerminalElement::prepaint() with tracing::error - Fix SIGWINCH comment accuracy (updates kernel winsize, not direct signal) - Document lock scope management in ordering comment
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.
Summary
Terminalstruct (viaArc<Mutex<>>) instead of moving it into the reader threadResizeHandlestruct that bundles resize refs (term, pty_master, current_size) with aresize_if_changed()methodresize_if_changed()fromTerminalElement::prepaint()when computed dimensions differ from stored sizePrograms like vim, htop, and shell prompts now respond correctly to window resize.
$COLUMNS/$LINESreflect actual terminal dimensions.Closes #310
Test plan
cargo fmt --checkpassescargo clippy --all -- -D warningspasses (0 warnings)cargo test --allpasses (494 passed)cargo build --allsucceedsecho $COLUMNSmatches window widthecho $COLUMNSupdates