Build: land the apex HTML reading surface #76

Closed
opened 2026-10-06 15:30:27 +02:00 by AlexKucera · 1 comment
Owner

Part of #20

Question

Execution (the map's bounded override): swap the reading surface to the apex HTML pipeline per ADR-0011.

  • Bundle the apex binary (resources); ReadingPresenter becomes markdown → apex → HTML fragment + the chunker data-source-line stamp (the paragraph map for click-to-edit and scroll-sync).
  • ReadingCanvasView → thin WKWebView representable; CSS custom properties from ProseTypography slots + flow knobs, injected at load; Settings pane unchanged.
  • DELETE the TextKit reading machinery — Decoration, table/quote/HR content blocks, canvas draw, framesForRange, ImagePopoverView — the known stale-flow defect dies here, unfixed by design.
  • Re-target ReadingPresenterTests at HTML string asserts.
  • Survives untouched: ReadingStateBox/CaretHintBox flow, toggle wiring (#68), ProseTypography, ProsePresenter (edit side).
  • DOX pass: Museion/AGENTS.md reading-mode section + the "no web-editor embedding" Work Guidance line (it becomes an editing-side rule).

Branch wayfinder/<this ticket>. xcodebuild build + test green; kitchen-sink + PERF-3k render correct.

[Generated by AI]

Part of #20 ## Question Execution (the map's bounded override): swap the reading surface to the apex HTML pipeline per ADR-0011. - Bundle the apex binary (resources); ReadingPresenter becomes markdown → apex → HTML fragment + the chunker `data-source-line` stamp (the paragraph map for click-to-edit and scroll-sync). - ReadingCanvasView → thin WKWebView representable; CSS custom properties from ProseTypography slots + flow knobs, injected at load; Settings pane unchanged. - DELETE the TextKit reading machinery — `Decoration`, table/quote/HR content blocks, canvas `draw`, `framesForRange`, `ImagePopoverView` — the known stale-flow defect dies here, unfixed by design. - Re-target ReadingPresenterTests at HTML string asserts. - Survives untouched: ReadingStateBox/CaretHintBox flow, toggle wiring (#68), ProseTypography, ProsePresenter (edit side). - DOX pass: Museion/AGENTS.md reading-mode section + the "no web-editor embedding" Work Guidance line (it becomes an editing-side rule). Branch `wayfinder/<this ticket>`. `xcodebuild` build + test green; kitchen-sink + PERF-3k render correct. [Generated by AI]
AlexKucera added the wayfinder:task label 2026-10-06 15:30:51 +02:00
AlexKucera changed title from Part of #20 to Build: land the apex HTML reading surface 2026-10-06 15:30:51 +02:00
AlexKucera added a new dependency 2026-10-06 15:30:59 +02:00
AlexKucera added a new dependency 2026-10-06 15:31:00 +02:00
AlexKucera self-assigned this 2026-10-06 17:51:22 +02:00
Author
Owner

Resolution

Landed on wayfinder/76-apex-html-reading @ f1c915f (local, unpushed — off the #75 ADR branch, which itself carries the merge of #71's landing; ADR-0011 rides along into this branch's history).

What landed

  • ReadingPresenter.swift (rewritten, −961/+501 lines net with the surface): stampSource (blank-line chunker, <!--S:N--> sentinels) → apexRender (bundled binary, -t html --no-mixed-lists --embed-images [--base-dir]) → stampHTML (regex restamp to data-source-line) → page(for:postFolder:) assembling the shell with styleSheet() — ProseTypography slots + flow knobs as CSS custom properties (family names, not member PS names; weight rides CSS). blocks(for:) provides the line↔UTF-16-range map for the #68 click→edit and scroll-sync contract. Fallback = escaped source in a <pre> (#69 rule). Footnotes now render natively (apex upgrade over #69's fallback decision — corpus has none).
  • ReadingSurface.swift (rewritten): ReadingStateBox/CaretHintBox kept; the canvas is one WKWebView reloaded in place (keyed render on generation+text+flowKey, never per keystroke; remount-free per #74). probeJS maps click→edit intent at the clicked block, ⌘-click→NSWorkspace, scroll→top-visible-line; decidePolicyFor allows only our own about:blank main-frame load; entry-caret scroll lands after didFinish; defaults observer reloads on flow-key change.
  • Deleted (ADR-0011: no fallbacks): ReadingCanvasView, Decoration, table/quote/HR content blocks, framesForRange, ImagePopoverView.
  • Untouched, as specified: ReadingStateBox/CaretHintBox flow, #68 toggle wiring, ProseTypography, ProsePresenter (edit side), Settings pane.
  • Bundling: apex 1.1.17 universal binary at Museion/Resources/apex — the fs-sync group ships it into Resources automatically (verified in the built .app; no pbxproj edit needed). Binary resolution: bundle → APEX_PATH → Homebrew (dev fallback). 1.8 MB.
  • Tests re-targeted at HTML string asserts: chunker/stamper self-checks, blocks(for:) map (monotonic, 1-based, exact chunk offsets), pipeline tests running the REAL bundled binary (headings/inline, 1. 1. 1. renumber, mixed-lists split, constructs with exact stamps, base64 embed, native footnotes), fallback, stylesheet vars. 94 tests green (xcodebuild test), swiftlint 0 errors on touched files.
  • DOX pass: Museion/AGENTS.md reading-mode section rewritten for the pipeline; "no web-editor embedding" Work Guidance line rescoped to the editing side (ADR-0011 reading-is-presentation ruling); MuseionTests/AGENTS.md test description updated.

Verified live (app launched, driven via AX + screenshots)

  • Kitchen-sink post (all constructs) renders in reading mode; PERF-3k ("The expected value of showing up", 3452 words) renders formatted, toggle feels instant; apex CLI itself ~20 ms/render (×3 runs).
  • Click-to-edit works: click a paragraph in reading → editing at that paragraph (verified via AX click + screenshot).
  • Alexander clicked around in the live app mid-session (both modes exercised) — no crash, no defect report.
  • PERF gate: pass/fail at 20 ms — measured via direct apex runs; in-app toggle visually instant on both kitchen-sink and PERF-3k.

Deviations / notes

  • apex wraps tables in <figure class="table-figure"> with a stray <figcaption> (link text when a link follows a table) — CSS hides figcaption (spike behavior, kept).
  • Signed/notarized per ADR-0011 applies to the release build; the bundled binary in-repo is the Homebrew artifact (adhoc, dev-signed). Notarization is a release-pipeline step, not a dev-branch fact.
  • Alexander's click-around doubled as an early calibration touch; the formal gate stays #72.

#72 (calibration) unblocked — calibrates the HTML surface.

[Generated by AI]

## Resolution **Landed on `wayfinder/76-apex-html-reading` @ f1c915f** (local, unpushed — off the #75 ADR branch, which itself carries the merge of #71's landing; ADR-0011 rides along into this branch's history). ### What landed - **`ReadingPresenter.swift`** (rewritten, −961/+501 lines net with the surface): `stampSource` (blank-line chunker, `<!--S:N-->` sentinels) → `apexRender` (bundled binary, `-t html --no-mixed-lists --embed-images [--base-dir]`) → `stampHTML` (regex restamp to `data-source-line`) → `page(for:postFolder:)` assembling the shell with `styleSheet()` — ProseTypography slots + flow knobs as CSS custom properties (family names, not member PS names; weight rides CSS). `blocks(for:)` provides the line↔UTF-16-range map for the #68 click→edit and scroll-sync contract. Fallback = escaped source in a `<pre>` (#69 rule). **Footnotes now render natively** (apex upgrade over #69's fallback decision — corpus has none). - **`ReadingSurface.swift`** (rewritten): `ReadingStateBox`/`CaretHintBox` kept; the canvas is one WKWebView reloaded in place (keyed render on generation+text+flowKey, never per keystroke; remount-free per #74). `probeJS` maps click→edit intent at the clicked block, ⌘-click→NSWorkspace, scroll→top-visible-line; `decidePolicyFor` allows only our own about:blank main-frame load; entry-caret scroll lands after `didFinish`; defaults observer reloads on flow-key change. - **Deleted** (ADR-0011: no fallbacks): `ReadingCanvasView`, `Decoration`, table/quote/HR content blocks, `framesForRange`, `ImagePopoverView`. - **Untouched, as specified:** ReadingStateBox/CaretHintBox flow, #68 toggle wiring, ProseTypography, ProsePresenter (edit side), Settings pane. - **Bundling:** apex 1.1.17 universal binary at `Museion/Resources/apex` — the fs-sync group ships it into Resources **automatically** (verified in the built .app; no pbxproj edit needed). Binary resolution: bundle → `APEX_PATH` → Homebrew (dev fallback). 1.8 MB. - **Tests re-targeted** at HTML string asserts: chunker/stamper self-checks, `blocks(for:)` map (monotonic, 1-based, exact chunk offsets), pipeline tests running the REAL bundled binary (headings/inline, `1. 1. 1.` renumber, mixed-lists split, constructs with exact stamps, base64 embed, native footnotes), fallback, stylesheet vars. 94 tests green (`xcodebuild test`), swiftlint 0 errors on touched files. - **DOX pass:** `Museion/AGENTS.md` reading-mode section rewritten for the pipeline; "no web-editor embedding" Work Guidance line rescoped to the editing side (ADR-0011 reading-is-presentation ruling); `MuseionTests/AGENTS.md` test description updated. ### Verified live (app launched, driven via AX + screenshots) - Kitchen-sink post (all constructs) renders in reading mode; PERF-3k ("The expected value of showing up", 3452 words) renders formatted, toggle feels instant; apex CLI itself ~20 ms/render (×3 runs). - Click-to-edit works: click a paragraph in reading → editing at that paragraph (verified via AX click + screenshot). - Alexander clicked around in the live app mid-session (both modes exercised) — no crash, no defect report. - PERF gate: pass/fail at 20 ms — measured via direct apex runs; in-app toggle visually instant on both kitchen-sink and PERF-3k. ### Deviations / notes - apex wraps tables in `<figure class="table-figure">` with a stray `<figcaption>` (link text when a link follows a table) — CSS hides figcaption (spike behavior, kept). - Signed/notarized per ADR-0011 applies to the release build; the bundled binary in-repo is the Homebrew artifact (adhoc, dev-signed). Notarization is a release-pipeline step, not a dev-branch fact. - Alexander's click-around doubled as an early calibration touch; the formal gate stays #72. **#72 (calibration) unblocked** — calibrates the HTML surface. [Generated by AI]
Sign in to join this conversation.