landing.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package model
  2. import (
  3. "charm.land/lipgloss/v2"
  4. "github.com/charmbracelet/crush/internal/agent"
  5. "github.com/charmbracelet/crush/internal/ui/common"
  6. "github.com/charmbracelet/ultraviolet/layout"
  7. )
  8. // selectedLargeModel returns the currently selected large language model from
  9. // the agent coordinator, if one exists.
  10. func (m *UI) selectedLargeModel() *agent.Model {
  11. if m.com.App.AgentCoordinator != nil {
  12. model := m.com.App.AgentCoordinator.Model()
  13. return &model
  14. }
  15. return nil
  16. }
  17. // landingView renders the landing page view showing the current working
  18. // directory, model information, and LSP/MCP status in a two-column layout.
  19. func (m *UI) landingView() string {
  20. t := m.com.Styles
  21. width := m.layout.main.Dx()
  22. cwd := common.PrettyPath(t, m.com.Config().WorkingDir(), width)
  23. parts := []string{
  24. cwd,
  25. }
  26. parts = append(parts, "", m.modelInfo(width))
  27. infoSection := lipgloss.JoinVertical(lipgloss.Left, parts...)
  28. _, remainingHeightArea := layout.SplitVertical(m.layout.main, layout.Fixed(lipgloss.Height(infoSection)+1))
  29. mcpLspSectionWidth := min(30, (width-1)/2)
  30. lspSection := m.lspInfo(mcpLspSectionWidth, max(1, remainingHeightArea.Dy()), false)
  31. mcpSection := m.mcpInfo(mcpLspSectionWidth, max(1, remainingHeightArea.Dy()), false)
  32. content := lipgloss.JoinHorizontal(lipgloss.Left, lspSection, " ", mcpSection)
  33. return lipgloss.NewStyle().
  34. Width(width).
  35. Height(m.layout.main.Dy() - 1).
  36. PaddingTop(1).
  37. Render(
  38. lipgloss.JoinVertical(lipgloss.Left, infoSection, "", content),
  39. )
  40. }