mission control for agent skills
Go agent-skillsagent-toolsai-agentsai-toolsai-workflowclaude-codeclicoding-agentscommand-line-tooldeveloper-toolsgoopencodeproductivity-toolsskill-discoveryskill-managementskillsterminal-appterminal-uituiworkflow-automation
fix: clean up registry preview fetch
Alvin Unreal53ba8b08247e
diff --git a/internal/tui/update.go b/internal/tui/update.goindex a104ec1..cd9b123 100644--- a/internal/tui/update.go+++ b/internal/tui/update.go@@ -2024,22 +2024,30 @@ func (m appModel) fetchRegistryPreviewCmd(key string, source string) tea.Cmd {if err != nil {continue}- if resp.StatusCode == http.StatusOK {- bodyBytes, err := io.ReadAll(io.LimitReader(resp.Body, 256*1024))- resp.Body.Close()- if err == nil && len(bodyBytes) > 0 {- return registryPreviewMsg{- key: key,- content: compat.SanitizePreviewContent(string(bodyBytes)),- }- }+ content, ok := readRegistryPreviewResponse(resp)+ if ok {+ return registryPreviewMsg{key: key, content: content}}- resp.Body.Close()}return registryPreviewMsg{key: key, content: ""}}}+func readRegistryPreviewResponse(resp *http.Response) (string, bool) {+ if resp.Body == nil {+ return "", false+ }+ defer resp.Body.Close()+ if resp.StatusCode != http.StatusOK {+ return "", false+ }+ bodyBytes, err := io.ReadAll(io.LimitReader(resp.Body, 256*1024))+ if err != nil || len(bodyBytes) == 0 {+ return "", false+ }+ return compat.SanitizePreviewContent(string(bodyBytes)), true+}+func (m appModel) currentRegistryPreviewCmd() tea.Cmd {if len(m.registryResults) == 0 || m.registrySelected < 0 || m.registrySelected >= len(m.registryResults) {return nildiff --git a/internal/tui/view.go b/internal/tui/view.goindex 3c0a1c1..d220332 100644--- a/internal/tui/view.go+++ b/internal/tui/view.go@@ -19,6 +19,7 @@ import ("github.com/charmbracelet/lipgloss")+var htmlBlockTagRE = regexp.MustCompile(`(?i)</?(?:br|p|div|li|h1|h2|h3|h4)\b[^>]*>`)var htmlTagRE = regexp.MustCompile(`<[^>]+>`)func (m appModel) View() string {@@ -780,9 +781,7 @@ 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 = htmlBlockTagRE.ReplaceAllString(markdown, "\n")markdown = htmlTagRE.ReplaceAllString(markdown, "")markdown = html.UnescapeString(markdown)lines := strings.Split(markdown, "\n")