1package model
2
3import (
4 "image"
5
6 "charm.land/lipgloss/v2"
7 "github.com/charmbracelet/crush/internal/ui/common"
8 "github.com/charmbracelet/crush/internal/workspace"
9 "github.com/charmbracelet/ultraviolet/layout"
10)
11
12// selectedLargeModel returns the currently selected large language model from
13// the agent coordinator, if one exists.
14func (m *UI) selectedLargeModel() *workspace.AgentModel {
15 if m.com.Workspace.AgentIsReady() {
16 model := m.com.Workspace.AgentModel()
17 return &model
18 }
19 return nil
20}
21
22// landingView renders the landing page view showing the current working
23// directory, model information, and LSP/MCP status in a two-column layout.
24func (m *UI) landingView() string {
25 t := m.com.Styles
26 width := m.layout.main.Dx()
27 cwd := common.PrettyPath(t, m.com.Workspace.WorkingDir(), width)
28
29 parts := []string{
30 cwd,
31 }
32
33 parts = append(parts, "", m.modelInfo(width))
34 infoSection := lipgloss.JoinVertical(lipgloss.Left, parts...)
35
36 var remainingHeightArea image.Rectangle
37 layout.Vertical(
38 layout.Len(lipgloss.Height(infoSection)+1),
39 layout.Fill(1),
40 ).Split(m.layout.main).Assign(new(image.Rectangle), &remainingHeightArea)
41
42 mcpLspSectionWidth := min(30, (width-2)/3)
43
44 lspSection := m.lspInfo(mcpLspSectionWidth, max(1, remainingHeightArea.Dy()), false)
45 mcpSection := m.mcpInfo(mcpLspSectionWidth, max(1, remainingHeightArea.Dy()), false)
46 skillsSection := m.skillsInfo(mcpLspSectionWidth, max(1, remainingHeightArea.Dy()), false)
47
48 content := lipgloss.JoinHorizontal(lipgloss.Left, lspSection, " ", mcpSection, " ", skillsSection)
49
50 return lipgloss.NewStyle().
51 Width(width).
52 Height(m.layout.main.Dy() - 1).
53 PaddingTop(1).
54 Render(
55 lipgloss.JoinVertical(lipgloss.Left, infoSection, "", content),
56 )
57}