Open a repository beneath its row in the mirror's listing

Clicking a repository in the explorer shows its card and files in a row
beneath it, fetched from /admin/mirror/repo, and a second click closes
it; the list stays where it was. The link still leads to the
repository's own page without script or with a modifier key.

A repository's files now take one line each, and an importance matrix
published beside the quantisations is marked as not a model rather than
offered for fetching.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-09-28 22:11:38 +02:00
1 parent 3fea39feb9
commit ff86e52126
4 files changed
+211 -69

No files matched your search

+66 -34
View File
@@ -123,6 +123,9 @@ type adminMirrorData struct {
Explore *explorer
// Back is the listing an open repository was reached from.
Back template.URL
// Inline is a repository rendered beneath its row in the listing, without
// the page around it.
Inline bool
// Card is the open repository's model card, rendered.
Card template.HTML
// RepoURL is the open repository on the registry's own site.
@@ -179,6 +182,23 @@ func (p *AccountPages) RegisterAdminMirror(mux *http.ServeMux, d MirrorDeps) {
p.renderMirror(w, r, m, "", "")
}))
// One repository as a fragment, for the row beneath it in the listing.
mux.HandleFunc("GET /admin/mirror/repo", p.adminOnly(
func(w http.ResponseWriter, r *http.Request, _ store.User) {
repo := strings.TrimSpace(r.URL.Query().Get("repo"))
if p.registry == nil || repo == "" {
http.NotFound(w, r)
return
}
d := adminMirrorData{CSRF: csrfFor(r), Inline: true, HasRegistry: true}
p.openRepo(r, &d, repo)
if d.RegistryErr != "" {
http.Error(w, "The registry: "+d.RegistryErr, http.StatusBadGateway)
return
}
render(w, "mirror_repo", d)
}))
mux.HandleFunc("POST /admin/mirror/fetch", p.mirrorAction(m,
func(ctx context.Context, admin store.User, r *http.Request) (string, error) {
// One form posts one source or fifteen. A sharded model is one
@@ -464,46 +484,52 @@ func (p *AccountPages) explore(r *http.Request, d *adminMirrorData) {
if repo := strings.TrimSpace(r.URL.Query().Get("repo")); repo != "" {
d.Back = exploreState(r.URL.Query()).href(d.Query, "", "")
got, err := p.registry.Repo(r.Context(), repo)
if err != nil {
d.RegistryErr = err.Error()
return
}
d.Repo = &got
d.RepoURL = strings.TrimSuffix(got.DownloadURL("", ""), "/resolve/"+revOrMain(got.Revision)+"/")
d.Card = renderCard(got.Card, d.RepoURL+"/blob/"+revOrMain(got.Revision)+"/")
var weights []hf.File
for _, f := range got.Files {
if !f.IsWeights() {
// Thirty files of which four are worth gigabytes. The rest are
// a README and a tokenizer, and listing them buries the ones
// somebody came for.
continue
}
weights = append(weights, f)
}
for _, set := range hf.Group(weights) {
rs := repoSet{
FileSet: set,
Model: defaultModelName(got.ID),
// The revision, not the date: two fetches of the same commit
// land in the same place, and a repository re-uploaded under
// the same branch lands somewhere else.
Version: got.ShortRevision(),
}
rs.Verdict = p.verdictFor(got.Architecture, set.Name)
for _, f := range set.Files {
rs.Sources = append(rs.Sources,
repoSource{URL: got.DownloadURL("", f.Path), Path: f.Path})
}
d.RepoSets = append(d.RepoSets, rs)
}
p.openRepo(r, d, repo)
return
}
p.exploreList(r, d)
}
// openRepo reads one repository: its card, and its weights grouped into what
// can be fetched.
func (p *AccountPages) openRepo(r *http.Request, d *adminMirrorData, repo string) {
got, err := p.registry.Repo(r.Context(), repo)
if err != nil {
d.RegistryErr = err.Error()
return
}
d.Repo = &got
d.RepoURL = strings.TrimSuffix(got.DownloadURL("", ""), "/resolve/"+revOrMain(got.Revision)+"/")
d.Card = renderCard(got.Card, d.RepoURL+"/blob/"+revOrMain(got.Revision)+"/")
var weights []hf.File
for _, f := range got.Files {
if !f.IsWeights() {
// Thirty files of which four are worth gigabytes. The rest are
// a README and a tokenizer, and listing them buries the ones
// somebody came for.
continue
}
weights = append(weights, f)
}
for _, set := range hf.Group(weights) {
rs := repoSet{
FileSet: set,
Model: defaultModelName(got.ID),
// The revision, not the date: two fetches of the same commit
// land in the same place, and a repository re-uploaded under
// the same branch lands somewhere else.
Version: got.ShortRevision(),
}
rs.Verdict = p.verdictFor(got.Architecture, set.Name)
for _, f := range set.Files {
rs.Sources = append(rs.Sources,
repoSource{URL: got.DownloadURL("", f.Path), Path: f.Path})
}
d.RepoSets = append(d.RepoSets, rs)
}
}
// defaultModelName is the catalog name a repository suggests.
//
// The last element, lowercased, with the quantisation marker dropped: the owner
@@ -523,6 +549,12 @@ func (p *AccountPages) verdictFor(arch, name string) gguf.Verdict {
if strings.Contains(strings.ToLower(name), "mmproj") {
return gguf.LlamaCpp(p.llamaVersion, "clip")
}
// Published beside the quantisations they were made with, and a GGUF
// file like them, so the repository's architecture would pass it.
if strings.Contains(strings.ToLower(name), "imatrix") {
return gguf.Verdict{Checked: true,
Reason: "it is an importance matrix for quantising, not a model"}
}
if arch == "" || !gguf.IsGGUF(name) {
return gguf.Verdict{Servable: true}
}