library: a server or skill on no agent no longer blanks the Library — one saved with every agent unticked was listed with its agents as null rather than none, and the page, looking in that list, stopped ("null is not an object (evaluating 'on.includes')"); it's listed with none, and the page takes a missing list for an empty one
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user