dsh-latex-studio: Implementing an Overleaf-Style LaTeX Workbench in DSH's Right Sidebar

Introduction

When working on agent development with DeepSeek Harness (DSH), you’ll frequently encounter LaTeX documents: writing papers, creating reports, generating materials with heavy formula usage. However, DSH’s chat pane doesn’t come with a built-in LaTeX editor. Every time you need to make changes, you have to edit files in an external editor, paste them back into DSH, or rely on the pdflatex command in the terminal. This fragmentation makes debugging and previewing cumbersome.

The tool introduced below, dsh-latex-studio, is designed to solve exactly this problem: it brings the Overleaf-style workflow—editing .tex on the left, with a live PDF preview on the right—into DSH’s right sidebar. Editing, compiling, and sync navigation all happen within the same window, without squeezing out the chat column.

What It Is

dsh-latex-studio is a LaTeX editing and preview plugin that runs in the DSH sidebar, developed by maintainer LZHMS. Its core value is enabling users to edit, compile, and preview LaTeX documents entirely within DSH, with Overleaf-style features such as sync navigation, multi-engine compilation, and automatic main document discovery.

Editor

The editor supports the following features:

  • Syntax highlighting: commands, environments, comments, inline math, braces, and separators, with colors that automatically adapt to the active theme.
  • Line number gutter: zero-padded numbers, synchronized with scrolling; in soft-wrap mode, line numbers align with logical lines, and continuation lines remain blank.
  • Current line highlighting: the line under the cursor gets a background color, and it follows correctly during scrolling and soft-wrapping.
  • Two-level undo: ↶/↷ keys enter/exit an edit group, allowing you to undo a combined operation at once; ⇤ jumps directly back to the most recent saved state.
  • Save logic: Ctrl+S to save; unsaved content is automatically saved before compilation; an unsaved file shows a ● dot before its name.
  • Zoom: Ctrl + mouse wheel or Ctrl + +/-/0 works in both the editor and the PDF view, ranging from 8–28 px (editor) / 40–300% (PDF).
  • Soft wrap: toggle with Alt+Z.
  • Inline annotations: select text and click the Comment button; the annotation content is written to a hidden sidecar file next to the .tex (the source file remains unmodified); annotated lines get a yellow background and a chip in the gutter; unfinished drafts are kept in memory and can be restored at any time.

Compilation

The compilation feature includes:

  • Engines: supports pdflatex, xelatex, and lualatex, auto-detected from PATH (MiKTeX or TeX Live); the toolbar displays the actual version of the current engine.
  • Mode menu: a dropdown next to Compile offers three modes:
  • Recompile: single-pass compilation.
  • Clean and recompile: cleans auxiliary files first, then compiles, preserving .bbl and PDF.
  • Auto compile: triggers automatically on save and when external file changes are accepted.
  • Main document discovery: after opening a sub-file (e.g., sec/method.tex) and compiling directly, the plugin automatically locates the root document (prefers main.tex, requiring it to contain \documentclass); if the root document has the sub-file commented out, the status bar will notify you.
  • Log handling: the Logs button tallies errors, warnings, and notices (red ⚠ and info counts); clicking it switches the PDF panel to a full-height log view, color-coded by severity.

PDF Panel

PDF preview is powered by the built-in pdf.js, with lazy-loaded per-page canvases to keep memory usage under control.

  • Selectable text: an independent text layer, pixel-aligned with the canvas.
  • Bidirectional SyncTeX: double-click in the source to scroll the PDF to the corresponding page; scroll or click a page in the PDF and the editor follows; relies on the system’s synctex utility and works correctly in multi-document projects.
  • Zoom: adjust via Ctrl + mouse wheel or the floating -/%/+ buttons, ranging from 40–300%.
  • Layout modes: </> source mode · ▯▯ split view · 🖹 PDF only; mode-switching buttons are also available in the source toolbar.

Multi-Writer Safety (Agent + Device Collaborative Editing)

When an agent or another program edits the same .tex file concurrently, the plugin provides the following safeguards:

  • 5-second watcher: when you have no unsaved edits, external file changes are automatically accepted; this prevents a stale buffer from overwriting the agent’s work.
  • Merge on unsaved edits: saving triggers a three-way line merge; if a “same-block inserted on both sides” duplicate is detected, it’s deduplicated into one; only truly overlapping edits will cause an abort.
  • Backup snapshots: before each write, the previous on-disk version is saved to .dsh-latex-studio-backups/, with the most recent 5 snapshots retained per file.

Installation & Enablement

Install from npm:

@zhaolee/dsh-latex-studio

Or install from source / GitHub Release tarball via DSH Desktop’s “Plugin Manager → Add plugin”.

Requirements

  • A TeX distribution (TeX Live / MiKTeX) must be installed on your machine, with at least one of pdflatex, xelatex, or lualatex available in PATH.
  • Documents must reside within the session’s workspace or in a location readable by the DSH process.

Caveats

  • Default is single-pass compilation: biblatex/biber, makeindex, and multi-pass cross-references require a second compilation pass to complete.
  • The compilation engine runs in the DSH Host user’s environment, with no container isolation.
  • Reverse sync is at page granularity (jumps to the first line of that page), not paragraph-anchored.
  • Annotations are anchored to logical lines (contextual content stored in a sidecar file); unfinished annotation drafts reside in memory, while saved annotations are persisted to the sidecar file.

Use Cases

Ideal for users who need to edit, preview, and debug LaTeX documents within DSH, especially those who frequently switch between source and PDF, or need to collaborate with an agent on document authoring.

Summary

dsh-latex-studio brings an Overleaf-style LaTeX workspace into the DSH sidebar, offering syntax highlighting, line numbers, sync navigation, multi-engine compilation, and more, with merge and backup protections tailored for multi-writer scenarios. If you write LaTeX in DSH, this plugin can reduce your dependency on external tools.

  • Directory page: https://www.skillhub.cn/plugins/LZHMS/dsh-latex-studio
  • GitHub: https://github.com/LZHMS/dsh-latex-studio
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye