feat(fix-cards): jump to the anchor

Jump on a Fix Card selects the anchor's span in the piece's
editor and makes the main window key (#204). The span is the
card's quote at its 1-based occurrence, resolved against the
LIVE session text so a dirty buffer still lands, and it rides
the reading flip-back's caret rail: caretHint widens from a
(location, token) tuple to FixCardRevealRequest (SwiftLint
large_tuple), one shared token counter so a jump and a flip-back
can never collide, a zero-length range stays a bare caret and a
non-zero range selects. A jump leaves reading mode first
(reading = false, not exitReading, which stamps its own
zero-length hint), writes nothing, and re-fires per click.

The palette offers Jump on every non-stale card that still shows
an action row; stale anchors have nothing to land on. The
landing math is ProseTextView.landingSpan - a bare caret hops
past leading blanks, a span never does (a quote that IS the
leading blanks selects those blanks) - and appliedText now
routes through anchorRange so Apply and Jump share one
occurrence math.

Two review rounds closed the view-layer gaps the pure pins
could not see: a jump dropped in reading mode; a main window
that never became key (NSApp.activate is a no-op once the
palette's click activated the app - the Coordinator makes
tv.window key instead); a cursor record taken before the scroll.

+3 tests (anchorRange occurrence math with a UTF-16 fixture, the
model's reveal stamp, landingSpan), each flip-verified. Rail
732/732; SwiftFormat and SwiftLint clean. DOX: Museion/AGENTS,
MuseionTests/AGENTS, GLOSSARY gains Jump.
This commit is contained in:
AlexKucera committed 2026-12-03 17:48:55 +01:00
1 parent d183d735d7
commit 97893147a6
10 files changed
+259 -52

No files matched your search

+27 -1
View File
@@ -4,7 +4,8 @@
//
// #146: the fix-card extensions of PostsModel — stored-card surfacing
// (#23), apply/skip/done (#25, S3.2/S3.3), and promote (#26, S4.1) —
// moved from PostsModel.swift (file-length ceiling), code unchanged.
// moved from PostsModel.swift (file-length ceiling), code unchanged;
// #204: the jump-to-the-anchor reveal (`revealCard`, `FixCardRevealRequest`).
//
import Foundation
@@ -133,6 +134,31 @@ extension PostsModel {
}
}
// MARK: Jump to the anchor (#204)
/// #204: one jump-to-the-anchor request — the anchor's span in the live
/// session text plus a token that advances per jump so the editor column
/// (which applies once per token) re-fires on a repeated jump. Ephemeral
/// view state: nothing here ever reaches disk.
struct FixCardRevealRequest: Equatable {
var range: NSRange
var token: Int
}
extension PostsModel {
/// #204: jump to a card's anchor — the palette's Jump. Resolves the
/// anchor against the LIVE session text (a dirty buffer still lands
/// where the writer sees it) and stamps one reveal request; the editor
/// column observes it and selects + reveals the span. A stale anchor
/// (quote gone, occurrence short) stamps nothing — the previous
/// request stands. Touches no text, no card, no disk: a jump is a view
/// act, the writer's hands stay on the wheel.
func revealCard(_ card: FixCardStore.StoredFixCard) {
guard let session, let range = FixCardStore.anchorRange(of: card, in: session.text) else { return }
revealRequest = FixCardRevealRequest(range: range, token: (revealRequest?.token ?? 0) + 1)
}
}
// MARK: Fix Card promote (#26, S4.1/S4.3)
/// #26 (S4.1): what Promote did — the Learning landed, or the operation