feat(posts): reveal in Finder and copy path
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
This commit is contained in:
1 parent
dd8637e7c7
commit
9aa0314564
10 files changed
+161
-9
No files matched your search
@@ -8,6 +8,8 @@
|
||||
// #179: the write-rail pins — one seam pairs every library store write
|
||||
// with exactly one rescan and owns the error strip; the model owns the
|
||||
// Home (no method takes one).
|
||||
// #205: the row menus' Reveal in Finder / Copy Path target — the piece's
|
||||
// post.md resolved on disk; a vanished piece answers nil.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@@ -68,6 +70,37 @@ func makeModelHome() throws -> (PostsModel, URL) {
|
||||
#expect(model.lastError == nil)
|
||||
}
|
||||
|
||||
@Test @MainActor func `reveal and copy path resolve the post file on disk`() throws {
|
||||
let (model, home) = try makeModelHome()
|
||||
let post = try PostStore.writeNew(body: "# Find Me\n", project: "essays", home: home)
|
||||
|
||||
let url = model.fileURL(for: post)
|
||||
|
||||
let expected = home.appendingPathComponent("projects/essays/\(post.id)/post.md")
|
||||
#expect(url == expected)
|
||||
#expect(FileManager.default.fileExists(atPath: url?.path ?? ""))
|
||||
}
|
||||
|
||||
@Test @MainActor func `reveal and copy path answer nil for a vanished piece`() throws {
|
||||
let (model, home) = try makeModelHome()
|
||||
let post = try PostStore.writeNew(body: "# Ghost\n", home: home)
|
||||
try PostStore.trash(post, home: home)
|
||||
|
||||
#expect(model.fileURL(for: post) == nil)
|
||||
}
|
||||
|
||||
@Test @MainActor func `reveal and copy path resolve an archived piece off the archive root`() throws {
|
||||
let (model, home) = try makeModelHome()
|
||||
let post = try PostStore.writeNew(body: "# Shelved\n", project: "essays", home: home)
|
||||
try PostStore.archive(post, home: home)
|
||||
|
||||
let url = model.fileURL(for: post)
|
||||
|
||||
let expected = home.appendingPathComponent("archive/essays/\(post.id)/post.md")
|
||||
#expect(url == expected)
|
||||
#expect(FileManager.default.fileExists(atPath: url?.path ?? ""))
|
||||
}
|
||||
|
||||
@Test @MainActor func `new project draft lands in the named project`() throws {
|
||||
let (model, home) = try makeModelHome()
|
||||
try PostStore.createProject(named: "essays", home: home)
|
||||
|
||||
Reference in new issue
Block a user