Make the engine choice explicit and show route-D telemetry

The toolbar now treats the engine as route-d|v1 instead of a boolean whose v1
state omitted the query parameter (which now means route-d on the server). Both
preview and PDF always send an explicit engine query, the old localStorage key
migrates, and route-D is the default with a v1 escape hatch.

The preview status tolerates a missing duration, displays the warning count with
details on hover, and reports when X-Preview-Engine differs from the selected
engine; PDF export shows a fallback notice. The README documents the toggle and
the X-Preview-Engine response header.
This commit is contained in:
gloamxun committed 2026-10-27 12:23:32 +08:00
1 parent 24c95938d2
commit cecad51f91
3 files changed
+53 -16

No files matched your search

+13 -5
View File
@@ -29,6 +29,12 @@ The landing page manages uploaded projects; opening one switches to the editor.
hash changed, so typing does not reload the view or jump the scroll position.
- Page cards take their aspect ratio and width from the preview payload, so A4
and Letter documents are both displayed without distortion.
- The preview toolbar switches between the experimental **Route-D** core and the
legacy **v1** pipeline. The choice is stored in `localStorage` and applies to
both preview and PDF export; Route-D is the default. The response header
`X-Preview-Engine` reports the engine that actually rendered (including a
fallback), and the status line shows preview duration, page count, warning
count (details on hover) and any engine fallback.
## Run
@@ -72,12 +78,14 @@ The frontend assumes the engine is the same origin and exposes:
| `PUT /api/projects/<id>/file?path=` | Write a text file |
| `POST /api/projects/<id>/files?path=` | Upload a file |
| `DELETE /api/projects/<id>/file?path=` | Delete a file |
| `POST /api/projects/<id>/preview` | Live preview of the main file |
| `POST /api/projects/<id>/pdf` | PDF of the main file |
| `POST /api/projects/<id>/preview?engine=route-d\|v1` | Live preview of the main file |
| `POST /api/projects/<id>/pdf?engine=route-d\|v1` | PDF of the main file |
The preview response is a JSON object with `status`, `durationMs`,
`pageWidthMm`, `pageHeightMm`, and `pages` (one inline SVG and hash per page).
Font faces are loaded from `/fonts.css` and `/fonts/*.ttf`.
Preview and PDF responses carry `X-Preview-Engine: route-d|v1`. The preview
response is a JSON object with `status`, `durationMs`, `pageWidthMm`,
`pageHeightMm`, and `pages` (one inline SVG and hash per page); Route-D
responses additionally carry `warnings` and edit metadata (`changedPages`,
`recomputedPages`). Font faces are loaded from `/fonts.css` and `/fonts/*.ttf`.
## Design notes