Compare commits

...
Author SHA1 Message Date
poli0981andClaude Opus 5.5 2f6948ec01 feat: a screen reader is told what appears - safety notices, the agent's and the update's banners, every short message, a game page's notice and each maintenance result, through UI Automation's notification (D89) (beta.35 PR-3)
Services/IAnnouncer over Services/UiaAnnouncer, the one place the App raises UI Automation's notification event:
only on its active window (a game that has the screen is never interrupted) and only when a screen reader listens.
An Alert (every one read): a safety notice as it arrives, a warning in the strip, the agent going offline, a game
page's refusal. A Status (a newer one replacing one not yet read): the strip's info and success, the agent back, an
update's step, a page's success, every Database maintenance result.

Every transient message goes through IMessageStrip now - MainWindowViewModel's six direct ISnackbarService calls
moved to it - and SnackbarStrip says what it shows. Services/ShellAnnouncements says only a change: the first state
is read with the window, a download's percent ticks are one step, a rebuilt window says nothing. The maintenance
line's LiveSetting, which announced nothing, is gone; no XAML may set one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 11:22:16 +07:00
24 changed files with 536 additions and 38 deletions

No files matched your search

+8 -4
View File
@@ -49,6 +49,11 @@ The same keys are in the user guide, [The screens](guide/07-screens.md#keyboard-
- **The frame-rate readout says the game's own frames, the displayed frames and the frame-generation factor together**
(*Native 62 FPS, displayed 118 FPS, frame generation ×1.9*) — never the larger number alone; a ray-tracing chip says its
value and where it came from (*Ray Tracing: Yes, measured*).
- **What appears is said as it appears**: a safety notice (hooking refused, measuring stopped, hooking turned off), the
capture agent going away and coming back, an update's steps, a short message at the bottom of the window, a notice on a
game's page and a result of **Tools ▸ Database maintenance** — in the words shown, while FrameLedger's window is the
active one. While a game has the screen nothing interrupts it; the notice stays in the window, and Windows' own
notifications from the icon by the clock are read by the screen reader itself.
- **The notices above the page can be read where they are shown**, and the button that answers one says which notice it
answers.
- **Tab goes from control to control**: pictures, lists and the rows of Settings are not stops of their own.
@@ -74,7 +79,7 @@ from the same translations. The documents — the user guide, this page, the leg
- **On every build**, by the project's own tests: what a screen reader is given for every page, window and dialog —
every place Tab stops has a name, no list or table item is read by its program name, no text is hidden from a screen
reader inside a control, no two buttons in a list share a name; every control that shows no text has a name; no colour is written
reader inside a control, no two buttons in a list share a name; each thing that appears is said once, in its words; every control that shows no text has a name; no colour is written
into a screen; every text reads against its background in both themes and after a theme switch; **Esc** closes the
open dialog without an answer; **Ctrl+1** … **Ctrl+5** open the pages in their order; the program declares it follows
each screen's scaling.
@@ -90,13 +95,12 @@ Each one with what to do instead. A barrier that is not on this list is worth re
its points or its name. The numbers are written out elsewhere: a session's figures and *Statistics per series* in its
summary, the table under the Compare chart, the list of changes under a trend chart, and **File ▸ Export ▸ Session
CSV** or **Session JSON**.
- **Nothing is announced when it appears** — a safety notice, a banner, a short message at the bottom of the window or
the result of **Tools ▸ Database maintenance**. A safety notice stays above the page until you answer it.
- **Headings are not marked as headings**, so a screen reader's heading keys do not move between the sections of a
page.
- **Windows contrast themes are not followed.** With Settings ▸ Theme on *System*, a contrast theme can give parts of
the window the wrong colours. Choose **Light** or **Dark** there: both keep their contrast.
- **The short messages at the bottom of the window close after four seconds.**
- **The short messages at the bottom of the window close after four seconds**, and cannot be read again once closed. A
screen reader is told each one as it appears.
- **Windows' text size setting** (Settings ▸ Accessibility ▸ Text size) **is not followed.** Use display scaling
(Settings ▸ System ▸ Display ▸ Scale) or Magnifier.
- **Page changes slide in** even when Windows' animation effects are off.
+6
View File
@@ -60,6 +60,12 @@ numeric core and does not move; the heading is the full version — corrected 20
…*, *Turn off: …*). Tab no longer stops on pictures, lists, Settings' rows, the FPS readout, the chips or the dialog
host, where it found nothing to say; an expander's button is named after its header.
- **A screen reader is told what appears** (owner decision D89): a safety notice as it arrives, the capture agent going
offline and coming back, an update's steps (not each percent), every short message at the bottom of the window, a
notice on a game's page and each result of Tools ▸ Database maintenance — in the words shown, and only while
FrameLedger's window is the active one, so a game that has the screen is never interrupted. The database line's live
region, which announced nothing, is gone.
### Changed
- **Documents corrected**: charts do take focus and keys (`docs/08_UI.md` said neither — `ChartKeyboardTests` measures
+20 -6
View File
@@ -149,7 +149,11 @@ The Menu sits in its own row **below** the TitleBar (never inside the drag regio
## Notifications policy
- **In-app, transient** (rules updated, export done, non-fatal capture warning): `ISnackbarService` snackbar, 4 s.
- **In-app, transient** (rules updated, export done, non-fatal capture warning): `ISnackbarService` snackbar, 4 s — shown
only through `IMessageStrip` (`Services/SnackbarStrip`) since beta.35, which says it to a screen reader as it shows it
(D89; `AnnouncementsTests.OnlyTheStripShowsASnackbarAndNoXamlSetsALiveSetting`).
- **Every one of these is said to a screen reader as it appears (beta.35, owner decision D89)** — §Accessibility, Screen
readers.
- **In-app, persistent** (Agent offline, ~~PawnIO missing,~~ update downloaded, a viewer's folder, the safety notices, *an alpha build* — since 2026-10-31, D74): `ui:InfoBar` banner pinned above content with action button. *(Corrected 2026-10-07: no PawnIO banner was ever built — CPU temperature reads N/A, and Settings ▸ System says it needs the admin mode and PawnIO; the viewer's banner (D52) and the safety notices were missing from the list.)*
- **System-level, app possibly minimized** (session saved with "View" action, capture error while in tray, update available): tray balloon/toast via H.NotifyIcon.
- One event → exactly one channel; never duplicate the same event across snackbar *and* tray.
@@ -1073,11 +1077,21 @@ handled key — so whether Esc alone would close a dialog through `IsCancel` is
unnamed). **The FPS readout says rule 6 aloud**: *Native 62 FPS, displayed 118 FPS, frame generation ×1.9*, a steady factor
with its share, a stand-alone number with its qualifier (`FpsPresentation.Spoken`). `ScreenReaderNamesTests` holds each
piece.
- Status lines that change after an action (the Database maintenance result) are `AutomationProperties.LiveSetting="Polite"`.
- **What appears is said as it appears (beta.35, owner decision D89).** `Services/IAnnouncer`, over UI Automation's
notification event in `Services/UiaAnnouncer` — the one place the App raises it, on its **active** window only (a game
that has the screen is never interrupted; the tray's Windows notifications cover a hidden window) and only when a
screen reader listens (`AutomationPeer.ListenerExists`). An **Alert** (`ImportantAll`, every one read): a safety notice as
it arrives (`SafetyNotices`), a warning in the strip, the capture agent going offline, a game page's refusal or warning.
A **Status** (`MostRecent` per activity, a newer one replacing one not yet read): the strip's info and success, the agent
back (`A11y_Agent_Connected`), an update's step (`Services/ShellAnnouncements` says a *change* only — the first state is
read with the window, a download's percent ticks are one step, a rebuilt window re-reads the same state silently), a
game page's success, every Database maintenance result line. The words are the window's, in its language.
`AnnouncementsTests`, `DatabaseMaintenanceViewModelTests.AResultIsSaidToAScreenReaderAsItAppears`.
- ~~Status lines that change after an action (the Database maintenance result) are `AutomationProperties.LiveSetting="Polite"`.~~
*(Corrected 2026-11-09: this announces nothing. WPF raises `LiveRegionChanged` only when the app raises it — "you
explicitly raise an event", Microsoft's* What's new in accessibility *for 4.7.1 — and `TextBlockAutomationPeer` raises
none (dotnet/wpf); the App raised no automation event anywhere. The setting marks the line as a live region and no
more.)*
more. It came out the same day, for the announcement above; no XAML may set one.)*
### Contrast
@@ -1182,8 +1196,8 @@ ScottPlot reads once when the control is made, before it has a window.
.NET 10.0.14 — not by listening): ~~a drop-down's items are named by a record's printed form (`Choice { Value = dark,
Label = Dark }`) and plain lists' items by their type; a control with no automation peer that still takes focus — a
chart, the FPS readout, the RT/PT/RR chips, the game's artwork — is a Tab stop Narrator says nothing about; text inside
a control template (the safety notices' title and message, the readout, the chips) is hidden from the control view~~
*(closed the same day, §Screen readers above, except a chart's: a plot is still a stop with no peer)*;
nothing is announced; no text is a heading; several charts tell series apart by colour alone; page transitions play
a control template (the safety notices' title and message, the readout, the chips) is hidden from the control view;
nothing is announced~~ *(closed the same day, §Screen readers above, except a chart's: a plot is still a stop with no
peer)*; no text is a heading; several charts tell series apart by colour alone; page transitions play
with Windows' animation effects off; Windows contrast themes are not followed. `ACCESSIBILITY.md` §Known limitations
states each to users with what to do instead.
+6 -1
View File
@@ -215,7 +215,12 @@ var result = await box.ShowDialogAsync(); // Wpf.Ui.Controls.MessageBoxResult.Pr
⚠ Name clash with `System.Windows.MessageBox` — in App code, `using MessageBox = Wpf.Ui.Controls.MessageBox;` ~~and ban the System one (BannedSymbols/analyzer note)~~ *(corrected 2026-10-04: nothing bans it. Three paths use the Win32 box on purpose — the crash dialog, the startup-failure dialog and the uninstall question — because they run when the shell's dialog host cannot be trusted. Use the WPF UI one everywhere else.)*
- Rich in-flow dialogs: `IContentDialogService` (host wired in MainWindow — a `ui:ContentDialogHost`, since 4.3.0 marks `SetDialogHost(ContentPresenter)` obsolete).
- Transient in-app: `ISnackbarService.Show(title, message, ControlAppearance.Success, new SymbolIcon(SymbolRegular.Checkmark24), TimeSpan.FromSeconds(4))`.
- Transient in-app: ~~`ISnackbarService.Show(title, message, ControlAppearance.Success, new SymbolIcon(SymbolRegular.Checkmark24), TimeSpan.FromSeconds(4))`~~
`IMessageStrip` (`Info` / `Success` / `Warn`) — `Services/SnackbarStrip` is the one caller of `ISnackbarService.Show`, and
says each message to a screen reader (beta.35, D89). A view model never holds `ISnackbarService`.
- A change a screen reader must hear goes through `IAnnouncer` (`Services/UiaAnnouncer`, UI Automation's notification
event). **`AutomationProperties.LiveSetting` alone says nothing in WPF**: the app must raise `LiveRegionChanged` itself,
and no XAML of the App's sets one (beta.35).
- System/tray notifications: H.NotifyIcon only (08_UI §Notifications policy).
## ScottPlot theme sync
+1
View File
@@ -398,6 +398,7 @@ public partial class App : System.Windows.Application
services.AddSingleton<IGamePicker, GamePicker>();
services.AddSingleton<IConfirmations, Confirmations>();
services.AddSingleton<AddGameFlow>();
services.AddSingleton<IAnnouncer, UiaAnnouncer>(); // beta.35 (D89): what appears is said to a screen reader
services.AddSingleton<IMessageStrip, SnackbarStrip>();
services.AddSingleton<IEditGamePrompt, EditGamePrompt>();
@@ -63,7 +63,7 @@
<DockPanel Margin="0,12,0,0">
<ui:ProgressRing Width="16" Height="16" Margin="0,0,8,0" DockPanel.Dock="Left" IsIndeterminate="True"
Visibility="{Binding IsBusy, Converter={StaticResource BoolToVis}}" />
<ui:TextBlock MaxWidth="680" HorizontalAlignment="Left" AutomationProperties.LiveSetting="Polite" Text="{Binding Status}" TextWrapping="Wrap" />
<ui:TextBlock MaxWidth="680" HorizontalAlignment="Left" Text="{Binding Status}" TextWrapping="Wrap" />
</DockPanel>
</StackPanel>
</UserControl>
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
namespace FrameLedger.App.Services;
/// <summary>How a screen reader treats an announcement (beta.35, D89).</summary>
public enum AnnouncementKind
{
/// <summary>A result or a change of state: read in turn, a newer one of the same kind replacing one not yet read.</summary>
Status,
/// <summary>Something the user must know — a safety notice, a failure, the agent gone: every one is read.</summary>
Alert,
}
@@ -23,9 +23,11 @@ public sealed class DatabaseMaintenancePrompts : IDatabaseMaintenancePrompts
private readonly IAgentRequests _agent;
private readonly IFileSaver _files;
private readonly RegisteredSettings _settings;
private readonly IAnnouncer? _announcer;
public DatabaseMaintenancePrompts(IContentDialogService dialogs, LedgerDatabase db, IAgentRequests agent, IFileSaver files, RegisteredSettings settings)
public DatabaseMaintenancePrompts(IContentDialogService dialogs, LedgerDatabase db, IAgentRequests agent, IFileSaver files, RegisteredSettings settings, IAnnouncer? announcer = null)
{
_announcer = announcer;
_dialogs = dialogs ?? throw new ArgumentNullException(nameof(dialogs));
_db = db ?? throw new ArgumentNullException(nameof(db));
_agent = agent ?? throw new ArgumentNullException(nameof(agent));
@@ -35,7 +37,7 @@ public sealed class DatabaseMaintenancePrompts : IDatabaseMaintenancePrompts
public async Task ShowAsync(CancellationToken ct = default)
{
var viewModel = new DatabaseMaintenanceViewModel(new LedgerMaintenance(_db), _db.Path, _agent, _files, this, _settings);
var viewModel = new DatabaseMaintenanceViewModel(new LedgerMaintenance(_db), _db.Path, _agent, _files, this, _settings, announcer: _announcer);
var dialog = new ContentDialog
{
Title = Strings.Maintenance_Title,
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
namespace FrameLedger.App.Services;
/// <summary>
/// Tells a screen reader what just appeared (beta.35, owner decision D89): a safety notice, a banner, a short message at the
/// bottom of the window, a result. A screen reader reads what has the focus; a notice that appears elsewhere was never
/// heard. The words are the ones the window shows, in its language.
/// </summary>
public interface IAnnouncer
{
/// <summary>Says <paramref name="text"/> to a screen reader, if one listens.</summary>
/// <param name="text">The words, as shown.</param>
/// <param name="kind">How the screen reader treats them.</param>
/// <param name="activity">What kind of thing speaks (<c>Notice</c>, <c>Strip</c>, <c>Agent</c>…): a screen reader groups announcements by it.</param>
void Announce(string text, AnnouncementKind kind, string activity);
}
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
namespace FrameLedger.App.Services;
/// <summary>Says nothing: where no screen reader is wired (tests, a viewer's pieces built by hand).</summary>
public sealed class NoAnnouncer : IAnnouncer
{
public static readonly NoAnnouncer Instance = new();
public void Announce(string text, AnnouncementKind kind, string activity)
{
}
}
@@ -22,13 +22,15 @@ public sealed class SafetyNotices : IDisposable
private readonly IAgentLink _agent;
private readonly IMessageStrip _strip;
private readonly TimeProvider _clock;
private readonly IAnnouncer _announcer;
private readonly UiThread _ui = new();
public SafetyNotices(IAgentLink agent, IMessageStrip strip, TimeProvider? clock = null)
public SafetyNotices(IAgentLink agent, IMessageStrip strip, TimeProvider? clock = null, IAnnouncer? announcer = null)
{
_agent = agent ?? throw new ArgumentNullException(nameof(agent));
_strip = strip ?? throw new ArgumentNullException(nameof(strip));
_clock = clock ?? TimeProvider.System;
_announcer = announcer ?? NoAnnouncer.Instance;
_agent.EventReceived += OnEvent;
}
@@ -128,7 +130,12 @@ public sealed class SafetyNotices : IDisposable
SafetyNotice? notice = Translate(envelope);
if (notice is not null)
{
_ui.Post(() => Items.Insert(0, notice));
// beta.35 (D89): said as it arrives — a notice above the page is never where a screen reader's focus is.
_ui.Post(() =>
{
Items.Insert(0, notice);
_announcer.Announce(notice.AccessibleName, AnnouncementKind.Alert, "Notice");
});
}
}
}
@@ -0,0 +1,66 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using FrameLedger.App.Update;
namespace FrameLedger.App.Services;
/// <summary>
/// What the shell's banners say to a screen reader (beta.35, D89): the capture agent going away and coming back, and an
/// update's steps. Only a change is said — the first state the window shows is read with the window, a download's percent
/// ticks are one step, and a rebuilt window (a language change) re-reads the same state and says nothing.
/// </summary>
[SuppressMessage("Performance", "CA1863:Use 'CompositeFormat'", Justification = "the format strings are resources that follow the UI culture, which changes at runtime")]
public sealed class ShellAnnouncements(IAnnouncer announcer)
{
private readonly IAnnouncer _announcer = announcer ?? throw new ArgumentNullException(nameof(announcer));
private bool _agentSeen;
private bool _agentBanner;
private UpdateStage? _update;
/// <summary>The agent's state changed; <paramref name="banner"/> is the banner's text, or null when there is none.</summary>
public void Agent(AgentConnectionState state, string? banner)
{
bool shown = banner is not null;
if (!_agentSeen)
{
(_agentSeen, _agentBanner) = (true, shown);
return;
}
if (shown && !_agentBanner)
{
_announcer.Announce(SpokenText.TitleAndBody(Strings.Agent_Banner_Offline_Title, banner), AnnouncementKind.Alert, "Agent");
}
else if (!shown && _agentBanner && state == AgentConnectionState.Connected)
{
_announcer.Announce(Strings.A11y_Agent_Connected, AnnouncementKind.Status, "Agent");
}
_agentBanner = shown;
}
/// <summary>The updater's step changed or ticked; <paramref name="banner"/> is the banner's text for that step.</summary>
public void Update(UpdateStage stage, string? version, string banner)
{
UpdateStage? before = _update;
_update = stage;
if (before is null || before == stage)
{
return;
}
string? said = stage switch
{
UpdateStage.Downloading => string.Format(CultureInfo.CurrentCulture, Strings.A11y_Update_Downloading_Format, version ?? string.Empty),
UpdateStage.Ready or UpdateStage.Deferred or UpdateStage.Applying => SpokenText.TitleAndBody(Strings.Update_Banner_Title, banner),
_ => null,
};
if (said is not null)
{
_announcer.Announce(said, AnnouncementKind.Status, "Update");
}
}
}
+20 -5
View File
@@ -6,17 +6,32 @@ using Wpf.Ui.Controls;
namespace FrameLedger.App.Services;
/// <summary><see cref="IMessageStrip"/> over the shell's <see cref="ISnackbarService"/>.</summary>
/// <summary>
/// <see cref="IMessageStrip"/> over the shell's <see cref="ISnackbarService"/> — and, since beta.35 (D89), said to a screen
/// reader as it is shown: a message at the bottom of the window that closes after four seconds was never heard. Every
/// transient message goes through here (<c>AccessibilityTests.OnlyTheStripShowsASnackbar</c>).
/// </summary>
public sealed class SnackbarStrip : IMessageStrip
{
private static readonly TimeSpan _duration = TimeSpan.FromSeconds(4);
private readonly ISnackbarService _snackbar;
private readonly IAnnouncer _announcer;
public SnackbarStrip(ISnackbarService snackbar) => _snackbar = snackbar ?? throw new ArgumentNullException(nameof(snackbar));
public SnackbarStrip(ISnackbarService snackbar, IAnnouncer? announcer = null)
{
_snackbar = snackbar ?? throw new ArgumentNullException(nameof(snackbar));
_announcer = announcer ?? NoAnnouncer.Instance;
}
public void Info(string title, string body) => _snackbar.Show(title, body, ControlAppearance.Secondary, new SymbolIcon(SymbolRegular.Info24), _duration);
public void Info(string title, string body) => Show(title, body, ControlAppearance.Secondary, SymbolRegular.Info24, AnnouncementKind.Status);
public void Success(string title, string body) => _snackbar.Show(title, body, ControlAppearance.Success, new SymbolIcon(SymbolRegular.Checkmark24), _duration);
public void Success(string title, string body) => Show(title, body, ControlAppearance.Success, SymbolRegular.Checkmark24, AnnouncementKind.Status);
public void Warn(string title, string body) => _snackbar.Show(title, body, ControlAppearance.Caution, new SymbolIcon(SymbolRegular.Warning24), _duration);
public void Warn(string title, string body) => Show(title, body, ControlAppearance.Caution, SymbolRegular.Warning24, AnnouncementKind.Alert);
private void Show(string title, string body, ControlAppearance appearance, SymbolRegular icon, AnnouncementKind kind)
{
_snackbar.Show(title, body, appearance, new SymbolIcon(icon), _duration);
_announcer.Announce(SpokenText.TitleAndBody(title, body), kind, "Strip");
}
}
@@ -0,0 +1,78 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Windows;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using System.Windows.Threading;
namespace FrameLedger.App.Services;
/// <summary>
/// <see cref="IAnnouncer"/> through UI Automation's notification event (beta.35, D89) — the one place the App raises it.
/// Narrator, NVDA and JAWS read a notification raised on a window's peer without moving the focus. WPF's live regions are not
/// used: WPF raises <c>LiveRegionChanged</c> only when the app does, which is what this is, said once rather than per line.
/// </summary>
/// <remarks>
/// <b>Only the App's active window speaks.</b> While a game has the screen, nothing interrupts it: the notice stays in the
/// window, and the tray's Windows notifications — which a screen reader reads itself — cover a hidden window. Nothing is
/// raised when no screen reader listens.
/// </remarks>
public sealed class UiaAnnouncer : IAnnouncer
{
private readonly Func<Window?> _target;
private readonly Func<bool> _listening;
private readonly Action<AutomationPeer, AutomationNotificationKind, AutomationNotificationProcessing, string, string> _raise;
/// <summary>The App's: its active window, Windows' own listener check, the peer's own event.</summary>
public UiaAnnouncer()
: this(ActiveWindow, Listening, Raise)
{
}
/// <summary>For the tests: where it speaks, whether anyone listens, and how it raises the event.</summary>
internal UiaAnnouncer(Func<Window?> target, Func<bool> listening, Action<AutomationPeer, AutomationNotificationKind, AutomationNotificationProcessing, string, string> raise)
{
_target = target ?? throw new ArgumentNullException(nameof(target));
_listening = listening ?? throw new ArgumentNullException(nameof(listening));
_raise = raise ?? throw new ArgumentNullException(nameof(raise));
}
/// <summary>What the processing of each kind is: every alert read, a status replaced by a newer one of its activity.</summary>
public static AutomationNotificationProcessing ProcessingOf(AnnouncementKind kind) =>
kind == AnnouncementKind.Alert ? AutomationNotificationProcessing.ImportantAll : AutomationNotificationProcessing.MostRecent;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "VSTHRD001:Avoid legacy thread switching APIs", Justification = "a WPF application has no JoinableTaskFactory; an event from the pipe posts the announcement to the windows' dispatcher and never waits (UiThread does the same)")]
public void Announce(string text, AnnouncementKind kind, string activity)
{
if (string.IsNullOrWhiteSpace(text))
{
return;
}
Dispatcher? dispatcher = System.Windows.Application.Current?.Dispatcher;
if (dispatcher is not null && !dispatcher.CheckAccess())
{
_ = dispatcher.BeginInvoke(() => Announce(text, kind, activity));
return;
}
if (!_listening() || _target() is not { } window)
{
return;
}
if ((UIElementAutomationPeer.FromElement(window) ?? UIElementAutomationPeer.CreatePeerForElement(window)) is { } peer)
{
_raise(peer, AutomationNotificationKind.Other, ProcessingOf(kind), text, "FrameLedger." + activity);
}
}
private static Window? ActiveWindow() =>
System.Windows.Application.Current?.Windows.OfType<Window>().FirstOrDefault(static w => w is { IsActive: true, IsVisible: true });
private static bool Listening() => AutomationPeer.ListenerExists(AutomationEvents.Notification);
private static void Raise(AutomationPeer peer, AutomationNotificationKind kind, AutomationNotificationProcessing processing, string text, string activity) =>
peer.RaiseNotificationEvent(kind, processing, text, activity);
}
+6
View File
@@ -29,6 +29,7 @@ public static class Strings
/// <summary>Every key, for an audit that walks them.</summary>
public static IReadOnlyList<string> Keys { get; } =
[
nameof(A11y_Agent_Connected),
nameof(A11y_Change_Format),
nameof(A11y_ChangeMarker_Format),
nameof(A11y_Chip_Format),
@@ -54,6 +55,7 @@ public static class Strings
nameof(A11y_SensorStat_Format),
nameof(A11y_TitleAndBody_Format),
nameof(A11y_ToggleSection_Format),
nameof(A11y_Update_Downloading_Format),
nameof(About_Doc_Notice),
nameof(About_Doc_Packages),
nameof(About_Doc_ThirdParty),
@@ -1242,6 +1244,8 @@ public static class Strings
nameof(Viewer_ChangesThisPc_Off),
];
public static string A11y_Agent_Connected => ResourceManager.GetString(nameof(A11y_Agent_Connected), Culture) ?? nameof(A11y_Agent_Connected);
public static string A11y_Change_Format => ResourceManager.GetString(nameof(A11y_Change_Format), Culture) ?? nameof(A11y_Change_Format);
public static string A11y_ChangeMarker_Format => ResourceManager.GetString(nameof(A11y_ChangeMarker_Format), Culture) ?? nameof(A11y_ChangeMarker_Format);
@@ -1292,6 +1296,8 @@ public static class Strings
public static string A11y_ToggleSection_Format => ResourceManager.GetString(nameof(A11y_ToggleSection_Format), Culture) ?? nameof(A11y_ToggleSection_Format);
public static string A11y_Update_Downloading_Format => ResourceManager.GetString(nameof(A11y_Update_Downloading_Format), Culture) ?? nameof(A11y_Update_Downloading_Format);
public static string About_Doc_Notice => ResourceManager.GetString(nameof(About_Doc_Notice), Culture) ?? nameof(About_Doc_Notice);
public static string About_Doc_Packages => ResourceManager.GetString(nameof(About_Doc_Packages), Culture) ?? nameof(About_Doc_Packages);
+8
View File
@@ -4880,4 +4880,12 @@
<value>表示/非表示:{0}</value>
<comment>review</comment>
</data>
<data name="A11y_Agent_Connected" xml:space="preserve">
<value>キャプチャエージェントに再接続しました。</value>
<comment>review</comment>
</data>
<data name="A11y_Update_Downloading_Format" xml:space="preserve">
<value>バージョン {0} をダウンロードしています。</value>
<comment>review</comment>
</data>
</root>
+6
View File
@@ -3671,4 +3671,10 @@ The documents below are the full terms; this summary does not replace them.</val
<data name="A11y_ToggleSection_Format" xml:space="preserve">
<value>Show or hide: {0}</value>
</data>
<data name="A11y_Agent_Connected" xml:space="preserve">
<value>The capture agent is connected again.</value>
</data>
<data name="A11y_Update_Downloading_Format" xml:space="preserve">
<value>Downloading version {0}.</value>
</data>
</root>
+6
View File
@@ -3666,4 +3666,10 @@ Các văn bản bên dưới là điều khoản đầy đủ; bản tóm tắt
<data name="A11y_ToggleSection_Format" xml:space="preserve">
<value>Hiện hoặc ẩn: {0}</value>
</data>
<data name="A11y_Agent_Connected" xml:space="preserve">
<value>Capture agent đã kết nối lại.</value>
</data>
<data name="A11y_Update_Downloading_Format" xml:space="preserve">
<value>Đang tải phiên bản {0}.</value>
</data>
</root>
@@ -35,6 +35,7 @@ public sealed partial class DatabaseMaintenanceViewModel : ObservableObject
private readonly IDatabaseMaintenancePrompts _prompts;
private readonly RegisteredSettings _settings;
private readonly TimeProvider _clock;
private readonly IAnnouncer _announcer;
[ObservableProperty]
[NotifyCanExecuteChangedFor(nameof(CheckIntegrityCommand), nameof(BackUpCommand), nameof(SweepCommand), nameof(CompactCommand))]
@@ -44,7 +45,7 @@ public sealed partial class DatabaseMaintenanceViewModel : ObservableObject
private string _status = Strings.Maintenance_Status_Ready;
public DatabaseMaintenanceViewModel(LedgerMaintenance ledger, string ledgerPath, IAgentRequests agent, IFileSaver files, IDatabaseMaintenancePrompts prompts,
RegisteredSettings settings, TimeProvider? clock = null)
RegisteredSettings settings, TimeProvider? clock = null, IAnnouncer? announcer = null)
{
_ledger = ledger ?? throw new ArgumentNullException(nameof(ledger));
ArgumentException.ThrowIfNullOrWhiteSpace(ledgerPath);
@@ -54,10 +55,17 @@ public sealed partial class DatabaseMaintenanceViewModel : ObservableObject
_prompts = prompts ?? throw new ArgumentNullException(nameof(prompts));
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
_clock = clock ?? TimeProvider.System;
_announcer = announcer ?? NoAnnouncer.Instance;
}
private bool CanRun => !IsBusy;
/// <summary>
/// beta.35 (D89): each action's result line is said as it appears — the line's <c>LiveSetting</c> said nothing, since WPF
/// raises a live region only when the app does.
/// </summary>
partial void OnStatusChanged(string value) => _announcer.Announce(value, AnnouncementKind.Status, "Maintenance");
/// <summary><c>PRAGMA integrity_check</c>: "no problems", or the count and SQLite's first line.</summary>
[RelayCommand(CanExecute = nameof(CanRun))]
private Task CheckIntegrityAsync() => RunAsync(async () =>
@@ -52,6 +52,7 @@ public sealed partial class GameDetailViewModel : ObservableObject
private readonly SessionDeletion? _deletion;
private readonly Func<string, bool> _exists;
private readonly GameArt? _art;
private readonly IAnnouncer _announcer;
private readonly CoverStore? _covers;
private readonly IImagePicker? _images;
private readonly long? _gameId;
@@ -294,8 +295,9 @@ public sealed partial class GameDetailViewModel : ObservableObject
SessionSeriesLoader loader, IHardwareSnapshotRepository hardware, SessionSelection sessionSelection, IGamePicker picker,
RegisteredSettings? settings = null, IAgentLink? agent = null, AntiCheatExceptions? exceptions = null, SessionDeletion? deletion = null,
UiMode? mode = null, GamePlayer? player = null, Func<string, bool>? executableExists = null, GameArt? art = null, CoverStore? covers = null,
IImagePicker? images = null)
IImagePicker? images = null, IAnnouncer? announcer = null)
{
_announcer = announcer ?? NoAnnouncer.Instance;
_art = art;
_covers = covers;
_images = images;
@@ -1144,6 +1146,19 @@ public sealed partial class GameDetailViewModel : ObservableObject
NoticeText = result.MessageFor(gameName);
NoticeSeverity = result.Succeeded ? InfoBarSeverity.Success : InfoBarSeverity.Warning;
OnPropertyChanged(nameof(NoticeVisible));
SayNotice();
}
/// <summary>
/// beta.35 (D89): the page's notice is said as it appears — it shows above the page, away from the button that was
/// pressed, where a screen reader's focus is.
/// </summary>
private void SayNotice()
{
if (NoticeText is { Length: > 0 } text)
{
_announcer.Announce(text, NoticeSeverity is InfoBarSeverity.Success or InfoBarSeverity.Informational ? AnnouncementKind.Status : AnnouncementKind.Alert, "Page");
}
}
/// <summary>
@@ -1166,6 +1181,7 @@ public sealed partial class GameDetailViewModel : ObservableObject
_ => (null, InfoBarSeverity.Informational),
};
OnPropertyChanged(nameof(NoticeVisible));
SayNotice();
}
private void Present(GameDetail detail)
@@ -13,7 +13,6 @@ using FrameLedger.App.Update;
using FrameLedger.Infrastructure.Ipc;
using FrameLedger.Shared;
using FrameLedger.Shared.Ipc;
using Wpf.Ui;
using Wpf.Ui.Controls;
namespace FrameLedger.App.ViewModels;
@@ -24,7 +23,8 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable,
private readonly IAgentLink _agent;
private readonly UiMode _mode;
private readonly BuildLine _line;
private readonly ISnackbarService _snackbar;
private readonly IMessageStrip _strip;
private readonly ShellAnnouncements _said;
private readonly IShellPresence _shell;
private readonly IPageNavigator _navigator;
private readonly UiThread _ui = new();
@@ -64,9 +64,10 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable,
private readonly ISessionSummaryOpener _summaries;
private readonly ImportLibraryFlow _import;
public MainWindowViewModel(IAgentLink agent, ISnackbarService snackbar, IShellPresence shell, IPageNavigator navigator, AddGameFlow addGame, SafetyNotices notices,
public MainWindowViewModel(IAgentLink agent, IMessageStrip strip, IShellPresence shell, IPageNavigator navigator, AddGameFlow addGame, SafetyNotices notices,
BugReportFlow bugReports, IUrlOpener urls, SessionSelection selection, SessionExportService exports, ISessionSummaryOpener summaries, ImportLibraryFlow import,
UpdateService updates, IDatabaseMaintenancePrompts maintenance, IDocumentWindows documents, UiMode? mode = null, BuildLine? line = null)
UpdateService updates, IDatabaseMaintenancePrompts maintenance, IDocumentWindows documents, UiMode? mode = null, BuildLine? line = null,
IAnnouncer? announcer = null)
{
_mode = mode ?? UiMode.Profile;
_line = line ?? BuildLine.Current;
@@ -82,7 +83,8 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable,
_exports = exports ?? throw new ArgumentNullException(nameof(exports));
_summaries = summaries ?? throw new ArgumentNullException(nameof(summaries));
_agent = agent ?? throw new ArgumentNullException(nameof(agent));
_snackbar = snackbar ?? throw new ArgumentNullException(nameof(snackbar));
_strip = strip ?? throw new ArgumentNullException(nameof(strip));
_said = new ShellAnnouncements(announcer ?? NoAnnouncer.Instance);
_shell = shell ?? throw new ArgumentNullException(nameof(shell));
_navigator = navigator ?? throw new ArgumentNullException(nameof(navigator));
_addGame = addGame ?? throw new ArgumentNullException(nameof(addGame));
@@ -148,6 +150,7 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable,
UpdateStage.Applying => (true, string.Format(CultureInfo.CurrentCulture, Strings.Update_Banner_Applying_Format, version), false),
_ => (false, string.Empty, false),
};
_said.Update(_updates.Stage, _updates.Version, UpdateBannerBody);
}
/// <summary>Help ▸ Check for updates (P4 PR-5): <c>11_UPDATER</c> §Flow, "Manual check".</summary>
@@ -184,6 +187,7 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable,
string? banner = AgentStatusPresentation.Banner(_agent.State);
AgentBannerBody = banner ?? string.Empty;
IsAgentBannerVisible = banner is not null;
_said.Agent(_agent.State, banner);
}
[RelayCommand]
@@ -244,7 +248,7 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable,
{
if (!_agent.IsConnected)
{
_snackbar.Show(Strings.Rules_Update_Title, Strings.Rules_Update_NoAgent, ControlAppearance.Caution, new SymbolIcon(SymbolRegular.Warning24), TimeSpan.FromSeconds(4));
_strip.Warn(Strings.Rules_Update_Title, Strings.Rules_Update_NoAgent);
return;
}
@@ -252,13 +256,12 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable,
{
IpcEnvelope ack = await _agent.RequestAsync(IpcMessageType.UpdateRules, new UpdateRulesRequest()).ConfigureAwait(true);
string outcome = IpcCodec.Payload<UpdateRulesAck>(ack)?.Outcome ?? string.Empty;
_snackbar.Show(Strings.Rules_Update_Title, string.Format(CultureInfo.CurrentCulture, Strings.Rules_Update_Done_Format, outcome),
ControlAppearance.Secondary, new SymbolIcon(SymbolRegular.Info24), TimeSpan.FromSeconds(4));
_strip.Info(Strings.Rules_Update_Title, string.Format(CultureInfo.CurrentCulture, Strings.Rules_Update_Done_Format, outcome));
}
catch (Exception ex) when (ex is IpcRequestException or TimeoutException or System.IO.IOException or InvalidOperationException)
{
Serilog.Log.Warning(ex, "ui: update rules did not complete");
_snackbar.Show(Strings.Rules_Update_Title, Strings.Rules_Update_Failed, ControlAppearance.Caution, new SymbolIcon(SymbolRegular.Warning24), TimeSpan.FromSeconds(4));
_strip.Warn(Strings.Rules_Update_Title, Strings.Rules_Update_Failed);
}
}
@@ -279,7 +282,7 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable,
{
if (!_urls.Open(IssueLink.Documentation))
{
_snackbar.Show(Strings.Menu_Help_Documentation, Strings.BugReport_BrowserRefused, ControlAppearance.Caution, new SymbolIcon(SymbolRegular.Warning24), TimeSpan.FromSeconds(4));
_strip.Warn(Strings.Menu_Help_Documentation, Strings.BugReport_BrowserRefused);
}
}
@@ -336,7 +339,7 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable,
if (_selection.SessionId is { } id)
{
_summaries.Open(id);
_snackbar.Show(Strings.Menu_File_Export, Strings.Export_Png_Body, ControlAppearance.Secondary, new SymbolIcon(SymbolRegular.Info24), TimeSpan.FromSeconds(4));
_strip.Info(Strings.Menu_File_Export, Strings.Export_Png_Body);
}
else
{
@@ -344,8 +347,7 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable,
}
}
private void NoSelection() =>
_snackbar.Show(Strings.Menu_File_Export, Strings.Export_NoSelection_Body, ControlAppearance.Caution, new SymbolIcon(SymbolRegular.Info24), TimeSpan.FromSeconds(4));
private void NoSelection() => _strip.Warn(Strings.Menu_File_Export, Strings.Export_NoSelection_Body);
/// <summary>
/// Tools ▸ Database maintenance… (P4 PR-7): integrity check, backup, the retention sweep (the Agent's) and compaction.
@@ -0,0 +1,174 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.IO;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using System.Xml.Linq;
using FluentAssertions;
using FrameLedger.App.Services;
using FrameLedger.App.Update;
using FrameLedger.Shared.Ipc;
using Wpf.Ui;
using Wpf.Ui.Controls;
namespace FrameLedger.App.Tests;
/// <summary>
/// What the App tells a screen reader as it appears (beta.35, owner decision D89): a screen reader reads what has the
/// focus, and a safety notice above the page, a message at the bottom of the window or a result line is never there. Each
/// source says it once, in the words it shows; the one class that raises UI Automation's notification is held on its own.
/// </summary>
public sealed class AnnouncementsTests
{
private sealed class FakeSnackbar : ISnackbarService
{
public List<(string Title, string Message, ControlAppearance Appearance)> Shown { get; } = [];
public TimeSpan DefaultTimeOut { get; set; } = TimeSpan.FromSeconds(4);
public void SetSnackbarPresenter(SnackbarPresenter contentPresenter)
{
}
public SnackbarPresenter? GetSnackbarPresenter() => null;
public void Show(string title, string message, ControlAppearance appearance, IconElement? icon, TimeSpan timeout) => Shown.Add((title, message, appearance));
}
[Fact]
public async Task EveryMessageOfTheStripIsSaidAsItIsShownAndAWarningIsAnAlert()
{
var snackbar = new FakeSnackbar();
var said = new RecordingAnnouncer();
var expected = await PagesLoadTests.OnStaAsync(() =>
{
// The strip makes the snackbar's icon, a WPF element: on the STA thread, as the App's dispatcher runs it.
var strip = new SnackbarStrip(snackbar, said);
strip.Info("Export", "Saved.");
strip.Warn("Update rules", "The agent is not connected.");
strip.Success("Backup", "Done.");
new SnackbarStrip(new FakeSnackbar()).Info("x", "y"); // with no announcer, as before: shown and nothing said
return (SpokenText.TitleAndBody("Export", "Saved."), SpokenText.TitleAndBody("Update rules", "The agent is not connected."), SpokenText.TitleAndBody("Backup", "Done."));
});
snackbar.Shown.Select(static s => s.Title).Should().Equal("Export", "Update rules", "Backup");
said.Said.Should().Equal(
(expected.Item1, AnnouncementKind.Status, "Strip"),
(expected.Item2, AnnouncementKind.Alert, "Strip"),
(expected.Item3, AnnouncementKind.Status, "Strip"));
}
[Fact]
public void ASafetyNoticeIsSaidOnceWhenItArrivesAndAnErrorOnlyByTheStrip()
{
var link = new FakeAgentLink();
var strip = new RecordingStrip();
var said = new RecordingAnnouncer();
using var notices = new SafetyNotices(link, strip, announcer: said);
link.Raise(IpcMessageType.CaptureRefused, new CaptureRefusedEvent(7, "Alpha", "GuardBlocked", "Easy Anti-Cheat", "EasyAntiCheat.sys"));
link.Raise(IpcMessageType.CaptureError, new CaptureErrorEvent(null, "InjectFailed", "boom"));
SafetyNotice notice = notices.Items.Should().ContainSingle().Subject;
said.Said.Should().ContainSingle().Which.Should().Be((notice.AccessibleName, AnnouncementKind.Alert, "Notice"),
"every notice is read — a refusal is the one thing a user must not miss");
strip.Shown.Should().ContainSingle("a capture error is the strip's, and the strip says it");
}
[Fact]
public void TheShellSaysOnlyAChangeOfTheAgentAndOfAnUpdatesStep()
{
var said = new RecordingAnnouncer();
var shell = new ShellAnnouncements(said);
shell.Agent(AgentConnectionState.Connecting, null);
shell.Agent(AgentConnectionState.Connected, null);
said.Said.Should().BeEmpty("the first state is read with the window, and connecting → connected shows no banner");
shell.Agent(AgentConnectionState.Offline, "not answering");
shell.Agent(AgentConnectionState.Offline, "not answering");
shell.Agent(AgentConnectionState.Connected, null);
said.Said.Select(static s => s.Kind).Should().Equal(AnnouncementKind.Alert, AnnouncementKind.Status);
said.Said[0].Text.Should().EndWith("not answering");
said.Said[1].Text.Should().Be(Strings.A11y_Agent_Connected);
said.Said.Clear();
shell.Update(UpdateStage.Idle, null, string.Empty);
shell.Update(UpdateStage.Downloading, "0.1.0-beta.36", "Downloading… 1%");
shell.Update(UpdateStage.Downloading, "0.1.0-beta.36", "Downloading… 40%");
shell.Update(UpdateStage.Ready, "0.1.0-beta.36", "Ready to install.");
shell.Update(UpdateStage.Ready, "0.1.0-beta.36", "Ready to install.");
said.Said.Select(static s => s.Activity).Should().Equal("Update", "Update");
said.Said[0].Text.Should().Contain("0.1.0-beta.36").And.NotContain("%", "the percent ticks are one step");
said.Said[1].Text.Should().EndWith("Ready to install.");
}
/// <summary>The one place that raises the notification: only when someone listens, only on the App's active window.</summary>
[Fact]
public async Task UiAutomationsNotificationIsRaisedOnTheTargetWindowOnlyWhenAScreenReaderListens()
{
var facts = await PagesLoadTests.OnStaAsync(() =>
{
var window = new Window();
var raised = new List<(AutomationPeer Peer, AutomationNotificationProcessing Processing, string Text, string Activity)>();
void Raise(AutomationPeer peer, AutomationNotificationKind kind, AutomationNotificationProcessing processing, string text, string activity) => raised.Add((peer, processing, text, activity));
new UiaAnnouncer(() => window, static () => false, Raise).Announce("unheard", AnnouncementKind.Alert, "Notice");
new UiaAnnouncer(static () => null, static () => true, Raise).Announce("nowhere", AnnouncementKind.Alert, "Notice");
var announcer = new UiaAnnouncer(() => window, static () => true, Raise);
announcer.Announce(" ", AnnouncementKind.Status, "Strip");
announcer.Announce("Alpha: hooking refused.", AnnouncementKind.Alert, "Notice");
announcer.Announce("Saved.", AnnouncementKind.Status, "Strip");
// The App's own: Windows' check and the peer's real event, on a window nobody shows — nothing listens here, nothing throws.
new UiaAnnouncer().Announce("quiet", AnnouncementKind.Status, "Strip");
UIElementAutomationPeer.CreatePeerForElement(window).RaiseNotificationEvent(AutomationNotificationKind.Other, AutomationNotificationProcessing.MostRecent, "x", "FrameLedger.Test");
window.Close();
return raised.Select(static r => (r.Peer is WindowAutomationPeer, r.Processing, r.Text, r.Activity)).ToList();
});
facts.Should().Equal(
(true, AutomationNotificationProcessing.ImportantAll, "Alpha: hooking refused.", "FrameLedger.Notice"),
(true, AutomationNotificationProcessing.MostRecent, "Saved.", "FrameLedger.Strip"));
}
[Fact]
public async Task AnAnnouncementFromAnotherThreadIsRaisedOnTheWindowsThread()
{
var raised = new List<int>();
Window? window = null;
UiaAnnouncer announcer = await PagesLoadTests.OnStaAsync(() =>
{
window = new Window();
return new UiaAnnouncer(() => window, static () => true, (_, _, _, _, _) => raised.Add(Environment.CurrentManagedThreadId));
});
int sta = await PagesLoadTests.OnStaAsync(static () => Environment.CurrentManagedThreadId);
await Task.Run(() => announcer.Announce("from the pipe", AnnouncementKind.Status, "Agent"), TestContext.Current.CancellationToken);
await PagesLoadTests.OnStaAsync(() =>
{
Visuals.Pump();
window!.Close();
return 0;
});
raised.Should().Equal(sta);
}
/// <summary>Every transient message goes through the strip, which says it; a LiveSetting would promise speech WPF never gives.</summary>
[Fact]
public void OnlyTheStripShowsASnackbarAndNoXamlSetsALiveSetting()
{
string app = Path.Combine(AccessibilityTests.RepoRoot(), "src", "FrameLedger.App");
string[] allowed = ["SnackbarStrip.cs", "MainWindow.xaml.cs", "App.xaml.cs"];
IEnumerable<string> sources = Directory.EnumerateFiles(app, "*.cs", SearchOption.AllDirectories)
.Where(static f => !f.Contains(Path.DirectorySeparatorChar + "obj" + Path.DirectorySeparatorChar, StringComparison.Ordinal));
sources.Where(f => File.ReadAllText(f).Contains("ISnackbarService", StringComparison.Ordinal) && !allowed.Contains(Path.GetFileName(f), StringComparer.Ordinal))
.Select(f => Path.GetRelativePath(app, f)).Should().BeEmpty("a snackbar shown past the strip is never said (D89)");
AccessibilityTests.AppXaml().Where(static x => x.Xaml.Descendants().Attributes().Any(static a => string.Equals(a.Name.LocalName, "AutomationProperties.LiveSetting", StringComparison.Ordinal)))
.Select(static x => x.File).Should().BeEmpty("WPF raises a live region only when the app does; the App says a change through IAnnouncer");
}
}
@@ -46,8 +46,8 @@ public sealed class DatabaseMaintenanceViewModelTests
}
}
private static DatabaseMaintenanceViewModel Vm(ScratchLedger s, FakeAgentLink agent, IFileSaver? saver = null, Prompts? prompts = null, MemorySettings? store = null) =>
new(new LedgerMaintenance(s.Db), s.Db.Path, agent, saver ?? new Saver(null), prompts ?? new Prompts(true), new RegisteredSettings(store ?? new MemorySettings()));
private static DatabaseMaintenanceViewModel Vm(ScratchLedger s, FakeAgentLink agent, IFileSaver? saver = null, Prompts? prompts = null, MemorySettings? store = null, IAnnouncer? announcer = null) =>
new(new LedgerMaintenance(s.Db), s.Db.Path, agent, saver ?? new Saver(null), prompts ?? new Prompts(true), new RegisteredSettings(store ?? new MemorySettings()), announcer: announcer);
private static string TempFile() => Path.Combine(Path.GetTempPath(), "fl-maint-" + Guid.NewGuid().ToString("N") + ".db");
@@ -70,6 +70,20 @@ public sealed class DatabaseMaintenanceViewModelTests
vm.IsBusy.Should().BeFalse();
}
/// <summary>beta.35 (D89): the result line is said as it appears; its LiveSetting announced nothing.</summary>
[Fact]
public async Task AResultIsSaidToAScreenReaderAsItAppears()
{
await using ScratchLedger s = await ScratchLedger.OpenAsync();
var said = new RecordingAnnouncer();
DatabaseMaintenanceViewModel vm = Vm(s, new FakeAgentLink(), announcer: said);
await vm.CheckIntegrityCommand.ExecuteAsync(null);
said.Said.Should().OnlyContain(static s => s.Kind == AnnouncementKind.Status && s.Activity == "Maintenance", "a result is a status: a newer one replaces one not yet read");
said.Said[^1].Text.Should().Be(Strings.Maintenance_Integrity_Ok, "the result is the last thing said, after the working line");
}
[Fact]
public async Task ABackupGoesToTheChosenFile()
{
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using FrameLedger.App.Services;
namespace FrameLedger.App.Tests;
/// <summary>What would have been said to a screen reader, in order (beta.35, D89).</summary>
internal sealed class RecordingAnnouncer : IAnnouncer
{
public List<(string Text, AnnouncementKind Kind, string Activity)> Said { get; } = [];
public void Announce(string text, AnnouncementKind kind, string activity) => Said.Add((text, kind, activity));
}