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): searchMemories mit limit 0 lieferte den 20er-Vorgabewert (R2-39)

purple3d306e566b79
diff --git a/src/stores/__tests__/stores.test.ts b/src/stores/__tests__/stores.test.ts
index 850c3d7b..86331e3e 100644
--- a/src/stores/__tests__/stores.test.ts
+++ b/src/stores/__tests__/stores.test.ts
@@ -574,6 +574,11 @@ describe('memoryStore', () => {
// fact → user, so the two facts should be user type
expect(results.every(e => e.type === 'user')).toBe(true)
})
+
+ it('R2-39: an explicit limit of 0 returns nothing, not the 20-entry default', () => {
+ const results = useMemoryStore.getState().searchMemories('TypeScript JavaScript', { limit: 0 })
+ expect(results).toHaveLength(0)
+ })
})
describe('getMemoriesForPrompt', () => {
diff --git a/src/stores/memoryStore.ts b/src/stores/memoryStore.ts
index ccbb5985..5438173e 100644
--- a/src/stores/memoryStore.ts
+++ b/src/stores/memoryStore.ts
@@ -794,7 +794,9 @@ export const useMemoryStore = create<MemoryState>()(
.filter(({ score }) => score > 0)
.sort((a, b) => b.score - a.score)
- const limit = options?.limit || 20
+ // R2-39: `|| 20` turned an explicit limit of 0 into 20, since 0 is
+ // falsy. `??` only falls back when the caller left it unset.
+ const limit = options?.limit ?? 20
return scored.slice(0, limit).map(({ entry }) => entry)
},