<feed xmlns='http://www.w3.org/2005/Atom'>
<title>lattex.git/src/main/fileSyncBridge.ts, branch v0.3.8</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.blackhao.com/lattex.git/'/>
<entry>
<title>Fix Overleaf file tree sync updates</title>
<updated>2026-04-25T20:21:27+00:00</updated>
<author>
<name>haoyuren</name>
<email>13851610112@163.com</email>
</author>
<published>2026-04-25T20:21:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.blackhao.com/lattex.git/commit/?id=59cb73960ee68a47adbdc05915847cb8d45f795e'/>
<id>59cb73960ee68a47adbdc05915847cb8d45f795e</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix OT sync corruption: match Overleaf ShareJS ack/echo handling</title>
<updated>2026-03-18T08:06:32+00:00</updated>
<author>
<name>haoyuren</name>
<email>13851610112@163.com</email>
</author>
<published>2026-03-18T08:06:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.blackhao.com/lattex.git/commit/?id=9b5256718c2117511f0253a656bb8cff7410b92a'/>
<id>9b5256718c2117511f0253a656bb8cff7410b92a</id>
<content type='text'>
The server broadcasts otUpdateApplied (with ops) to ALL clients including
the sender. Our bridge was treating its own echoed ops as remote ops and
re-applying them, causing text duplication (e.g. "simulatorimulator").

Rewrite OT handling to match Overleaf's ShareJS _onMessage pattern:
- ACK = no ops OR meta.source matches our publicId (own echo)
- REMOTE = ops from a different source
- ACK path calls onAck() without re-applying ops
- OtClient silently drops duplicate acks in synchronized state
- OtClient drops stale remote ops (version &lt; current)
- Remove pendingEchos counter in favor of meta.source detection

Also: refresh MCP comment contexts on new-comment/delete-thread events,
add Overleaf reference repo to .gitignore.

Co-Authored-By: Claude Opus 4.6 &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The server broadcasts otUpdateApplied (with ops) to ALL clients including
the sender. Our bridge was treating its own echoed ops as remote ops and
re-applying them, causing text duplication (e.g. "simulatorimulator").

Rewrite OT handling to match Overleaf's ShareJS _onMessage pattern:
- ACK = no ops OR meta.source matches our publicId (own echo)
- REMOTE = ops from a different source
- ACK path calls onAck() without re-applying ops
- OtClient silently drops duplicate acks in synchronized state
- OtClient drops stale remote ops (version &lt; current)
- Remove pendingEchos counter in favor of meta.source detection

Also: refresh MCP comment contexts on new-comment/delete-thread events,
add Overleaf reference repo to .gitignore.

Co-Authored-By: Claude Opus 4.6 &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix OT ack/error swallowed when doc transitions to editor mode</title>
<updated>2026-03-16T00:13:57+00:00</updated>
<author>
<name>haoyuren</name>
<email>13851610112@163.com</email>
</author>
<published>2026-03-16T00:13:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.blackhao.com/lattex.git/commit/?id=c667ff6a58b36b67bb92ff5a20df646e0777c6d5'/>
<id>c667ff6a58b36b67bb92ff5a20df646e0777c6d5</id>
<content type='text'>
When addEditorDoc is called while the bridge has in-flight OT ops
(awaitingConfirm), the ack/error response was ignored because
handleOtUpdate/handleOtError skipped editor docs entirely. This left
the bridge's OtClient stuck and the edit appeared lost until
removeEditorDoc re-discovered the discrepancy.

Fix: always process acks regardless of editor doc status, and only
skip OT errors for editor docs when the bridge has no OtClient.

Co-Authored-By: Claude Opus 4.6 &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When addEditorDoc is called while the bridge has in-flight OT ops
(awaitingConfirm), the ack/error response was ignored because
handleOtUpdate/handleOtError skipped editor docs entirely. This left
the bridge's OtClient stuck and the edit appeared lost until
removeEditorDoc re-discovered the discrepancy.

Fix: always process acks regardless of editor doc status, and only
skip OT errors for editor docs when the bridge has no OtClient.

Co-Authored-By: Claude Opus 4.6 &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Add online users popover, MCP get_online_users, claude-workspace, stronger CLAUDE.md</title>
<updated>2026-03-15T23:47:29+00:00</updated>
<author>
<name>haoyuren</name>
<email>13851610112@163.com</email>
</author>
<published>2026-03-15T23:47:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.blackhao.com/lattex.git/commit/?id=a36b73505754acab6872d23c9add58dfca3cecdd'/>
<id>a36b73505754acab6872d23c9add58dfca3cecdd</id>
<content type='text'>
- Online users: click "N online" badge to see user names with cursor colors
- MCP get_online_users tool: main process tracks users in .lattex-online-users.json
- CLAUDE.md: show current user's Overleaf name (fetched from /user/settings)
- CLAUDE.md: mandatory first steps with MUST/NEVER language at top of file
- claude-workspace/ directory: untracked scratch space for Claude Code experiments
- chokidar + bridge skip claude-workspace/ to prevent syncing to Overleaf

Co-Authored-By: Claude Opus 4.6 &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- Online users: click "N online" badge to see user names with cursor colors
- MCP get_online_users tool: main process tracks users in .lattex-online-users.json
- CLAUDE.md: show current user's Overleaf name (fetched from /user/settings)
- CLAUDE.md: mandatory first steps with MUST/NEVER language at top of file
- claude-workspace/ directory: untracked scratch space for Claude Code experiments
- chokidar + bridge skip claude-workspace/ to prevent syncing to Overleaf

Co-Authored-By: Claude Opus 4.6 &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix file sync for non-active tabs, MCP compile integration, OT resilience</title>
<updated>2026-03-15T23:21:06+00:00</updated>
<author>
<name>haoyuren</name>
<email>13851610112@163.com</email>
</author>
<published>2026-03-15T23:21:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.blackhao.com/lattex.git/commit/?id=c9d673d83037167553dcef3947065266743b2d5f'/>
<id>c9d673d83037167553dcef3947065266743b2d5f</id>
<content type='text'>
- Fix .bib (and other non-active tab) edits disappearing: call otLeaveDoc
  on tab switch so bridge takes back OT ownership; release .bib pre-loads
  immediately after reading content for citation autocomplete
- Always update lastKnownContent in processDocChange for editor docs to
  prevent stale state accumulation
- Flush pending OT ops in OverleafDocSync.destroy() before tab switch
- Add three-way merge in replaceContent to preserve concurrent remote edits
- Wire MCP compile to UI: file-based signal between MCP server and Electron
  main process, with compile animation and PDF refresh in renderer
- Add CLSI flush before compile to prevent stale cached results
- Add OT error recovery: re-join doc and re-apply disk changes on otUpdateError
- Add bridge reconnect handling: reset OtClient on docRejoined for non-editor docs
- Add compile concurrency lock to prevent duplicate compiles
- removeEditorDoc compares disk vs server content to catch in-flight ops

Co-Authored-By: Claude Opus 4.6 &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- Fix .bib (and other non-active tab) edits disappearing: call otLeaveDoc
  on tab switch so bridge takes back OT ownership; release .bib pre-loads
  immediately after reading content for citation autocomplete
- Always update lastKnownContent in processDocChange for editor docs to
  prevent stale state accumulation
- Flush pending OT ops in OverleafDocSync.destroy() before tab switch
- Add three-way merge in replaceContent to preserve concurrent remote edits
- Wire MCP compile to UI: file-based signal between MCP server and Electron
  main process, with compile animation and PDF refresh in renderer
- Add CLSI flush before compile to prevent stale cached results
- Add OT error recovery: re-join doc and re-apply disk changes on otUpdateError
- Add bridge reconnect handling: reset OtClient on docRejoined for non-editor docs
- Add compile concurrency lock to prevent duplicate compiles
- removeEditorDoc compares disk vs server content to catch in-flight ops

Co-Authored-By: Claude Opus 4.6 &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix sync race condition: external edits overwritten by remote ops</title>
<updated>2026-03-15T20:02:15+00:00</updated>
<author>
<name>haoyuren</name>
<email>13851610112@163.com</email>
</author>
<published>2026-03-15T20:02:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.blackhao.com/lattex.git/commit/?id=72b38fed1d75fcb3420beeeeefd3dc2fc442e64b'/>
<id>72b38fed1d75fcb3420beeeeefd3dc2fc442e64b</id>
<content type='text'>
When Claude Code writes to disk, a debounce timer is set. If a remote
Overleaf op arrives during the debounce, onEditorContentChanged would
write the remote content back to disk, overwriting Claude Code's edit.

Fix: skip disk write and lastKnownContent update in onEditorContentChanged
when a debounce is pending (external disk change waiting to be processed).
Also increase writesInProgress guard to 800ms to exceed chokidar's 500ms
polling interval.

Co-Authored-By: Claude Opus 4.6 &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When Claude Code writes to disk, a debounce timer is set. If a remote
Overleaf op arrives during the debounce, onEditorContentChanged would
write the remote content back to disk, overwriting Claude Code's edit.

Fix: skip disk write and lastKnownContent update in onEditorContentChanged
when a debounce is pending (external disk change waiting to be processed).
Also increase writesInProgress guard to 800ms to exceed chokidar's 500ms
polling interval.

Co-Authored-By: Claude Opus 4.6 &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>v0.3.0: Fix sync exclusions, add editor zoom, cached PDF loading</title>
<updated>2026-03-15T09:27:43+00:00</updated>
<author>
<name>haoyuren</name>
<email>13851610112@163.com</email>
</author>
<published>2026-03-15T09:27:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.blackhao.com/lattex.git/commit/?id=d1ee677591bd5e6e8b1726b2281621adf6131332'/>
<id>d1ee677591bd5e6e8b1726b2281621adf6131332</id>
<content type='text'>
- Exclude CLAUDE.md from sync (move to .claude/ dotfile dir, clean up root copy)
- Add Ctrl+wheel font zoom for editor (capture phase, disable Electron built-in zoom)
- Load cached PDF on project connect (avoid recompile to see last PDF)
- Add synctex debug logging for PDF↔source navigation troubleshooting
- Fix .claude/ dir creation order (mkdir before write)

Co-Authored-By: Claude Opus 4.6 &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- Exclude CLAUDE.md from sync (move to .claude/ dotfile dir, clean up root copy)
- Add Ctrl+wheel font zoom for editor (capture phase, disable Electron built-in zoom)
- Load cached PDF on project connect (avoid recompile to see last PDF)
- Add synctex debug logging for PDF↔source navigation troubleshooting
- Fix .claude/ dir creation order (mkdir before write)

Co-Authored-By: Claude Opus 4.6 &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix server compile: download PDF to .build dir, prevent artifact sync to Overleaf</title>
<updated>2026-03-15T09:00:12+00:00</updated>
<author>
<name>haoyuren</name>
<email>13851610112@163.com</email>
</author>
<published>2026-03-15T09:00:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.blackhao.com/lattex.git/commit/?id=183af193dcf46838506958a50daad61c6b29a23d'/>
<id>183af193dcf46838506958a50daad61c6b29a23d</id>
<content type='text'>
The root cause of server compile failures was that output.pdf was being
saved into the synced project directory, causing FileSyncBridge to upload
it back to Overleaf as a project file. CLSI then failed because it found
an existing output.pdf blocking its compilation output.

Changes:
- Save compile artifacts (PDF, synctex.gz) to .build/ subdirectory instead
  of the synced project root — .build is a dotfile dir ignored by chokidar
- Add pdf/pdfxref/stderr/stdout/chktex to FileSyncBridge ignore patterns
- Add rootResourcePath to compile request body (matches Overleaf web client)
- Implement PDF download with fallback via direct build ID URL construction
- Add server compile handler, compile dropdown menu, PDF save button
- Fix resolved comment highlight flash on startup (null initial state)
- Fix EPIPE crash on startup when stdout/stderr is closed
- Fix synctex inverse search to use relative paths via OT doc join

Co-Authored-By: Claude Opus 4.6 &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The root cause of server compile failures was that output.pdf was being
saved into the synced project directory, causing FileSyncBridge to upload
it back to Overleaf as a project file. CLSI then failed because it found
an existing output.pdf blocking its compilation output.

Changes:
- Save compile artifacts (PDF, synctex.gz) to .build/ subdirectory instead
  of the synced project root — .build is a dotfile dir ignored by chokidar
- Add pdf/pdfxref/stderr/stdout/chktex to FileSyncBridge ignore patterns
- Add rootResourcePath to compile request body (matches Overleaf web client)
- Implement PDF download with fallback via direct build ID URL construction
- Add server compile handler, compile dropdown menu, PDF save button
- Fix resolved comment highlight flash on startup (null initial state)
- Fix EPIPE crash on startup when stdout/stderr is closed
- Fix synctex inverse search to use relative paths via OT doc join

Co-Authored-By: Claude Opus 4.6 &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Add new file sync to Overleaf, Copy Comments button with file filtering</title>
<updated>2026-03-15T03:26:36+00:00</updated>
<author>
<name>haoyuren</name>
<email>13851610112@163.com</email>
</author>
<published>2026-03-15T03:26:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.blackhao.com/lattex.git/commit/?id=c261b8c4a95a7af64e3cd95a65c50f4dcbbb802c'/>
<id>c261b8c4a95a7af64e3cd95a65c50f4dcbbb802c</id>
<content type='text'>
- Sync new local files (created by Claude Code etc.) to Overleaf via REST API
- Create intermediate folders as needed, handle both text docs and binaries
- Scan for orphaned files on startup that weren't synced previously
- Add "Copy Comments" quick action: copies unresolved comments for current file
  to clipboard with line numbers, context, author names, and timestamps
- Filter comments to active file only, exclude resolved threads

Co-Authored-By: Claude Opus 4.6 &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- Sync new local files (created by Claude Code etc.) to Overleaf via REST API
- Create intermediate folders as needed, handle both text docs and binaries
- Scan for orphaned files on startup that weren't synced previously
- Add "Copy Comments" quick action: copies unresolved comments for current file
  to clipboard with line numbers, context, author names, and timestamps
- Filter comments to active file only, exclude resolved threads

Co-Authored-By: Claude Opus 4.6 &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix Claude Code → Overleaf sync: remove hash from applyOtUpdate, fix OT bugs</title>
<updated>2026-03-13T23:46:46+00:00</updated>
<author>
<name>haoyuren</name>
<email>13851610112@163.com</email>
</author>
<published>2026-03-13T23:46:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.blackhao.com/lattex.git/commit/?id=11166a63affc4e95450f677d860c8bfdb8211bd9'/>
<id>11166a63affc4e95450f677d860c8bfdb8211bd9</id>
<content type='text'>
Root cause: SHA-1 hash sent with applyOtUpdate didn't match Overleaf's
server-side computation, causing "Invalid hash" error, disconnect, and
rollback of all synced changes.

- Remove hash field from applyOtUpdate to skip server-side hash check
- Switch applyOtUpdate from fire-and-forget to emitWithAck for reliable ack
- Fix getOldDoc bug: save base doc when changes start accumulating instead
  of incorrectly using current doc (caused wrong delete ops)
- Fix ack handler: only ack when no 'op' field (was acking remote ops too)
- Await fileSyncBridge.start() instead of fire-and-forget
- Add joinDoc retry logic for transient joinLeaveEpoch mismatch errors
- Clear pending ack callbacks on WebSocket close to prevent timeout errors
- Add otUpdateError logging for server-side rejections
- Add file-based bridge logging for debugging sync issues

Co-Authored-By: Claude Opus 4.6 &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Root cause: SHA-1 hash sent with applyOtUpdate didn't match Overleaf's
server-side computation, causing "Invalid hash" error, disconnect, and
rollback of all synced changes.

- Remove hash field from applyOtUpdate to skip server-side hash check
- Switch applyOtUpdate from fire-and-forget to emitWithAck for reliable ack
- Fix getOldDoc bug: save base doc when changes start accumulating instead
  of incorrectly using current doc (caused wrong delete ops)
- Fix ack handler: only ack when no 'op' field (was acking remote ops too)
- Await fileSyncBridge.start() instead of fire-and-forget
- Add joinDoc retry logic for transient joinLeaveEpoch mismatch errors
- Clear pending ack callbacks on WebSocket close to prevent timeout errors
- Add otUpdateError logging for server-side rejections
- Add file-based bridge logging for debugging sync issues

Co-Authored-By: Claude Opus 4.6 &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
