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): sensible Erinnerung blockt nicht mehr den ganzen Sync (R2-37)

purple016ddedc8dcb
diff --git a/src/components/settings/MemorySettings.tsx b/src/components/settings/MemorySettings.tsx
index e9340396..feb628aa 100644
--- a/src/components/settings/MemorySettings.tsx
+++ b/src/components/settings/MemorySettings.tsx
@@ -153,7 +153,10 @@ function MemorySettingsPanel() {
const result = await synchronizeMemoryCollection(activeOwner, sensitiveSyncConsent, resolution, controller.signal)
if (syncController.current !== controller) return
setSyncConflicts(result.conflicts)
- setSyncMessage(`Synced ${result.uploaded} uploads and ${result.downloaded} downloads. ${result.conflicts.length} conflicting memories left unchanged.`)
+ const omittedNote = result.omittedSensitive > 0
+ ? ` ${result.omittedSensitive} sensitive ${result.omittedSensitive === 1 ? 'memory was' : 'memories were'} left out (not uploaded).`
+ : ''
+ setSyncMessage(`Synced ${result.uploaded} uploads and ${result.downloaded} downloads. ${result.conflicts.length} conflicting memories left unchanged.${omittedNote}`)
} catch (error) {
if (syncController.current !== controller) return
if (quelle === 'finalize') { setLegacyReview(null); setConfirmLegacyRemoval(false) }
diff --git a/src/lib/__tests__/memory-sync-coordinator.test.ts b/src/lib/__tests__/memory-sync-coordinator.test.ts
index d99a3eca..29ad8b2b 100644
--- a/src/lib/__tests__/memory-sync-coordinator.test.ts
+++ b/src/lib/__tests__/memory-sync-coordinator.test.ts
@@ -88,11 +88,24 @@ it('preserves malformed saved metadata and refuses network work rather than trea
expect(fixture.pull).not.toHaveBeenCalled()
expect(fixture.write).not.toHaveBeenCalled()
})
-it('requires extra consent before sending sensitive payloads', async () => {
+it('R2-37: leaves a sensitive memory out of the upload instead of blocking the whole sync', async () => {
useMemoryStore.setState({ entries: [{ ...memory, sensitive: true }] })
- await expect(synchronizeMemoryCollection('A')).rejects.toThrow('Sensitive memories need explicit permission')
+ const result = await synchronizeMemoryCollection('A')
+ expect(result.uploaded).toBe(0)
+ expect(result.omittedSensitive).toBe(1)
expect(fixture.write).not.toHaveBeenCalled()
- expect((await synchronizeMemoryCollection('A', true)).uploaded).toBe(1)
+ // With consent, the same write goes up after all.
+ const withConsent = await synchronizeMemoryCollection('A', true)
+ expect(withConsent.uploaded).toBe(1)
+ expect(withConsent.omittedSensitive).toBe(0)
+})
+it('R2-37: a harmless pull still lands even when a sensitive push is held back', async () => {
+ useMemoryStore.setState({ entries: [{ ...memory, sensitive: true }] })
+ remote = [{ memory_id: 'two', revision: 1, payload: { id: 'two', type: 'user', title: 'Other', content: 'Pulled fact', description: '', tags: [], source: 'manual', createdAt: 1, updatedAt: 1 }, deleted: false, updated_at: '2026-09-09T00:00:00Z' }]
+ const result = await synchronizeMemoryCollection('A')
+ expect(result.downloaded).toBe(1)
+ expect(result.omittedSensitive).toBe(1)
+ expect(useMemoryStore.getState().entries.some(e => e.id === 'two')).toBe(true)
})
it('preserves intent after an uncertain accepted first upload and propagates intervening deletion', async () => {
useMemoryStore.setState({ entries: [memory] })
diff --git a/src/lib/memory-sync.ts b/src/lib/memory-sync.ts
index dfb18cfc..3f914593 100644
--- a/src/lib/memory-sync.ts
+++ b/src/lib/memory-sync.ts
@@ -113,8 +113,16 @@ export async function synchronizeMemoryCollection(owner: string, allowSensitive
plan.conflicts = plan.conflicts.filter(item => item.id !== choice.id)
}
for (const [id, expectedRevision] of forcedDeletes) plan.push.push({ id, expectedRevision, payload: null })
- if (!allowSensitive && plan.push.some(write => write.payload?.sensitive)) {
- throw new MemorySyncError('invalid', 'Sensitive memories need explicit permission for cloud storage before this collection can synchronize')
+ // R2-37: this used to throw and abort the WHOLE plan (including the pull
+ // half, which never touches a sensitive record) whenever a single
+ // sensitive write needed upload permission. A sensitive memory now just
+ // stays local: it is dropped from the push list, the rest of the sync
+ // proceeds, and the caller is told how many were left out.
+ let omittedSensitive = 0
+ if (!allowSensitive) {
+ const before = plan.push.length
+ plan.push = plan.push.filter(write => !write.payload?.sensitive)
+ omittedSensitive = before - plan.push.length
}
const incoming = new Map(plan.pull.map(item => [item.memory.id, item.memory]))
const removed = new Set([...plan.remove.map(item => item.id), ...forcedDeletes.keys()])
@@ -155,7 +163,7 @@ export async function synchronizeMemoryCollection(owner: string, allowSensitive
} }
}))
guard()
- return { downloaded: plan.pull.length, uploaded, removed: plan.remove.length, conflicts }
+ return { downloaded: plan.pull.length, uploaded, removed: plan.remove.length, conflicts, omittedSensitive }
}, signal)
} finally { running = false }
}