Preserve wikilink text in Obsidian indexing and fix duplicate sync

Two fixes:
- Convert wikilinks to display text instead of stripping them entirely.
  [[Noah]] becomes "Noah", [[target|display]] becomes "display". This
  was causing names and references in wikilinks to be invisible to search.
- Switch _get_obsidian_indexed_files to async engine to avoid stale reads
  from the separate sync engine, which caused files to be re-indexed
  every cycle.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-31 07:35:24 -04:00
parent 73e952c617
commit 00c9b44c0e
2 changed files with 19 additions and 7 deletions
+6 -2
View File
@@ -106,8 +106,12 @@ class ObsidianService:
embeds = [e.split(":")[0].strip() if ":" in e else e.strip() for e in embeds]
# Clean body content
# Remove wikilinks [[...]] and embeds [[!...]]
cleaned_content = re.sub(r"\[\[.*?\]\]", "", body_content)
# Remove embeds ![[...]]
cleaned_content = re.sub(r"!\[\[.*?\]\]", "", body_content)
# Convert wikilinks to display text: [[target|display]] → display, [[target]] → target
cleaned_content = re.sub(
r"\[\[([^\]|]+\|)?([^\]]+)\]\]", r"\2", cleaned_content
)
cleaned_content = re.sub(r"\n{3,}", "\n\n", cleaned_content).strip()
return {