Repository navigation
render-pipeline: emit display-list-v2 navigation so \href/\url are clickable (#323) - #737
Conversation
…clickable (#323) What changed: - `v1::CAP_LINKS`: `display-list-v2-links` is negotiated, accepted only next to `display-list-v2`, echoed when accepted, and dropped with the parent. Accepting it declines `display-list-v2-delta`, the way `-window` does: the `display_list_delta` line carries its own header and no `navigation`, so a frame rebuilt from base + delta would have no links at all. - New `links` module: finds every `\url`/`\href` in the source (mirroring the compiler's own `url_argument` — braced arguments, nested braces, `\{`/`\}`, `%` comments, `\nolinkurl` excluded), attributes glyph clusters to them by source span, and unions them into link rectangles. - `DisplayList::navigation`, serialised as the top-level `navigation` object by both JSON writers when `Wire::links` is on and the document has a link. Anything else is byte-for-byte the line it was. The URI has to be read back out of the document's own bytes: the pinned `vendor/compiler` has no link record to read — `\url` keeps only its text and `\href` drops its URL (`let (_url, url_span) = ..`), because #131 never merged. A `\url`/`\href` from a macro body carries the invocation's span and so yields no link; that limitation is documented in the module and in §7 of the proposal, which also corrects its own "producer inputs already exist" claim. Nothing here resolves or opens a URI — it records a string and a rectangle, and the Mac consumer applies its scheme allowlist. Rectangles reproduce pdfTeX: horizontal extent from the link's own glyphs, vertical extent from the line box (the union of the line's cluster boxes, so a roman `\href` and a typewriter `\url` on one line share a top and bottom, as pdflatex gives them), all four sides grown by `\pdflinkmargin` = 1pt. What was run: - cargo test -p flashtex-render-pipeline --test links_navigation test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out - cargo test -p flashtex-render-pipeline --lib test result: ok. 169 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out - pdflatex + PyMuPDF oracle on the same source: https://example.com Rect(165.427001953125, 126.8499755859375, 266.7959899902344, 137.9749755859375) https://ex.org/a Rect(287.49700927734375, 126.8499755859375, 330.4739990234375, 137.9749755859375) emitted: [165.4199, 126.8506, 266.8021, 137.9749] and [287.4972, 126.8506, 330.4739, 137.9749] — max delta 0.007 bp against the proposal's 0.5 bp bar. Next step: the PDF half of #323 as a stacked PR — `render-pipeline/src/pdf.rs` calls `flashtex_pdf::exact::render_exact`, so an exported PDF still has no `/Annots`; `render_exact_with` and `navigation::Navigation` already exist in the pinned `vendor/pdf` and need no vendor edit. Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent subagent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…mance job) What changed: - `crates/perf-bench/src/measure.rs` lists every `v1::Capabilities` field explicitly, so the new `links` field has to be named there too. CI's "engine performance" job builds this crate and failed on E0063. What was run: - cd crates/perf-bench && cargo build --all-targets builds, except the pre-existing macOS-only `memprofile` link error (`_malloc_trim`, a glibc symbol; that bin is built on the Linux runner). - cd crates/flashtex-cli && cargo build --all-targets clean; it is the other crate depending on ../render-pipeline. Next step: none; this closes the only cross-crate fallout of the new field. Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent subagent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
|
Follow-up commit |
… x clusters What changed: - `links::navigation` asked `containing` for every cluster of every page, and `containing` walked the whole span list. On a bibliography page of 500 `\url`s and 200k clusters that is 10^8 comparisons per compile, on the path the "engine performance" job measures. - `SpanIndex` groups spans by document and sorts them by start byte, so attribution is one `partition_point` per cluster. `scan` yields one document's spans already sorted and never overlapping — a `\href` skips past its own body, so a `\url` inside link text is never a second span — which is what makes the single binary search exact rather than approximate; a `debug_assert` pins that invariant. What was run: - cargo test -p flashtex-render-pipeline --lib test result: ok. 169 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out - cargo test -p flashtex-render-pipeline --test links_navigation test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out Next step: none; the emitted bytes are unchanged, this is only the cost of producing them. Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent subagent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
|
Also The single binary search is exact rather than approximate because |
What changed:
- `--links` sets `Wire::links` for `--v2`, alongside the existing `--images`
and `--device-color`. Off by default, so every existing caller's bytes are
unchanged. Without it the binary that the oracle harness and hand debugging
use could not produce a `navigation` object at all.
What was run:
- flashtex-render --tex main.tex --v2 out.json --links, then the emitted line
decoded by the Mac app's own model (apps/mac FlashTeXProtocol, built from
this tree, linked against a 20-line harness):
decoded links: 2 destinations: 0
page 1 class url rects 1 target uri("https://example.com") source main.tex:67..92
page 1 class url rects 1 target uri("https://ex.org/a") source main.tex:97..132
hit at first rect centre -> uri("https://example.com")
hit just outside -> MISS (correct)
so the producer's shape is the one `RenderingV2.Navigation` decodes, and the
consumer's own half-open `Rect.contains` hit test lands on the link.
Next step: none.
Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
What changed: - Drops `apps/mac/Package.resolved`, which `swift build` created in my worktree while I was checking that the emitted `navigation` decodes with the Mac app's own model, and which `git add -A` then swept into 3d8b303. It is not on `main`, this lane does not own `apps/mac`, and nothing in this PR needs it. Removed in a new commit rather than by amending a pushed one. What was run: - git show --stat HEAD: one deletion, apps/mac/Package.resolved. Next step: none. Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent subagent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
The consumer decodes what this emits — verified, not argued`3d8b3030` adds `flashtex-render --links` (parity with `--images` / `--device-color`; off by default, so existing callers' bytes are unchanged). With it I could take a real emitted line and run it through the Mac app's own model — `apps/mac` `FlashTeXProtocol` built from this tree, linked against a 20-line harness that decodes `RenderingV2.Envelope` and uses the consumer's own half-open `Rect.contains`: This mattered because (This is as far as the Swift side can be taken today: the
|
Correction to the whole-crate numbers in the PR bodyThe PR body reports one pre-existing failure. That was read off a partial Same five binaries on a detached Identical. None of them touches links, navigation, capability negotiation or The targeted evidence is unaffected: |
|
Commander (daniel-parent): independent Opus review of
PR #737 — render-pipeline: emit display-list-v2
|
…ries real /Link annotations (#323) Stacked on #737 (merged just above). The perf-bench baseline conflict is resolved to main's file; the four hyperlink fixtures' `export.pdf` digests are re-recorded from a --release run in a follow-up commit on this lane (see `merge_digests.py`). Implementation-Agent: Claude Code (mac-claude-a / lane-integrate2) Commit-Executor: git via Claude Code Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn
…he integration batch + package definitions The pin reads main again after the second integration pass (#827 cherry-picks, #863, #950, #737/#739/#758/#732/#740/#825, visual-oracle tooling) and the `metadata.packages` work (`crate::package_definitions`, tex-expansion's `package_defs.rs`). `git archive` of this tree's `crates/compiler` and `crates/tex-expansion`, PINs at the merge commit, VENDORING.md rows updated, `scripts/check-vendor-pins.sh` both "up to date". render-pipeline 819/0 in both profiles against the new pins; compiler 1368/0, tex-expansion 150/0 release; Mac inventory sync current; swift build clean. Implementation-Agent: Claude Code (mac-claude-a) Commit-Executor: git via Claude Code Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn
What
The producer half of
display-list-v2-links(#323). The Mac consumer hasbeen on
mainsince #333; nothing was emitting for it —crates/render-pipeline/src/v1.rs:67said so outright("
display-list-v2-linksis not negotiated here").v1.rs):CAP_LINKS = "display-list-v2-links", acceptedonly next to
display-list-v2, echoed when accepted, and dropped with theparent (
is_display_list_family). Accepting it declinesdisplay-list-v2-delta, exactly as-windowdoes and for the same reason:the
display_list_deltaline carries its own header and nonavigation, soa frame rebuilt from base + delta would lose every link.
crates/render-pipeline/src/links.rs: finds every\url/\hrefinthe source, attributes glyph clusters to them by source span, and unions
those into link rectangles.
display.rs):DisplayList::navigation, written as thetop-level
navigationobject by both JSON writers (theValuetree andthe direct byte writer) when
Wire::linksis on and the document has alink. Key order is the same alphabetical order, so
write_json_matches_the_value_treestill holds, and it is charged inestimated_json_bytes_forso a declined capability cannot inflate thepre-serialisation size check.
Where the URI comes from — please read this bit
The proposal claims "producer inputs already exist on the compiler side
(
Parsed::hyperref)". They do not. #131 never merged; neithercrates/compilernor the pinnedcrates/render-pipeline/vendor/compilerhasany link record.
\urlkeeps only its typeset text, and\hrefdiscards itsURL outright:
What does survive is the span: every cluster of a link carries the source
range of the construct that produced it. So the URI is read back out of the
document's own bytes at that span (
links::scan, mirroring the compiler's ownurl_argument: braced arguments only, nested braces counted,\{/\}unescaped,
%comments skipped,\nolinkurlexcluded). This is the sametechnique — and the same documented limitation — as the
linebreak-skipfeature: a
\url/\hrefproduced by a macro body carries the invocation'sspan and yields no link. The alternative is a compiler change plus a
vendor/re-pin, which is a different lane.No vendor edit. Nothing here resolves, opens or fetches anything: the producer
records a URI string and a rectangle; the Mac consumer applies its own scheme
allowlist (
DisplayListLinks.allowedURISchemes).Why
\href/\urlare not clickable in the app. The Swift side already decodesnavigationand hit-tests it; it just never receives one. The shipping Macrequest is
[display-list-v2, display-list-v2-images, display-list-v2-links](
PreviewV2View.swift:274), so this is the only missing piece for the preview.Consumer shape — matched, not invented
Checked against
apps/mac/Sources/FlashTeXProtocol/RenderingV2.swiftonmain(Navigation, :523) and its fixture, rather than against the proposalalone. Two things the proposal does not say and the Swift model does:
Navigation.linksandNavigation.destinationsare non-optional, sodestinationsis always written, empty included. A producer that omitted itwould fail
JSONDecoderoutright — this is exactly the drift mac: consume display-list-v2-diagnostics — v2 suggestions reach Problems and Tab-to-fix (after #358) #363 hit.Linkdecodes eitherrectorrects. A wrapped link is emitted asone entry per page carrying
rects, not one entry per line piece as §3describes, so a wrapped link's target/source/identity stay together; a
single-piece link still writes
rect.Overlap check
GH-323-V2-LINKS-PRODUCERheld bydaniel-parent(coord.py claim→CLAIMED).gh pr list --state all --search "links navigation"/"href hyperref":pdf: hyperref link annotations, named destinations and outlines (exact route) + links contract proposal #132 (pdf writer, MERGED), mac: clickable links in the preview — consumer of display-list-v2-links (#323, step 1) #333 (Mac consumer, MERGED), compiler: accept
hyperrefand\hypersetup, and break URLs the way url.sty does (rebase of #385) #388 (compilerhyperref/url breaks, MERGED), compiler: hyperref options, autoref/nameref, link/destination/bookmark records (35/132) #131 (compiler link records, CLOSED,
unmerged — confirmed
2350d0fais not an ancestor oforigin/main). Noopen PR touches
crates/render-pipeline's link path.coord.py claims: no other actor on links/navigation.Test results
Geometry against the oracle. pdflatex + hyperref on
See \url{https://example.com} and \href{https://ex.org/a}{click here} end.,read back with PyMuPDF (
page.get_links(), already y-down from the top-left):emitted (ticks / 2^20):
Largest deviation 0.007 bp, against §4's 0.5 bp bar. Note both rectangles
share a top and a bottom although one is typewriter and the other roman:
pdfTeX takes a link's height and depth from the line box, so the vertical
extent is the union of the line's cluster boxes (
links::line_extent), not thelink's own glyph boxes. Taking it from the link's own glyphs put the
\href2.21 bp short; that is why
line_extentexists.Whole-crate run and the pre-existing failure:
Pre-existing on
main— the identical assertion fails on a clean9c5b028dworktree, unrelated to this change (colorbox path drawing). Everyother binary is green.
Not done
render-pipeline/src/pdf.rscallsflashtex_pdf::exact::render_exact, so an exported PDF still has no/Annots.navigation::Navigationandrender_exact_withalready exist inthe pinned
vendor/pdf(pdf: hyperref link annotations, named destinations and outlines (exact route) + links contract proposal #132), so this needs no vendor edit — it is astacked PR on this branch, per the small-PR preference.
destinationsentries,outline,outline_open,page_mode,open_action,infoandborder/colorare all hyperref option/anchor state that the pinnedcompiler does not expose. Every link is therefore
class: "url"with auritarget;target: {destination: ..}needs compiler: hyperref options, autoref/nameref, link/destination/bookmark records (35/132) #131's compiler records and avendor/re-pin.warning still fires even when the capability is negotiated. It comes from the
frozen
vendor/compilerand suppressing it here would change thediagnosticsbytes of an otherwise unrelated reply; it should go with there-pin.
apps/mac's test target does not compile onmain(
PreviewV2Tests.swift:807, from Preview page readout works on the pane that ships #689), so the Swift side of this could notbe executed end to end. That is main's state, not this branch's, and is worth
its own fix.
🤖 Generated with Claude Code
https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz