Implement live accessibility announcements
The board speaks when files change under the user, per DESIGN/10 § Live board announcements. BoardDiff is the pure snapshot summarizer (identity sets for cards/lanes added/edited/moved/deleted — ids, not tallies, so pro-m1's semantic commit engine can build on it; edited = rendered content only, moved beats edited, implied events don't steal the subject). BoardAnnouncer is the decision seam: focusOutcome computes the vanishing-focus sentence and the walk-up-then-sideways recovery (next lane by order, else previous, board container only when none remain, never the trash); speech(for:) is the one-sentence precedence ladder — raised condition > bracket completion > cleared condition > vanished focus > digest — foreign-only for the last two rungs, so app-mediated echoes stay silent. BoardStore.land assembles ReloadFacts and posts exactly one sentence per reload through the injectable announce outlet (AccessibilityAnnouncer, medium priority, never interrupting). Selection recovery layers on top of ItemReferenceSet re-resolution — survivors veto, the emptied selection lands on the vanished item's lane and re-arms ⌘N's active-lane memory. performWholesale(announcing:) arms a completion phrase consumed by the closing reload — nil on every base bracket today; pro-m1 fills git phrasings. Locks raised outside the reload path (vanished root, unwritable location) announce through the same ladder, and the banner strip is a labeled "Board status" container whose row labels are the announced sentences (AccessibilityPhrases.bannerLabel — one string for eye and ear). Announcements classify at reload granularity (WatchOrigin) as a deliberate interim: DESIGN/02's EchoLedger (per-file classification, the announcer's specified input, git-free) was scheduled with the auto-committer that the edition split moved to pro-m1 — filed on the Redesign board for a ruling. 1533 unit tests green, both schemes build. Claude-Session: https://claude.ai/code/session_01SR4XGjmBE16ZUYWpfFHXwY
This commit is contained in:
@@ -134,4 +134,131 @@ struct AccessibilityPhrasesTests {
|
||||
#expect(AccessibilityPhrases.trashVisibility(shown: true) == "Trash shown")
|
||||
#expect(AccessibilityPhrases.trashVisibility(shown: false) == "Trash hidden")
|
||||
}
|
||||
|
||||
// MARK: - The live board digest
|
||||
|
||||
/// 10-accessibility.md's own example sentence, reproduced exactly — which is what fixes the
|
||||
/// category order's first pair (edited before added).
|
||||
@Test("The digest is the design's own sentence")
|
||||
func digestExample() {
|
||||
var diff = BoardDiff()
|
||||
diff.cards.edited = [id(1), id(2)]
|
||||
diff.cards.added = [id(3)]
|
||||
|
||||
#expect(AccessibilityPhrases.boardChanged(diff) == "Board changed: 2 cards edited, 1 card added")
|
||||
}
|
||||
|
||||
@Test("Zero categories are omitted, never spoken as 'and 0 cards moved'")
|
||||
func digestOmitsEmptyCategories() {
|
||||
var diff = BoardDiff()
|
||||
diff.cards.deleted = [id(1)]
|
||||
|
||||
#expect(AccessibilityPhrases.boardChanged(diff) == "Board changed: 1 card deleted")
|
||||
}
|
||||
|
||||
@Test("Every count folds its plural")
|
||||
func digestFoldsPlurals() {
|
||||
var diff = BoardDiff()
|
||||
diff.cards.moved = [id(1)]
|
||||
diff.lanes.added = [id(2), id(3)]
|
||||
|
||||
#expect(AccessibilityPhrases.boardChanged(diff) == "Board changed: 1 card moved, 2 lanes added")
|
||||
}
|
||||
|
||||
/// Cards before lanes, and within a kind: edited, added, moved, deleted.
|
||||
@Test("The category order is fixed, cards before lanes")
|
||||
func digestOrdering() {
|
||||
var diff = BoardDiff()
|
||||
diff.cards.edited = [id(1)]
|
||||
diff.cards.added = [id(2)]
|
||||
diff.cards.moved = [id(3)]
|
||||
diff.cards.deleted = [id(4)]
|
||||
diff.lanes.edited = [id(5)]
|
||||
diff.lanes.added = [id(6)]
|
||||
diff.lanes.moved = [id(7)]
|
||||
diff.lanes.deleted = [id(8)]
|
||||
|
||||
#expect(
|
||||
AccessibilityPhrases.boardChanged(diff)
|
||||
== "Board changed: 1 card edited, 1 card added, 1 card moved, 1 card deleted, "
|
||||
+ "1 lane edited, 1 lane added, 1 lane moved, 1 lane deleted"
|
||||
)
|
||||
}
|
||||
|
||||
/// "Silence about a mutating board is a lie" — a change no bucket counts still says something.
|
||||
@Test("An uncounted change is the bare sentence")
|
||||
func digestBareSentence() {
|
||||
var diff = BoardDiff()
|
||||
diff.boardChanged = true
|
||||
|
||||
#expect(AccessibilityPhrases.boardChanged(diff) == "Board changed")
|
||||
}
|
||||
|
||||
@Test("A board that did not change says nothing at all")
|
||||
func digestSilence() {
|
||||
#expect(AccessibilityPhrases.boardChanged(BoardDiff()) == nil)
|
||||
}
|
||||
|
||||
// MARK: - A vanishing focus
|
||||
|
||||
@Test("A vanished card is named — the design's own sentence")
|
||||
func vanishedCard() {
|
||||
#expect(
|
||||
AccessibilityPhrases.vanishedFocus(.card(title: "Fix login"))
|
||||
== "Card 'Fix login' was deleted externally"
|
||||
)
|
||||
}
|
||||
|
||||
@Test("A vanished lane names itself and what went with it")
|
||||
func vanishedLane() {
|
||||
#expect(
|
||||
AccessibilityPhrases.vanishedFocus(.lane(title: "Doing", cards: 5))
|
||||
== "Lane 'Doing' was deleted externally, with 5 cards"
|
||||
)
|
||||
#expect(
|
||||
AccessibilityPhrases.vanishedFocus(.lane(title: "Doing", cards: 1))
|
||||
== "Lane 'Doing' was deleted externally, with 1 card"
|
||||
)
|
||||
}
|
||||
|
||||
/// "With 0 cards" would be an odd way to say "and nothing else went with it".
|
||||
@Test("An empty lane vanishing has no count clause")
|
||||
func vanishedEmptyLane() {
|
||||
#expect(
|
||||
AccessibilityPhrases.vanishedFocus(.lane(title: "Done", cards: 0))
|
||||
== "Lane 'Done' was deleted externally"
|
||||
)
|
||||
}
|
||||
|
||||
@Test("An untitled item still gets a name in the sentence")
|
||||
func vanishedUntitled() {
|
||||
#expect(
|
||||
AccessibilityPhrases.vanishedFocus(.card(title: nil))
|
||||
== "Card 'Untitled' was deleted externally"
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - The banner strip
|
||||
|
||||
/// The tone must reach a VoiceOver user as a *word*: colour cannot carry it, and the row's label
|
||||
/// and its announcement are the same string by construction.
|
||||
@Test("A banner row speaks its tone before its headline")
|
||||
func bannerLabel() {
|
||||
#expect(AccessibilityPhrases.bannerLabel(tone: .error, headline: "Couldn't move 'Fix login'")
|
||||
== "Error: Couldn't move 'Fix login'")
|
||||
#expect(AccessibilityPhrases.bannerTonePrefix(.warning) == "Warning")
|
||||
#expect(AccessibilityPhrases.bannerTonePrefix(.info) == "Status", "the platform's word for a calm state")
|
||||
}
|
||||
|
||||
@Test("A healed condition states the regained capability, not the vanished cause")
|
||||
func clearedConditions() {
|
||||
#expect(AccessibilityPhrases.readOnlyLockCleared == "The board is editable again")
|
||||
#expect(AccessibilityPhrases.reloadBreakageCleared == "The board is loading again")
|
||||
}
|
||||
}
|
||||
|
||||
/// Distinct identities for the digest cases, which care only about *counts* — the diff's own suite
|
||||
/// is where identity is at stake.
|
||||
private func id(_ n: Int) -> ItemID {
|
||||
ItemID(rawValue: "0000000\(n)-0000-4000-8000-000000000000")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user