Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(memory+models): reachable JSON memory import + clearer Ollama pull errors

purplee1d08f2e1824
diff --git a/src/components/models/DiscoverModels.tsx b/src/components/models/DiscoverModels.tsx
index 2f8331b2..7066a7cb 100644
--- a/src/components/models/DiscoverModels.tsx
+++ b/src/components/models/DiscoverModels.tsx
@@ -21,7 +21,7 @@ import { useModelStore } from '../../stores/modelStore'
import { useWorkflowStore } from '../../stores/workflowStore'
import { getProviderIdFromModel } from '../../api/providers'
import { matchesLmStudioInstalled, type InstalledModelLike } from '../../lib/lmstudio-match'
-import { hfUrlToOllamaRef, hfUrlToLmStudioSubdir, parseHfUrl, extractGgufQuant } from '../../lib/hf-to-provider'
+import { hfUrlToOllamaRef, hfUrlToLmStudioSubdir, parseHfUrl, extractGgufQuant, isShardedOrIncompatibleGguf } from '../../lib/hf-to-provider'
import { GlassCard } from '../ui/GlassCard'
import { GlowButton } from '../ui/GlowButton'
import { ProgressBar } from '../ui/ProgressBar'
@@ -505,8 +505,17 @@ export function DiscoverModels({ category, search = '', searchSubmitToken = 0 }:
// a cryptic HTTP 400; tell them what to do.
const formatPullError = (modelName: string, err: unknown): string => {
const msg = err instanceof Error ? err.message : String(err)
- if (/shard|5245|split/i.test(msg)) {
- return `${modelName} is split into multiple GGUF parts — split GGUF isn't supported yet (Ollama rejects it, ollama/ollama#5245). Pick a single-file quant of this model instead.`
+ // Sharded / "not compatible with llama.cpp" repos genuinely can't go via
+ // Ollama (ollama/ollama#5245) — point at LM Studio.
+ if (isShardedOrIncompatibleGguf(msg)) {
+ return `${modelName} can't be pulled into Ollama — its HuggingFace repo is split into parts or isn't a flat single-file GGUF. Download it via LM Studio instead (it loads sharded GGUF fine), or pick a single-file quant.`
+ }
+ // A bare HTTP 400 from `ollama pull hf.co/...` is usually an OUT-OF-DATE
+ // Ollama (HF-pull support is version-gated) — the same ref succeeds on
+ // current Ollama. Tell the user instead of surfacing "ollama: 400"
+ // (Aldrich Ironhart, Discord 2026-06-07: "Gemma 4 26B MoE → ollama: 400").
+ if (/\b400\b/.test(msg)) {
+ return `Ollama rejected the download of ${modelName} (HTTP 400). This is almost always an out-of-date Ollama — update it from ollama.com/download and retry. Otherwise download via LM Studio, or pick a single-file quant.`
}
return `Download failed: ${msg}`
}
diff --git a/src/components/settings/MemorySettings.tsx b/src/components/settings/MemorySettings.tsx
index 37cf105c..091be069 100644
--- a/src/components/settings/MemorySettings.tsx
+++ b/src/components/settings/MemorySettings.tsx
@@ -27,8 +27,10 @@ export function MemorySettings() {
// Feature FF: reveal outdated (stale/superseded) entries, read-only.
const [showOutdated, setShowOutdated] = useState(false)
const [reembedState, setReembedState] = useState<'idle' | 'running' | 'done'>('idle')
+ // Import feedback (konata-session 2026-06-07): report how many memories were
+ // imported — or why none were. The import used to fail silently.
+ const [importMsg, setImportMsg] = useState<string | null>(null)
const fileInputRef = useRef<HTMLInputElement>(null)
- const jsonInputRef = useRef<HTMLInputElement>(null)
// ── New memory form state ───────────────────────────────────
const [newTitle, setNewTitle] = useState('')
@@ -92,28 +94,30 @@ export function MemorySettings() {
URL.revokeObjectURL(url)
}
- const handleImportMd = (e: React.ChangeEvent<HTMLInputElement>) => {
+ // One Import button for BOTH .md and .json. The old UI wired the single
+ // button only to the markdown picker, so the JSON path (jsonInputRef /
+ // handleImportJSON) was unreachable — a user who imported a .json export saw
+ // nothing happen (konata-session 2026-06-07). Route by extension, fall back
+ // to sniffing the content, and always report the result.
+ const handleImport = (e: React.ChangeEvent<HTMLInputElement>) => {
const file = e.target.files?.[0]
+ e.target.value = '' // allow re-picking the same file
if (!file) return
const reader = new FileReader()
reader.onload = (ev) => {
const content = ev.target?.result as string
- if (content) importFromMarkdown(content)
+ if (!content) { setImportMsg('Could not read that file.'); return }
+ const trimmed = content.trimStart()
+ const isJson = /\.json$/i.test(file.name) || trimmed.startsWith('{') || trimmed.startsWith('[')
+ const count = isJson ? importFromJSON(content) : importFromMarkdown(content)
+ setImportMsg(
+ count > 0
+ ? `Imported ${count} ${count === 1 ? 'memory' : 'memories'}.`
+ : 'No memories found in that file. Use a Locally Uncensored .md or .json export (JSON needs an "entries" or "memories" array).',
+ )
}
+ reader.onerror = () => setImportMsg('Could not read that file.')
reader.readAsText(file)
- e.target.value = ''
- }
-
- const handleImportJSON = (e: React.ChangeEvent<HTMLInputElement>) => {
- const file = e.target.files?.[0]
- if (!file) return
- const reader = new FileReader()
- reader.onload = (ev) => {
- const content = ev.target?.result as string
- if (content) importFromJSON(content)
- }
- reader.readAsText(file)
- e.target.value = ''
}
const handleClear = () => {
@@ -388,9 +392,12 @@ export function MemorySettings() {
>
<Trash2 size={10} /> {confirmClear ? 'Sure?' : 'Clear'}
</GlowButton>
- <input ref={fileInputRef} type="file" accept=".md,.txt" onChange={handleImportMd} className="hidden" />
- <input ref={jsonInputRef} type="file" accept=".json" onChange={handleImportJSON} className="hidden" />
+ <input ref={fileInputRef} type="file" accept=".md,.txt,.json" onChange={handleImport} className="hidden" />
</div>
+
+ {importMsg && (
+ <p className="text-[0.6rem] text-gray-500 dark:text-gray-400 px-0.5">{importMsg}</p>
+ )}
</div>
)
}
diff --git a/src/lib/__tests__/hf-to-provider.test.ts b/src/lib/__tests__/hf-to-provider.test.ts
new file mode 100644
index 00000000..3f1bd0a4
--- /dev/null
+++ b/src/lib/__tests__/hf-to-provider.test.ts
@@ -0,0 +1,62 @@
+/**
+ * hf-to-provider — GGUF quant extraction, Ollama HF refs, and the
+ * sharded/incompatible-pull classifier.
+ *
+ * Regression focus (Aldrich Ironhart, Discord 2026-06-07): unsloth "UD"
+ * dynamic quants (Q4_K_XL / Q4_K_XS) were not recognised, so the Ollama HF
+ * reference dropped the quant tag entirely.
+ */
+import { describe, it, expect } from 'vitest'
+import { extractGgufQuant, hfUrlToOllamaRef, isShardedOrIncompatibleGguf } from '../hf-to-provider'
+
+describe('extractGgufQuant', () => {
+ it('reads classic K-quants', () => {
+ expect(extractGgufQuant('model-Q4_K_M.gguf')).toBe('Q4_K_M')
+ expect(extractGgufQuant('model.Q5_K_S.gguf')).toBe('Q5_K_S')
+ expect(extractGgufQuant('model_Q3_K_L.gguf')).toBe('Q3_K_L')
+ })
+ it('reads unsloth UD dynamic quants (the konata/Aldrich regression)', () => {
+ expect(extractGgufQuant('gemma-4-26B-A4B-it-UD-Q4_K_XL.gguf')).toBe('Q4_K_XL')
+ expect(extractGgufQuant('model-UD-Q4_K_XS.gguf')).toBe('Q4_K_XS')
+ })
+ it('reads bare K-quants, Q*_0/1, IQ, and float types', () => {
+ expect(extractGgufQuant('model-Q6_K.gguf')).toBe('Q6_K')
+ expect(extractGgufQuant('model-Q8_0.gguf')).toBe('Q8_0')
+ expect(extractGgufQuant('model-IQ4_XS.gguf')).toBe('IQ4_XS')
+ expect(extractGgufQuant('model-F16.gguf')).toBe('F16')
+ })
+ it('returns undefined when no quant token is present', () => {
+ expect(extractGgufQuant('model.gguf')).toBeUndefined()
+ expect(extractGgufQuant('not-a-gguf.txt')).toBeUndefined()
+ })
+})
+
+describe('hfUrlToOllamaRef', () => {
+ it('builds hf.co/<user>/<repo>:<quant> from a HF blob URL + filename', () => {
+ const url = 'https://huggingface.co/unsloth/gemma-4-26B-A4B-it-GGUF/resolve/main/gemma-4-26B-A4B-it-UD-Q4_K_XL.gguf'
+ // With the XL fix the quant tag is now preserved instead of dropped.
+ expect(hfUrlToOllamaRef(url, 'gemma-4-26B-A4B-it-UD-Q4_K_XL.gguf'))
+ .toBe('hf.co/unsloth/gemma-4-26B-A4B-it-GGUF:Q4_K_XL')
+ })
+ it('falls back to a tag-less ref when the filename has no recognised quant', () => {
+ const url = 'https://huggingface.co/acme/Some-Model-GGUF/resolve/main/model.gguf'
+ expect(hfUrlToOllamaRef(url, 'model.gguf')).toBe('hf.co/acme/Some-Model-GGUF')
+ })
+ it('returns null for a non-HuggingFace URL', () => {
+ expect(hfUrlToOllamaRef('https://example.com/model.gguf', 'model.gguf')).toBeNull()
+ })
+})
+
+describe('isShardedOrIncompatibleGguf', () => {
+ it('flags sharded / split / not-compatible pull errors', () => {
+ expect(isShardedOrIncompatibleGguf('Error: repository is not GGUF or is not compatible with llama.cpp')).toBe(true)
+ expect(isShardedOrIncompatibleGguf('model is split into multiple parts')).toBe(true)
+ expect(isShardedOrIncompatibleGguf('sharded gguf not supported (ollama/ollama#5245)')).toBe(true)
+ })
+ it('does NOT flag a bare HTTP 400 (handled separately as out-of-date Ollama)', () => {
+ expect(isShardedOrIncompatibleGguf('ollama: 400')).toBe(false)
+ })
+ it('does NOT flag unrelated errors', () => {
+ expect(isShardedOrIncompatibleGguf('connection refused')).toBe(false)
+ })
+})
diff --git a/src/lib/hf-to-provider.ts b/src/lib/hf-to-provider.ts
index 94f12450..d5739631 100644
--- a/src/lib/hf-to-provider.ts
+++ b/src/lib/hf-to-provider.ts
@@ -42,12 +42,29 @@ export function parseHfUrl(url: string): HfRef | null {
* given on `hf.co/<repo>` references).
*/
export function extractGgufQuant(filename: string): string | undefined {
+ // Recognise unsloth "UD" dynamic quants (Q4_K_XL / Q4_K_XS) and bare K-quants
+ // (Q6_K) in addition to the classic Q*_K_{M,S,L}. Without the XL/XS arm,
+ // unsloth files like `...-UD-Q4_K_XL.gguf` produced NO quant tag, so the
+ // Ollama HF ref fell back to a tag-less `hf.co/<repo>` pull (Aldrich Ironhart,
+ // Discord 2026-06-07 — "Gemma 4 26B MoE" → ollama 400).
const m = filename.match(
- /[-._](Q\d_K_[MSL]|Q\d_[01]|IQ\d_[A-Z0-9_]+|F16|BF16|F32)\.gguf$/i
+ /[-._](Q\d_K_(?:XL|XS|[MSL])|Q\d_K|Q\d_[01]|IQ\d_[A-Z0-9_]+|F16|BF16|F32)\.gguf$/i
)
return m?.[1].toUpperCase()
}
+/**
+ * True when an Ollama pull error names a HuggingFace repo Ollama can't ingest
+ * as a flat single-file GGUF — split into shards or "not compatible with
+ * llama.cpp" (ollama/ollama#5245). Such models download fine via LM Studio.
+ * A bare HTTP 400 is handled separately by the caller (it's more often an
+ * out-of-date Ollama than a bad repo — Aldrich Ironhart, Discord 2026-06-07:
+ * "Gemma 4 26B MoE → ollama: 400", yet the same pull succeeds on current Ollama).
+ */
+export function isShardedOrIncompatibleGguf(errMsg: string): boolean {
+ return /shard|split|5245|not\s*gguf|not\s*compatible|repository is not/i.test(errMsg)
+}
+
/**
* Build the Ollama HF reference for a HuggingFace GGUF download URL.
*
diff --git a/src/stores/__tests__/stores.test.ts b/src/stores/__tests__/stores.test.ts
index 4f143a80..3341e2d8 100644
--- a/src/stores/__tests__/stores.test.ts
+++ b/src/stores/__tests__/stores.test.ts
@@ -398,6 +398,43 @@ describe('memoryStore', () => {
})
})
+ // konata-session 2026-06-07 (Aldrich Ironhart "memory import issue"): the
+ // single Import button only opened the .md picker, so JSON import was dead;
+ // importFromJSON also accepted ONLY {entries:[...]} and reported nothing.
+ describe('import (tolerant shapes + count)', () => {
+ it("imports LU's own {entries:[...]} export and returns the count", () => {
+ const n = useMemoryStore.getState().importFromJSON(JSON.stringify({ entries: [
+ { type: 'user', title: 'A', content: 'alpha' },
+ { type: 'project', title: 'B', content: 'beta' },
+ ] }))
+ expect(n).toBe(2)
+ expect(useMemoryStore.getState().entries).toHaveLength(2)
+ })
+ it('tolerates a bare array', () => {
+ expect(useMemoryStore.getState().importFromJSON(JSON.stringify([{ content: 'x' }, { content: 'y' }]))).toBe(2)
+ })
+ it('tolerates a {memories:[...]} shape', () => {
+ expect(useMemoryStore.getState().importFromJSON(JSON.stringify({ memories: [{ content: 'z' }] }))).toBe(1)
+ })
+ it('returns 0 for invalid JSON and for entries without content', () => {
+ expect(useMemoryStore.getState().importFromJSON('not json')).toBe(0)
+ expect(useMemoryStore.getState().importFromJSON(JSON.stringify({ entries: [{ title: 'no content' }] }))).toBe(0)
+ expect(useMemoryStore.getState().entries).toHaveLength(0)
+ })
+ it('regenerates ids so a re-imported export never collides', () => {
+ const json = JSON.stringify({ entries: [{ id: 'fixed-id', type: 'user', title: 'T', content: 'c' }] })
+ useMemoryStore.getState().importFromJSON(json)
+ useMemoryStore.getState().importFromJSON(json)
+ const ids = useMemoryStore.getState().entries.map(e => e.id)
+ expect(new Set(ids).size).toBe(2)
+ })
+ it('importFromMarkdown returns the number of parsed entries', () => {
+ const md = '# Memory\n\n## User\n\n- **Likes** — coffee [drinks] *(import)*\n'
+ expect(useMemoryStore.getState().importFromMarkdown(md)).toBe(1)
+ expect(useMemoryStore.getState().entries[0].content).toBe('coffee')
+ })
+ })
+
describe('addMemory', () => {
it('adds a MemoryFile to the store', () => {
useMemoryStore.getState().addMemory({
diff --git a/src/stores/memoryStore.ts b/src/stores/memoryStore.ts
index 2e70e47e..76a724af 100644
--- a/src/stores/memoryStore.ts
+++ b/src/stores/memoryStore.ts
@@ -202,11 +202,12 @@ interface MemoryState {
// Settings
updateMemorySettings: (updates: Partial<MemorySettings>) => void
- // Export / Import
+ // Export / Import — importers return the number of entries actually added
+ // so the UI can give feedback (konata-session 2026-06-07: silent 0-import).
exportAsMarkdown: () => string
- importFromMarkdown: (markdown: string) => void
+ importFromMarkdown: (markdown: string) => number
exportAsJSON: () => string
- importFromJSON: (json: string) => void
+ importFromJSON: (json: string) => number
// Legacy compat (used by old code paths during transition)
addEntry: (category: MemoryCategory, content: string, source?: string) => void
@@ -627,6 +628,7 @@ export const useMemoryStore = create<MemoryState>()(
lastSynced: Date.now(),
}))
}
+ return newEntries.length
},
exportAsJSON: () => {
@@ -635,17 +637,47 @@ export const useMemoryStore = create<MemoryState>()(
},
importFromJSON: (json) => {
+ let raw: any
try {
- const data = JSON.parse(json)
- if (Array.isArray(data.entries)) {
- set((state) => ({
- entries: [...state.entries, ...data.entries],
- lastSynced: Date.now(),
- }))
- }
+ raw = JSON.parse(json)
} catch {
log.error('Failed to parse memory JSON import')
+ return 0
+ }
+ // Tolerant shape handling: accept LU's own {entries:[...]} export, a
+ // bare [...] array, or {memories:[...]} (konata-session 2026-06-07 —
+ // imports silently produced 0 entries on any other shape).
+ const arr: any[] = Array.isArray(raw) ? raw
+ : Array.isArray(raw?.entries) ? raw.entries
+ : Array.isArray(raw?.memories) ? raw.memories
+ : []
+ const VALID: MemoryType[] = ['user', 'feedback', 'project', 'reference']
+ const now = Date.now()
+ const newEntries: MemoryFile[] = []
+ for (const e of arr) {
+ const content = String(e?.content ?? e?.text ?? e?.value ?? '').trim()
+ if (!content) continue
+ newEntries.push({
+ // Always mint a fresh id so a re-imported export can never collide
+ // with an existing entry's id (which broke edit/remove-by-id).
+ id: uuid(),
+ type: VALID.includes(e?.type) ? e.type : 'user',
+ title: String(e?.title ?? content).slice(0, 60).replace(/\n/g, ' '),
+ description: String(e?.description ?? content).slice(0, 120),
+ content,
+ tags: Array.isArray(e?.tags) ? e.tags.map((t: any) => String(t)) : [],
+ createdAt: typeof e?.createdAt === 'number' ? e.createdAt : now,
+ updatedAt: now,
+ source: String(e?.source ?? 'import'),
+ })
+ }
+ if (newEntries.length > 0) {
+ set((state) => ({
+ entries: [...state.entries, ...newEntries],
+ lastSynced: now,
+ }))
}
+ return newEntries.length
},
// ── Legacy Compat ───────────────────────────────────────