feat(library): search by title and body (#144)
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
The library offered only project/pass-state browsing — no way to find a
piece by content ("which piece was it that talked about X", FEAT-004).
The library column gains a plain-text search field under the Posts
header: a 250 ms-debounced title+body filter over the non-archived
pieces, flat results with title matches first (both halves keep the
scan's Finder order), a mono match count, and the full row context menu
(Rename/Convert/Move/Archive/Trash) on result rows — extracted into one
postRow helper shared with the sections. Body matches go through
PostStore.readBody, so frontmatter never matches (machinery, not
prose). Clearing returns the project sections; state is view-local, so
both render sites (unfocused layout + focus-mode reveal) get the field.
The scan runs as a nonisolated static async helper awaited from
.task(id: trimmedQuery): off MainActor (a nonisolated async function
doesn't inherit the caller's actor) while staying INSIDE the structured
task, so a superseding keystroke or clear actually cancels the sweep
between pieces — the spec's Task.detached shape never received
cancellation (two-reviewer convergence in the finish-audit caught it,
plus the code comment claiming it did), and trimming the task id stops
whitespace-only edits from re-running identical scans.
Deliberately deferred: re-filter on a watcher rescan while a query sits
unchanged (any keystroke refreshes), and a PostScanCache-style body
memo (full-body re-read per sweep — same unbounded-read ceiling as
Post.scan; upgrade path noted in the helper's ponytail comment).
Known pre-existing (unchanged by this diff, proven by stash control):
repo-wide swiftlint exits 2 with 289 violations / 72 serious at HEAD;
this diff adds zero error-severity violations.
Suite 574/574 (xcresult executed count).
Closes #144
This commit is contained in:
1 parent
a2f6dc1653
commit
53c314d4e1
6 files changed
+225
-25
No files matched your search
@@ -10,6 +10,8 @@ All notable changes to this project will be documented in this file. The format
|
||||
|
||||
### Added
|
||||
|
||||
- **library:** Search across titles and bodies (#144, FEAT-004) — the library column gains a plain-text search field under the Posts header: a debounced (250 ms) title+body filter over the non-archived pieces, body scan off MainActor through `PostStore.readBody` (frontmatter never searched), flat results with title matches first (Finder order preserved), match count, and the full context menu on result rows. Clearing returns the project sections. Suite 574 (issue #144)
|
||||
|
||||
- **editor:** Drop an image into the prose (#141) — dragging an image file onto a saved post's prose editor COPIES it (never moves) into the piece's `assets/` under a parser-clean slugged name (collision `-2` via the shared uniqueFile helper) and inserts `` at the drop point with `alt` selected for immediate type-over; one edit step = one undo. The type gate is exactly the publish rail's set (#34's `Micropub.mimeType` — PNG/JPEG/GIF/WebP/SVG: nothing enters `assets/` that can't ship), a Finder folder or a dropped SYMLINK refuses (`copyItem` would land the link itself and the publish rail would refuse the whole send), and drafts/outline/guest surfaces refuse loudly with a transient strip. Routing rides the window-level SwiftUI drop destination — field-verified to starve every deeper drag destination (nested SwiftUI targets never fire, AppKit NSDraggingDestination never fires) — pure-markdown sets keep the open-as-guest behavior, mixed md+image sets refuse loudly instead of silently dropping the images. The drop-point mapping inverts the one geometry source that answers under SwiftUI hosting (`firstRect`, bottom-up screen coords): a viewport-banded sample→bracket→binary-search over it — non-contiguous layout returns garbage rects for off-screen characters, so only in-band rects are trusted — then a whitespace-gap slide so a landing never splices inside a word or an existing ref; the solve is a pure function pinned by windowless tests, and the typewriter inset re-syncs after the edit so scrolling never freezes. Eleven tests incl. a flip-verified finish-audit cycle; suite 557 (issue #141)
|
||||
- **publish:** Illustrations travel with it (PRD S6.2, G12) — a piece's `assets/` ink-sketch images now publish: Send as Draft first uploads every referenced image to Micro.blog's media endpoint (discovered per send via `GET ?q=config`, one multipart `file` POST per FILE — duplicate refs share an upload — decoding Location/body-url behind the trust gate), then each `` ref REWRITES IN PLACE with its uploaded URL in the wire content, so the image renders exactly where the writer placed it and the alt rides the markdown (live dogfood killed the first shape: a Micropub `photo` property renders wherever the theme decides — the bottom — losing position; no property ships at all now). The piece on disk never changes. The floor (G12): a photo without alt text never ships — the send refuses naming the illustration BEFORE anything touches the wire, and a parsed body ref is the only way an image ships. Pre-flight gates every payload: the endpoint's exact formats only (PNG/JPEG/GIF/WebP/SVG — nothing enters `assets/` that can't ship), path containment resolved through symlinks (a planted link never uploads outside-file bytes under the writer's token), all-or-nothing uploads. A URL carrying markdown-active characters rides the angle form `` — a plain-paren destination would close at the first `)` and smuggle a live link into the published post (the frontmatter trust gate doesn't cover markdown's grammar). The mentor is consulted for nothing — style judgment stays with the author. Seventeen tests incl. a flip-verified audit cycle; suite 546 (issue #34)
|
||||
- **publish:** Micropub draft → publish to Micro.blog (PRD S6.1, G2/G11) — a Publish button in the editor toolbar opens the two-step ask: Send as Draft (JSON Micropub `h=entry` create — name = the piece's Title, markdown content verbatim, `post-status: draft`; the piece's frontmatter `category:` is accepted but never travels), review via the Micro.blog preview link, then Publish (the `action=update` post-status flip against the piece's remembered `micropub_url` — persisted in frontmatter so a draft survives a reopen; Send Again re-drafts after edits). The Micro.blog app token lives in the Keychain (login keychain, entered once in the sheet, re-offered only on an auth failure — rotation replaces). Every draft URL passes a format gate at both the decode and the scan read-back: the URL is trust-boundary data landing in frontmatter, and a newline-`---` rider would close the block and reparse as attacker markdown in the writer's piece; the preview URL is display-only, never the publish target. Frontmatter-only stamps keep the body and foreign keys byte-identical (issue #33)
|
||||
|
||||
Reference in new issue
Block a user