From 14b353ed6c32bf2272a05a88f7ea468df8a3a79e Mon Sep 17 00:00:00 2001 From: yetone Date: Fri, 25 Sep 2026 15:43:01 +0800 Subject: [PATCH] =?UTF-8?q?library:=20a=20server=20or=20skill=20on=20no=20?= =?UTF-8?q?agent=20no=20longer=20blanks=20the=20Library=20=E2=80=94=20one?= =?UTF-8?q?=20saved=20with=20every=20agent=20unticked=20was=20listed=20wit?= =?UTF-8?q?h=20its=20agents=20as=20null=20rather=20than=20none,=20and=20th?= =?UTF-8?q?e=20page,=20looking=20in=20that=20list,=20stopped=20("null=20is?= =?UTF-8?q?=20not=20an=20object=20(evaluating=20'on.includes')");=20it's?= =?UTF-8?q?=20listed=20with=20none,=20and=20the=20page=20takes=20a=20missi?= =?UTF-8?q?ng=20list=20for=20an=20empty=20one?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/gui/assets/library.js | 1 + internal/library/library_test.go | 15 +++++++++++++++ internal/library/sync.go | 8 +++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/internal/gui/assets/library.js b/internal/gui/assets/library.js index a6f1350d7..33a21aa3b 100644 --- a/internal/gui/assets/library.js +++ b/internal/gui/assets/library.js @@ -82,6 +82,7 @@ // Agent chips for a server or a skill: each agent that could have it, lit // when it does. A chip whose agent couldn't be given it says why. function agentChips(all, on, onChange, opts = {}) { + on ||= []; const box = el("div", "lib-agents"); for (const a of all) { const has = on.includes(a.id); diff --git a/internal/library/library_test.go b/internal/library/library_test.go index edaec9c0a..df067d4bd 100644 --- a/internal/library/library_test.go +++ b/internal/library/library_test.go @@ -500,3 +500,18 @@ func TestGitHubSource(t *testing.T) { } } } + +// A server or skill on no agent is listed with none, not null: the page +// looks in the list, and a null blanked the whole Library. +func TestReadNoAgents(t *testing.T) { + sandbox(t) + ok(t)(SaveServer("", Server{Name: "lone", Transport: "stdio", Command: "lone-mcp"})) + v, err := Read(nil) + if err != nil { + t.Fatal(err) + } + b, _ := json.Marshal(v.Servers) + if !strings.Contains(string(b), `"agents":[]`) { + t.Errorf("servers: %s", b) + } +} diff --git a/internal/library/sync.go b/internal/library/sync.go index 4d1fc5848..51e6d6296 100644 --- a/internal/library/sync.go +++ b/internal/library/sync.go @@ -196,6 +196,12 @@ func Read(problems []Problem) (*View, error) { return m } for _, s := range l.MCP { + // one on no agent yet has none, not null, for the page to look in + if s.Agents == nil { + c := *s + c.Agents = []string{} + s = &c + } sv := ServerView{Server: s, Icon: serverIcon(l, s), Problems: of("mcp:" + s.Name)} for _, t := range targets { if t.MCP != nil && slices.Contains(s.Agents, t.Agent.ID) { @@ -210,7 +216,7 @@ func Read(problems []Problem) (*View, error) { v.Servers = append(v.Servers, sv) } for _, s := range l.Skills { - sv := SkillView{Name: s.Name, Agents: s.Agents, Icon: skillIcon(s), Problems: of("skill:" + s.Name)} + sv := SkillView{Name: s.Name, Agents: append([]string{}, s.Agents...), Icon: skillIcon(s), Problems: of("skill:" + s.Name)} if s.Source != nil { sv.Source, sv.Kind = s.Source.String(), s.Source.Kind }