From 36186cf919026d97fc0c1ce3f078be9e27e5d361 Mon Sep 17 00:00:00 2001 From: 491034170 <142008960+491034170@users.noreply.github.com> Date: Sat, 13 Jun 2026 21:12:28 +0800 Subject: [PATCH 1/2] fix(windows): ignore memory import markdown fences --- desktop/windows/src/main/memoryImport/parse.test.ts | 12 ++++++++++++ desktop/windows/src/main/memoryImport/parse.ts | 10 ++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/desktop/windows/src/main/memoryImport/parse.test.ts b/desktop/windows/src/main/memoryImport/parse.test.ts index 618cec0daf..3dc16c5dd9 100644 --- a/desktop/windows/src/main/memoryImport/parse.test.ts +++ b/desktop/windows/src/main/memoryImport/parse.test.ts @@ -13,11 +13,23 @@ describe('parseMemoryDump', () => { ]) }) + it('handles common pasted markdown list markers', () => { + const dump = `— Enjoys tea +‣ Uses Windows +⁃ Keeps notes in Obsidian` + expect(parseMemoryDump(dump)).toEqual(['Enjoys tea', 'Uses Windows', 'Keeps notes in Obsidian']) + }) + it('handles numbered lists', () => { const dump = `1. Lives in Seattle\n2) Is learning Spanish` expect(parseMemoryDump(dump)).toEqual(['Lives in Seattle', 'Is learning Spanish']) }) + it('drops markdown code fences around copied dumps', () => { + const dump = "```markdown\n- Likes coffee\n- Prefers short replies\n```" + expect(parseMemoryDump(dump)).toEqual(['Likes coffee', 'Prefers short replies']) + }) + it('drops conversational scaffolding but keeps real memories', () => { const dump = `Sure! Here are your saved memories: - Has a dog diff --git a/desktop/windows/src/main/memoryImport/parse.ts b/desktop/windows/src/main/memoryImport/parse.ts index 1388398a73..aca796c9b0 100644 --- a/desktop/windows/src/main/memoryImport/parse.ts +++ b/desktop/windows/src/main/memoryImport/parse.ts @@ -20,9 +20,10 @@ const SCAFFOLDING = [ /^i (?:currently )?(?:remember|have stored|don'?t have)\b.*(?:memor|the following|about you)/i ] -// Remove a single leading list marker: -, *, •, –, or "1." / "1)". +// Remove a single leading list marker: -, *, common bullet/dash markers, +// or "1." / "1)". function stripMarker(line: string): string { - return line.replace(/^\s*(?:[-*•–]\s+|\d+[.)]\s+)/, '') + return line.replace(/^\s*(?:[-*\u2022\u2013\u2014\u2023\u2043]\s+|\d+[.)]\s+)/, '') } // Strip surrounding markdown emphasis / heading syntax. @@ -34,10 +35,15 @@ function stripFormatting(s: string): string { return t.trim() } +function isMarkdownFence(line: string): boolean { + return /^\s*(?:```|~~~)/.test(line) +} + export function parseMemoryDump(dump: string): string[] { const out: string[] = [] const seen = new Set() for (const raw of dump.split(/\r?\n/)) { + if (isMarkdownFence(raw)) continue const stripped = stripFormatting(stripMarker(raw)) if (stripped.length < 3) continue // blank lines, stray numbering/punctuation if (SCAFFOLDING.some((re) => re.test(stripped))) continue From 1d014a789c263a75436acd25f09056b6941d4999 Mon Sep 17 00:00:00 2001 From: 491034170 <142008960+491034170@users.noreply.github.com> Date: Wed, 17 Jun 2026 07:48:56 +0800 Subject: [PATCH 2/2] Format memory import fence test --- desktop/windows/src/main/memoryImport/parse.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/windows/src/main/memoryImport/parse.test.ts b/desktop/windows/src/main/memoryImport/parse.test.ts index 3dc16c5dd9..714cbfd02b 100644 --- a/desktop/windows/src/main/memoryImport/parse.test.ts +++ b/desktop/windows/src/main/memoryImport/parse.test.ts @@ -26,7 +26,7 @@ describe('parseMemoryDump', () => { }) it('drops markdown code fences around copied dumps', () => { - const dump = "```markdown\n- Likes coffee\n- Prefers short replies\n```" + const dump = '```markdown\n- Likes coffee\n- Prefers short replies\n```' expect(parseMemoryDump(dump)).toEqual(['Likes coffee', 'Prefers short replies']) })