docs(devlog): #204 session log, INDEX row, window

The Fix Cards Jump log: the four grilling answers, the caret-rail
reuse decision, both review rounds, and the flip-verified pins.
INDEX and the AGENTS window carry the row; the rolling window
drops issue192's entry. The release 0.1.2 log's rows belong to
another session and stay in the working tree.
This commit is contained in:
AlexKucera committed 2026-12-03 17:48:55 +01:00
1 parent 97893147a6
commit dd8637e7c7
3 files changed
+83 -3

No files matched your search

@@ -0,0 +1,79 @@
# Fix Cards: Jump to the anchor (#204)
> **Date:** 2026-12-03
> **Type:** issue
> **Reference:** https://git.babylondreams.de/AlexKucera/Museion/issues/204 — "Fix Cards should allow jumping to the relevant paragraph."
## Goal
Give the Fix Cards palette a **Jump** action: clicking it on a card lands the writer on the span the card points at — the anchor quote (1-based occurrence) selected in the prose editor, scrolled into view, the main window made key so typing can start at once. The ticket body was empty; four grilling answers settled the shape (borderless Jump in the action row; select the full span + scroll; activate the main window; stale anchors offer none, closed cards keep it).
## What Was Done
- `FixCardStore.anchorRange(of:in:)` — the nth-occurrence math `appliedText` already used, answered as the `NSRange` a jump selects (nil for stale / empty quote / occurrence below 1; the lane never gates it — a demonstration card's anchor is still a real place). `appliedText` now routes through it (one math, −3 lines).
- `PostsModel.revealCard(_:)` + `FixCardRevealRequest {range, token}` + the stored `revealRequest` — resolves the span against the LIVE `session.text` (a dirty buffer still lands) and stamps a request whose token advances per jump so repeats re-fire. Writes nothing.
- The editor column feeds the request into the existing #71 caret rail: `PostEditorView.caretHint` widened from `(location, token)` to `FixCardRevealRequest?` (a zero-length range = bare caret, non-zero = select the span); one shared `flipToken` counter; a jump leaves reading mode first (`reading = false`, not `exitReading`, which stamps its own zero-length hint). The Coordinator's `applyCaretHint` selects, scrolls (runloop hop, the #71 layout race), and makes the main window key on jumps only.
- `ProseTextView.landingSpan(for:in:)` — the landing math as a pure static: a bare caret hops past leading blanks, a span never does; both clamp to the text.
- `FixCardsPalette`: a borderless **Jump** button in every non-stale card's action row (open and closed alike).
- Pins in `FixCardApplyTests` (`// MARK: Jump to the anchor (#204)`): `anchorRange` occurrence math incl. a UTF-16 emoji fixture; `revealCard` stamps against the live text, re-fires, stale stamps nothing, no write; `landingSpan` hop gate + clamps.
- DOX: `Museion/AGENTS.md` (store, model, palette bullets), `MuseionTests/AGENTS.md`, `GLOSSARY.md` gains **Jump** beside Apply; file headers updated.
**Verification (finish-up step 1, run bare):** `./scripts/full-test.sh` exit 0 — **732 executed / 732 passed / 0 failed** (the rail's log shows `SwiftCompile` lines for every edited file); `swiftformat . --lint` exit 0 (0/153); `swiftlint .` exit 0 (0 violations / 142 files). Every new pin flip-verified with the guard off and the tree restored byte-exact: emoji UTF-16 (Character-count rewrite → location 6 ≠ 7), dirty-buffer location (snapshot text → 14 ≠ 26), token advance (constant token → 0 ≠ 1), landingSpan hop (always-hop → `{3,3}` ≠ `{0,3}`). Two review rounds: an implement-close general review (REQUEST_CHANGES → 2 should-fix + nits fixed) and a three-reviewer finish-audit (ponytail / security / general, all APPROVE after fixes).
## Decisions & Rationale
| Decision | Rationale |
|----------|-----------|
| Ride the #71 caret rail (`caretHint`) instead of a second reveal path | One landing mechanism, one layout-race fix, one `appliedCaretToken`. The token counter stays SHARED — two independent counters could collide and a jump would silently never apply |
| `FixCardRevealRequest` doubles as the hint type | SwiftLint `large_tuple` rejects a 3-member tuple; the request already IS `(range, token)`, the exact shape the hint needs |
| Resolve the span against the live `session.text`, not disk | The card's quote is validated on disk but the writer may have typed since; a disk range would drift under a dirty buffer (pinned: buffer location 26 vs snapshot 14) |
| Jump visibility follows the DISK `anchorStatus` | A card valid on disk whose quote the dirty buffer removed still shows Jump and `revealCard` stamps nothing — a documented silent degrade. Folding a live check into `stale` would also hide Apply: a behavior change outside #204, left for a ruling |
| Closed non-stale cards keep Jump; a closed AND promoted card has none | The span is still a real place after the card closes. The action row's pre-existing `open \|\| promotedAt == nil` gate hides the whole row for a fully resolved card — kept for the smallest diff; docs say so plainly |
| Window keying in the Coordinator (`tv.window?.makeKeyAndOrderFront`), not `NSApp.activate` | `NSApp.activate(ignoringOtherApps:)` is a no-op once the app is active — the palette's click already activated it — and deprecated since macOS 14. The Coordinator owns `tv.window`; gated on a positive span so the #71 flip-back path is untouched |
| `reading = false` directly in the handler | `exitReading(caret:)` bumps the token and stamps its own zero-length hint — it would overwrite the jump |
| Hoist the landing math into `landingSpan` | The Coordinator method needs an NSTextView; the repo pins pure statics (`caretPastLeadingBlanks` precedent). +3 lines bought a pin that caught the hop bug |
| No view-layer pins | Repo convention: pure seams pinned, SwiftUI views dogfooded. The three view-layer deltas are named under Open Items |
| No `Closes #204` in the commit | House precedent is the maintainer closes after dogfood; the commit references the ticket only |
## Gotchas & Fixes
| Problem | Root Cause | Fix |
|---------|------------|-----|
| First review: a Jump while the editor was in READING mode did nothing | `reading == true` mounts `ReadingSurface` (no `ProseTextView`); the next `exitReading` would overwrite the hint | `reading = false` in the `.onChange` handler — the remounted Coordinator applies the jump after the generation load; main-queue FIFO puts the jump's scroll after the restore scroll |
| First review: "type immediately" failed — main window stayed behind the palette | `NSApp.activate` cannot re-key within an already-active app; `makeFirstResponder` on a non-key window routes no keystrokes | `makeKeyAndOrderFront` on `tv.window` inside the Coordinator's existing async hop, jumps only |
| `updateNSView` hit SwiftLint's 50-line `function_body_length` | swiftformat expanded the one-line `if span > 0 { … }` into four brace-lines | Extracted the caret-hint block into `Coordinator.applyCaretHint(_:tv:session:)` |
| Audit: a quote that IS the document's leading blanks selected the title | The #ui-r1 leading-blank hop ran for non-zero spans too (the load restore gates its hop on zero length) | `landingSpan` hops only a bare caret; pinned with `"\n\n\nTitle line."` |
| Audit: jump → ⌘S → reopen restored an off-screen selection | `cursorUpdate` ran before the async `scrollRangeToVisible`, recording the pre-jump `scrollOffset` | The record moved into the async hop, after the scroll |
| Test literal compared UTF-16 length with `.count` | `NSRange.length` is UTF-16 units, `String.count` is graphemes — equal for ASCII only | `("…" as NSString).length` + an emoji fixture (location 7 UTF-16 vs 6 Characters) |
| My first UTF-16 probe was useless (7 / 7) | Python `len(str)` counts code points — neither UTF-16 units nor graphemes | Compute Swift test literals with a `swift` probe, not Python |
| First flip-run read green-ish (18 s, the target test absent from the output) | Bare `xcodebuild` after a seconds-old edit can serve a stale binary (#197) | `touch` the file, count `SwiftCompile` lines in the run log, then trust the result — the re-run failed exactly the target expect |
| Two patch anchors missed (once on tab count, once on an indentation-only blank line) | swiftformat/indentation drift between read and patch | Assert-anchored replaces fired BEFORE any write both times; located regions by stripped markers |
| Audit nit: `appliedText` and `anchorRange` were near-copies | The span math existed twice and must change together | `appliedText` = lane gate + `anchorRange` + `replacingCharacters` |
## Files Changed
| File | Change Summary |
|------|---------------|
| `Museion/FixCardStore.swift` | `anchorRange(of:in:)`; `appliedText` routes through it |
| `Museion/PostsModel.swift` | stored `revealRequest: FixCardRevealRequest?` |
| `Museion/PostsModelCards.swift` | `FixCardRevealRequest`, `revealCard(_:)`; header names #204 |
| `Museion/PostEditorView.swift` | `caretHint` → `FixCardRevealRequest?`; the #204 `.onChange` observer; `ProseTextView.landingSpan`; `Coordinator.applyCaretHint` (select, scroll, key on jumps, record after scroll); docs |
| `Museion/FixCardsWindow.swift` | borderless **Jump** on non-stale cards; CardRow doc + header |
| `MuseionTests/FixCardApplyTests.swift` | three #204 pins |
| `Museion/AGENTS.md` | store / model / palette bullets carry #204 |
| `MuseionTests/AGENTS.md` | `FixCardApplyTests` row names the #204 pins |
| `GLOSSARY.md` | **Jump** entry beside Apply |
| `CHANGELOG.md` | `[Unreleased]` → Added |
| `docs/devlog/INDEX.md`, `AGENTS.md` | this log's row + the rolling window |
## Open Items & Next Steps
- [ ] Dogfood on the real app: Jump from reading mode; Jump on a card whose quote sits at the very top of a piece; Jump → ⌘S → reopen lands on the span.
- [ ] Close #204 (maintainer).
- [ ] Ruling wanted: should a disk-valid / buffer-stale card hide Jump? A live check folded into `stale` would also hide Apply — decide both together.
- [ ] Optional: restructure the action-row gate so a closed + promoted card keeps Jump.
- [ ] Unpinned view-layer deltas (no render harness): the `reading = false` handler, `makeKeyAndOrderFront` on jump, `cursorUpdate` after the scroll.
---
*Log written by write-log skill*
+2 -1
View File
@@ -5,6 +5,7 @@ Complete history of session logs in this directory, newest first. One-line summa
<!-- write-log: full-index -->
| Date | Type | File | Summary |
|------|------|------|---------|
| 2026-12-03 | issue | [20261203-issue204-fix-cards-jump-to-the-anchor_log.md](20261203-issue204-fix-cards-jump-to-the-anchor_log.md) | Fix Cards gain Jump: the anchor span selected in the editor, the main window keyed, over the #71 caret rail |
| 2026-12-03 | generic | [20261203-image-drop-27-2-drag-routing-pastes-path_log.md](20261203-image-drop-27-2-drag-routing-pastes-path_log.md) | macOS 27.2 routes drags to the deepest view: NSTextView pasted the file path; the editor now owns drops through one router (rail 729/729) |
| 2026-12-03 | milestone | [20261203-release-011-apex-refresh-is-step-one_log.md](20261203-release-011-apex-refresh-is-step-one_log.md) | Release 0.1.1: apex 1.1.59 refreshed FIRST (full recipe now in the release skill), bump + tag 4a056f9, rail 720/720, DMG notarized; push on go |
| 2026-12-01 | milestone | [20261201-release-010-readme-notes-packaging_log.md](20261201-release-010-readme-notes-packaging_log.md) | Release 0.1.0: version bump + tag, README feature/usage rewrite, distilled release notes, release.sh (Developer ID DMG, notarize); rail 717/717; Developer ID cert pending |
@@ -90,4 +91,4 @@ Complete history of session logs in this directory, newest first. One-line summa
| 2026-09-25 | issue | [20260925-issue50-profile-backup-s2-6_log.md](20260925-issue50-profile-backup-s2-6_log.md) | #50 S2.6 daily profile backup: liveness gate, curated copy, retention 7, RESTORE.md — 8 tests green |
| 2026-09-16 | issue | [20260916-issue14-acp-bridge-s2-2_log.md](20260916-issue14-acp-bridge-s2-2_log.md) | #14 M0 ACP bridge: NDJSON JSON-RPC client, mentor pane, fix-card round-trip, crash restart — 37 tests green |
| 2026-09-05 | issue | [20260905-issue48-provisioning-failure-alert-retry-ux_log.md](20260905-issue48-provisioning-failure-alert-retry-ux_log.md) | #48 shipped: failure card with retry/Not-Now, traversal guard, temp sweep — 30 tests green |
| 2026-09-03 | issue | [20260903-issue42-engine-gate-s2-1_log.md](20260903-issue42-engine-gate-s2-1_log.md) | Engine gate S2.1 shipped: six-path probe, blocking sheet, state.json, About mirror — 12 tests green |
| 2026-09-03 | issue | [20260903-issue42-engine-gate-s2-1_log.md](20260903-issue42-engine-gate-s2-1_log.md) | Engine gate S2.1 shipped: six-path probe, blocking sheet, state.json, About mirror — 12 tests green |