Files
museion/docs/devlog/20261008-issue77-editing-parity_log.md
T
2026-10-08 14:18:32 +02:00

66 lines
5.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Issue 77 — Fix: editing-side line spacing → writing-surface parity (S1.2)
> **Date:** 2026-10-08
> **Type:** issue
> **Reference:** [Wayfinder map #20](https://git.babylondreams.de/AlexKucera/Museion/issues/20) · ticket [#77](https://git.babylondreams.de/AlexKucera/Museion/issues/77) · ruling [#78](https://git.babylondreams.de/AlexKucera/Museion/issues/78)
## Goal
Alexander expanded #77 live: with reading ruled calm (#78), the writing side must look "as close as possible to the reading side, but with plain Markdown" — line spacing, font sizes, bold/italic applied to the Markdown, headers bold. Later adds: same 66ch line width as reading, less-tight heading space, scroll-only scrollbar. Then finish-audit (3-agent reviewer fanout) and fixes.
## What Was Done
**Ticket + map work (Gitea)**
- #77 body rewritten to the parity scope (was line-spacing only); round comment records the four taste calls.
- Map #20 repaired: #78's CALM ruling appended to Decisions so far; two dead fog lines cleared (settled by #72's rework); typography-tuning-as-map-work pinned in Out of scope.
**Build** (`wayfinder/76-apex-html-reading`, commits `8fe5f48` → `1f7557a`)
- `ProsePresenter.swift` rewritten: heading ladder h1 30 / h2 22 / h3 19-bold / h4+ bold body (was 26/20/no-h3); half-height blank separators (9pt); quote = secondary ink + 20pt indent; fence interiors mono-14 on substrate (fence-state prefix scan feeds per-paragraph reattribute); inline traits — `**bold**`, `_italic_` (CommonMark intraword-`_` rule), `` `code` ``, link labels ink + underline with brackets/URL dimmed; list markers dim. Marks stay visible-dimmed everywhere (plain store = source of truth).
- Leading calibrated to CSS 1.8 via `lineHeightMultiple(font:cssLineHeight:)` — TextKit multiplies the font's natural box (~1.2×), so copying the CSS number overshoots ~20%. Per-kind leading: body 1.8, headings 1.15, code 1.5, each from its own face's metrics (audit fix).
- 66ch editor measure: `ProseTypography.measureWidth` = zero-glyph advance × 66 + 48pt padding; `PostEditorView` caps + centers the editing surface at it.
- Heading spacing 75/30 (CSS 90/30 minus the visible blank separator's ~15pt). Overlay scrollbar (`scrollerStyle = .overlay`).
- Audit fixes (`1f7557a`): HIGH fence-delimiter-edit staleness (coordinator fingerprints delimiter count; moved count ⇒ full re-attribute, caret preserved); fonts + measureWidth cached `nonisolated(unsafe) static let`; 7+ hashes → body; tab-lead dim; intraword spans unclaim on reject; fenceState reuses contentLines+classify; marker regexes as literals; dead colors/forwarders deleted (−~55 lines).
- `MuseionTests/ProsePresenterTests.swift` new — 11→12 tests pinning ladder, blanks, quote, fence, traits, intraword, calibration, retrofit (real, not the vacuous first draft), delimiter count.
## Decisions & Rationale
| Decision | Rationale |
|----------|-----------|
| Expand #77 instead of a new ticket | Same surface, same branch, obligation born in #73's decoupling; the map's frontier stays one ticket |
| Fold uncontroversial parity, ask only 4 taste calls | Blank-line height, inline-scope, block parity, heading spacing genuinely fork; sizes/leading/bold don't |
| Leading calibrated from font metrics, not CSS number | px `line-height` ≠ TextKit `lineHeightMultiple` (natural box ≈1.2×size); calibration makes parity exact |
| 66ch via zero-glyph × 66 + padding | Same body face as reading.css `--measure`, so toggle round-trips keep line breaks |
| Delimiter-count fingerprint for fence edits | Count is the cross-paragraph state; moved count ⇒ full re-attribute is O(doc) but rare and correct; per-keystroke path stays one-paragraph |
| `nonisolated(unsafe) static let` fonts | NSFont isn't Sendable; instances immutable after creation — same stance as the regex literals |
## Gotchas & Fixes
| Problem | Root Cause | Fix |
|---------|------------|-----|
| `###### ` classified as body | `hasPrefix("#### ")` misses 6 hashes | hash-count classify with CommonMark ≤6 cap |
| Test sampling offset 0 on heading lines | 0 is the dimmed `#` marker, not the text | sample at the heading text's range |
| Patch turned `"\t"` into a raw tab (build error) | Literal escape injection in string replace | byte-level python fix + grep verify |
| Swift Regex: no lookbehind, not Sendable, `matches(of:)` API | swift-regex limits | boundary-char helpers, `nonisolated(unsafe)`, String-side `matches(of:)` |
| SwiftFormat reflows between write and patch | Stale multi-line match strings failed | re-read before replace; exact-string asserts |
| All screenshots black while app + window verified alive | Known dead-capture trap (session state) | per macos-ui-automation skill: hand visual pass to Alexander instead of debugging |
| Vacuous "retrofit" test | Sampled paragraph at location 0 — prefix-scan guard skips it | real in-fence paragraph + outside-fence case |
| 28 lint errors after rewrite | 1-char identifiers (error severity), `try!` | renames + regex literals (disables deleted) |
## Files Changed
| File | Change Summary |
|------|----------------|
| `Museion/ProsePresenter.swift` | parity rewrite + audit fixes (classify/fence/inline/spacing) |
| `Museion/ProseTypography.swift` | size constants, cached fonts, measureWidth, CSS-token colors; dead colors deleted |
| `Museion/PostEditorView.swift` | 66ch measure + centering, overlay scrollbar, fence-count coordinator |
| `MuseionTests/ProsePresenterTests.swift` | new — 12 tests pinning the parity map |
| `Museion/AGENTS.md`, `MuseionTests/AGENTS.md` | DOX pass for the rework |
## Open Items & Next Steps
- [ ] Alexander's visual pass in-app (done condition of #77): kitchen-sink + calibration piece; heading spacing/measure knobs are one-liners if it feels off
- [ ] Ticket #77 stays open until that ruling; resolution comment + map gist follow
- [ ] Branch unpushed (repo policy — explicit authorization each push)
*Log written by write-log skill*