Skip to content

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

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

fix(pi-pi): truncate widget message to terminal width#20
dwainm wants to merge 1 commit into
disler: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, '')
jetnet pushed a commit to jetnet/pi-coms that referenced this pull request May 23, 2026
agent-team.ts, agent-chain.ts, pi-pi.ts, subagent-widget.ts:

- Deduplicate parseAgentFile() → use shared agent-loader (SEC-001, PR disler#3)
- Clamp renderCard width to prevent RangeError: Invalid count -1
  on narrow terminals (Issue disler#17, PR disler#20)
- Use process.execPath + findPiCli() for snap-safe subprocess
  spawning (PR disler#13)
- Forward damage-control.ts extension to subagent processes when
  present, falling back to --no-extensions (Issue disler#24)
- Normalize CRLF line endings in all readFileSync calls (PR disler#1)
- Wrap 'No experts found' message with truncateToWidth() (PR disler#20)
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