mission control for agent skills
Go agent-skillsagent-toolsai-agentsai-toolsai-workflowclaude-codeclicoding-agentscommand-line-tooldeveloper-toolsgoopencodeproductivity-toolsskill-discoveryskill-managementskillsterminal-appterminal-uituiworkflow-automation
fix: tighten registry preview layout
Alvin Unrealc0510fcb35c8
diff --git a/internal/tui/update.go b/internal/tui/update.goindex e995843..e44d607 100644--- a/internal/tui/update.go+++ b/internal/tui/update.go@@ -230,6 +230,9 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {m.syncViewport()return m, nilcase "up", "k":+ if m.registryLoading {+ return m, nil+ }if len(m.registryResults) > 0 {m.registrySelected--if m.registrySelected < 0 {@@ -240,6 +243,9 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {}return m, nilcase "down", "j":+ if m.registryLoading {+ return m, nil+ }if len(m.registryResults) > 0 {m.registrySelected++if m.registrySelected >= len(m.registryResults) {@@ -250,6 +256,9 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {}return m, nilcase " ":+ if m.registryLoading {+ return m, nil+ }if len(m.registryResults) > 0 {s := m.registryResults[m.registrySelected]status, _ := m.checkRegistrySkillStatus(s)@@ -268,6 +277,9 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {}return m, nilcase "enter":+ if m.registryLoading {+ return m, nil+ }// List is focused: start project install confirmationselectedCount := len(m.registrySelectedKeys)if selectedCount > 0 {@@ -320,6 +332,9 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {}return m, nilcase "g":+ if m.registryLoading {+ return m, nil+ }// list focused: start global install confirmationselectedCount := len(m.registrySelectedKeys)if selectedCount > 0 {@@ -1982,12 +1997,12 @@ func (m appModel) fetchRegistryPreviewCmd(key string, source string) tea.Cmd {continue}if resp.StatusCode == http.StatusOK {- bodyBytes, err := io.ReadAll(resp.Body)+ bodyBytes, err := io.ReadAll(io.LimitReader(resp.Body, 256*1024))resp.Body.Close()if err == nil && len(bodyBytes) > 0 {return registryPreviewMsg{key: key,- content: string(bodyBytes),+ content: compat.SanitizePreviewContent(string(bodyBytes)),}}}diff --git a/internal/tui/update_test.go b/internal/tui/update_test.goindex 37f783b..c91781e 100644--- a/internal/tui/update_test.go+++ b/internal/tui/update_test.go@@ -676,10 +676,18 @@ func TestTUIRegistryListRenderingWithContextAndFocus(t *testing.T) {if !strings.Contains(viewStr1, "My Display Name") || !strings.Contains(viewStr1, "my-org/my-repo") {t.Fatal("expected view to contain display name and source context")}- // Prefix for highlighted-only row starts with ">"- if !strings.Contains(viewStr1, ">My Display Name") {- t.Errorf("expected prefix '>' for highlighted row, got view:\n%s", viewStr1)+ // Prefix reserves one marker cell for selection: focused/unselected is "> Name".+ if !strings.Contains(viewStr1, "> My Display Name") {+ t.Errorf("expected prefix '> ' for highlighted unselected row, got view:\n%s", viewStr1)}+ m.registrySelectedKeys = map[string]registry.Skill{+ "https://github.com/my-org/my-repo/skills/my-folder\x00my-display-name": m.registryResults[0],+ }+ viewSelected := m.View()+ if !strings.Contains(viewSelected, ">*My Display Name") {+ t.Errorf("expected selected marker to replace reserved blank as '>*', got view:\n%s", viewSelected)+ }+ m.registrySelectedKeys = nil// Verify parsed Repository/Folder and matched Description in Right Paneif !strings.Contains(viewStr1, "Source: my-org/my-repo") {t.Errorf("expected parsed Source to be displayed, got view:\n%s", viewStr1)@@ -687,7 +695,7 @@ func TestTUIRegistryListRenderingWithContextAndFocus(t *testing.T) {if !strings.Contains(viewStr1, "Path: skills/my-folder") {t.Errorf("expected parsed Path to be displayed, got view:\n%s", viewStr1)}- if !strings.Contains(viewStr1, "This is a great skill description!") {+ if !strings.Contains(viewStr1, "This is a great skill description") {t.Errorf("expected matched Description to be displayed, got view:\n%s", viewStr1)}@@ -746,6 +754,7 @@ func TestTUIRegistryModeKeySeparation(t *testing.T) {// Test 2: List focusedm.registryFocusList = true+ m.registryLoading = false// Pressing 'j' should navigate list downmodelTmp, _ = m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'j'}})@@ -786,13 +795,15 @@ func TestTUIRegistryPreviewAndNoInstallCommands(t *testing.T) {}m.registrySelected = 0- // 1. Without preview fetched, it should show the derived preview context+ key := "https://github.com/my-org/my-repo/skills/test-folder" + "\x00" + "test-skill"++ // 1. Before async preview fetch returns, show an explicit loading state.viewStr1 := m.View()if strings.Contains(viewStr1, "No preview available") {- t.Error("expected derived preview context, but found 'No preview available'")+ t.Error("must not show 'No preview available'")}- if !strings.Contains(viewStr1, "A lazyskills skill named 'Test Skill'") {- t.Error("expected derived preview description to be shown")+ if !strings.Contains(viewStr1, "Loading preview") {+ t.Error("expected loading preview indicator before async fetch result")}// 2. Install Commands section must not be present in the right pane@@ -800,11 +811,20 @@ func TestTUIRegistryPreviewAndNoInstallCommands(t *testing.T) {t.Error("Install section must be completely removed from the right pane")}- // 3. With HTTP raw preview fetched and cached- key := "https://github.com/my-org/my-repo/skills/test-folder" + "\x00" + "test-skill"- m.registryPreviews[key] = "This is a fetched SKILL.md markdown preview!"+ // 3. Empty fetch result should fall back to useful metadata context.+ m.registryPreviews[key] = ""viewStr2 := m.View()- if !strings.Contains(viewStr2, "This is a fetched SKILL.md markdown preview!") {+ if !strings.Contains(viewStr2, "A lazyskills skill named") {+ t.Error("expected derived preview context after empty fetch result")+ }++ // 4. Fetched preview is rendered as markdown-ish text, with HTML tags stripped.+ m.registryPreviews[key] = "# Heading\n<p>This is a fetched <strong>SKILL.md</strong> markdown preview!</p>"+ viewStr3 := m.View()+ if !strings.Contains(viewStr3, "This is a fetched") {t.Error("expected the fetched HTTP preview to be displayed")}+ if strings.Contains(viewStr3, "<p>") || strings.Contains(viewStr3, "<strong>") {+ t.Error("expected HTML tags to be stripped from fetched preview")+ }}diff --git a/internal/tui/view.go b/internal/tui/view.goindex 0f04de4..f37a600 100644--- a/internal/tui/view.go+++ b/internal/tui/view.go@@ -2,6 +2,8 @@ package tuiimport ("fmt"+ "html"+ "regexp""strings""sync""time"@@ -17,6 +19,8 @@ import ("github.com/charmbracelet/lipgloss")+var htmlTagRE = regexp.MustCompile(`<[^>]+>`)+func (m appModel) View() string {viewStart := time.Now()defer func() {@@ -772,6 +776,35 @@ func renderMarkdownPreview(markdown string, width int) []string {return lines}+func sanitizeRegistryPreviewContent(markdown string) string {+ markdown = compat.SanitizePreviewContent(markdown)+ markdown = strings.ReplaceAll(markdown, "\r\n", "\n")+ markdown = strings.ReplaceAll(markdown, "\r", "\n")+ for _, tag := range []string{"br", "p", "div", "li", "h1", "h2", "h3", "h4"} {+ markdown = regexp.MustCompile(`(?i)</?`+tag+`\b[^>]*>`).ReplaceAllString(markdown, "\n")+ }+ markdown = htmlTagRE.ReplaceAllString(markdown, "")+ markdown = html.UnescapeString(markdown)+ lines := strings.Split(markdown, "\n")+ for i, line := range lines {+ lines[i] = strings.TrimRight(line, " \t")+ }+ return strings.TrimSpace(strings.Join(lines, "\n"))+}++func appendRegistryPreviewLines(lines []string, title string, markdown string, width int, maxLines int) []string {+ markdown = sanitizeRegistryPreviewContent(markdown)+ if markdown == "" {+ return lines+ }+ rendered := renderMarkdownPreview(markdown, width)+ if len(rendered) > maxLines {+ rendered = append(rendered[:maxLines], dimStyle.Render("…"))+ }+ lines = append(lines, "", sectionHeaderStyle.Render(title))+ return append(lines, rendered...)+}+func stripMarkdownFrontmatter(markdown string) string {trimmed := strings.TrimLeft(markdown, "\ufeff\r\n\t ")if !strings.HasPrefix(trimmed, "---\n") && !strings.HasPrefix(trimmed, "---\r\n") {@@ -1808,20 +1841,27 @@ func (m appModel) registryModalOverlay(layout appLayout) string {leftContentLines = append(leftContentLines, " No skills found in registry.")} else {// Show results+ rowIndent := " "+ rowWidth := leftWidth - lipgloss.Width(rowIndent)+ if rowWidth < 10 {+ rowWidth = leftWidth+ rowIndent = ""+ }for idx, s := range m.registryResults {isSel := falseif m.registrySelectedKeys != nil {_, isSel = m.registrySelectedKeys[s.Source+"\x00"+s.Slug]}- prefix := " "- if idx == m.registrySelected && isSel {- prefix = ">*"- } else if idx == m.registrySelected {- prefix = ">"- } else if isSel {- prefix = " *"+ focusMarker := " "+ if idx == m.registrySelected {+ focusMarker = ">"+ }+ selectMarker := " "+ if isSel {+ selectMarker = "*"}+ prefix := focusMarker + selectMarkerprefixWidth := lipgloss.Width(prefix)status, _ := m.checkRegistrySkillStatus(s)@@ -1844,7 +1884,7 @@ func (m appModel) registryModalOverlay(layout appLayout) string {rightPart = installsStyled}rightPartWidth := lipgloss.Width(rightPart)- availNameWidth := leftWidth - prefixWidth - rightPartWidth - 1 // 1 space padding+ availNameWidth := rowWidth - prefixWidth - rightPartWidth - 1 // 1 space paddingif availNameWidth < 5 {availNameWidth = 5}@@ -1884,8 +1924,8 @@ func (m appModel) registryModalOverlay(layout appLayout) string {// Pad the linelinePlain := prefix + truncatedPlain- paddingLen := leftWidth - lipgloss.Width(linePlain) - rightPartWidth- line := prefix + styledText+ paddingLen := rowWidth - lipgloss.Width(linePlain) - rightPartWidth+ line := rowIndent + prefix + styledTextif paddingLen > 0 {line += strings.Repeat(" ", paddingLen)}@@ -1894,9 +1934,9 @@ func (m appModel) registryModalOverlay(layout appLayout) string {if idx == m.registrySelected {var lineStyled stringif m.registryFocusList {- lineStyled = selectedStyle.Render(padRight(prefix+truncatedPlain, leftWidth-rightPartWidth-1) + " " + rightPart)+ lineStyled = selectedStyle.Render(rowIndent + padRight(prefix+truncatedPlain, rowWidth-rightPartWidth-1) + " " + rightPart)} else {- lineStyled = inactiveSelectedStyle.Render(padRight(prefix+truncatedPlain, leftWidth-rightPartWidth-1) + " " + rightPart)+ lineStyled = inactiveSelectedStyle.Render(rowIndent + padRight(prefix+truncatedPlain, rowWidth-rightPartWidth-1) + " " + rightPart)}leftContentLines = append(leftContentLines, lineStyled)} else {@@ -1979,33 +2019,35 @@ func (m appModel) registryModalOverlay(layout appLayout) string {if matchedPreview == "" && fetchedPreview != "" {matchedPreview = fetchedPreview}+ previewLoading := false+ if matchedDesc == "" && matchedPreview == "" {+ if m.registryPreviews == nil {+ previewLoading = true+ } else if _, fetched := m.registryPreviews[key]; !fetched {+ previewLoading = true+ }+ }if matchedDesc != "" {- rightContentLines = append(rightContentLines,- "",- sectionHeaderStyle.Render("Description:"),- wrapText(matchedDesc, rightWidth),- )+ rightContentLines = appendRegistryPreviewLines(rightContentLines, "Description:", matchedDesc, rightWidth, 5)}if matchedPreview != "" {+ rightContentLines = appendRegistryPreviewLines(rightContentLines, "Preview:", matchedPreview, rightWidth, 12)+ }++ if previewLoading {rightContentLines = append(rightContentLines,"",sectionHeaderStyle.Render("Preview:"),- wrapText(matchedPreview, rightWidth),+ runningStyle.Render("Loading preview..."),)- }-- if matchedDesc == "" && matchedPreview == "" {+ } else if matchedDesc == "" && matchedPreview == "" {// Surface metadata as description context so we don't just say No preview availablederivedDesc := fmt.Sprintf("A lazyskills skill named '%s' (slug: '%s'), available from source '%s'.", s.DisplayName, s.Slug, repo)if folder != "" {derivedDesc += fmt.Sprintf(" Located under subfolder path '%s'.", folder)}- rightContentLines = append(rightContentLines,- "",- sectionHeaderStyle.Render("Preview Context:"),- wrapText(derivedDesc, rightWidth),- )+ rightContentLines = appendRegistryPreviewLines(rightContentLines, "Preview Context:", derivedDesc, rightWidth, 6)}} else {rightContentLines = append(rightContentLines, dimStyle.Render("Select a registry search result to view details."))