Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): QUANT_PRIORITY fallback + preserve curated size when HF omits sizes
[._.]/ Adam Eivyf669284f16ff
diff --git a/server/services/huggingFaceCatalog.js b/server/services/huggingFaceCatalog.jsindex ce3e98725c..c15e84b257 100644--- a/server/services/huggingFaceCatalog.js+++ b/server/services/huggingFaceCatalog.js@@ -388,13 +388,31 @@ function pickVariantForBudget(variants, usableBytes) {return sized.find((v) => estimatedResidentBytes(v.sizeBytes) <= usableBytes) || sized[sized.length - 1]}+// The QUANT_PRIORITY-preferred variant — the sensible default when no RAM budget+// applies and no curator-chosen quant matches (e.g. a curated LM Studio entry+// whose blobs come back without sizes). Picks a balanced Q4-ish build rather than+// the size-desc `variants[0]`, which (sizeless ⇒ stable sort ⇒ HF file order)+// could wrongly default a small machine to a BF16/Q8 build.+function preferredQuantVariant(variants) {+ const rank = (q) => {+ const i = QUANT_PRIORITY.findIndex((p) => p.toLowerCase() === String(q).toLowerCase())+ return i === -1 ? QUANT_PRIORITY.length : i+ }+ return [...variants].sort((a, b) => rank(a.quant) - rank(b.quant))[0]+}+// Promote a chosen variant onto the result's primary install fields so the-// default card reflects it (id/quant/size) without the client having to re-pick.+// default card reflects it (id/quant) without the client having to re-pick. Only+// overwrite the size when the variant actually has one — otherwise keep the+// result's existing size (a curated entry's hard-coded estimate, or toResult's+// label) instead of replacing it with a bare quant string.function applyVariant(result, variant) {result.id = variant.installIdresult.quant = variant.quant- result.sizeBytes = variant.sizeBytes- result.size = variant.size+ if (Number.isFinite(variant.sizeBytes)) {+ result.sizeBytes = variant.sizeBytes+ result.size = variant.size+ }}// Parse an LM Studio identifier into its repo base + quant for quant-aware@@ -667,7 +685,7 @@ function applyGgufVariants(result, model, { backend, usableBytes, installedIds }// memory were unknown.const chosen = (usableBytes != null ? pickVariantForBudget(variants, usableBytes) : null)|| variants.find((v) => v.quant && v.quant === result.quant)- || variants[0]+ || preferredQuantVariant(variants)applyVariant(result, chosen)for (const v of variants) v.recommended = v.installId === result.idresult.installed = chosen.installeddiff --git a/server/services/huggingFaceCatalog.test.js b/server/services/huggingFaceCatalog.test.jsindex f11f0f23d3..fc2ebfb836 100644--- a/server/services/huggingFaceCatalog.test.js+++ b/server/services/huggingFaceCatalog.test.js@@ -592,6 +592,23 @@ describe('huggingFaceCatalog', () => {expect(catalog[0].id).toBe(`hf.co/${repo}:Q8_0`)})+ it('falls back to the QUANT_PRIORITY quant (not HF file order) and keeps the curated size when HF omits sizes', async () => {+ const repo = 'lmstudio-community/NoSize-Curated-GGUF'+ // BF16 listed first; with no sizes the size-desc sort is stable (file order),+ // so the fallback must NOT just take variants[0] or a small box defaults to BF16.+ fetch.mockResolvedValueOnce(response({ id: repo, siblings: [+ { rfilename: 'M-BF16.gguf' }, { rfilename: 'M-Q4_K_M.gguf' }, { rfilename: 'M-Q8_0.gguf' },+ ] }))+ const catalog = [{ id: repo, key: 'nosize', name: 'NoSize', category: 'chat', size: '2.0 GB' }]+ // 8 GB box: budget pick can't fire (no sizes) — must land on the balanced+ // QUANT_PRIORITY default, not the largest by file order.+ await enrichCatalogWithVariants(catalog, { backend: 'lmstudio', systemMemoryBytes: 8 * 1024 ** 3, installedIds: [] })++ expect(catalog[0].id).toBe(`${repo}@Q4_K_M`)+ // The curated size estimate is preserved (not clobbered with a bare quant label).+ expect(catalog[0].size).toBe('2.0 GB')+ })+it('leaves a bare Ollama registry name untouched (no HF repo → no picker)', async () => {fetch.mockResolvedValue(response([]))const catalog = [{ id: 'llama3.2', key: 'llama3.2', name: 'Llama 3.2 3B', category: 'chat', size: '2.0 GB' }]