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:
gloamxun committed 2026-10-27 21:01:24 +08:00
1 parent 30f1df03ca
commit e2e80e8728
7 files changed
+61 -10

No files matched your search

+13 -1
View File
@@ -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);