@@ -1,8 +1,18 @@
1package chat
1package chat
3−import tea "github.com/charmbracelet/bubbletea"
3+import (
6+ tea "github.com/charmbracelet/bubbletea"
7+ "github.com/charmbracelet/lipgloss"
8+ "github.com/kujtimiihoxha/termai/internal/config"
9+ "github.com/kujtimiihoxha/termai/internal/tui/styles"
10+ "github.com/kujtimiihoxha/termai/internal/version"
5−type sidebarCmp struct{}
13+type sidebarCmp struct {
7func (m *sidebarCmp) Init() tea.Cmd {
17func (m *sidebarCmp) Init() tea.Cmd {
8 return nil
18 return nil
@@ -13,7 +23,174 @@ func (m *sidebarCmp) Update(tea.Msg) (tea.Model, tea.Cmd) {
15func (m *sidebarCmp) View() string {
25func (m *sidebarCmp) View() string {
16− return "Sidebar"
26+ return styles.BaseStyle.Width(m.width).Render(
27+ lipgloss.JoinVertical(
40+func (m *sidebarCmp) session() string {
41+ sessionKey := styles.BaseStyle.Foreground(styles.PrimaryColor).Render("Session")
42+ sessionValue := styles.BaseStyle.
43+ Foreground(styles.Forground).
44+ Width(m.width - lipgloss.Width(sessionKey)).
45+ Render(": New Session")
46+ return lipgloss.JoinHorizontal(
53+func (m *sidebarCmp) modifiedFile(filePath string, additions, removals int) string {
55+ if additions > 0 && removals > 0 {
56+ stats = styles.BaseStyle.Foreground(styles.ForgroundDim).Render(fmt.Sprintf("%d additions and %d removals", additions, removals))
57+ } else if additions > 0 {
58+ stats = styles.BaseStyle.Foreground(styles.ForgroundDim).Render(fmt.Sprintf("%d additions", additions))
59+ } else if removals > 0 {
60+ stats = styles.BaseStyle.Foreground(styles.ForgroundDim).Render(fmt.Sprintf("%d removals", removals))
62+ filePathStr := styles.BaseStyle.Foreground(styles.Forground).Render(filePath)
64+ return styles.BaseStyle.
67+ lipgloss.JoinHorizontal(
76+func (m *sidebarCmp) lspsConfigured() string {
77+ lsps := styles.BaseStyle.Width(m.width).Foreground(styles.PrimaryColor).Render("LSP Configuration:")
78+ lspsConfigured := []struct {
82+ {"golsp", "path/to/lsp1"},
83+ {"vtsls", "path/to/lsp2"},
86+ var lspViews []string
87+ for _, lsp := range lspsConfigured {
88+ lspName := styles.BaseStyle.Foreground(styles.Forground).Render(
89+ fmt.Sprintf("• %s", lsp.name),
91+ lspPath := styles.BaseStyle.Foreground(styles.ForgroundDim).Render(
92+ fmt.Sprintf("(%s)", lsp.path),
94+ lspViews = append(lspViews,
98+ lipgloss.JoinHorizontal(
108+ return styles.BaseStyle.
111+ lipgloss.JoinVertical(
114+ lipgloss.JoinVertical(
122+func (m *sidebarCmp) modifiedFiles() string {
123+ modifiedFiles := styles.BaseStyle.Width(m.width).Foreground(styles.PrimaryColor).Render("Modified Files:")
129+ {"file1.txt", 10, 5},
130+ {"file2.txt", 20, 0},
131+ {"file3.txt", 0, 15},
133+ var fileViews []string
134+ for _, file := range files {
135+ fileViews = append(fileViews, m.modifiedFile(file.path, file.additions, file.removals))
138+ return styles.BaseStyle.
141+ lipgloss.JoinVertical(
144+ lipgloss.JoinVertical(
152+func (m *sidebarCmp) logo() string {
153+ logo := fmt.Sprintf("%s %s", styles.OpenCodeIcon, "OpenCode")
155+ version := styles.BaseStyle.Foreground(styles.ForgroundDim).Render(version.Version)
157+ return styles.BaseStyle.
161+ lipgloss.JoinHorizontal(
170+func (m *sidebarCmp) header() string {
171+ header := lipgloss.JoinVertical(
179+func (m *sidebarCmp) cwd() string {
180+ cwd := fmt.Sprintf("cwd: %s", config.WorkingDirectory())
181+ return styles.BaseStyle.
182+ Foreground(styles.ForgroundDim).
187+func (m *sidebarCmp) SetSize(width, height int) {
192+func (m *sidebarCmp) GetSize() (int, int) {
193+ return m.width, m.height
19func NewSidebarCmp() tea.Model {
196func NewSidebarCmp() tea.Model {