Change summary
internal/tui/components/chat/sidebar/sidebar.go | 23 ++++++++++++++++++
internal/tui/page/chat/chat.go | 21 +++++++++--------
2 files changed, 33 insertions(+), 11 deletions(-)
Detailed changes
@@ -33,6 +33,8 @@ type FileHistory struct {
latestVersion history.File
}
+const LogoHeightBreakpoint = 40
+
type SessionFile struct {
History FileHistory
FilePath string
@@ -100,8 +102,14 @@ func (m *sidebarCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
func (m *sidebarCmp) View() string {
t := styles.CurrentTheme()
parts := []string{}
+
if !m.compactMode {
- parts = append(parts, m.logo)
+ if m.height > LogoHeightBreakpoint {
+ parts = append(parts, m.logo)
+ } else {
+ // Use a smaller logo for smaller screens
+ parts = append(parts, m.smallerScreenLogo(), "")
+ }
}
if !m.compactMode && m.session.ID != "" {
@@ -504,6 +512,19 @@ func (s *sidebarCmp) currentModelBlock() string {
)
}
+func (m *sidebarCmp) smallerScreenLogo() string {
+ t := styles.CurrentTheme()
+ title := t.S().Base.Foreground(t.Secondary).Render("Charmβ’")
+ title += " " + styles.ApplyBoldForegroundGrad("CRUSH", t.Secondary, t.Primary)
+ remainingWidth := m.width - lipgloss.Width(title) - 3
+ if remainingWidth > 0 {
+ char := "β±"
+ lines := strings.Repeat(char, remainingWidth)
+ title += " " + t.S().Base.Foreground(t.Primary).Render(lines)
+ }
+ return title
+}
+
// SetSession implements Sidebar.
func (m *sidebarCmp) SetSession(session session.Session) tea.Cmd {
m.session = session
@@ -52,11 +52,12 @@ const (
)
const (
- CompactModeBreakpoint = 120 // Width at which the chat page switches to compact mode
- EditorHeight = 5 // Height of the editor input area including padding
- SideBarWidth = 31 // Width of the sidebar
- SideBarDetailsPadding = 1 // Padding for the sidebar details section
- HeaderHeight = 1 // Height of the header
+ CompactModeWidthBreakpoint = 120 // Width at which the chat page switches to compact mode
+ CompactModeHeightBreakpoint = 30 // Height at which the chat page switches to compact mode
+ EditorHeight = 5 // Height of the editor input area including padding
+ SideBarWidth = 31 // Width of the sidebar
+ SideBarDetailsPadding = 1 // Padding for the sidebar details section
+ HeaderHeight = 1 // Height of the header
// Layout constants for borders and padding
BorderWidth = 1 // Width of component borders
@@ -178,7 +179,7 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if p.forceCompact {
p.setCompactMode(true)
cmd = p.updateCompactConfig(true)
- } else if p.width >= CompactModeBreakpoint {
+ } else if p.width >= CompactModeWidthBreakpoint && p.height >= CompactModeHeightBreakpoint {
p.setCompactMode(false)
cmd = p.updateCompactConfig(false)
}
@@ -421,20 +422,20 @@ func (p *chatPage) setCompactMode(compact bool) {
}
}
-func (p *chatPage) handleCompactMode(newWidth int) {
+func (p *chatPage) handleCompactMode(newWidth int, newHeight int) {
if p.forceCompact {
return
}
- if newWidth < CompactModeBreakpoint && !p.compact {
+ if (newWidth < CompactModeWidthBreakpoint || newHeight < CompactModeHeightBreakpoint) && !p.compact {
p.setCompactMode(true)
}
- if newWidth >= CompactModeBreakpoint && p.compact {
+ if (newWidth >= CompactModeWidthBreakpoint && newHeight >= CompactModeHeightBreakpoint) && p.compact {
p.setCompactMode(false)
}
}
func (p *chatPage) SetSize(width, height int) tea.Cmd {
- p.handleCompactMode(width)
+ p.handleCompactMode(width, height)
p.width = width
p.height = height
var cmds []tea.Cmd