mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-20 20:34:19 +00:00
fix(tui): unify layout and visual consistency across TUI panels
- Add colorSkillPath() for progressive luminance on nested skill paths (cyan group → gray sub-dirs → white skill name) in list and audit TUIs - Move filter bar below panels in audit and log TUIs for consistent layout - Align log TUI left panel width (25%, max 45) with audit TUI proportions - Show elapsed time on pull/push completion messages - Use relative paths in audit results for group hierarchy display - Render license field in green, adjust content overlay spacing
This commit is contained in:
@@ -423,6 +423,10 @@ func auditInstalled(sourcePath, mode, projectRoot, threshold string, opts auditO
|
||||
}
|
||||
sr.Result.Threshold = threshold
|
||||
sr.Result.IsBlocked = sr.Result.HasSeverityAtOrAbove(threshold)
|
||||
// Use relative path so TUI shows group hierarchy (e.g. "frontend/vue/skill").
|
||||
if rel, err := filepath.Rel(sourcePath, sr.Result.ScanTarget); err == nil && rel != sr.Result.SkillName {
|
||||
sr.Result.SkillName = rel
|
||||
}
|
||||
results = append(results, sr.Result)
|
||||
elapsed = append(elapsed, sr.Elapsed)
|
||||
}
|
||||
@@ -561,6 +565,9 @@ func auditFiltered(sourcePath string, names, groups []string, mode, projectRoot,
|
||||
}
|
||||
sr.Result.Threshold = threshold
|
||||
sr.Result.IsBlocked = sr.Result.HasSeverityAtOrAbove(threshold)
|
||||
if rel, err := filepath.Rel(sourcePath, sr.Result.ScanTarget); err == nil && rel != sr.Result.SkillName {
|
||||
sr.Result.SkillName = rel
|
||||
}
|
||||
results = append(results, sr.Result)
|
||||
elapsed = append(elapsed, sr.Elapsed)
|
||||
}
|
||||
@@ -618,6 +625,9 @@ func auditSkillByName(sourcePath, name, mode, projectRoot, threshold string, jso
|
||||
elapsed := time.Since(start)
|
||||
result.Threshold = threshold
|
||||
result.IsBlocked = result.HasSeverityAtOrAbove(threshold)
|
||||
if rel, err := filepath.Rel(sourcePath, result.ScanTarget); err == nil && rel != result.SkillName {
|
||||
result.SkillName = rel
|
||||
}
|
||||
|
||||
summary = summarizeAuditResults(1, []*audit.Result{result}, threshold)
|
||||
summary.Scope = "single"
|
||||
|
||||
@@ -40,14 +40,14 @@ type auditItem struct {
|
||||
}
|
||||
|
||||
func (i auditItem) Title() string {
|
||||
name := i.result.SkillName
|
||||
name := colorSkillPath(i.result.SkillName)
|
||||
if len(i.result.Findings) == 0 {
|
||||
return tc.Green.Render("✓") + " " + ac.ItemName.Render(name)
|
||||
return tc.Green.Render("✓") + " " + name
|
||||
}
|
||||
if i.result.IsBlocked {
|
||||
return tc.Red.Render("✗") + " " + ac.ItemName.Render(name)
|
||||
return tc.Red.Render("✗") + " " + name
|
||||
}
|
||||
return tc.Yellow.Render("!") + " " + ac.ItemName.Render(name)
|
||||
return tc.Yellow.Render("!") + " " + name
|
||||
}
|
||||
|
||||
func (i auditItem) Description() string { return "" }
|
||||
@@ -271,9 +271,6 @@ func (m auditTUIModel) View() string {
|
||||
// ── Horizontal split layout ──
|
||||
var b strings.Builder
|
||||
|
||||
// Filter bar (full width, top)
|
||||
b.WriteString(m.renderFilterBar())
|
||||
|
||||
// Panel height (matches WindowSizeMsg overhead)
|
||||
panelHeight := m.termHeight - 6
|
||||
if panelHeight < 6 {
|
||||
@@ -309,7 +306,10 @@ func (m auditTUIModel) View() string {
|
||||
|
||||
body := lipgloss.JoinHorizontal(lipgloss.Top, leftPanel, borderPanel, rightPanel)
|
||||
b.WriteString(body)
|
||||
b.WriteString("\n\n")
|
||||
b.WriteString("\n")
|
||||
|
||||
// Filter bar (below panels, matching list TUI layout)
|
||||
b.WriteString(m.renderFilterBar())
|
||||
|
||||
// Summary footer
|
||||
b.WriteString(m.renderSummaryFooter())
|
||||
|
||||
@@ -568,8 +568,8 @@ func diffFingerprint(items []copyDiffEntry) string {
|
||||
|
||||
// actionCategory groups diff items by the user action needed.
|
||||
type actionCategory struct {
|
||||
kind string // "sync", "force", "collect", "warn"
|
||||
label string // e.g. "sync will add"
|
||||
kind string // "sync", "force", "collect", "warn"
|
||||
label string // e.g. "sync will add"
|
||||
names []string
|
||||
expand bool // true = list skill names
|
||||
}
|
||||
|
||||
@@ -480,7 +480,7 @@ func (m listTUIModel) renderDetailPanel(e skillEntry) string {
|
||||
|
||||
// License
|
||||
if d.License != "" {
|
||||
row("License:", d.License)
|
||||
row("License:", tc.Green.Render(d.License))
|
||||
}
|
||||
|
||||
// Disk path
|
||||
|
||||
@@ -380,7 +380,7 @@ func renderContentOverlay(m listTUIModel) string {
|
||||
if fileName != "" {
|
||||
b.WriteString(dimStyle.Render(fmt.Sprintf(" ─ %s", fileName)))
|
||||
}
|
||||
b.WriteString("\n")
|
||||
b.WriteString("\n\n")
|
||||
|
||||
sw := sidebarWidth(m.termWidth)
|
||||
// panelW is the lipgloss Width (includes PaddingLeft); textW is usable text width
|
||||
@@ -416,7 +416,7 @@ func renderContentOverlay(m listTUIModel) string {
|
||||
|
||||
body := lipgloss.JoinHorizontal(lipgloss.Top, leftPanel, borderPanel, rightPanel)
|
||||
b.WriteString(body)
|
||||
b.WriteString("\n")
|
||||
b.WriteString("\n\n")
|
||||
|
||||
help := "j/k browse l/Enter expand h collapse Ctrl+d/u scroll g/G top/bottom Esc back q quit"
|
||||
if scrollInfo != "" {
|
||||
@@ -579,9 +579,9 @@ func (m listTUIModel) handleContentMouse(msg tea.MouseMsg) (tea.Model, tea.Cmd)
|
||||
// ─── Tree Navigation Helpers ─────────────────────────────────────────
|
||||
|
||||
// contentViewHeight returns the usable height for the content area.
|
||||
// Reserves extra lines as breathing room above the help bar.
|
||||
// Overhead: leading(1) + title(1) + gap(1) + body-newline(1) + blank(1) + help(1) + trailing(1) = 7
|
||||
func (m *listTUIModel) contentViewHeight() int {
|
||||
h := m.termHeight - 5
|
||||
h := m.termHeight - 7
|
||||
if h < 5 {
|
||||
h = 5
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
)
|
||||
|
||||
// skillItem wraps skillEntry to implement bubbles/list.Item interface.
|
||||
@@ -24,13 +26,14 @@ func (i skillItem) FilterValue() string {
|
||||
}
|
||||
|
||||
// Title returns the skill name with a type badge for the list delegate.
|
||||
// Inline colors: name → bright white, badge: tracked → green, local → gray.
|
||||
// Color hierarchy: top-level group → cyan, sub-dirs → dim, separator → faint, skill name → bright white.
|
||||
func (i skillItem) Title() string {
|
||||
nameStr := i.entry.Name
|
||||
if i.entry.RelPath != "" && i.entry.RelPath != i.entry.Name {
|
||||
nameStr = i.entry.RelPath
|
||||
}
|
||||
title := tc.Emphasis.Render(nameStr)
|
||||
|
||||
title := colorSkillPath(nameStr)
|
||||
|
||||
if i.entry.RepoName != "" {
|
||||
title += " " + tc.Green.Render("[tracked]")
|
||||
@@ -52,6 +55,40 @@ func (i skillItem) Description() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// colorSkillPath renders a skill path with progressive luminance:
|
||||
// top-level group → cyan, sub-dirs → dark gray..light gray, "/" → faint, skill name → bright white.
|
||||
func colorSkillPath(path string) string {
|
||||
segments := strings.Split(path, "/")
|
||||
if len(segments) <= 1 {
|
||||
return tc.Emphasis.Render(path)
|
||||
}
|
||||
|
||||
sep := tc.Faint.Render("/")
|
||||
dirs := segments[:len(segments)-1]
|
||||
name := segments[len(segments)-1]
|
||||
|
||||
const (
|
||||
grayStart = 241 // darkest sub-dir
|
||||
grayEnd = 249 // lightest sub-dir (approaching white)
|
||||
)
|
||||
|
||||
var parts []string
|
||||
for idx, dir := range dirs {
|
||||
if idx == 0 {
|
||||
parts = append(parts, tc.Cyan.Render(dir))
|
||||
} else {
|
||||
gray := grayStart
|
||||
if subCount := len(dirs) - 1; subCount > 1 {
|
||||
gray = grayStart + (idx-1)*(grayEnd-grayStart)/(subCount-1)
|
||||
}
|
||||
style := lipgloss.NewStyle().Foreground(lipgloss.Color(fmt.Sprintf("%d", gray)))
|
||||
parts = append(parts, style.Render(dir))
|
||||
}
|
||||
}
|
||||
|
||||
return strings.Join(parts, sep) + sep + tc.Emphasis.Render(name)
|
||||
}
|
||||
|
||||
// toSkillItems converts a slice of skillEntry to skillItem slice.
|
||||
func toSkillItems(entries []skillEntry) []skillItem {
|
||||
items := make([]skillItem, len(entries))
|
||||
|
||||
@@ -542,9 +542,6 @@ func (m logTUIModel) View() string {
|
||||
}
|
||||
|
||||
// ── Horizontal split layout ──
|
||||
// Filter bar (full width, top)
|
||||
b.WriteString(m.renderLogFilterBar())
|
||||
|
||||
// Panel height: terminal minus filter(1) + stats footer(1) + help(1) + newlines(2)
|
||||
panelHeight := m.termHeight - 5
|
||||
if panelHeight < 6 {
|
||||
@@ -582,6 +579,9 @@ func (m logTUIModel) View() string {
|
||||
b.WriteString(body)
|
||||
b.WriteString("\n")
|
||||
|
||||
// Filter bar (below panels, matching list TUI layout)
|
||||
b.WriteString(m.renderLogFilterBar())
|
||||
|
||||
// Stats footer
|
||||
b.WriteString(m.renderStatsFooter())
|
||||
|
||||
@@ -651,14 +651,14 @@ func (m logTUIModel) renderLogFilterBar() string {
|
||||
}
|
||||
|
||||
// logListWidth returns the left panel width for horizontal layout.
|
||||
// 40% of terminal, clamped to [30, 60].
|
||||
// 25% of terminal, clamped to [30, 45] — aligned with audit TUI proportions.
|
||||
func logListWidth(termWidth int) int {
|
||||
w := termWidth * 2 / 5
|
||||
w := termWidth / 4
|
||||
if w < 30 {
|
||||
w = 30
|
||||
}
|
||||
if w > 60 {
|
||||
w = 60
|
||||
if w > 45 {
|
||||
w = 45
|
||||
}
|
||||
return w
|
||||
}
|
||||
|
||||
@@ -7,13 +7,13 @@ func TestLogListWidth(t *testing.T) {
|
||||
termWidth int
|
||||
want int
|
||||
}{
|
||||
{50, 30}, // 50*2/5=20 → clamped to min 30
|
||||
{70, 30}, // 70*2/5=28 → clamped to min 30
|
||||
{80, 32}, // 80*2/5=32
|
||||
{100, 40}, // 100*2/5=40
|
||||
{120, 48}, // 120*2/5=48
|
||||
{160, 60}, // 160*2/5=64 → clamped to max 60
|
||||
{200, 60}, // 200*2/5=80 → clamped to max 60
|
||||
{50, 30}, // 50/4=12 → clamped to min 30
|
||||
{70, 30}, // 70/4=17 → clamped to min 30
|
||||
{80, 30}, // 80/4=20 → clamped to min 30
|
||||
{100, 30}, // 100/4=25 → clamped to min 30
|
||||
{120, 30}, // 120/4=30
|
||||
{160, 40}, // 160/4=40
|
||||
{200, 45}, // 200/4=50 → clamped to max 45
|
||||
}
|
||||
for _, tt := range tests {
|
||||
got := logListWidth(tt.termWidth)
|
||||
@@ -28,11 +28,11 @@ func TestLogDetailPanelWidth(t *testing.T) {
|
||||
termWidth int
|
||||
wantMin int // detail width must be >= 30
|
||||
}{
|
||||
{50, 30}, // 50-30-3=17 → clamped to min 30
|
||||
{70, 37}, // 70-30-3=37
|
||||
{100, 57}, // 100-40-3=57
|
||||
{120, 69}, // 120-48-3=69
|
||||
{160, 97}, // 160-60-3=97
|
||||
{50, 30}, // 50-30-3=17 → clamped to min 30
|
||||
{70, 37}, // 70-30-3=37
|
||||
{100, 67}, // 100-30-3=67
|
||||
{120, 87}, // 120-30-3=87
|
||||
{160, 117}, // 160-40-3=117
|
||||
}
|
||||
for _, tt := range tests {
|
||||
got := logDetailPanelWidth(tt.termWidth)
|
||||
|
||||
@@ -58,6 +58,7 @@ func cmdPull(args []string) error {
|
||||
func pullFromRemote(cfg *config.Config, dryRun, force bool) error {
|
||||
ui.Header("Pulling from remote")
|
||||
|
||||
pullStart := time.Now()
|
||||
spinner := ui.StartSpinner("Checking repository...")
|
||||
|
||||
// Check if source is a git repo
|
||||
@@ -129,7 +130,8 @@ func pullFromRemote(cfg *config.Config, dryRun, force bool) error {
|
||||
}
|
||||
}
|
||||
|
||||
spinner.Success("Pull complete")
|
||||
spinner.Stop()
|
||||
ui.SuccessMsg("Pull complete (%.1fs)", time.Since(pullStart).Seconds())
|
||||
|
||||
// Sync to all targets
|
||||
fmt.Println()
|
||||
|
||||
@@ -262,7 +262,8 @@ func cmdPush(args []string) error {
|
||||
return nil // Error already displayed
|
||||
}
|
||||
|
||||
spinner.Success("Push complete")
|
||||
spinner.Stop()
|
||||
ui.SuccessMsg("Push complete (%.1fs)", time.Since(start).Seconds())
|
||||
|
||||
e := oplog.NewEntry("push", "ok", time.Since(start))
|
||||
e.Args = map[string]any{"message": opts.message}
|
||||
|
||||
Reference in New Issue
Block a user