Skip to content

fix(pi-pi): truncate widget message to terminal width#20

Open
dwainm wants to merge 1 commit intodisler:mainfrom
dwainm:fix/pi-pi-truncate-width
Open

fix(pi-pi): truncate widget message to terminal width#20
dwainm wants to merge 1 commit intodisler:mainfrom
dwainm:fix/pi-pi-truncate-width

Conversation

@dwainm
Copy link
Copy Markdown

@dwainm dwainm commented Mar 18, 2026

Problem

The 'No experts found' message in the pi-pi widget render was causing a TUI crash on narrow terminals:

Error: Rendered line 62 exceeds terminal width (60 > 49)

This occurred when the terminal width was less than the message length.

Solution

Wrap the message with truncateToWidth() to ensure it fits within the available width:

// Before
return ["", theme.fg("dim", "  No experts found...")];

// After  
return ["", truncateToWidth(theme.fg("dim", "  No experts found..."), width, "")];

Testing

  • Tested on terminal width 49 (previously crashed)
  • Message now truncates gracefully instead of throwing

Prevents TUI crash when terminal width < message length.
The 'No experts found' message was exceeding terminal bounds
causing 'Rendered line exceeds terminal width' error.

Fixes: truncateToWidth(theme.fg(...), width, '')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant