跳到正文
DEV Community· JackieBoomBoomBoom·· 1 小時前AI 評分56

KeepThread 如何在 Chrome MV3 中實現 AI 對話至 Obsidian 的本機無損同步

How I built lossless in-place AI chat -> Obsidian sync in Chrome MV3 (zero cloud, no )

AI 導讀

KeepThread 透過 Chrome MV3 和 File System Access API,在瀏覽器本機把 AI 對話無損同步至 Obsidian,無需後端伺服器。

正文

Cover image for How I built lossless in-place AI chat -> Obsidian sync in Chrome MV3 (zero cloud, no <all_urls>)

JackieBoomBoomBoom

If you use Obsidian as a local Markdown workspace (raw/ -> wiki/ or alongside obsidian-skills), bringing web conversations from ChatGPT, Claude, Perplexity, or DeepSeek into your vault usually hits three walls:

  1. Re-exporting a continued thread overwrites your handwritten notes, custom YAML properties, and [[backlinks]] (or creates Note (1).md duplicates).
  2. Naive regex conversion of \( ... \) and \[ ... \] math delimiters mangles literal $ or parentheses inside fenced code blocks.
  3. Virtualized long chats unmount older DOM turns off-screen, silently truncating your saved note if you re-sync later.

Here is how I solved all three 100% locally inside the browser in KeepThread (v1.4.5 live on Chrome Web Store; also on Microsoft Edge Add-ons)—using the File System Access API with zero backend servers and no <all_urls> permission:

1. Lossless In-Place Merge by conversation_id

Instead of overwriting .md files, each synced note wraps the AI transcript inside HTML comment boundaries while keeping handwritten blocks (<!-- keepthread:notes:start/end --> and trailing notes) plus user-added YAML keys and #tags intact. Even if you rename the note inside your synced folder, KeepThread locates it by conversation_id and merges only the new turns.

2. Code-Fence Immunity for LaTeX & Citations

Before normalizing ChatGPT/Claude/DeepSeek math delimiters (\[ \] -> $$ $$, \( \) -> $ $) or remapping Perplexity/Gemini footnotes into ## Sources, the parser splits Markdown by top-level, blockquote-nested, and list-nested code fences so code snippets stay 100% untouched.

(If you just want a free, zero-install tool for fixing broken AI math delimiters & <think> tags in the browser, I extracted that parser into a standalone page here: Free AI LaTeX to Obsidian Fixer)

3. Virtualized DOM Anti-Truncation + Bounded Host Hang Guards

On long virtualized threads, KeepThread compares turn signatures against your existing archive—flagging partial open-tab captures under Needs Full Capture (v1.4.5) instead of letting a shifted scroll window wipe earlier turns. Every FileSystemDirectoryHandle.queryPermission() check is also wrapped in a bounded timeout so Windows Chrome handle hangs never cause infinite spinners.

Single-thread Markdown & offline image .zip exports are free forever (optional $19 one-time Lifetime Pro, no subscription). Happy to answer any questions about Chrome's File System Access API or Obsidian .base / YAML edge cases!

來源:DEV Community · dev.to