on main help sign in
chore: make the sidebar a bit more responsive
commitb8f74f33c52759625a1a5cd9f5f1a0b95675a781 authorKujtim Hoxha <kujtimii.h@gmail.com> dateFri 11 Jul 2025, 16:35 (1 year ago) parentf6a79e4
2 files changed+33−11
internal/tui/components/chat/sidebar/sidebar.go+22−1 internal/tui/page/chat/chat.go+11−10
internal/tui/components/chat/sidebar/sidebar.go+22−1
@@ -33,6 +33,8 @@ type FileHistory struct {
3333 latestVersion history.File
3434}
3535
36+const LogoHeightBreakpoint = 40
37+
3638type SessionFile struct {
3739 History FileHistory
3840 FilePath string
@@ -100,8 +102,14 @@ func (m *sidebarCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
100102func (m *sidebarCmp) View() string {
101103 t := styles.CurrentTheme()
102104 parts := []string{}
105+
103106 if !m.compactMode {
104− parts = append(parts, m.logo)
107+ if m.height > LogoHeightBreakpoint {
108+ parts = append(parts, m.logo)
109+ } else {
110+ // Use a smaller logo for smaller screens
111+ parts = append(parts, m.smallerScreenLogo(), "")
112+ }
105113 }
106114
107115 if !m.compactMode && m.session.ID != "" {
@@ -504,6 +512,19 @@ func (s *sidebarCmp) currentModelBlock() string {
504512 )
505513}
506514
515+func (m *sidebarCmp) smallerScreenLogo() string {
516+ t := styles.CurrentTheme()
517+ title := t.S().Base.Foreground(t.Secondary).Render("Charm™")
518+ title += " " + styles.ApplyBoldForegroundGrad("CRUSH", t.Secondary, t.Primary)
519+ remainingWidth := m.width - lipgloss.Width(title) - 3
520+ if remainingWidth > 0 {
521+ char := "╱"
522+ lines := strings.Repeat(char, remainingWidth)
523+ title += " " + t.S().Base.Foreground(t.Primary).Render(lines)
524+ }
525+ return title
526+}
527+
507528// SetSession implements Sidebar.
508529func (m *sidebarCmp) SetSession(session session.Session) tea.Cmd {
509530 m.session = session
internal/tui/page/chat/chat.go+11−10
@@ -52,11 +52,12 @@ const (
5252)
5353
5454const (
55− CompactModeBreakpoint = 120 // Width at which the chat page switches to compact mode
56− EditorHeight = 5 // Height of the editor input area including padding
57− SideBarWidth = 31 // Width of the sidebar
58− SideBarDetailsPadding = 1 // Padding for the sidebar details section
59− HeaderHeight = 1 // Height of the header
55+ CompactModeWidthBreakpoint = 120 // Width at which the chat page switches to compact mode
56+ CompactModeHeightBreakpoint = 30 // Height at which the chat page switches to compact mode
57+ EditorHeight = 5 // Height of the editor input area including padding
58+ SideBarWidth = 31 // Width of the sidebar
59+ SideBarDetailsPadding = 1 // Padding for the sidebar details section
60+ HeaderHeight = 1 // Height of the header
6061
6162 // Layout constants for borders and padding
6263 BorderWidth = 1 // Width of component borders
@@ -178,7 +179,7 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
178179 if p.forceCompact {
179180 p.setCompactMode(true)
180181 cmd = p.updateCompactConfig(true)
181− } else if p.width >= CompactModeBreakpoint {
182+ } else if p.width >= CompactModeWidthBreakpoint && p.height >= CompactModeHeightBreakpoint {
182183 p.setCompactMode(false)
183184 cmd = p.updateCompactConfig(false)
184185 }
@@ -421,20 +422,20 @@ func (p *chatPage) setCompactMode(compact bool) {
421422 }
422423}
423424
424−func (p *chatPage) handleCompactMode(newWidth int) {
425+func (p *chatPage) handleCompactMode(newWidth int, newHeight int) {
425426 if p.forceCompact {
426427 return
427428 }
428− if newWidth < CompactModeBreakpoint && !p.compact {
429+ if (newWidth < CompactModeWidthBreakpoint || newHeight < CompactModeHeightBreakpoint) && !p.compact {
429430 p.setCompactMode(true)
430431 }
431− if newWidth >= CompactModeBreakpoint && p.compact {
432+ if (newWidth >= CompactModeWidthBreakpoint && newHeight >= CompactModeHeightBreakpoint) && p.compact {
432433 p.setCompactMode(false)
433434 }
434435}
435436
436437func (p *chatPage) SetSize(width, height int) tea.Cmd {
437− p.handleCompactMode(width)
438+ p.handleCompactMode(width, height)
438439 p.width = width
439440 p.height = height
440441 var cmds []tea.Cmd