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
73 lines
8.9 KiB
Markdown
73 lines
8.9 KiB
Markdown
# #205 — Reveal in Finder + Copy Path on piece rows
|
||
|
||
> **Date:** 2026-12-03
|
||
> **Type:** issue
|
||
> **Reference:** https://git.babylondreams.de/AlexKucera/Museion/issues/205 — "Add Reveal in Finder and Copy Path to sidebar"
|
||
|
||
## Goal
|
||
|
||
Give every piece row a Finder hand-off: **Reveal in Finder** opens the piece's `post.md` selected, **Copy Path** puts its absolute path on the clipboard. The ticket was a title only — no body, no comments. The owner resolved the fog in one clarifying round: both the library column's row menu AND the Archive pane's row menu; the `post.md` FILE path (not the folder); Archive entries appended after its existing Move Back / Rename / Convert.
|
||
|
||
Scenario (the slice's north star): given a piece whose folder exists under the watched Home, right-click → Reveal / Copy Path → Finder opens with `post.md` selected / the absolute `post.md` path lands on the pasteboard — and a vanished piece (folder gone) does nothing, silently.
|
||
|
||
## What Was Done
|
||
|
||
- `Museion/PostsModelIdentity.swift` — `PostsModel.fileURL(for:) -> URL?`: the piece's `post.md` resolved through the ONE id→folder resolver `PostStore.folder(of:home:)` against the model-owned `watchedHome`. Pure read; nil when the folder is gone. Header names the second resident.
|
||
- `Museion/WorkspaceChrome.swift` — `FinderHandOffButtons: View` (Reveal → `NSWorkspace.shared.activateFileViewerSelecting`, Copy Path → `NSPasteboard.general` `clearContents` + `setString(url.path)`), each behind `if let url = model.fileURL(for:)`. `import AppKit` added; header updated.
|
||
- `Museion/PostsLibraryColumn.swift` + `Museion/ArchivePaneView.swift` — two lines each inside the existing `.contextMenu`: `Divider()` + `FinderHandOffButtons(model:post:)`. Library: between Move to Archive and the destructive Trash. Archive: appended after Convert.
|
||
- `MuseionTests/PostsModelTests.swift` — three pins: projects/ resolve → exact URL + file exists; archive/ resolve → exact URL + file exists; vanished-after-trash → nil. Header lines added.
|
||
- `Museion/AGENTS.md` — five bullets: WorkspaceChrome (the new struct), PostsLibraryColumn (the fragment's placement), PostsModel extensions list (names `PostsModelIdentity.swift`), LibraryPostRow (menu count + callers-attach attribution), PostsModelWrites (reverted to its original text after the read moved out).
|
||
- Reviews: implement close (standards + spec, two rounds) and finish-audit (general + security + ponytail). Findings below.
|
||
|
||
## Decisions & Rationale
|
||
|
||
| Decision | Rationale |
|
||
|----------|-----------|
|
||
| The seam is a model read, not a view helper | The SwiftUI menu body is untested by repo convention; `fileURL(for:)` is the observable the pins can reach. Resolves against `watchedHome` (the model owns the Home — no public method takes one, #179). |
|
||
| `fileURL` lives in `PostsModelIdentity.swift`, not `PostsModelWrites.swift` | First landed in the writes file; the standards review flagged a read parked under `// MARK: Projects` in the write-rail file. The identity file's charter is "(Home, ID) questions route through here" — a path IS that identity resolved. Not the write rail: nothing written, no strip. |
|
||
| One `FinderHandOffButtons` struct shared by both menus | First version pasted the two Buttons + AppKit closures into both menus verbatim (Duplicated Code). Extracted to the shared-chrome file. A `finderButtons(model:post:)` View-extension wrapper was tried and DELETED — a Middle Man: same-length call, module-wide extension for two callers. |
|
||
| `post.md` path, POSIX `url.path` | Owner decision. Finder's own Copy Path yields the POSIX path; `url.absoluteString` would be a one-line swap if a `file://` form is ever wanted. |
|
||
| nil when the piece is gone → both entries no-op | The scenario's third line. Never reveal a stale path; the next rescan drops the row. |
|
||
| Three pins, not one | Each guards a distinct discriminator: projects/ resolve, archive/ resolve (D1 makes Archive half the feature — the general reviewer caught the gap), vanished → nil. The flip cycle proved the vanished and archive pins redden independently of the resolve pin. |
|
||
| `clearContents()` before `setString` | Drops every declaration from the previous pasteboard owner — no stale file-URL or RTF flavor survives beside the new string (security review confirmed). |
|
||
| Declined: rename `fileURL` → `postMDURL`/`documentURL` | Sibling of the resolver `folder(of:)`; the doc comment states the target. Reviewer judgement call, declined. |
|
||
| Declined: folder-present-but-`post.md`-deleted edge | `folder(of:)` answers the directory; the file check is Finder's. Outside the scenario's "folder gone"; self-heals on rescan. |
|
||
|
||
## Gotchas & Fixes
|
||
|
||
| Problem | Root Cause | Fix |
|
||
|---------|------------|-----|
|
||
| `-only-testing` on the new pins printed `** TEST SUCCEEDED **` but the bundle said `executed: 0` | Backticked free-function names match zero Swift Testing tests under a name filter — the vacuous-green trap (#31/#134). Suite-name filters don't run free functions either (MuseionTests/AGENTS.md). | Stopped hand-rolling; the sanctioned rail `./scripts/full-test.sh start` + `status` is the only scoped-or-full verdict, counts from `xcresulttool` only. |
|
||
| Two mis-patches in a row on `WorkspaceChrome.swift`'s tail (a collapsed newline in `PaneHeader.body`, then the new struct nested four levels deep inside `PaneHeader`) | The patch tool kept the leading tabs of my `old_string`; the end-of-file anchor had no trailing context to pin the column | After the second failure, rewrote the tail via a scripted read/replace/write instead of a third patch; verified 4 top-level structs, 0 extensions, balanced braces. Rule: two failed patches in one region → rewrite the enclosing region, don't patch a third time. |
|
||
| Formatter flagged `ArchivePaneView.swift` closing brace (indent) — twice, same line | My inserted `.contextMenu` entries were right; the closing brace one tab off | `swiftformat` on the file; it touched only that brace (+14/−0 → pure additions). |
|
||
| Standards review: 4 LOW findings on the first shape | Duplicated menu pair; read in the write-rail file; tautological `#expect(lastError == nil)`; test header missing #205 | All fixed; second-round review confirmed all four hold. |
|
||
| Finish-audit fanout: 2 of 3 reviewer children died on HTTP 429 | Provider rate limit — three children plus the parent stream over the budget; both died before any tool call (transcripts held only the brief echo) | Solo, staggered re-dispatch after ~3 min cool-down; both completed. Nothing reported on a dead child. |
|
||
| Post-fix lint flagged two files for trailing newline | The kernel's `write_file` after `read_file()["text"]` dropped the EOF newline in my own fix batch | `swiftformat` on the two files. Exactly why the audit skill says re-lint after fixes. The verify rail was re-run on the final bytes afterwards. |
|
||
| RED proof: stashing the impl produced a compile error, not a test failure | The method didn't exist pre-fix — the pins can't build without the seam | That IS the honest red. The discriminating flip came later: bypassing the resolver (build `projects/<project>/<id>/post.md` without consulting disk) reddened exactly the vanished + archive pins (`733/735`), resolve pin green. |
|
||
|
||
## Files Changed
|
||
|
||
| File | Change Summary |
|
||
|------|---------------|
|
||
| `Museion/PostsModelIdentity.swift` | `fileURL(for:)` — the row menus' post.md resolver; header names #205 |
|
||
| `Museion/WorkspaceChrome.swift` | `FinderHandOffButtons` struct + `import AppKit`; header updated |
|
||
| `Museion/PostsLibraryColumn.swift` | `Divider()` + the fragment between Move to Archive and Trash |
|
||
| `Museion/ArchivePaneView.swift` | `Divider()` + the fragment appended after Convert |
|
||
| `MuseionTests/PostsModelTests.swift` | three pins (projects/ resolve, archive/ resolve, vanished → nil) + header |
|
||
| `Museion/AGENTS.md` | five bullets (Chrome, LibraryColumn, PostsModel extensions, LibraryPostRow, Writes reverted) |
|
||
| `docs/devlog/20261203-issue205-reveal-in-finder-copy-path_log.md` | this log |
|
||
| `docs/devlog/INDEX.md`, `AGENTS.md` | log registration (row + 10-row window) |
|
||
|
||
## Verification
|
||
|
||
Final tree (run `20261203T171228Z`, postdates the last edit): `./scripts/full-test.sh` **735 executed / 735 passed / 0 failed** (734 baseline + 1 new pin… the three pins replaced the original two, net +1); `swiftformat --lint` exit 0, 0/5 files; `swiftlint lint` exit 0, 0 findings; `xcodebuild build` green. Flip: resolver bypass → `733/735`, exactly the vanished + archive pins red with their designed assertions.
|
||
|
||
## Open Items & Next Steps
|
||
|
||
- [ ] `DESIGN.md:188` row-menu enumeration ("Rename / Convert / Move / Trash") has been stale since #108 — pre-existing, outside the DOX chain, not this diff. Lands with the next DESIGN.md sweep.
|
||
- [ ] Unpinned by convention: the SwiftUI menu bodies (labels, placement, `activateFileViewerSelecting`, pasteboard contents). Two review rounds were their only gate. Hand-test: right-click a piece in the library or Archive pane.
|
||
|
||
---
|
||
|
||
*Log written by write-log skill*
|