Every piece row gains a Finder hand-off: Reveal in Finder opens the piece's post.md selected, Copy Path puts its absolute path on the clipboard (#205). One shared FinderHandOffButtons fragment in the workspace chrome serves both menus - the library column (between Move to Archive and the destructive Trash) and the Archive pane (appended after Convert). Both act on PostsModel.fileURL(for:), which resolves the piece through the one PostStore.folder(of:home:) resolver against the watched Home (never the scan snapshot) and answers nil when the piece is gone, so a vanished row no-ops instead of revealing a stale path. fileURL lives in PostsModelIdentity - the (Home, ID) file - not the write rail: a pure read, nothing written, no strip. A View-extension wrapper was tried and deleted as a Middle Man; the menus mount the struct directly. +3 tests (projects/ resolve, archive/ resolve, vanished -> nil), flip-verified: bypassing the resolver reddens exactly the vanished and archive pins (733/735). Rail 735/735; SwiftFormat and SwiftLint clean. Reviews: standards + spec (two rounds), then finish-audit (general, security, ponytail) - the audit added the archive-root pin and fixed three stale headers. DOX: five Museion/AGENTS bullets. The release 0.1.2 log's rows still belong to another session and stay in the working tree; INDEX and the AGENTS window here carry only the #205 row. Closes #205
42 lines
1.9 KiB
Swift
42 lines
1.9 KiB
Swift
//
|
|
// PostsModelIdentity.swift
|
|
// Museion
|
|
//
|
|
// brief-28 (home-repoint-retains-old-editor-target): document identity for
|
|
// the open session. Every "is this piece open" question in the model
|
|
// routes through here — select, the structural rail, the pass guard, the
|
|
// card refresh, Micropub. The bare `session.postID == id` comparison is
|
|
// retired: two libraries can hold the same slug, and the id alone matched
|
|
// a session retained from another library (the repoint finding's seam).
|
|
// #205: also the piece's on-disk path (`fileURL(for:)`) — the same
|
|
// (Home, ID) identity resolved to post.md for the row menus' Finder
|
|
// hand-off; nil when the piece is gone.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
extension PostsModel {
|
|
/// brief-28: is the open session THIS library's piece `id`? Identity is
|
|
/// (Home, ID) — `watchedHome` is the Home half, so the answer is "the
|
|
/// buffer belongs to the piece the current library lists under that id".
|
|
/// A session born under another Home (or an external guest) is never
|
|
/// the open piece, whatever its id says; nothing bound = nothing open.
|
|
func openSessionTargets(_ id: String) -> Bool {
|
|
guard let session, let home = watchedHome else { return false }
|
|
return session.targets(postID: id, home: home)
|
|
}
|
|
|
|
/// #205: the piece's `post.md` on disk — the row menus' Reveal in
|
|
/// Finder / Copy Path target. The same (Home, ID) identity resolved to
|
|
/// a path: `watchedHome` is the Home half, `PostStore.folder(of:)` the
|
|
/// ONE id→folder resolver (never the scan snapshot — the folder is
|
|
/// what Finder opens). A pure read — nothing written, no strip. Nil
|
|
/// when the piece is gone, so the menu entries no-op instead of
|
|
/// revealing a stale path.
|
|
func fileURL(for post: Post) -> URL? {
|
|
guard let home = watchedHome,
|
|
let dir = PostStore.folder(of: post.id, home: home) else { return nil }
|
|
return dir.appendingPathComponent("post.md")
|
|
}
|
|
}
|