You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
truncateMiddle returns a string longer than maxLength when maxLength is 1 or 2 #37458
keepEnd is Math.floor((maxLength - 1) / 2), which is 0 when maxLength is 1 or 2. str.slice(-0) is str.slice(0) — the whole string — so instead of truncating, the function returns the entire input with an ellipsis attached. maxLength >= 3 is unaffected, which is why this hasn't shown up before.
This is reachable from the TUI. packages/tui/src/ui/dialog-select.tsx:701:
The Math.max(1, ...) guard is there to handle narrow terminals, but it clamps to exactly the broken value. Running that expression against a 39-char detail string:
terminal width=13 -> maxLength=1 -> result is 40 chars (overflows)
terminal width=14 -> maxLength=2 -> result is 41 chars (overflows)
terminal width=15 -> maxLength=3 -> result is 3 chars (correct)
So below ~15 columns the detail line renders the full untruncated string and overflows the layout it was meant to fit. packages/opencode/src/cli/cmd/run/splash.ts:203 uses the same Math.max(1, ...) shape.
Same root cause as #37368, but a different function — #37369 fixes truncateLeft and doesn't touch this one.
Note: packages/core/src/util/path.ts:31 has an independent copy of truncateMiddle with the same -0 defect. It currently has no callers, so it isn't user-visible. Happy to fix it in the same PR or leave it out.
Steps to reproduce
Resize the terminal to 14 columns or fewer
Open a select dialog that renders a detail line (e.g. the session or model picker) with a detail string longer than the width
The detail renders in full instead of truncated, overflowing the dialog
Activity
github-actions commentedon Jul 17, 2026
This issue might be a duplicate of existing (closed) issues. Please check:
truncateMiddlereturns the whole string whenmaxLengthis 1 or 2slice(-0)defect intruncateMiddlewhenmaxLength <= 2If those were previously fixed and regressed, or if the fix was never merged, that context would be helpful to include.
github-actions commentedon Sep 17, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.