Conversation
renderFooter passed `m.width - len(helpText) - len(schemaInfo) - 2` straight to strings.Repeat. When the spec's info.title/version was long or the terminal narrow, the count went negative and strings.Repeat panicked with "strings: negative Repeat count", crashing the TUI. Clamp the padding count at zero. Also measure widths with lipgloss.Width instead of len so multi-byte titles are counted by display columns, not bytes — matching how renderHeader already measures and avoiding a false negative count on Unicode titles. Add TestFooterRenderNarrowWidth, which drives renderFooter and View at widths 0/1/10/40 with a long title; it panics before the fix and passes after.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix footer panic on narrow widths and long titles
Summary
renderFootercrashes the whole TUI withstrings: negative Repeat countfor some specs / terminal sizes.The bug
renderFooterbuilds the footer padding like this:schemaInfois"<info.title> v<info.version>". When that string is long relative to the terminal width — a long API title, or just a narrow window — the count goes negative, andstrings.Repeatpanics on a negative count:The guard above only zeroes
helpText; it never accounts forschemaInfoitself overflowing, so even an emptyhelpTextcan't save it.A second, latent issue: widths are measured with
len()(bytes), not display columns. A multi-byteinfo.titleover-counts versus the real terminal width and can drive the count negative even when the text visually fits.renderHeaderalready useslipgloss.Width()for this; the footer was inconsistent.The fix
0beforestrings.Repeat.lipgloss.Width()instead oflen(), matchingrenderHeaderand correctly handling Unicode titles.The sibling renderers (
renderEndpoints/renderComponents/renderWebhooks) get their repeat count fromcalculateContentWidth, which already clamps viamax(1, ...), so they were never affected and are left unchanged.Testing
Added
TestFooterRenderNarrowWidth, which drivesrenderFooterandView()at widths0,1,10, and40against a spec with a long title + version. It panics before the fix and passes after.go test -vpasses