Repository navigation
Export PDF: four routes collapse to one (flashtex-pdf-exact), Print sends its bytes, long documents still export - #671
Merged
Merged
Conversation
Four PDF export affordances collapse to one. The three removed routes each wrote a lower-fidelity version of the same document: - `File > Export PDF…` (⌘⇧E) drew the runtime-v1 page items with CoreGraphics: Times fallback faces, no images, monochrome. - `File > Export PDF via Rust Writer…` (⌘⌥E) piped the v1 envelope to `flashtex-pdf`, which re-encodes by character (a self-described SHIM). - `Export PDF (v2)…` in the v2 pane ran the preview's own draw routine (labelled experimental). What stays is the exact route, now plain `File > Export PDF…` on ⌘⇧E: the loaded display list through `flashtex-pdf-exact from-v2` — original GIDs, embedded font programs, verbatim decimals, typed rules, `path_fill`/ `path_stroke` and image XObjects. `flashtex build` already standardised on it. The README's "the exact route refuses images / TikZ" notes were stale; crates/ pdf `v2.rs` paints both today. `File > Print…` (⌘P) now prints exactly those bytes instead of a parallel CoreGraphics rendering, so Print and Export can no longer disagree. Producing them runs the tool, so `PrintController.printableDocument` is async and `prepareDocument` takes finished bytes rather than a `CompileResult`. Print and Export share one predicate (`ShellModel.exportPDFRefusal()`): a historical preview refuses, a windowed display list refuses by name rather than writing blank pages, and a missing `flashtex-pdf-exact` is reported. Menu enablement reads a new change-only mirror, `toolbarExportable`, so the File menu does not re-evaluate on every v2 frame. `PDFExport.render` survives only as the capture-proposal preview painter and `GlyphRunRenderer.pdfData` only as the export side of the parity harness; both go with the v1 preview renderer in the follow-up. Implementation-Agent: claude-opus-5 (export-consolidation lane) Commit-Executor: claude-opus-5 direct git (Cursor usage limit) Co-authored-by: GoKubar <[email protected]>
… media box) Implementation-Agent: claude-opus-5 (export-consolidation lane) Commit-Executor: claude-opus-5 direct git (Cursor usage limit) Co-authored-by: GoKubar <[email protected]>
Without this, collapsing to the exact route would have *introduced* a regression: a document long enough to engage `display-list-v2-window` could still be exported today through the (bad) v1 route, and after the collapse could not be exported from the app at all. Re-requesting an unwindowed display list does not work: the window engages only after the producer has already refused the unwindowed reply as over the 16 MiB reply limit, so the same request would be refused again. That ceiling belongs to the JSON Lines transport, not to the document. The producer's own `--v2 FILE` side output has no line limit, and `flashtex-render` writes the complete list of the last render to it even when the reply it sent was the over-limit refusal — `Outputs::write` runs off `Reply.rendered`, which that refusal still carries (render-pipeline protocol.rs). So Export and Print now run the same producer binary one-shot in worker mode, hand it the current buffers on stdin, ignore the reply, and take the complete list from the file. This is what `flashtex build --v2` does. The list is produced from the request the app just sent, so it matches the editor by construction; the file is private to the run and read only after the process exited, so there is no freshness check and no torn read. No Rust change. The refusal copy now distinguishes the two situations the coordinator asked to separate: "windowed for viewing" is not a refusal at all, while a windowed document with no discoverable `flashtex-render` says it is too large to send in one reply and names both fixes (attach with ⌘⇧R, or `flashtex build`). Implementation-Agent: claude-opus-5 (export-consolidation lane) Commit-Executor: claude-opus-5 direct git (Cursor usage limit) Co-authored-by: GoKubar <[email protected]>
Implementation-Agent: claude-opus-5 (export-consolidation lane) Commit-Executor: claude-opus-5 direct git (Cursor usage limit) Co-authored-by: GoKubar <[email protected]>
Also neutral progress wording: the same resolver serves Print. Implementation-Agent: claude-opus-5 (export-consolidation lane) Commit-Executor: claude-opus-5 direct git (Cursor usage limit) Co-authored-by: GoKubar <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The app offered four PDF export affordances. Three of them wrote a
lower-fidelity version of the same document:
flashtex-pdf, a self-described SHIM that re-encodes by characterThe exact route survives, renamed to plain
File > Export PDF…on ⌘⇧E.flashtex buildalready standardised on it. The other three are removed.Print
File > Print…(⌘P) printed a separate CoreGraphics rendering, so Print andExport could disagree about the same document. It now prints exactly the bytes
Export writes. Producing them runs the tool, so
PrintController.printableDocumentis
asyncandprepareDocumenttakes finished bytes instead of aCompileResult.Print and Export share one predicate,
ShellModel.exportPDFRefusal():(a document big enough to engage the page window has to go through
flashtex build— called out indocs/user/gui.md);flashtex-pdf-exactis reported instead of silently disabling.Menu enablement reads a new change-only mirror,
toolbarExportable, so the Filemenu is not re-evaluated on every v2 frame.
Long documents still export (the regression this would otherwise have shipped)
A document long enough to engage
display-list-v2-windowcould, before this PR,still be exported through the low-fidelity v1 route. Collapsing to the exact
route alone would have left it with no in-app export at all.
Re-requesting an unwindowed list does not fix that: the window engages only
after the producer has already refused the unwindowed reply as over the 16 MiB
limit (
V2PageWindow.swift—overLimitFailure/declinedSiblingare the onlycallers of
engage()), so the same request would be refused again. That ceilingbelongs to the JSON Lines transport, not to the document.
The producer's own
--v2 FILEside output has no line limit, andflashtex-renderwrites the complete list of the last render to it even whenthe reply it sent was the over-limit refusal —
Outputs::writeruns offReply.rendered, whichcrates/render-pipeline/src/protocol.rs:502stillcarries on that path. So Export and Print now run the same producer binary
one-shot in worker mode, hand it the current buffers on stdin, ignore the reply,
and take the complete list from the file (
WholeDocumentList.swift). This iswhat
flashtex build --v2does. No Rust change. The list comes from therequest the app just sent, so it matches the editor by construction; the file is
private to that run and read only after the process exited, so there is no
freshness check and no torn read.
The two situations now read differently, because they are different:
re-renders, reporting "Rendering all N pages…" in the status bar;
flashtex-renderdiscoverable → "this document is too largeto send in one reply… attach it with ⌘⇧R, build crates/render-pipeline, or run
flashtex build".Stale docs corrected
apps/mac/README.mdclaimed the exact route "still refuses image items" and"refuses
path_fill/path_stroke", recommendingExport PDF (v2)…for those.crates/pdf/src/v2.rspaints both today (glyph_run, rule, path_fill, path_stroke and image), so removing the draw-routine export costs no fidelity.What is left of the removed code
PDFExport.rendersurvives only as the capture-proposal preview painter(
ProposalPreview.swift) andGlyphRunRenderer.pdfDataonly as the export sideof the v2 parity harness. Both go with the v1 preview renderer in the follow-up.
Verification
Mac gate on
mac-m1max-aunder the fleet lock, real Rust release binaries(
FLASHTEX_PDF_EXACT,FLASHTEX_RENDER, …):swift buildexit 0;swift testexit 0; 1370 tests, 12 skipped, 0 failures, against the 1364 / 11 / 0 baseline.
The +6 / +1 delta is this branch's own tests (
RustPDFExportTestsandRustPDFExportPipeTestsremoved,PrintControllerTestsrewritten and extended).Both windowed tests ran rather than skipped, which is the point — the
re-render path passed in 0.094 s and the no-producer refusal in 0.007 s. Also
green:
testDocumentPrintIsTheExactExportOfTheSameDisplayList(real tool; theprinted bytes compared against a direct
flashtex-pdf-exactrun) and the wholeV2WindowTests/V2WindowLiveTestssuite including the 40-page over-limitend-to-end case.
An earlier run showed two
RuntimeTranscriptTestsfailures on a file this branchdoes not touch. Confirmed environmental rather than assumed: run in isolation
under the lock, 3/3 green on
origin/mainand 3/3 green on this branch. Theone genuine failure that run (a fractional media box PDFKit reports rounded) was
mine and is fixed in e63bb84.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu