Skip to content

fix: truncate task panel lines to terminal width#3

Open
xuli500177 wants to merge 2 commits into
QuintinShaw:mainfrom
xuli500177:fix/task-panel-truncation
Open

fix: truncate task panel lines to terminal width#3
xuli500177 wants to merge 2 commits into
QuintinShaw:mainfrom
xuli500177:fix/task-panel-truncation

Conversation

@xuli500177

Copy link
Copy Markdown

Fix: Truncate task panel lines to terminal width

Problem

When a workflow has a long name or phase name, the task panel renders a line exceeding the terminal width, causing pi-tui to crash with:

Error: Rendered line 440 exceeds terminal width (69 > 45).

Root Cause

renderPanel() builds status lines without respecting the terminal width:

return `  ${icon} ${r.workflowName}  ${done}/${agents.length} agents${phase}`;

When workflowName + phase is long, the line overflows.

Fix

  1. Pass width from the Component.render() callback to renderPanel()
  2. Truncate lines that exceed maxWidth

The lines in rows are intentionally plain text (no ANSI codes), so string.length is sufficient for width calculation.

root added 2 commits June 9, 2026 02:48
When a workflow has a long name or phase name, the task panel renders
a line exceeding the terminal width, causing pi-tui to crash with
'Rendered line exceeds terminal width'.

Changes:
- Add width parameter to renderPanel()
- Truncate lines that exceed maxWidth
- Pass width from Component.render() callback
The hint line uses theme.fg('dim', ...) which adds ANSI escape codes.
Truncating after color application would still exceed terminal width.
Now truncate the plain text first, then apply color.
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