← Back to PRs

#5509: Fix TUI crash when terminal window is too narrow

by omar-khaled-2 open 2026-01-31 15:41 View on GitHub →
docs
Fixes #5490. Uses visibleWidth from @mariozechner/pi-tui to correctly calculate string width. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR updates the `SearchableSelectList` TUI component to compute prompt/input/layout widths using `visibleWidth` from `@mariozechner/pi-tui` instead of a local ANSI-stripping width function, addressing crashes and rendering issues when the terminal is very narrow and when strings include wide characters. It also adds focused tests asserting that rendered lines don’t exceed a specified terminal width, including a wide-character case. <h3>Confidence Score: 3/5</h3> - Reasonably safe to merge, but edge cases with extremely small widths could still crash due to negative widths passed into truncation. - Change is localized and conceptually correct (use a more accurate width calculator), and tests were added. However, there are still paths where calculated widths can go negative when the terminal width is extremely small, which is directly related to the original crash class. Also, some width calculations still rely on `.length` rather than `visibleWidth`, which could reintroduce mis-measurements with styled prefixes. - src/tui/components/searchable-select-list.ts <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs