6119
My
mysis / files
mysis / internal / tui / styles.go
4.0 KB
1// Package tui provides the terminal user interface for Mysis. 2package tui 3 4import ( 5 "github.com/charmbracelet/lipgloss" 6 "github.com/xonecas/mysis/internal/styles" 7) 8 9// TUI-specific styles building on base styles 10var ( 11 // Log/Conversation styles 12 LogStyle = lipgloss.NewStyle(). 13 Background(styles.ColorBg) 14 15 // Role-based message styles 16 UserStyle = lipgloss.NewStyle(). 17 Foreground(styles.ColorUser). 18 Background(styles.ColorBg). 19 Bold(true) 20 21 AssistantStyle = lipgloss.NewStyle(). 22 Foreground(styles.ColorAssistant). 23 Background(styles.ColorBg) 24 25 SystemStyle = lipgloss.NewStyle(). 26 Foreground(styles.ColorSystem). 27 Background(styles.ColorBg). 28 Italic(true) 29 30 ToolStyle = lipgloss.NewStyle(). 31 Foreground(styles.ColorTool). 32 Background(styles.ColorBg) 33 34 ToolSuccessStyle = lipgloss.NewStyle(). 35 Foreground(styles.ColorSuccess). 36 Background(styles.ColorBg) 37 38 ToolErrorStyle = lipgloss.NewStyle(). 39 Foreground(styles.ColorError). 40 Background(styles.ColorBg) 41 42 // Input styles 43 InputBorderStyle = lipgloss.NewStyle(). 44 Border(lipgloss.NormalBorder(), true, false, false, false). // Top border only 45 BorderForeground(styles.ColorBorder). 46 Background(styles.ColorBg). 47 Padding(0, 1) 48 49 InputPromptStyle = lipgloss.NewStyle(). 50 Foreground(styles.ColorBrand). 51 Background(styles.ColorBg). 52 Bold(true) 53 54 InputTextStyle = lipgloss.NewStyle(). 55 Foreground(styles.ColorTeal). 56 Background(styles.ColorBg) 57 58 InputPlaceholderStyle = lipgloss.NewStyle(). 59 Foreground(styles.ColorMuted). 60 Background(styles.ColorBg). 61 Italic(true) 62 63 // Status bar styles 64 StatusBarStyle = lipgloss.NewStyle(). 65 Border(lipgloss.NormalBorder(), true, false, false, false). // Top border only 66 BorderForeground(styles.ColorBorder). 67 Background(styles.ColorBg) 68 69 // Status icon styles (3-char width each: [ <icon> ]) 70 IconAutoplayStyle = lipgloss.NewStyle(). 71 Foreground(styles.ColorTeal). 72 Background(styles.ColorBg). 73 Width(3). 74 Align(lipgloss.Center) 75 76 IconInfoStyle = lipgloss.NewStyle(). 77 Foreground(styles.ColorSuccess). 78 Background(styles.ColorBg). 79 Width(3). 80 Align(lipgloss.Center) 81 82 IconWarningStyle = lipgloss.NewStyle(). 83 Foreground(styles.ColorTool). 84 Background(styles.ColorBg). 85 Width(3). 86 Align(lipgloss.Center) 87 88 IconErrorStyle = lipgloss.NewStyle(). 89 Foreground(styles.ColorError). 90 Background(styles.ColorBg). 91 Width(3). 92 Align(lipgloss.Center) 93 94 // Connection status icons (network activity) 95 IconLLMStyle = lipgloss.NewStyle(). 96 Foreground(styles.ColorTeal). // Cyan/teal for LLM thinking 97 Background(styles.ColorBg). 98 Width(3). 99 Align(lipgloss.Center) 100 101 IconMCPStyle = lipgloss.NewStyle(). 102 Foreground(styles.ColorBrand). // Purple for MCP server communication 103 Background(styles.ColorBg). 104 Width(3). 105 Align(lipgloss.Center) 106 107 // Status text styles 108 StatusTextStyle = lipgloss.NewStyle(). 109 Foreground(styles.ColorMuted). 110 Background(styles.ColorBg) 111 112 StatusTextErrorStyle = lipgloss.NewStyle(). 113 Foreground(styles.ColorError). 114 Background(styles.ColorBg) 115 116 StatusTextOKStyle = lipgloss.NewStyle(). 117 Foreground(styles.ColorSuccess). 118 Background(styles.ColorBg) 119 120 // Scrollbar style 121 ScrollbarStyle = lipgloss.NewStyle(). 122 Foreground(styles.ColorBorder). 123 Background(styles.ColorBg) 124 125 // Dimmed text 126 DimmedStyle = lipgloss.NewStyle(). 127 Foreground(styles.ColorMuted). 128 Background(styles.ColorBg) 129) 130 131// RoleStyle returns the appropriate style for a message role. 132func RoleStyle(role string) lipgloss.Style { 133 switch role { 134 case "user": 135 return UserStyle 136 case "assistant": 137 return AssistantStyle 138 case "system": 139 return SystemStyle 140 case "tool": 141 return ToolStyle 142 default: 143 return SystemStyle 144 } 145} 146 147// RoleLabel returns a styled label for message roles. 148func RoleLabel(role string) string { 149 switch role { 150 case "user": 151 return UserStyle.Render("You") 152 case "assistant": 153 return AssistantStyle.Render("Agent") 154 case "system": 155 return SystemStyle.Render("System") 156 case "tool": 157 return ToolStyle.Render("Tool") 158 default: 159 return DimmedStyle.Render("Unknown") 160 } 161}