3.6 KiB
3.6 KiB
Issue 76 — Task: build the apex HTML reading surface (S1.2)
Date: 2026-10-06 Type: issue Reference: Wayfinder map #20 · ADR-0011 · spike #74 · ADR #75
What landed
Branch wayfinder/76-apex-html-reading (off the #75 ADR branch, which merged #71's landing — the swap needs the surface it replaces), commits cc04ec2 (feature) + f1c915f (lint/DOX).
Rewritten
Museion/ReadingPresenter.swift— the apex HTML pipeline:stampSource(blank-line chunker,<!--S:N-->sentinels) →apexRender(bundled binary;-t html --no-mixed-lists --embed-images [--base-dir]) →stampHTML(regex restamp todata-source-line) →page(for:postFolder:)withstyleSheet()(ProseTypography slots + flow knobs as CSS custom properties; family names, weight rides CSS).blocks(for:)= line↔UTF-16-range map (the #68 contract). Fallback = escaped source<pre>; footnotes render natively (apex upgrade over #69's fallback).Museion/ReadingSurface.swift—ReadingStateBox/CaretHintBoxkept; one WKWebView reloaded in place (render keyed generation+text+flowKey); probeJS click→edit at clicked block, ⌘-click→NSWorkspace, scroll→top-line into stateBox;decidePolicyForallows only our about:blank main-frame load; entry scroll afterdidFinish; defaults observer reloads on flow-key change.Museion/Resources/apex— apex 1.1.17 universal binary (1.8 MB); the fs-sync root group ships it into Resources automatically (verified in the built .app — no pbxproj edit).
Deleted (ADR-0011: no fallbacks — the stale-flow defect dies unfixed): ReadingCanvasView, Decoration, table/quote/HR content blocks, framesForRange, ImagePopoverView.
Untouched: #68 toggle wiring, ProseTypography, ProsePresenter, Settings pane.
Verification
xcodebuild testgreen (94 tests; pipeline tests run the real bundled binary — mixed-lists split,1. 1. 1.renumber, base64 embed, exactdata-source-linestamps). SwiftLint 0 errors, SwiftFormat clean on touched files.- Live in-app: kitchen-sink + PERF-3k render formatted, toggle instant (apex ~20 ms/render ×3), click-to-edit lands at the clicked paragraph, frontmatter invisible. Alexander clicked around the live app mid-session — no crash, no defect.
- Perfect gates: PERF-3k pass (20 ms ≪ spike's 33 ms end-to-end).
Lessons
- fs-sync root groups DO ship nested non-source files into Resources —
Museion/Resources/apexneeded no pbxproj wiring. Verify in the built .app before assuming either way (my first check read a stale DerivedData tree from a different project hash and nearly sent me into pbxproj surgery). - SwiftFormat between write and patch reflows closures — re-read before patching (skill-documented; bit anyway).
- Long
write_filecalls can corrupt mid-file (garbled unicode, truncated CSS) — write shorter files or verify after. execute_codestring replacements can inject literal control chars into escape sequences (a"\t"became a raw tab → "Unprintable ASCII character" build error). Fix byte-level with Python, verify withcat -v.- apex quirks folded into tests: tables wrapped in
<figure>with stray<figcaption>(CSS hides), footnotes native,--no-mixed-listsrequired.
Follow-ups
- #72 calibration gate unblocked (pointer comment posted: calibrate THIS branch, the HTML surface).
- Release pipeline owes apex signing+notarization (ADR-0011; dev bundle is the adhoc Homebrew artifact).