Files
magpie/internal/library/glance_test.go
T
yetone 69c47c9e57 library, gui: the Library page is drawn at once from a glance, and the agents' own skills and out-of-date copies come in after it (#541)
Even with the memo, the first read after skills change still reads
them through, and before this the page showed only its outline until
the whole read was done (0day404, #541: minutes on Windows).

library.Glance (GET /api/library?glance=1) is the view without
FoundSkills and the skills' Behind, marked partial. The page asks for it
first, draws it, then asks for the whole read. The Skills tab shows "In
your agents · Looking through the agents' skill folders…" (aria-busy)
until the whole read comes. The other tabs aren't drawn again for it. A
whole read that a change answered first is dropped (take() counts the
answers), so it never draws an older library over a newer one.

Read now runs behind and foundSkills after letting go of the library
lock, so a change doesn't wait on them either.

New strings in zh, zh-TW, ja and de. docs/subsystems/library.md
describes the memo and the glance.

Tests:
- TestGlanceLeavesOutTheAgentsSkills (Go).
- library-loading.test.cjs: drawn from the glance, the wait row, then
  the found skill, with reads glance then read. Chromium and WebKit, 980
  and 420px. Red on the old library.js.

Run: go test -tags nogui ./internal/library ./internal/gui; node --test
for library-*.test.cjs, skill*.test.cjs, gui-ja, gui-de and i18n-keys in
both engines; gofmt; vet on darwin, linux and windows.
2026-10-10 19:53:02 +08:00

33 lines
822 B
Go

package library
import (
"path/filepath"
"testing"
)
// A glance at the page leaves out what takes reading the agents' skill
// folders through, and says so; the whole read has it.
func TestGlanceLeavesOutTheAgentsSkills(t *testing.T) {
h := sandbox(t)
for _, d := range []string{".claude/skills/deck", ".codex/skills/deck"} {
skill(t, filepath.Join(h, d), "deck", "Slides")
}
g, err := Glance(nil)
if err != nil {
t.Fatal(err)
}
if !g.Partial || g.FoundSkills == nil || len(g.FoundSkills) != 0 {
t.Fatalf("glance: partial %v, found %+v", g.Partial, g.FoundSkills)
}
if len(g.Agents) == 0 {
t.Fatal("a glance has the agents")
}
v, err := Read(nil)
if err != nil {
t.Fatal(err)
}
if v.Partial || len(v.FoundSkills) != 1 {
t.Fatalf("read: partial %v, found %+v", v.Partial, v.FoundSkills)
}
}