Skip to content

Improve LaTeX workspace, SyncTeX jumps, and edit safety#101

Open
SmallSpider0 wants to merge 2 commits into
ResearAI:mainfrom
SmallSpider0:fix/latex-workspace-synctex
Open

Improve LaTeX workspace, SyncTeX jumps, and edit safety#101
SmallSpider0 wants to merge 2 commits into
ResearAI:mainfrom
SmallSpider0:fix/latex-workspace-synctex

Conversation

@SmallSpider0
Copy link
Copy Markdown

@SmallSpider0 SmallSpider0 commented May 21, 2026

Problem

DeepScientist's LaTeX editor did not yet feel like a coherent, safe paper-writing workspace for real multi-file manuscripts:

  • Opening chapter files, BibTeX files, or style files could fragment the workflow across separate editor instances instead of staying inside one LaTeX project workspace.
  • The PDF preview could not reliably jump back to the corresponding LaTeX source location.
  • Raw SyncTeX line/column data was not enough for word-level selection, especially across files, repeated words, front matter, and ambiguous rendered tokens such as citation numbers.
  • The editor chrome used more vertical space than necessary for long-form paper editing.
  • If an external process changed the active LaTeX source file, such as an AI edit or terminal command, the editor could keep stale content in memory; saving from that stale buffer could silently overwrite the external change.

Solving this is meaningful because research papers are usually multi-file projects, and DeepScientist agents may edit the same LaTeX files that the user has open. A local-first research OS needs Overleaf-like ergonomics plus local filesystem safety: one project workspace, quick source switching, compile/preview in context, accurate PDF-to-source navigation, and protection against losing edits made outside the browser editor.

Solution

  • Add a recursive LaTeX project manifest API that lists editable/source/resource files, identifies the main file, and records \\input, \\include, bibliography, and style/resource relationships.
  • Compile LaTeX with SyncTeX enabled and persist SyncTeX metadata in build records.
  • Add a reverse SyncTeX API for PDF-to-source lookup.
  • Improve backend source selection by combining SyncTeX samples, PDF word boxes, PDF context words, LaTeX tokenization, macro aliases, front-matter remapping, and confidence-based fallbacks.
  • Avoid false source selections for low-information ambiguous PDF tokens; fall back to line-start cursor placement when evidence is weak.
  • Update the LaTeX editor so files inside the same LaTeX project switch inside one editor, rather than creating duplicate top-level editors or internal source tabs.
  • Add a shared LaTeX open queue and stable LaTeX workspace tab identity.
  • Support first-double-click cross-file PDF jumps by waiting until Monaco is bound to the target source file before applying selection/reveal.
  • Use Monaco selection directly for PDF-to-source jumps and remove the previous marker-style behavior.
  • Add LaTeX/BibTeX Monaco language registration and snippets/highlighting support.
  • Compress the LaTeX editor top bar into a denser single-row layout.
  • Track file revisions when opening/saving quest LaTeX sources so backend optimistic conflict checks can reject stale writes instead of re-reading the latest revision right before save.
  • Refresh the active LaTeX editor automatically when the file changes externally and the local buffer is clean.
  • Pause autosave and show explicit reload/overwrite actions when the file changes externally while the local buffer is dirty.
  • Listen for AI file-diff events, window focus, visibility changes, and periodic polling to catch external source updates.
  • Update English and Chinese workflow docs for the new LaTeX workspace and external-change behavior.

Test

python -m compileall src/deepscientist
pytest tests/test_latex_runtime.py tests/test_api_contract_surface.py tests/test_memory_and_artifact.py::test_save_document_rejects_stale_revision_after_external_change -q
npm --prefix src/ui run build
git diff --check

Result:

36 passed
UI build passed

@SmallSpider0 SmallSpider0 changed the title Improve LaTeX workspace and SyncTeX PDF-to-source jumps Improve LaTeX workspace, SyncTeX jumps, and edit safety May 21, 2026
@SmallSpider0 SmallSpider0 changed the title Improve LaTeX workspace, SyncTeX jumps, and edit safety Improve LaTeX workspace, SyncTeX jumps, and version safety May 21, 2026
@SmallSpider0 SmallSpider0 force-pushed the fix/latex-workspace-synctex branch from e184386 to 1af9fdd Compare May 21, 2026 09:49
@SmallSpider0 SmallSpider0 changed the title Improve LaTeX workspace, SyncTeX jumps, and version safety Improve LaTeX workspace, SyncTeX jumps, and edit safety May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant