Skip to content

Improve LaTeX editor save, compile, and editing assistance#99

Open
SmallSpider0 wants to merge 5 commits into
ResearAI:mainfrom
SmallSpider0:fix/latex-save-compile-main-file
Open

Improve LaTeX editor save, compile, and editing assistance#99
SmallSpider0 wants to merge 5 commits into
ResearAI:mainfrom
SmallSpider0:fix/latex-save-compile-main-file

Conversation

@SmallSpider0
Copy link
Copy Markdown

@SmallSpider0 SmallSpider0 commented May 20, 2026

Summary

  • Improve the LaTeX editor save path so dirty state, active file selection, and compile target stay consistent across file switches.
  • Add background autosave for LaTeX source edits, with save-failure state preserved instead of silently clearing unsaved changes.
  • Add manual save compile-on-save behavior: Ctrl/Cmd+S or the Save button saves the active LaTeX file and, by default, starts one PDF compile after the save succeeds.
  • Keep background autosaves lightweight: autosave only persists source edits and does not trigger PDF compilation.
  • Add a default-on Auto compile on save toggle so users can disable manual-save-triggered compilation per LaTeX project.
  • Compile the selected main file explicitly instead of relying on stale editor state or folder heuristics.
  • Register Monaco-backed LaTeX and BibTeX languages so .tex and .bib files no longer render as plaintext.
  • Add LaTeX/BibTeX tokenization and editing assistance for commands, math spans, comments, environments, citations, labels, and BibTeX entries.

Root Cause

The LaTeX editor previously depended mainly on manual save and compile actions. This made it easy to lose recent edits if the user refreshed, switched files, or forgot to save before compiling. It also allowed save/compile ordering problems where the build could use stale content or the wrong main file.

At the editor layer, Monaco was mounted with plaintext and only bare custom language IDs were registered at runtime. As a result, Monaco had no useful tokenizer, comment configuration, bracket/autoclose behavior, or rich completion behavior for LaTeX and BibTeX.

Fix

  • Added autosave for LaTeX editor buffers with dirty-state race protection.
  • Added Ctrl/Cmd+S handling for the LaTeX editor.
  • Added manual-save compile-on-save:
    • Save and Ctrl/Cmd+S save first.
    • If the save succeeds and the buffer is clean, one compile is started.
    • Background autosaves do not compile.
    • If a compile is already queued/running, no duplicate compile is started.
  • Added a persisted Auto compile on save toggle, defaulting to enabled.
  • Passed main_file_id into LaTeX compile requests so the selected main file is compiled consistently.
  • Added reusable Monaco LaTeX/BibTeX language registration.
  • Switched the LaTeX plugin editor to custom Monaco language IDs.
  • Extended completions with LaTeX commands, environments, citation/label suggestions, and BibTeX snippets.
  • Updated English and Chinese workflow docs to describe autosave and manual-save compile-on-save behavior.

Testing

  • git diff --check
  • npm --prefix src/ui run build
  • python -m compileall src/deepscientist

@SmallSpider0 SmallSpider0 changed the title Fix LaTeX editor save errors and compile target selection Improve LaTeX editor save, compile, and editing assistance May 20, 2026
Add debounced autosave, Ctrl/Cmd+S handling, save failure status, lifecycle protection, and race-safe dirty-state handling for the LaTeX editor. Update localized UI strings and workflow docs.
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