Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions pkg/tui/page/chat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,13 @@ const pendingSpinnerHeight = 3

// renderCollapsedSidebar renders the sidebar in collapsed mode (at top of screen).
func (p *chatPage) renderCollapsedSidebar(sl sidebarLayout) string {
// Guard against unset/invalid layout (can happen before WindowSizeMsg is received).
width := max(0, sl.innerWidth)
height := max(0, sl.sidebarHeight)
if width == 0 || height == 0 {
return ""
}

sidebarView := p.sidebar.View()
sidebarLines := strings.Split(sidebarView, "\n")

Expand All @@ -614,18 +621,18 @@ func (p *chatPage) renderCollapsedSidebar(sl sidebarLayout) string {
}

// Replace the last line with a subtle divider
divider := styles.FadingStyle.Render(strings.Repeat("─", sl.innerWidth))
if len(sidebarLines) >= sl.sidebarHeight {
sidebarLines[sl.sidebarHeight-1] = divider
divider := styles.FadingStyle.Render(strings.Repeat("─", width))
if len(sidebarLines) >= height {
sidebarLines[height-1] = divider
} else {
sidebarLines = append(sidebarLines, divider)
}

sidebarWithDivider := strings.Join(sidebarLines, "\n")

return lipgloss.NewStyle().
Width(sl.innerWidth).
Height(sl.sidebarHeight).
Width(width).
Height(height).
Align(lipgloss.Left, lipgloss.Top).
Render(sidebarWithDivider)
}
Expand Down
Loading