Compile editor buffers without waiting for a save
Project preview accepts ?buffer=1 and reads the editor text from the POST body. The source is still expanded with project includes/packages/images, but the file on disk is not touched, so typing can drive layout immediately while the normal 450 ms save timer runs independently. Add a server test that previews buffer text, finds it in the SVG, and verifies hello.tex on disk was not rewritten. Roadmap notes that warm buffer previews are still ~430 ms (article) and ~2.1 s (arXiv), and that dirty-page streaming is the next latency step.
This commit is contained in:
1 parent
30f1df03ca
commit
e2e80e8728
7 files changed
+61
-10
No files matched your search
@@ -51,7 +51,7 @@ floats (`\floatsep`, `\textfloatsep`, `\intextsep`, `\topfraction`,
|
||||
absolute limits, splitting), marks, Rust output hook, multi-page PDF, and the
|
||||
route-D service endpoints (`/api/route-d/preview|pdf|edit`, project preview and
|
||||
PDF opt-in with `?engine=route-d`; flat `/preview` and project previews now
|
||||
prefer route-D with a v1 fallback). 1070 workspace tests are green and no oracle
|
||||
prefer route-D with a v1 fallback). 1071 workspace tests are green and no oracle
|
||||
fixture is ignored. Preview JSON also carries a `warnings` array naming
|
||||
environments route-D cannot lay out and control words that survived layout, so
|
||||
unsupported source is reported instead of being silently typeset.
|
||||
|
||||
@@ -16,20 +16,20 @@ cargo test --workspace --offline
|
||||
|
||||
or run `./scripts/verify-route-d.sh`, which executes both.
|
||||
|
||||
The workspace currently passes **1070 tests**:
|
||||
The workspace currently passes **1071 tests**:
|
||||
|
||||
| Suite | Tests |
|
||||
| --- | --- |
|
||||
| route-D unit (engine) | 444 |
|
||||
| engine binary unit | 433 |
|
||||
| server integration | 65 |
|
||||
| server integration | 66 |
|
||||
| v1 integration | 71 |
|
||||
| pdfLaTeX oracle | 42 |
|
||||
| route-D integration | 10 |
|
||||
| engine/core unit | 4 + 1 |
|
||||
|
||||
Latest full run (web trial increment): `./scripts/verify-route-d.sh` passes
|
||||
with fmt clean and **1070 tests** green.
|
||||
with fmt clean and **1071 tests** green.
|
||||
|
||||
Latest live check (2026-10-27): the debug server served `examples/hello.tex`
|
||||
from `target/debug/texrra serve`; `POST /preview` answered 200 with
|
||||
|
||||
+2
-2
@@ -370,7 +370,7 @@ Math coverage includes fractions/roots, scripts, `\left...\right` with body-scal
|
||||
|
||||
Paragraph units carry a `ParagraphFont`; `Unit::paragraph_with_face` and `Unit::paragraph_with_style_and_face` select Roman, bold, italic, mono, or sans. The corresponding Computer Modern TFM (`cmr10`, `cmbx10`, `cmti10`, `cmbxti10`, `cmtt10`, `cmss10`, `cmssbx10`, `cmssi10`, `cmcsc10`) supplies advances, kerns, ligatures, and italic correction for layout, the display list selects the matching face, and the PDF writes Computer Modern Type1 outlines for each built-in face (`cmr10`/`cmbx10`/`cmti10`/`cmbxti10`/`cmtt10`/`cmss10`/`cmssbx10`/`cmssi10`/`cmcsc10`, plus `cmmi10` for mathematical italic letters, `cmsy10` for math symbols and `cmex10` for big operators), falling back to Liberation subsets only for characters the Type1 encodings cannot address; those fallback glyphs keep their Unicode text under PDF extraction, so accented and Greek words round-trip; Type1 faces carry a ToUnicode CMap built from the requested characters, so glyphs whose names are ambiguous in the Adobe Glyph List (capital Omega, which would otherwise extract as U+2126) keep their intended code points. `Engine::edit` preserves the face when reflowing an edited paragraph.
|
||||
|
||||
The crate currently has 444 unit tests plus ten route-D integration tests and forty-two oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 1070 tests (444 core unit, 433 engine binary unit, 10 route-D integration, 42 oracle, 71 v1 integration, 65 server, 4 engine unit, 1 core unit), with none ignored. The flat `/preview` endpoint and the project preview/PDF endpoints now try route-D first and fall back to v1 on error (`?engine=v1` or `TEXRRA_ENGINE=v1` forces v1; flat and project responses carry `X-Preview-Engine`, naming the engine used). A geometry-less project now defaults to Letter, matching pdfLaTeX, where the old v1 path used A4.
|
||||
The crate currently has 444 unit tests plus ten route-D integration tests and forty-two oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 1071 tests (444 core unit, 433 engine binary unit, 10 route-D integration, 42 oracle, 71 v1 integration, 66 server, 4 engine unit, 1 core unit), with none ignored. The flat `/preview` endpoint and the project preview/PDF endpoints now try route-D first and fall back to v1 on error (`?engine=v1` or `TEXRRA_ENGINE=v1` forces v1; flat and project responses carry `X-Preview-Engine`, naming the engine used). A geometry-less project now defaults to Letter, matching pdfLaTeX, where the old v1 path used A4.
|
||||
|
||||
### M0 incremental demo
|
||||
|
||||
@@ -524,7 +524,7 @@ deliberately open rather than approximated:
|
||||
|
||||
## Limits and remaining gaps
|
||||
|
||||
The suite currently stands at 1070 passing tests, with the workspace clean.
|
||||
The suite currently stands at 1071 passing tests, with the workspace clean.
|
||||
Route-D serves both flat `/preview` and project preview/PDF requests by default
|
||||
(automatic v1 fallback; `?engine=v1` or `TEXRRA_ENGINE=v1` opts out). The
|
||||
objective's areas are implemented to the limits below; complex-script shaping is
|
||||
|
||||
@@ -49,11 +49,16 @@ execution is not a goal.
|
||||
- project-scoped sessions and changed-page reporting;
|
||||
- web `applyPages` skips pages whose hash is unchanged;
|
||||
- a 90 ms preview debounce and 450 ms save debounce.
|
||||
- Incremental progress in the working tree:
|
||||
- project previews accept `?buffer=1` with the editor text as the request
|
||||
body, so preview no longer waits for the 450 ms disk save;
|
||||
- the web editor previews on a 40 ms debounce while saving on the old timer;
|
||||
- `changedPages` already identifies the pages that need repainting.
|
||||
- Incremental bottlenecks:
|
||||
- the server still returns every page's SVG JSON;
|
||||
- the browser downloads all pages before hash-skipping;
|
||||
- project edits wait for the save timer before preview;
|
||||
- the arxiv project's preview/layout is still in the 1.4–1.5 s range;
|
||||
- measured warm buffer previews are still about 430 ms for article-basic
|
||||
and 2.1 s for the arXiv template; the <100 ms target is not met;
|
||||
- no WebSocket/SSE stream or dirty-page patch protocol.
|
||||
|
||||
## Architecture
|
||||
|
||||
@@ -46,7 +46,7 @@ now means route-D.
|
||||
|
||||
| Area | Route-D | Evidence / impact |
|
||||
| --- | --- | --- |
|
||||
| Article/report basics: title, sections, lists, TOC, page numbers | Supported | corpus and 1070-test suite |
|
||||
| Article/report basics: title, sections, lists, TOC, page numbers | Supported | corpus and 1071-test suite |
|
||||
| Inline/display math, equations, tags, cleveref | Supported | math tests, oracle fixtures |
|
||||
| Floats, captions, tables, booktabs | Supported | table/math tests, corpus |
|
||||
| PNG/JPEG/BMP `\includegraphics` | Supported | project image tests |
|
||||
|
||||
+13
-1
@@ -1532,10 +1532,22 @@ fn handle_project_request(
|
||||
}
|
||||
}
|
||||
(&Method::Post, [id, "preview"]) => {
|
||||
let (source, file_name) = match store.main_source(id) {
|
||||
let (mut source, file_name) = match store.main_source(id) {
|
||||
Ok(source) => source,
|
||||
Err(error) => return respond_api_error(request, 422, &error),
|
||||
};
|
||||
if query_param(url, "buffer").is_some() {
|
||||
let bytes = match read_body_bytes(&mut request, MAX_SOURCE_BYTES) {
|
||||
Ok(bytes) => bytes,
|
||||
Err(error) => return respond_api_error(request, 413, &error),
|
||||
};
|
||||
source = match String::from_utf8(bytes) {
|
||||
Ok(source) => source,
|
||||
Err(_) => {
|
||||
return respond_api_error(request, 400, "preview buffer is not UTF-8");
|
||||
}
|
||||
};
|
||||
}
|
||||
if uses_route_d(url) {
|
||||
let expanded = expand_project_source(&source, &store, id);
|
||||
let images = load_project_images(&expanded, &store, id);
|
||||
|
||||
@@ -1258,6 +1258,40 @@ fn project_preview_resolves_bibtex() {
|
||||
assert!(!text.contains("[?]"), "{text}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_preview_compiles_the_editor_buffer_without_saving() {
|
||||
let server = TestServer::start("route-d-buffer");
|
||||
let buffer =
|
||||
"\\documentclass{article}\n\\begin{document}\n\nBuffer preview.\n\n\\end{document}\n";
|
||||
let preview = server.request(
|
||||
"POST",
|
||||
"/api/projects/hello/preview?engine=route-d&buffer=1",
|
||||
buffer.as_bytes(),
|
||||
"text/plain; charset=utf-8",
|
||||
);
|
||||
assert_eq!(preview.status, 200, "{}", preview.text());
|
||||
let value: Value = serde_json::from_slice(&preview.body).expect("preview JSON");
|
||||
assert_eq!(value["status"], "ok", "{}", value["message"]);
|
||||
let mut text = String::new();
|
||||
for page in value["pages"].as_array().expect("pages") {
|
||||
if let Some(svg) = page["svg"].as_str() {
|
||||
for piece in svg.split('>') {
|
||||
if let Some(content) = piece.split('<').next() {
|
||||
text.push_str(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let text: String = text.split_whitespace().collect();
|
||||
assert!(text.contains("Bufferpreview"), "{text}");
|
||||
let raw = server.get("/api/projects/hello/raw?path=hello.tex");
|
||||
assert_eq!(raw.status, 200);
|
||||
assert!(
|
||||
!raw.text().contains("Buffer preview"),
|
||||
"buffer preview must not write the file"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_preview_can_switch_to_route_d() {
|
||||
let server = TestServer::start("route-d-toggle");
|
||||
|
||||
Reference in new issue
Block a user