fix(app): the job bar and the connection state are live regions; error toasts interrupt

- The job bar is a status bar for screen readers; it announces which job starts and when the queue
  empties (ShellViewModel.JobAnnouncement), never its progress ticks.
- The status strip's connection text announces a change of server state.
- Toast.IsError: error notices are announced at once; other notices queue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-06 08:10:36 +00:00
1 parent a7f5f83e04
commit 577774ad6a
5 files changed
+56 -9

No files matched your search

+22 -1
View File
@@ -1,10 +1,15 @@
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Input;
namespace Titano.Ui.Controls;
/// <summary>40-px strip under the title bar: current job, progress, time left and a stop (or pause) button (DESIGN §4).</summary>
/// <summary>
/// 40-px strip under the title bar: current job, progress, time left and a stop (or pause) button (DESIGN §4). Screen
/// readers see a status bar; its name is <c>AutomationProperties.Name</c> (the owner keeps it to the job's state, so
/// it can be a live region that does not speak every progress tick), else <see cref="Text"/>.
/// </summary>
public class JobBar : Control
{
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(nameof(Text), typeof(string), typeof(JobBar));
@@ -39,4 +44,20 @@ public class JobBar : Control
/// <summary>Glyph of the action button: stop by default; the client shows pause (DESIGN §4 job bar).</summary>
public IconData? ActionGlyph { get => (IconData?)GetValue(ActionGlyphProperty); set => SetValue(ActionGlyphProperty, value); }
protected override AutomationPeer OnCreateAutomationPeer() => new JobBarAutomationPeer(this);
}
/// <summary>The job bar seen by UI Automation: a status bar holding the progress bar and the pause button.</summary>
public sealed class JobBarAutomationPeer(JobBar owner) : FrameworkElementAutomationPeer(owner)
{
protected override AutomationControlType GetAutomationControlTypeCore() => AutomationControlType.StatusBar;
protected override string GetClassNameCore() => nameof(JobBar);
protected override string GetNameCore()
{
var name = base.GetNameCore();
return string.IsNullOrEmpty(name) ? ((JobBar)Owner).Text ?? string.Empty : name;
}
}
+9 -1
View File
@@ -19,6 +19,9 @@ public sealed class Toast : ObservableObject
public ICommand? ActionCommand { get; init; }
public string? ActionToolTip { get; init; }
public TimeSpan Lifetime { get; init; } = TimeSpan.FromSeconds(8);
/// <summary>Something failed: screen readers say it at once, ahead of other notices (assertive, not polite).</summary>
public bool IsError { get; init; }
}
/// <summary>
@@ -131,10 +134,15 @@ public class ToastHost : ItemsControl
Dispatcher.BeginInvoke(() => Dismiss(toast));
}
/// <summary>
/// A UI Automation notification rather than a live region: a toast is a new element, not a text that changes, and
/// the host's peer is always in the tree. Notices queue (polite); errors interrupt (assertive).
/// </summary>
private void Announce(Toast toast)
{
var text = string.IsNullOrEmpty(toast.Message) ? toast.Title : toast.Title + " " + toast.Message;
UIElementAutomationPeer.CreatePeerForElement(this)?.RaiseNotificationEvent(
AutomationNotificationKind.Other, AutomationNotificationProcessing.ImportantMostRecent, text, "Titano.Toast");
AutomationNotificationKind.Other, toast.IsError ? AutomationNotificationProcessing.ImportantAll : AutomationNotificationProcessing.All,
text, "Titano.Toast");
}
}