Spike A: CodeEditSourceEditor fork as prose editor (mode B, anchor proof) #52
Notifications
Due Date
No due date set.
Blocks
Depends on
#55 Verdict: substrate decision + ADR-0010
AlexKucera/museion
#51 Spike corpus: pin the eight posts as markdown
AlexKucera/museion
Reference: AlexKucera/museion#52
Reference in new issue
Block a user
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-presentationinspike/codeedit/, editing the calibration piece, mode B: styled source, dimmed syntax, rendered reading toggle.AlexKucera/CodeEditSourceEditor0.15.8-helm(same fork and revision as Classis).AttributedString(markdown:)); note the renderer choice for the ADR.ref/Web-Prototype/museion-workspace.html.PERF-3k.md, note any hitching.[Generated by AI]
Corpus is pinned (#51):
spike/prose/onspike/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]
Spike A resolution — CodeEditSourceEditor fork
0.15.8-helmas prose editorThrowaway 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
HighlightProvidingwrapping the stock tree-sitter client (helm'sMonokaiHighlighterpattern). Compromise (substrate limit, confirmed in fork source): one font size for everything —EditorThemecaptures map to color/bold/italic over a single base font (attributesForbuilds every run from it); no per-capture size, noNSParagraphStyle, so no variable heading sizes and no paragraph spacing. Rhythm comes fromlineHeightMultiple: 1.45alone. Reading toggle uses the same per-blockAttributedString(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 —textViewInsetsderives 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'tsplits mid-word after the typographic apostrophe at the soft-wrap boundary (custom line-basedTextLayoutManagerbreaking, not standard UAX#14). Prose-feel cost; screenshots show it.Emphasis— any style — adds aCATextLayerthat re-draws the span's string on top of the live glyphs (EmphasisManager.createTextLayer, CodeEditTextView 0.12.3-helm): hardcodedNSColor.black,bounds.origin.y += 1offset. 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.@Statewrites duringmakeNSViewControllerare 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.@preconcurrencyimports required (Swift 5.9 lib vs 6.2 spike target); CodeEditLanguages/Symbols resource bundles must ship inside the wrapping.app(NSBundle.moduletraps otherwise); all theme colors must be sRGB —MinimapView.setThemecallsbrightnessComponenton every theme color even with the minimap disabled, and grayscale/calibrated colors raiseNSColorRaiseWithColorSpaceErrorand crash at launch.[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]