on main help sign in
Merge pull request #127 from charmbracelet/truncate-logo

fix(tui): logo: make sure we truncate the logo if it exceeds the width

commitf31b0512ba949353e17ec7774a4b5de17e7bdfcf authorKujtim Hoxha <kujtimii.h@gmail.com> dateThu 10 Jul 2025, 20:27 (1 year ago) parente34ff95ddeec85
2 files changed+11−1
internal/tui/components/chat/sidebar/sidebar.go+1 internal/tui/components/logo/logo.go+10−1
internal/tui/components/chat/sidebar/sidebar.go+1
@@ -250,6 +250,7 @@ func (m *sidebarCmp) logoBlock() string {
250250 TitleColorB: t.Primary,
251251 CharmColor: t.Secondary,
252252 VersionColor: t.Primary,
253+ Width: m.width - 2,
253254 })
254255}
255256
internal/tui/components/logo/logo.go+10−1
@@ -98,7 +98,16 @@ func Render(version string, compact bool, o Opts) string {
9898
9999 // Return the wide version.
100100 const hGap = " "
101− return lipgloss.JoinHorizontal(lipgloss.Top, leftField.String(), hGap, crush, hGap, rightField.String())
101+ logo := lipgloss.JoinHorizontal(lipgloss.Top, leftField.String(), hGap, crush, hGap, rightField.String())
102+ if o.Width > 0 {
103+ // Truncate the logo to the specified width.
104+ lines := strings.Split(logo, "\n")
105+ for i, line := range lines {
106+ lines[i] = ansi.Truncate(line, o.Width, "")
107+ }
108+ logo = strings.Join(lines, "\n")
109+ }
110+ return logo
102111}
103112
104113// renderWord renders letterforms to fork a word.