MCPcopy
hub / github.com/docker/docker-agent / renderCollapsedSidebar

Method renderCollapsedSidebar

pkg/tui/page/chat/chat.go:472–506  ·  view source on GitHub ↗

renderCollapsedSidebar renders the sidebar in collapsed mode (at top of screen).

(sl sidebarLayout)

Source from the content-addressed store, hash-verified

470
471// renderCollapsedSidebar renders the sidebar in collapsed mode (at top of screen).
472func (p *chatPage) renderCollapsedSidebar(sl sidebarLayout) string {
473 // Guard against unset/invalid layout (can happen before WindowSizeMsg is received).
474 width := max(0, sl.innerWidth)
475 height := max(0, sl.sidebarHeight)
476 if width == 0 || height == 0 {
477 return ""
478 }
479
480 sidebarView := p.sidebar.View()
481 sidebarLines := strings.Split(sidebarView, "\n")
482
483 // Place toggle glyph at the far right of the first line
484 if sl.showToggle() && sl.mode != sidebarVertical && len(sidebarLines) > 0 {
485 toggleGlyph := styles.MutedStyle.Render("«")
486 glyphW := lipgloss.Width(toggleGlyph)
487 padded := lipgloss.NewStyle().Width(width - glyphW).Render(sidebarLines[0])
488 sidebarLines[0] = padded + toggleGlyph
489 }
490
491 // Replace the last line with a subtle divider
492 divider := styles.FadingStyle.Render(strings.Repeat("─", width))
493 if len(sidebarLines) >= height {
494 sidebarLines[height-1] = divider
495 } else {
496 sidebarLines = append(sidebarLines, divider)
497 }
498
499 sidebarWithDivider := strings.Join(sidebarLines, "\n")
500
501 return lipgloss.NewStyle().
502 Width(width).
503 Height(height).
504 Align(lipgloss.Left, lipgloss.Top).
505 Render(sidebarWithDivider)
506}
507
508// View renders the chat page (messages + sidebar only, no editor or resize handle)
509func (p *chatPage) View() string {

Callers 1

ViewMethod · 0.95

Calls 5

showToggleMethod · 0.80
ViewMethod · 0.65
RenderMethod · 0.65
WidthMethod · 0.45
HeightMethod · 0.45

Tested by

no test coverage detected