test(search): red pin for snapshot invalidation
CI / ci (push) Canceled after 0s
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:
1 parent
5915178ce8
commit
c0cd60b798
3 files changed
+146
No files matched your search
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user