CI / ci (push) Canceled after 0s
Markdown lists in the prose editor become structural: Tab/⇧Tab indent/outdent the item under the caret (wrapped lines ride along, caret follows), ⌥↑/⌥↓ move the item with its subtree among siblings. Every structural edit is one range replacement — a single undo step over the plain mode-B store (ADR-0010 stands). List parents fold visually: a gutter chevron collapses children to near-zero height with a rust ▸ and a "⋯ N" summary after the parent's line. Folding is view state — the buffer never changes (ADR-0013's posture carried to prose). Field findings baked in: SwiftUI-hosted TextKit2 never calls NSTextView.draw(_:) and every NSTextLayoutManager fragment query returns empty, so the chrome renders offscreen into a layer-contents image and geometry comes from firstRect(forCharacterRange:) (screen → window → view). Includes the finish-audit round: sibling block-for- block ⌥-move swap (was stealing the sibling's subtree), blank-line indent dirt, fold-key dedupe, hidden-parent chevron filtering, plain-click-only hit zone, no-parents raster skip. Closes #115 [Generated by AI]
7.6 KiB
7.6 KiB
Build S5 (#115): prose-list shortcuts — Tab/⇧Tab, ⌥ moves, visual collapse
Date: 2026-10-19 Type: issue Reference: Museion #115 (map #110), git.babylondreams.de/AlexKucera/Museion
Goal
Ticket #115 (Build S5, last open slice of wayfinder map #110 "Outliner II"): in the prose editor, when the caret sits on a markdown list line, Tab/⇧Tab indent/outdent the item (wrapped lines ride along), ⌥↑/⌥↓ move the item with its subtree among siblings, and list parents get visual collapse (fold chevron + "⋯ N" summary). All edits are plain text edits through the mode-B store (ADR-0010); fold is view state, never a text edit (ADR-0013 posture in prose).
What Was Done
Museion/ProseList.swift(new, pure nonisolated model): line scan (Line),Item(marker line/end, block, fold scope, hidden-line count, indent),ParentHint+parents(in:)for fold targets,Edit= one range replacement per structural action (single undo step). Indent derives the unit from the previous sibling's content column (CommonMark: "- "→2, "1. "→3); outdent strips ≤2 columns with the caret riding the shift; move = sibling-adjacent swap preserving between-text; fences end blocks; lazy continuations belong to the item; blank lines before the first child fold too.Museion/ProseListTextView.swift(new): NSTextView subclass installed byProseTextView.makeNSView.keyDown/insertBacktabintercept Tab/⇧Tab/⌥↑/⌥↓ (function-key scalars \u{F700}/\u{F701} with .function/.numericPad device bits stripped); edits apply throughshouldChangeText/didChangeTextso undo + coordinator reattribute stay native. Folds:Foldkeyed by marker-line location, re-keyed on edit to the nearest parent with the same marker text (no match → dies), hidden scopes styled near-zero height viaProseTypography.foldedAttributes, caret landing inside a hidden scope parks at the marker end.- Chrome (chevrons ▾/▸ in the gutter, rust "⋯ N" after the folded parent's text): rendered offscreen into an NSImage set as a click-through overlay's
layer.contents(ProseChromeView, installed inviewDidMoveToWindow, refreshed on every edit/geometry change, deferred one main-queue tick). Fold toggle via gutter/marker click inmouseDown(plain single-clicks only). Museion/ProseTypography.swift: addedfoldedAttributes(0.1pt clear font, lineHeightMultiple 0.01, zero spacing).Museion/ProsePresenter.swift:listMarkerPatternmade internal so ProseList's marker math agrees with classify.Museion/PostEditorView.swift:ProseListTextView()in place of the stock view; coordinator callsrefreshFolds()after every textDidChange.MuseionTests/ProseListTests.swift(new): scan/indent/outdent/move pins +ProseFoldRenderingTests(@MainActor): buffer never changes on fold, hidden scopes carry folded attrs, unfold restores, folds re-key after an edit above, fold dies when marker text vanishes.- Finish-audit pass (3-reviewer fanout) fixed: ⌥-move sibling-subtree theft (block-for-block swap), indent blank-line space injection, fold-key dedupe, hidden-parent chevron/hit filtering, shift/double-click hit-zone over-capture, no-parents raster skip + double-render elimination.
Decisions & Rationale
| Decision | Rationale |
|---|---|
Chrome via layer.contents image, not draw(_:) |
SwiftUI-hosted TextKit2 never calls NSTextView.draw(_:) — field-verified with probes (zero calls while the window renders). A plain overlay subview's draw was never invoked either; a layer background proved the layer pipeline composites. Offscreen NSImage → layer.contents is the only path that displays. |
Line geometry via firstRect(forCharacterRange:) (screen → window.convertFromScreen → view) |
Every NSTextLayoutManager fragment query (location bridge, textLayoutFragment(for:), enumerateTextLayoutFragments) returns nothing under this hosting — live counters showed P=3 E=0 F=0 while the text visibly rendered. The selection/caret pipeline is the only geometry source that answers. Screen coords cost one convert. |
| Refresh deferred one main-queue tick | Refresh points fire inside textDidChange, after TextKit2 invalidated layout but before re-layout — synchronous queries find nothing. |
| Fold re-key = nearest parent with same marker text | Simplest honest rule under plain-text edits; documented ceiling (duplicate marker texts can mis-attach) with edit-delta capture as the upgrade path, key dedupe added by audit. |
| Marker regex shared with ProsePresenter | ProseList's indent math must agree with classify's list detection — one pattern, internal visibility. |
| Structural edits as ONE range replacement | Single undo step; caret rides natively; ADR-0010's plain store stays the source of truth. |
Gotchas & Fixes
| Problem | Root Cause | Fix |
|---|---|---|
| NSLog probes never appeared in unified log (even lldb-injected NSLog) — "code never runs" conclusions were wrong | Log capture for this process is dead on this machine; AppKit os_log lines DO appear | Switched to visual in-app probes (rendered counters "P= E= R=") + lldb live inspection of the running process |
ProseListTextView() convenience init re-route through init(frame:textContainer: nil) gutted the view (textStorage nil, string = silent no-op) — crashed 3 fold tests |
NSTextView's TextKit stack is only built by its own designated init path | Install chrome in viewDidMoveToWindow; never override inits |
| Stale app bundle: "BUILD SUCCEEDED" while the Products dylib kept a 10:14 object (old probe strings inside) — user tested the wrong binary twice | Incremental xcodebuild skipped externally-edited sources (fs-synced groups + external tool edits) | Delete the .app + touch sources + rebuild; verify via grep for new strings in the dylib and its mtime before every handoff |
| User typed into an existing outline post → zero probes | Outline posts route to OutlineEditorView (different surface) | Test on File ▸ New Post drafts (prose path) |
| Classis (terminal app) kept stealing focus mid-automation | Other agent sessions actively drive this machine | Atomic osascript blocks (raise + frontmost + click + capture); finally the user drove the app manually |
| Swift Testing suites emit no "Test Case" lines — grep-based pass counts measured nothing | XCTest-style greps don't match Swift Testing output | xcodebuild -resultBundlePath + xcresulttool get test-results summary |
| Parallel test shards crash the host at 0.000s on this machine | Pre-known flakiness | Always -parallel-testing-enabled NO |
Files Changed
| File | Change Summary |
|---|---|
Museion/ProseList.swift |
new — pure list scan/mutation model |
Museion/ProseListTextView.swift |
new — key interception, folds, layer-contents chrome, firstRect geometry |
Museion/ProseTypography.swift |
+ foldedAttributes |
Museion/ProsePresenter.swift |
listMarkerPattern internal |
Museion/PostEditorView.swift |
installs ProseListTextView; coordinator refreshFolds() |
MuseionTests/ProseListTests.swift |
new — 39 pins incl. audit repros |
Museion/AGENTS.md, MuseionTests/AGENTS.md |
DOX rows for the new files |
Open Items & Next Steps
- Map #110 close: record Decisions and close (all slices landed — S4 #114, P1 #113, S6 #112, S7 #111, S5 #115)
- Deferred (ponytail-review, next time these files are open):
ParentHint→Itemconsolidation,contentLinesreuse,performIndent/performMoveinlining (~50 lines) - Ceiling comments mark: fold re-key delta capture, visible-height chrome raster, CommonMark lazy-continuation fidelity (headings/fences)
Log written by write-log skill