Files
MuyueWorkspace/internal/tui/config_tab.go
Augustin 44691225e7
All checks were successful
CI / build (push) Successful in 2m41s
refactor: modularize TUI, improve error handling, add CI caching and tests
Split monolithic app.go into focused modules (dashboard, chat, workflow,
config, agents, terminal, commands, handlers). Add proper error handling
for installer commands, proxy pipes, and MCP config parsing. Fix daemon
channel buffer, cap orchestrator history, compile think regex once, and
set HTTP timeouts on preview server. Improve CI with Go module caching,
dependency download step, and test stage with race detection.

😘 Generated with Crush

Assisted-by: GLM-5-Turbo via Crush <crush@charm.land>
2026-04-20 19:13:48 +02:00

106 lines
3.1 KiB
Go

package tui
import (
"fmt"
"regexp"
"strings"
"github.com/charmbracelet/lipgloss"
)
var versionRegex = regexp.MustCompile(`\d+\.\d+\.\d+`)
func extractVersion(s string) string {
return versionRegex.FindString(s)
}
func (m Model) renderConfig() string {
var b strings.Builder
b.WriteString(sectionStyle.Render("Profile"))
b.WriteString("\n")
if m.config != nil {
fields := []struct {
label string
value string
}{
{"Name", m.config.Profile.Name},
{"Pseudo", m.config.Profile.Pseudo},
{"Email", m.config.Profile.Email},
{"Editor", m.config.Profile.Preferences.Editor},
{"Shell", m.config.Profile.Preferences.Shell},
{"Theme", m.config.Profile.Preferences.Theme},
{"Default AI", m.config.Profile.Preferences.DefaultAI},
}
for _, f := range fields {
labelStyle := lipgloss.NewStyle().Foreground(mutedColor).Width(14)
valueStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#E0E0E0"))
b.WriteString(fmt.Sprintf(" %s %s\n", labelStyle.Render(f.label+":"), valueStyle.Render(f.value)))
}
if len(m.config.Profile.Languages) > 0 {
labelStyle := lipgloss.NewStyle().Foreground(mutedColor).Width(14)
valueStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#E0E0E0"))
b.WriteString(fmt.Sprintf(" %s %s\n", labelStyle.Render("Languages:"), valueStyle.Render(strings.Join(m.config.Profile.Languages, ", "))))
}
}
b.WriteString("\n")
b.WriteString(sectionStyle.Render("AI Providers"))
b.WriteString("\n")
if m.config != nil {
for _, p := range m.config.AI.Providers {
active := ""
if p.Active {
active = itemOKStyle.Render(" active")
}
keyStatus := itemMissingStyle.Render("no key")
if p.APIKey != "" {
keyStatus = itemOKStyle.Render("configured")
}
nameStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#E0E0E0")).Bold(true)
b.WriteString(fmt.Sprintf(" %s model=%s key=%s%s\n",
nameStyle.Render(p.Name), p.Model, keyStatus, active))
}
}
b.WriteString("\n")
b.WriteString(sectionStyle.Render("BMAD Method"))
b.WriteString("\n")
if m.config != nil {
installed := itemMissingStyle.Render("no")
if m.config.BMAD.Installed {
installed = itemOKStyle.Render("yes")
}
b.WriteString(fmt.Sprintf(" Installed: %s\n", installed))
b.WriteString(fmt.Sprintf(" Global: %v\n", m.config.BMAD.Global))
}
b.WriteString("\n")
b.WriteString(sectionStyle.Render("Terminal"))
b.WriteString("\n")
if m.config != nil {
b.WriteString(fmt.Sprintf(" Custom Prompt: %v\n", m.config.Terminal.CustomPrompt))
b.WriteString(fmt.Sprintf(" Prompt Theme: %s\n", m.config.Terminal.PromptTheme))
}
b.WriteString("\n")
b.WriteString(sectionStyle.Render(fmt.Sprintf("Skills (%d)", len(m.skillList))))
b.WriteString("\n")
if len(m.skillList) > 0 {
for _, s := range m.skillList {
target := s.Target
if target == "" {
target = "both"
}
b.WriteString(fmt.Sprintf(" %-20s %s %s\n",
lipgloss.NewStyle().Foreground(lipgloss.Color("#E0E0E0")).Render(s.Name),
lipgloss.NewStyle().Foreground(aiColor).Render("["+target+"]"),
s.Description))
}
} else {
b.WriteString(" No skills. Run `muyue skills init` to install built-ins.\n")
}
return b.String()
}