fix: prevent TUI crashes when terminal is resized to narrow widths#791
Open
liruifengv wants to merge 3 commits into
Open
fix: prevent TUI crashes when terminal is resized to narrow widths#791liruifengv wants to merge 3 commits into
liruifengv wants to merge 3 commits into
Conversation
- Truncate ThinkingComponent live spinner and all rendered lines to width - Truncate GoalCompletionMessageComponent output to width - Truncate CronMessageComponent output to width - Return placeholder in GutterContainer when gutters exceed width - Add narrow-width tests and update width-safety rules in AGENTS.md and write-tui skill
🦋 Changeset detectedLatest commit: a418845 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
… narrow widths pi-tui's editor wordWrapLine recurses infinitely when layoutWidth is 1 and the text contains wide graphemes (e.g. CJK). Skip rendering CustomEditor when the terminal is narrower than paddingX to avoid the crash.
Contributor
|
❌ Nix build failed |
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.
Related Issue
No related issue. This PR fixes crashes reported via
~/.pi/agent/pi-crash.logwhen the terminal is resized to a very narrow width.Problem
pi-tui enforces that every line returned by
Component.render(width)must fit withinwidth; otherwise it throws a hard crash. Several TUI components built lines manually without a final truncation guard, so resizing the terminal below the component's fixed minimum width (e.g. the live⠋ thinking...spinner at 13 columns) caused the application to crash and write a debug log to~/.pi/agent/pi-crash.log.Separately, pi-tui's
Editor.wordWrapLinerecurses infinitely when the layout width becomes1and the editor text contains a wide grapheme (e.g. CJK characters), producing aRangeError: Maximum call stack size exceeded.What changed
truncateToWidth(line, width, '…')guard toThinkingComponentso the live spinner and all thinking lines fit the available width.GoalCompletionMessageComponentandCronMessageComponentto handle bullet/indent + content overflow at extreme narrow widths.GutterContainerto return a placeholder when the requested width is smaller than the gutters themselves, instead of clamping the inner width to 1 and producing an over-wide line.CustomEditor.renderto skip rendering when the terminal is narrower than the editor's padding; this avoids the upstream pi-tuiwordWrapLineinfinite recursion on wide graphemes at a 1-column layout width.@earendil-works/pi-tui@0.74.0viapnpm patchto break thewordWrapLinerecursion whenmaxWidth <= 1and a wide grapheme cannot be split further, emitting the grapheme as its own overflow chunk instead.apps/kimi-code/AGENTS.mdand thewrite-tuiskill so future components follow the same pattern.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.