library: an agent that is not installed is listed only for what magpie gave it here, not for a synced tick (izhidigua on X)
A library synced from another computer carries each item's agent ticks. held() counted a tick as a reason to list a not-installed agent, so on a computer without Claude, Claude Code or Pi the MCP switches (and any row withGone widens) listed them, while Skills showed only the installed four. Take-it-out (Target.Gone) is for what magpie wrote into the agent on this computer, which Applied records and sync never carries; a tick alone gave it nothing to take out. held() now counts only Applied (skills, MCP, hooks, env, router, router rules). Run, on mote at this tree: TestGoneAgentWithOnlySyncedTicksIsNotListed (new; claude-desktop, claude and pi ticked from a sync, none installed, nothing Applied), red on the old code (all three listed), green now; TestGoneAgentListedToTakeOut still passes (an Applied agent is listed); go test ./internal/library; gofmt -l; go vet of internal/library for linux, windows and host. Not tried: the reporter's two computers; the whole GUI suite (no page file changed). Full suite, mote, at 7bb2f5ac0 (this change onbb9c5ae15), log kept whole: go test -count=1 -timeout 45m ./... : internal/library ok; reds elsewhere, none in code this touches: gateway TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (#7117, red on origin/main), gui TestAppReplacesItsOlderGatewayOnceIdle, TestGatewayPauseRollsBack, TestSetPortServesWhenTheOldOneWasTaken (TempDir cleanup, #6297, #7112; ok alone). At the pushed head6aab35abdthe library package ok again.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -97,3 +97,39 @@ func TestGoneAgentListedToTakeOut(t *testing.T) {
|
||||
t.Errorf("hermes, holding nothing, is still listed: %+v", a)
|
||||
}
|
||||
}
|
||||
|
||||
// izhidigua on X: after the config was synced to a computer without Claude
|
||||
// Code, Claude Desktop and Pi, Skills listed the agents installed there,
|
||||
// and MCP the uninstalled ones as well, ticked on its servers by the other
|
||||
// computer. A tick that came with the library is nothing magpie wrote
|
||||
// here: an agent not installed is listed only for what it holds
|
||||
// (Applied), as for a server or a skill alike.
|
||||
func TestGoneAgentWithOnlySyncedTicksIsNotListed(t *testing.T) {
|
||||
h := sandbox(t)
|
||||
write(t, filepath.Join(h, ".claude/settings.json"), "{}")
|
||||
write(t, filepath.Join(h, ".pi/agent/settings.json"), "{}")
|
||||
for _, n := range []string{"claude", "claude.exe", "pi", "pi.exe"} {
|
||||
os.Remove(filepath.Join(h, "bin", n))
|
||||
}
|
||||
src := filepath.Join(h, "src/skills")
|
||||
skill(t, filepath.Join(src, "pdf"), "pdf", "Read PDFs")
|
||||
all := []string{"claude", "claude-desktop", "pi", "codex"}
|
||||
ok(t)(InstallSkills(src, []string{"pdf"}, all))
|
||||
ok(t)(SaveServer("", Server{Name: "fs", Transport: "stdio", Command: "npx", Args: []string{"-y", "@mcp/fs"}, Agents: all}))
|
||||
v, err := Read(nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, a := range v.Agents {
|
||||
if a.Gone {
|
||||
t.Errorf("%s is listed as gone, holding nothing written here", a.ID)
|
||||
}
|
||||
}
|
||||
if !slices.ContainsFunc(v.Agents, func(a AgentView) bool { return a.ID == "codex" && !a.Gone }) {
|
||||
t.Errorf("codex isn't listed: %+v", v.Agents)
|
||||
}
|
||||
// the ticks stay for the day it is installed
|
||||
if got := v.Servers[0].Agents; !slices.Contains(got, "pi") || !slices.Contains(got, "claude") {
|
||||
t.Errorf("the server's ticks were changed: %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1063,14 +1063,14 @@ func (l *Library) held(have []*Target) []*Target {
|
||||
for _, t := range have {
|
||||
in[t.Agent.ID] = true
|
||||
}
|
||||
// what magpie wrote here, not a tick: one a synced library brought from
|
||||
// another computer for an agent this one never had is nothing to take
|
||||
// out of it, and listed on every row of the servers and skills ticked
|
||||
// for it (izhidigua on X: MCP listed the Claude family and Pi, which
|
||||
// aren't installed, and Skills didn't)
|
||||
has := func(id string) bool {
|
||||
if a := l.Applied[id]; a != nil && (len(a.Skills) > 0 || len(a.MCP) > 0 || len(a.Hooks) > 0 || len(a.Env) > 0 || a.Router || len(a.RouterRules) > 0) {
|
||||
return true
|
||||
}
|
||||
return slices.ContainsFunc(l.Skills, func(s *Skill) bool { return s.gives(id) }) ||
|
||||
slices.ContainsFunc(l.MCP, func(s *Server) bool { return slices.Contains(s.Agents, id) }) ||
|
||||
slices.ContainsFunc(l.Hooks, func(h *Hook) bool { return slices.Contains(h.Agents, id) }) ||
|
||||
slices.ContainsFunc(l.Env, func(e *EnvVar) bool { return slices.Contains(e.Agents, id) })
|
||||
a := l.Applied[id]
|
||||
return a != nil && (len(a.Skills) > 0 || len(a.MCP) > 0 || len(a.Hooks) > 0 || len(a.Env) > 0 || a.Router || len(a.RouterRules) > 0)
|
||||
}
|
||||
var out []*Target
|
||||
for _, a := range append(apps(), agent.All()...) {
|
||||
|
||||
Reference in New Issue
Block a user