test(search): red pin for snapshot invalidation
CI / ci (push) Canceled after 0s

The mounted search snapshot is keyed only to the trimmed query, so
library mutations never restart the sweep: archived/trashed rows
linger in the results and edited bodies never enter them until the
query changes or the view remounts.

Pin the invalidation contract at controller level, the way the pure
seam is pinned: LibrarySearch.SearchKey (query + Home + the model's
content revision) and the LibrarySearch.Snapshot isFresh gate decide
whether a landed sweep may render. The rail pins drive the real
rescan path and prove archive, trash, and a same-query body edit
each move PostsModel.contentRevision. The property is a stub here —
never bumped — so those three pins fail red on this commit.
This commit is contained in:
AlexKucera committed 2026-11-11 22:19:01 +01:00
1 parent 5915178ce8
commit c0cd60b798
3 files changed
+146

No files matched your search

+27
View File
@@ -32,4 +32,31 @@ nonisolated enum LibrarySearch {
}
return titleHits + bodyHits
}
/// #144 (mounted half): the identity of one search sweep — the
/// trimmed query, the Home it ran under, and the library content
/// revision it saw (`PostsModel.contentRevision`). The column's
/// `.task(id:)` re-keys on ANY difference, so a keystroke, a Home
/// repoint, or a library write that landed after the last sweep
/// restarts it instead of serving the stale snapshot.
nonisolated struct SearchKey: Equatable {
var query: String
var homePath: String
var revision: Int
}
/// #144 (mounted half): one landed sweep — the results plus the key
/// that produced them. `isFresh` is the column's stale gate: results
/// render only under the key that computed them, so an archived,
/// trashed, renamed, or since-edited library drops to the recompute
/// state, never stale rows.
nonisolated struct Snapshot: Equatable {
var key: SearchKey
var results: [Post]
/// A snapshot renders only under its own key.
func isFresh(for key: SearchKey) -> Bool {
self.key == key
}
}
}
+9
View File
@@ -96,6 +96,15 @@ final class PostsModel {
/// all times (#107).
private(set) var posts: [Post] = []
/// #144 (mounted half): the library content revision — the search
/// snapshot's invalidation signal. The rescan rail bumps it whenever
/// a scan sees the library change: a Post-list change OR any re-read
/// post.md (a body-only edit compares equal as a Post — #143's skip
/// keeps the list still — yet the search must re-sweep). The `posts`
/// assignment skip stays untouched: panes never regroup on bumps,
/// only the mounted search re-keys.
private(set) var contentRevision = 0
/// The selected Post's id; nil = nothing selected (empty editor).
/// #146: setter internal — the split-out domain extensions set it.
var selectedPostID: String?