Comments, phase 3 — search, the thread find, announcements, and a11y

Board search reaches comment bodies through a search-owned transient
index: the first live-query keystroke sweeps comments/*/index.md
off-actor (.draft and comments/.trash excluded), keystrokes re-filter
in memory, the index discards on clear — the snapshot stays O(cards).
⌘F routes by focus: the comments pane gets an app-owned find bar
spanning the whole rendered thread (next/prev cross rows with
wraparound); body and composer keep NSTextFinder; Find Next/Previous
graduate from FutureCommands. Foreign comment changes speak
path-shaped beside the announcer's ladder ("New comment on 'X'",
plural folds), narrowed by EchoLedger receipts consumed through
CommentPath.classify — and that read fixed a latent footprint bug
where a comment receipt resolved against the card's attachment
listing, read .absent, and classified the user's own write as
foreign. The pane completes its a11y story: flattened comment
elements with Edit/Delete/Reveal custom actions (un-flattening
during inline edit), phrase-table vocabulary, labeled composer and
sort control, and an audit over the open pane on a comment-seeded
fixture (runnable only where automation permission exists).

Claude-Session: https://claude.ai/code/session_01SR4XGjmBE16ZUYWpfFHXwY
This commit is contained in:
2026-07-30 21:30:22 -04:00
parent fe3ffac48e
commit 9588f7b1f0
31 changed files with 3036 additions and 73 deletions
+85
View File
@@ -85,3 +85,88 @@ public struct CommentPath: Sendable, Equatable {
return CommentPath(cardPath: cardPath, kind: .comment(ItemID(rawValue: entry)))
}
}
// MARK: - CommentThreadChanges
/// **What happened to one card's thread between two reads** `BoardDiff` one level down, and for the
/// same consumer: something has to say what changed before anything can say it out loud.
///
/// ### Why the thread and not the snapshot
///
/// `BoardDiff` compares two `BoardModel`s, and a `BoardModel` has never heard of a comment that is
/// 01-storage-format.md Enhanced schema's stated exception to snapshot completeness, and it is why
/// foreign comment changes are "described by **path shape**" rather than by a diff. The path shape
/// answers *what kind* of change a path is (`CommentPath` above); this answers *which comments*
/// changed, from the only two pictures anything in the app actually holds the thread the card
/// window was showing, and the thread it has just re-read (`CardComments.reload`).
///
/// ### Three buckets, and the one that is deliberately absent
///
/// Arrivals, edits and departures, which are the three the verb family names ("Comment on", "Edit
/// comment on", "Delete comment on" 06-history-undo.md's family per 01). **An attachment landing
/// on a comment is not a change here**: the comparison is the `index.md` document, so a file imported
/// into a comment's `attachments/` moves nothing in this value. That is deliberate rather than an
/// omission 10-accessibility.md announces comment *arrivals*, the design's verb family is about the
/// comment's text, and a chip appearing is a visible change with no sentence written for it.
///
/// `.draft` and `comments/.trash/` never appear because they are not in a thread at all
/// (`CommentThread`'s own exclusion), so "a draft saved on another machine" and "a comment this window
/// deleted a moment ago" are both silent by construction rather than by a filter.
public struct CommentThreadChanges: Sendable, Equatable {
/// Comments in the new thread that were not in the old one.
public var arrived: [ItemID] = []
/// Comments in both, whose `index.md` differs.
public var edited: [ItemID] = []
/// Comments in the old thread that are not in the new one.
public var deleted: [ItemID] = []
public init(arrived: [ItemID] = [], edited: [ItemID] = [], deleted: [ItemID] = []) {
self.arrived = arrived
self.edited = edited
self.deleted = deleted
}
public var isEmpty: Bool {
arrived.isEmpty && edited.isEmpty && deleted.isEmpty
}
/// The comparison. Order follows the **new** thread for the two buckets it can (the display order
/// the loader produced) and the old thread for departures, so a caller naming "the" arrival names
/// the one a reader would reach first.
public static func between(_ old: CommentThread, _ new: CommentThread) -> CommentThreadChanges {
let older = Dictionary(old.comments.map { ($0.id, $0) }, uniquingKeysWith: { first, _ in first })
let newer = Set(new.comments.map(\.id))
var changes = CommentThreadChanges()
for comment in new.comments {
guard let was = older[comment.id] else {
changes.arrived.append(comment.id)
continue
}
if was.document != comment.document {
changes.edited.append(comment.id)
}
}
for comment in old.comments where !newer.contains(comment.id) {
changes.deleted.append(comment.id)
}
return changes
}
/// This value with everything the `EchoLedger` vouched for removed **the app's own writes never
/// announce as foreign** (10-accessibility.md Live board announcements), applied per comment.
///
/// It is a narrowing rather than a gate for `EchoVerdicts.foreign`'s reason: a reload can carry an
/// app-mediated edit *and* a foreign arrival at once (an agent files a comment in the same debounce
/// window as the user's inline save), and the honest sentence describes the half nobody vouched
/// for rather than all of it or none of it.
public func excluding(_ vouched: Set<ItemID>) -> CommentThreadChanges {
guard !vouched.isEmpty else { return self }
return CommentThreadChanges(
arrived: arrived.filter { !vouched.contains($0) },
edited: edited.filter { !vouched.contains($0) },
deleted: deleted.filter { !vouched.contains($0) }
)
}
}