Skip to content

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

address review (codex): gate Install on the selected quant's installed state

[._.]/ Adam Eivy471638fdc4f0
diff --git a/client/src/components/settings/LocalLlmTab.jsx b/client/src/components/settings/LocalLlmTab.jsx
index 8e2e5deebf..41c3eb52fb 100644
--- a/client/src/components/settings/LocalLlmTab.jsx
+++ b/client/src/components/settings/LocalLlmTab.jsx
@@ -742,6 +742,9 @@ export function LocalLlmTab() {
const recommendedId = variants.find((v) => v.recommended)?.installId;
const chosenId = selectedVariants[m.key] || (idMatchesVariant ? m.id : recommendedId) || m.id;
const chosenVariant = variants.find((v) => v.installId === chosenId) || null;
+ // Installed state is per-quant (Ollama tracks each separately),
+ // so gate Install on the SELECTED variant, not the result default.
+ const chosenInstalled = chosenVariant ? chosenVariant.installed : m.installed;
const size = chosenVariant?.size || m.size;
const sizeBytes = chosenVariant?.sizeBytes ?? m.sizeBytes;
const fit = chosenVariant?.fit;
@@ -770,7 +773,7 @@ export function LocalLlmTab() {
>
{variants.map((v) => (
<option key={v.installId} value={v.installId}>
- {v.quant}{v.size ? ` · ${v.size}` : ''}{v.recommended ? ' · recommended' : ''}{v.fit === 'too-large' ? ' · exceeds RAM' : ''}
+ {v.quant}{v.size ? ` · ${v.size}` : ''}{v.installed ? ' · installed' : ''}{v.recommended ? ' · recommended' : ''}{v.fit === 'too-large' ? ' · exceeds RAM' : ''}
</option>
))}
</select>
@@ -817,7 +820,7 @@ export function LocalLlmTab() {
</div>
</div>
<div className="flex flex-col items-end gap-1 shrink-0">
- {m.installed ? (
+ {chosenInstalled ? (
<span className="text-xs px-2 py-1 text-port-success">Installed</span>
) : m.installable === false ? (
// Audio models with no PortOS runtime (or a fixed-checkpoint
diff --git a/server/services/huggingFaceCatalog.js b/server/services/huggingFaceCatalog.js
index 4069956aba..0d98e522c8 100644
--- a/server/services/huggingFaceCatalog.js
+++ b/server/services/huggingFaceCatalog.js
@@ -353,15 +353,22 @@ function applyVariant(result, variant) {
result.size = variant.size
}
-function isInstalled(backend, result, installedIds) {
- const installed = new Set(installedIds.map((id) => normalizeInstalledForBackend(backend, id)))
- if (installed.has(normalizeInstalledForBackend(backend, result.id))) return true
- if (backend === 'lmstudio') {
- return installed.has(normalizeInstalledForBackend(backend, result.repository))
- }
+// Is a specific backend install id present in the installed set? Ollama tracks
+// each `hf.co/<repo>:<quant>` as its own model, so this is quant-precise there;
+// LM Studio detection is repo-level (the normalizer drops `@quant`), so every
+// quant of an installed repo reads installed — the best granularity LM Studio's
+// list exposes.
+function installIdInstalled(backend, installId, repository, installedSet) {
+ if (installedSet.has(normalizeInstalledForBackend(backend, installId))) return true
+ if (backend === 'lmstudio') return installedSet.has(normalizeInstalledForBackend(backend, repository))
return false
}
+function isInstalled(backend, result, installedIds) {
+ const installedSet = new Set(installedIds.map((id) => normalizeInstalledForBackend(backend, id)))
+ return installIdInstalled(backend, result.id, result.repository, installedSet)
+}
+
function toResult(model, backend, requestedCategory, installedIds, installedAudioRepos = new Set()) {
const repoId = repoIdOf(model)
if (!repoId || !repoId.includes('/')) return null
@@ -493,7 +500,8 @@ function contextLengthOf(model) {
// `?blobs=true` record (the search listing carries neither). Both are fetched
// from the same cached repo record, so a result missing either triggers one
// (deduped) per-repo fetch.
-async function enrichWithSizes(results, { backend, usableBytes } = {}) {
+async function enrichWithSizes(results, { backend, usableBytes, installedIds = [] } = {}) {
+ const installedSet = new Set(installedIds.map((id) => normalizeInstalledForBackend(backend, id)))
await Promise.allSettled(results.map(async (result) => {
const isAudio = result.category === 'audio'
const needsSize = !Number.isFinite(result.sizeBytes)
@@ -507,6 +515,9 @@ async function enrichWithSizes(results, { backend, usableBytes } = {}) {
if (!isAudio) {
const variants = buildVariants(model, backend, usableBytes)
if (variants.length > 0) {
+ // Per-quant installed state — Ollama tracks each quant separately, so the
+ // card must gate Install on the *selected* variant, not one repo-wide flag.
+ for (const v of variants) v.installed = installIdInstalled(backend, v.installId, result.repository, installedSet)
// Always anchor the result on one of its own variants so the install id
// and the client's controlled <select> agree. Prefer the RAM-aware pick;
// otherwise the QUANT_PRIORITY default toResult chose (matched by quant);
@@ -521,6 +532,9 @@ async function enrichWithSizes(results, { backend, usableBytes } = {}) {
// Flag whichever variant the result now points at as recommended so the
// UI can mark it (covers both the RAM-aware and QUANT_PRIORITY default).
for (const v of variants) v.recommended = v.installId === result.id
+ // Realign the result-level installed flag with the (possibly RAM-switched)
+ // default variant — toResult computed it against the pre-switch id.
+ result.installed = chosen.installed
result.variants = variants
}
}
@@ -608,5 +622,5 @@ export async function searchHuggingFaceModels({ backend, query = '', category =
.sort((a, b) => b.score - a.score || b.downloads - a.downloads)
.slice(0, limit)
- return enrichWithSizes(results, { backend, usableBytes })
+ return enrichWithSizes(results, { backend, usableBytes, installedIds })
}
diff --git a/server/services/huggingFaceCatalog.test.js b/server/services/huggingFaceCatalog.test.js
index 9da101f7d8..fbd9a031b0 100644
--- a/server/services/huggingFaceCatalog.test.js
+++ b/server/services/huggingFaceCatalog.test.js
@@ -301,6 +301,29 @@ describe('huggingFaceCatalog', () => {
expect(result.installed).toBe(true)
})
+ it('marks per-quant installed state for Ollama variants and aligns the result flag with the default', async () => {
+ const repo = 'empero-ai/Qwythos-9B-Installed-GGUF'
+ fetch
+ .mockResolvedValueOnce(listing(repo, ['Qwythos-9B-Q4_K_M.gguf', 'Qwythos-9B-Q8_0.gguf', 'Qwythos-9B-BF16.gguf']))
+ .mockResolvedValueOnce(blobs(repo, {
+ 'Qwythos-9B-Q4_K_M.gguf': 5_500_000_000,
+ 'Qwythos-9B-Q8_0.gguf': 9_500_000_000,
+ 'Qwythos-9B-BF16.gguf': 18_000_000_000,
+ }))
+
+ // Only the Q4_K_M quant is installed on Ollama.
+ const [result] = await searchHuggingFaceModels({
+ backend: 'ollama', query: 'qwythos', systemMemoryBytes: 128 * 1024 ** 3, installedIds: [`hf.co/${repo}:Q4_K_M`]
+ })
+
+ const byQuant = Object.fromEntries(result.variants.map((v) => [v.quant, v.installed]))
+ expect(byQuant).toEqual({ BF16: false, Q8_0: false, Q4_K_M: true })
+ // 128 GB box defaults to BF16, which is NOT installed — so the card must
+ // offer Install, not claim "Installed" off the repo's Q4 presence.
+ expect(result.id).toBe(`hf.co/${repo}:BF16`)
+ expect(result.installed).toBe(false)
+ })
+
it('anchors the LM Studio default on a variant even when the repo omits file sizes', async () => {
const repo = 'bartowski/NoSize-GGUF'
fetch