Spike A: CodeEditSourceEditor fork as prose editor (mode B, anchor proof) #52

Closed
opened 2026-09-26 11:38:56 +02:00 by AlexKucera · 2 comments
Owner

Part of #16
Blocked by: 51

Question

Can the CodeEditSourceEditor fork — the presumptive leader — present prose source as calm writing? Throwaway SwiftUI spike on spike/editor-presentation in spike/codeedit/, editing the calibration piece, mode B: styled source, dimmed syntax, rendered reading toggle.

  • Pin AlexKucera/CodeEditSourceEditor 0.15.8-helm (same fork and revision as Classis).
  • Typography: paragraph rhythm, soft wrap, centered measure, variable heading sizes — or the documented compromise if the substrate forces uniform.
  • Reading toggle: cheap is fine (AttributedString(markdown:)); note the renderer choice for the ADR.
  • Fix-Card anchor proof (this substrate carries it as presumptive leader): highlight a quote-anchored span, and demonstrate the stale-anchor case — anchor not found after the text changed — with the alert wording from ref/Web-Prototype/museion-workspace.html.
  • Editing feel: IME, undo, selection. Performance: load and edit PERF-3k.md, note any hitching.
  • Resolution comment: the verdict criteria as a checklist with findings; screenshots or a short screen recording linked as assets.

[Generated by AI]

Part of #16 Blocked by: 51 ## Question Can the CodeEditSourceEditor fork — the presumptive leader — present prose source as calm writing? Throwaway SwiftUI spike on `spike/editor-presentation` in `spike/codeedit/`, editing the calibration piece, mode B: styled source, dimmed syntax, rendered reading toggle. - Pin `AlexKucera/CodeEditSourceEditor` `0.15.8-helm` (same fork and revision as Classis). - Typography: paragraph rhythm, soft wrap, centered measure, variable heading sizes — or the documented compromise if the substrate forces uniform. - Reading toggle: cheap is fine (`AttributedString(markdown:)`); note the renderer choice for the ADR. - **Fix-Card anchor proof (this substrate carries it as presumptive leader):** highlight a quote-anchored span, and demonstrate the stale-anchor case — anchor not found after the text changed — with the alert wording from `ref/Web-Prototype/museion-workspace.html`. - Editing feel: IME, undo, selection. Performance: load and edit `PERF-3k.md`, note any hitching. - Resolution comment: the verdict criteria as a checklist with findings; screenshots or a short screen recording linked as assets. [Generated by AI]
AlexKucera added the wayfinder:prototype label 2026-09-26 11:38:59 +02:00
AlexKucera added a new dependency 2026-09-26 11:39:02 +02:00
AlexKucera added a new dependency 2026-09-26 11:39:03 +02:00
Author
Owner

Corpus is pinned (#51): spike/prose/ on spike/editor-presentation @ 3b3544e. Note: the calibration piece has no blockquote/italics in the source — its epigraph is plain prose in curly quotes. Full inventory + word counts in the #51 resolution.

[Generated by AI]

Corpus is pinned (#51): `spike/prose/` on `spike/editor-presentation` @ 3b3544e. Note: the calibration piece has no blockquote/italics in the source — its epigraph is plain prose in curly quotes. Full inventory + word counts in the [#51 resolution](https://git.babylondreams.de/AlexKucera/Museion/issues/51#issuecomment-22188). [Generated by AI]
AlexKucera self-assigned this 2026-09-30 13:43:11 +02:00
Author
Owner

Spike A resolution — CodeEditSourceEditor fork 0.15.8-helm as prose editor

Throwaway spike on spike/editor-presentation @ f31af14 (spike/codeedit/). Self-check: PASS: 4 headings, anchor @ 72 len 108; PERF-3k anchor search 2.5 ms (Spike B: 2.4 ms — parity). Assets: spike/codeedit/assets/spikeA-{calibration,anchor,stale,reading}.png.

Verdict criteria checklist

Mode B prose editing — WORKS with documented compromise. Styled source view: bold headings, dimmed markdown markers, green-tinted blockquotes via regex HighlightProviding wrapping the stock tree-sitter client (helm's MonokaiHighlighter pattern). Compromise (substrate limit, confirmed in fork source): one font size for everything — EditorTheme captures map to color/bold/italic over a single base font (attributesFor builds every run from it); no per-capture size, no NSParagraphStyle, so no variable heading sizes and no paragraph spacing. Rhythm comes from lineHeightMultiple: 1.45 alone. Reading toggle uses the same per-block AttributedString(markdown:) renderer stance as Spike B — for ADR-0010, the reading renderer is a non-issue (cheap everywhere).

Typography — PARTIAL, substrate-limited. Centered measure works (SwiftUI container frame(maxWidth: 720); the substrate has no text-measure knob — textViewInsets derives from gutter width). Soft wrap works. Variable heading sizes: not expressible. Paragraph spacing: not expressible.

Fix-Card anchor proof — WORKS cleanly. Whitespace-tolerant quote search → emphasisManager.replaceEmphases([Emphasis(range, style: .outline(color:))], for: "fix-card-anchor") + setCursorPositions(_, scrollToVisible: true). Layer-backed, survives re-highlighting, scrolls to the span. Stale quote → nil → alert with the prototype wording ("The Post changed after this Fix Card was issued; no text was selected or changed."). Screenshots: spikeA-anchor.png (outline + selection on the DM quote, toolbar "anchored @ 72–180"), spikeA-stale.png (alert). Anchor search 0.7–2.8 ms on calibration corpus, 2.5 ms on PERF-3k.

Findings for the verdict

  • don't splits mid-word after the typographic apostrophe at the soft-wrap boundary (custom line-based TextLayoutManager breaking, not standard UAX#14). Prose-feel cost; screenshots show it.
  • Emphasis ghost-doubling (mechanism identified): every Emphasis — any style — adds a CATextLayer that re-draws the span's string on top of the live glyphs (EmphasisManager.createTextLayer, CodeEditTextView 0.12.3-helm): hardcoded NSColor.black, bounds.origin.y += 1 offset. Invisible on black body text, a black ghost copy on any colored span (green-tinted quotes show it plainly; also broken in dark mode by design). Not fixable from the API side — dodging it means selection-only anchors (no emphasis) or a fork patch. Verified on user screenshot at native res.
  • @State writes during makeNSViewController are silently dropped — coordinator-captured controller must live in a reference box, not @State (cost us the "(no ctrl!)" detour). Notable integration cost on this substrate.
  • Build traps (documented in-code): @preconcurrency imports required (Swift 5.9 lib vs 6.2 spike target); CodeEditLanguages/Symbols resource bundles must ship inside the wrapping .app (NSBundle.module traps otherwise); all theme colors must be sRGB — MinimapView.setTheme calls brightnessComponent on every theme color even with the minimap disabled, and grayscale/calibrated colors raise NSColorRaiseWithColorSpaceError and crash at launch.
  • Editor [any TextViewCoordinator] API is clean; captured-controller pattern works (helm #160 style) once stored correctly.

Perf & feel notes

Load + first highlight of the calibration corpus: sub-2 ms. PERF-3k typing not hitched in manual pass (same algorithm as Spike B, 2.5 ms full-document anchor search). No IME pass yet — no IME on the manual pass; undo/selection feel native (TextKit-class NSTextView under the hood).

Bottom line for ADR-0010: anchors are a clean win on this substrate; typography is the compromise — uniform font size, no paragraph spacing, two rendering warts (mid-word wrap at apostrophe, emphasis ghosting). Spike B (TextKit2) showed none of these limits.

[Generated by AI]

## Spike A resolution — CodeEditSourceEditor fork `0.15.8-helm` as prose editor Throwaway spike on `spike/editor-presentation` @ `f31af14` (`spike/codeedit/`). Self-check: `PASS: 4 headings, anchor @ 72 len 108; PERF-3k anchor search 2.5 ms` (Spike B: 2.4 ms — parity). Assets: `spike/codeedit/assets/spikeA-{calibration,anchor,stale,reading}.png`. ### Verdict criteria checklist **Mode B prose editing — WORKS with documented compromise.** Styled source view: bold headings, dimmed markdown markers, green-tinted blockquotes via regex `HighlightProviding` wrapping the stock tree-sitter client (helm's `MonokaiHighlighter` pattern). Compromise (substrate limit, confirmed in fork source): **one font size for everything** — `EditorTheme` captures map to color/bold/italic over a single base font (`attributesFor` builds every run from it); no per-capture size, no `NSParagraphStyle`, so **no variable heading sizes and no paragraph spacing**. Rhythm comes from `lineHeightMultiple: 1.45` alone. Reading toggle uses the same per-block `AttributedString(markdown:)` renderer stance as Spike B — for ADR-0010, the reading renderer is a non-issue (cheap everywhere). **Typography — PARTIAL, substrate-limited.** Centered measure works (SwiftUI container `frame(maxWidth: 720)`; the substrate has no text-measure knob — `textViewInsets` derives from gutter width). Soft wrap works. Variable heading sizes: **not expressible**. Paragraph spacing: **not expressible**. **Fix-Card anchor proof — WORKS cleanly.** Whitespace-tolerant quote search → `emphasisManager.replaceEmphases([Emphasis(range, style: .outline(color:))], for: "fix-card-anchor")` + `setCursorPositions(_, scrollToVisible: true)`. Layer-backed, survives re-highlighting, scrolls to the span. Stale quote → nil → alert with the prototype wording ("The Post changed after this Fix Card was issued; no text was selected or changed."). Screenshots: `spikeA-anchor.png` (outline + selection on the DM quote, toolbar "anchored @ 72–180"), `spikeA-stale.png` (alert). Anchor search 0.7–2.8 ms on calibration corpus, 2.5 ms on PERF-3k. ### Findings for the verdict - **`don't` splits mid-word** after the typographic apostrophe at the soft-wrap boundary (custom line-based `TextLayoutManager` breaking, not standard UAX#14). Prose-feel cost; screenshots show it. - **Emphasis ghost-doubling (mechanism identified)**: every `Emphasis` — any style — adds a `CATextLayer` that **re-draws the span's string on top of the live glyphs** (`EmphasisManager.createTextLayer`, CodeEditTextView 0.12.3-helm): hardcoded `NSColor.black`, `bounds.origin.y += 1` offset. Invisible on black body text, a black ghost copy on any colored span (green-tinted quotes show it plainly; also broken in dark mode by design). Not fixable from the API side — dodging it means selection-only anchors (no emphasis) or a fork patch. Verified on user screenshot at native res. - **`@State` writes during `makeNSViewController` are silently dropped** — coordinator-captured controller must live in a reference box, not `@State` (cost us the "(no ctrl!)" detour). Notable integration cost on this substrate. - Build traps (documented in-code): `@preconcurrency` imports required (Swift 5.9 lib vs 6.2 spike target); CodeEditLanguages/Symbols resource bundles must ship inside the wrapping `.app` (`NSBundle.module` traps otherwise); **all theme colors must be sRGB** — `MinimapView.setTheme` calls `brightnessComponent` on every theme color even with the minimap disabled, and grayscale/calibrated colors raise `NSColorRaiseWithColorSpaceError` and crash at launch. - Editor `[any TextViewCoordinator]` API is clean; captured-controller pattern works (helm #160 style) once stored correctly. ### Perf & feel notes Load + first highlight of the calibration corpus: sub-2 ms. PERF-3k typing not hitched in manual pass (same algorithm as Spike B, 2.5 ms full-document anchor search). No IME pass yet — no IME on the manual pass; undo/selection feel native (TextKit-class NSTextView under the hood). Bottom line for ADR-0010: anchors are a clean win on this substrate; typography is the compromise — uniform font size, no paragraph spacing, two rendering warts (mid-word wrap at apostrophe, emphasis ghosting). Spike B (TextKit2) showed none of these limits. [Generated by AI]
Sign in to join this conversation.