Records the #73 pivot: reading = apex → HTML → WKWebView + our CSS; ADR-0010's reading stance superseded, editing stance stands; ADR-0001 boundary ruled (native-only governs editing, reading is presentation). Bundling: prebuilt binary in resources, signed + notarized. TextKit reading machinery deleted, not fallback.
1.9 KiB
1.9 KiB
0011 — Apex HTML reading pipeline
Reading mode renders markdown through apex (MIT, unified dialect) as an HTML fragment loaded into a single WKWebView styled by our CSS — typography slots become CSS custom properties, and a blank-line-chunked data-source-line stamp (sentinel HTML comments, applied post-conversion; apex emits no source positions) carries the click-to-edit and scroll-sync map at paragraph granularity. Proven live in the #74 spike (PERF-3k: ~18 ms apex, 33 ms end-to-end, zero mis-stamps corpus-wide); ruled in #73. Supersedes ADR-0010's reading stance — its editing stance (TextKit2 mode B) stands — and records ADR-0001's boundary as ruled: native-only governs the editing side; reading is presentation, so WKWebView is allowed.
Considered Options
- TextKit reading renderer (#71 build) — deleted, not kept as fallback: fallbacks rot, and its stale-flow defect dies unfixed by design. The decoupling obligation (editing side up to par as a plain-text surface) is ticketed separately (#77).
loadFileURLinstead ofloadHTMLString— 4× first paint (255 ms vs ~67 ms) from sandbox negotiation;--embed-imagesbase64 inlining needs no file access at all and writes nothing into the vault.
Consequences
- Bundling: the prebuilt apex binary ships in app resources, signed + notarized. No source build in CI, no user install gate — a renderer must not grow a gate.
- One WKWebView, reloaded in place. Remounting per document (
.id(sel)) was the dominant switch cost — hundreds of ms of web-process respawn;loadHTMLStringon a retained view feels instant. --no-mixed-listsis required, not tuning: apex's default merges an ordered list following a bullet list into one<ul>, killing1. 1. 1.auto-renumbering.- Early handoff: stdout EOF is conversion done; apex's ~65 ms teardown is reaped async via
terminationHandler(the error path still waits for exit status).