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.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(memory): eine Sicherung ohne das Feld loescht die Marke Sensitive nicht mehr
purple0cbfd63b4f02
diff --git a/src/stores/__tests__/memory-sensitive.test.ts b/src/stores/__tests__/memory-sensitive.test.tsindex bc5b8609..b8773793 100644--- a/src/stores/__tests__/memory-sensitive.test.ts+++ b/src/stores/__tests__/memory-sensitive.test.ts@@ -39,3 +39,50 @@ it('does not let an automatic resolution modify a protected target', () => {useMemoryStore.getState().applyWriteDecision({ action: 'UPDATE', targetId: id, mergedContent: 'Changed' })expect(useMemoryStore.getState().entries[0].content).toBe('Synthetic private preference')})++/**+ * R2-2: eine Sicherung aus 2.6.9 kennt das Feld `sensitive` nicht. Der+ * Importpfad las es trotzdem als `=== true`, ein fehlendes Feld wurde also zu+ * `false`, und weil `importDigest` die Marke fuehrt, machte gerade sie den+ * Eintrag zum Update. Danach laeuft die Nachbehandlung und bettet die eben+ * entmarkierte Erinnerung frisch ein: sie steht wieder in KI-Anfragen UND in+ * der Vektorsuche.+ */+it('keeps the sensitive mark when the imported file does not know the field', () => {+ add()+ const datei = JSON.parse(useMemoryStore.getState().exportAsJSON())+ // Genau die Form von 2.6.9: das Feld existiert nicht.+ for (const e of datei.entries) delete e.sensitive++ const ergebnis = useMemoryStore.getState().importFromJSON(JSON.stringify(datei))++ expect(ergebnis.updated).toBe(0)+ expect(ergebnis.alreadyPresent).toBe(1)+ expect(useMemoryStore.getState().entries).toHaveLength(1)+ expect(useMemoryStore.getState().entries[0].sensitive).toBe(true)+ expect(useMemoryStore.getState().getMemoriesForPrompt('private', 8192)).toBe('')+})++it('still drops the mark when the file says so, and says how often', () => {+ // Negativkontrolle: eine gewollte Aenderung muss weiter durchkommen, sonst+ // liesse sich eine Marke nie wieder loeschen.+ add()+ const datei = JSON.parse(useMemoryStore.getState().exportAsJSON())+ for (const e of datei.entries) e.sensitive = false++ const ergebnis = useMemoryStore.getState().importFromJSON(JSON.stringify(datei))++ expect(ergebnis.updated).toBe(1)+ expect(ergebnis.unmarkedSensitive).toBe(1)+ expect(useMemoryStore.getState().entries[0].sensitive).toBe(false)+ expect(useMemoryStore.getState().getMemoriesForPrompt('private', 8192)).toContain('Synthetic private')+})++it('names the dropped marks in the sentence the settings page shows', async () => {+ const { describeMemoryImport } = await import('../memoryStore')+ expect(describeMemoryImport({ added: 0, updated: 1, alreadyPresent: 0, unmarkedSensitive: 1 }))+ .toBe('Imported 0 new memories, 1 updated, 1 no longer marked sensitive.')+ // Ohne Vorfall bleibt der Satz wortgleich mit dem des Webs.+ expect(describeMemoryImport({ added: 0, updated: 1, alreadyPresent: 0 }))+ .toBe('Imported 0 new memories, 1 updated.')+})diff --git a/src/stores/memoryStore.ts b/src/stores/memoryStore.tsindex a4ebd20f..b3f478c1 100644--- a/src/stores/memoryStore.ts+++ b/src/stores/memoryStore.ts@@ -91,6 +91,13 @@ export interface MemoryImportResult {updated: number/** Already in this collection, left untouched. */alreadyPresent: number+ /**+ * How many of the refreshed records lost their "sensitive" mark because the+ * file said so. Only present when it actually happened: a mark falling is a+ * privacy event and gets its own number, but a clean import must not carry a+ * zero about sensitive memories through every sentence.+ */+ unmarkedSensitive?: number}/** Everything that decides whether a known record still matches the file. */@@ -109,6 +116,7 @@ export function describeMemoryImport(result: MemoryImportResult): string {const parts = [`Imported ${result.added} new ${noun(result.added)}`]if (result.updated > 0) parts.push(`${result.updated} updated`)if (result.alreadyPresent > 0) parts.push(`${result.alreadyPresent} already present`)+ if (result.unmarkedSensitive) parts.push(`${result.unmarkedSensitive} no longer marked sensitive`)return `${parts.join(', ')}.`}@@ -1063,6 +1071,21 @@ export const useMemoryStore = create<MemoryState>()(const confirmedAt = prop(e, 'confirmedAt')const originalId = asString(prop(e, 'id'))const supersededBy = asString(prop(e, 'supersededBy'))+ const scopeValue = asString(scope)+ // The app's own export carries the record id, so the same file read+ // twice meets its own entries again. A file without ids still meets+ // them through content, type and scope — the only three fields+ // isSameMemory reads, which is why this can stand before the draft.+ //+ // It HAS to stand here: a 2.6.9 backup does not know the field+ // `sensitive` at all, and reading a missing field as `=== true` turned+ // it into `false`. Because importDigest carries the mark, that very+ // mark then made the record an update, and the follow-up below+ // re-embedded it — the memory was back in AI requests and back in+ // vector search. A file may only drop a mark by saying so.+ const known = (originalId ? pool.find((p) => p.id === originalId) : undefined)+ ?? pool.find((p) => isSameMemory(p, { content, type, scope: scopeValue }))+ const fileSensitive = prop(e, 'sensitive')const draft: Omit<MemoryFile, 'id' | 'createdAt'> = {type,title: (asString(prop(e, 'title')) ?? content).slice(0, 60).replace(/\n/g, ' '),@@ -1073,17 +1096,12 @@ export const useMemoryStore = create<MemoryState>()(source: asString(prop(e, 'source')) ?? 'import',sourceKind: sourceKind === 'chat' || sourceKind === 'voice' || sourceKind === 'screen' ? sourceKind : undefined,confirmedAt: typeof confirmedAt === 'number' && Number.isFinite(confirmedAt) && confirmedAt > 0 && confirmedAt <= now ? confirmedAt : undefined,- sensitive: prop(e, 'sensitive') === true,- scope: asString(scope),+ sensitive: fileSensitive === undefined ? known?.sensitive === true : fileSensitive === true,+ scope: scopeValue,// A missing replacement must not reactivate an outdated fact.stale: prop(e, 'stale') === true || supersededBy !== undefined,validFrom: asNumber(prop(e, 'validFrom')),}- // The app's own export carries the record id, so the same file read- // twice meets its own entries again. A file without ids still meets- // them through content, type and scope.- const known = (originalId ? pool.find((p) => p.id === originalId) : undefined)- ?? pool.find((p) => isSameMemory(p, draft))// A known record keeps its id and its birthday; only a genuinely new// one gets a fresh id, which is why no import can collide with an// existing entry's id (that once broke edit/remove-by-id).@@ -1109,10 +1127,15 @@ export const useMemoryStore = create<MemoryState>()(const newEntries: MemoryFile[] = []const updates = new Map<string, MemoryFile>()let alreadyPresent = 0+ // A mark that falls is a privacy event, so it is counted and named.+ let unmarkedSensitive = 0for (const { entry, known } of landed) {if (!known) newEntries.push(entry)else if (importDigest(known) === importDigest(entry)) alreadyPresent++- else updates.set(entry.id, entry)+ else {+ if (known.sensitive === true && entry.sensitive !== true) unmarkedSensitive+++ updates.set(entry.id, entry)+ }}if (newEntries.length > 0 || updates.size > 0) {set((state) => ({@@ -1126,7 +1149,12 @@ export const useMemoryStore = create<MemoryState>()(if (entry.sensitive) void deleteVector(entry.id)else void enqueueEmbedding(entry)}- return { added: newEntries.length, updated: updates.size, alreadyPresent }+ return {+ added: newEntries.length,+ updated: updates.size,+ alreadyPresent,+ ...(unmarkedSensitive > 0 ? { unmarkedSensitive } : {}),+ }},// ── Legacy Compat ───────────────────────────────────────