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

+1 -1
View File
@@ -262,7 +262,7 @@ public sealed class JobsViewModel : SectionViewModel
private void UpdateShell()
{
if (_model.Current is { } current)
Shell.SetJob(JobText.Bar(current), current.Fraction ?? 0, indeterminate: current.Fraction is null);
Shell.SetJob(JobText.Bar(current), current.Fraction ?? 0, indeterminate: current.Fraction is null, name: JobText.Name(current.Job));
else
Shell.SetJob(null, 0);
// The rail badge, the status strip and the Running chip count the same jobs: running or paused (Jobs.html).
+8 -4
View File
@@ -4,6 +4,7 @@
xmlns:ui="clr-namespace:Titano.Ui.Controls;assembly=Titano.Ui"
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
xmlns:shell="clr-namespace:Titano.App.Shell"
xmlns:infra="clr-namespace:Titano.App.Infrastructure"
xmlns:s="clr-namespace:Titano.App.Sections"
Title="{Binding WindowTitle}"
Width="1440" Height="900" MinWidth="1200" MinHeight="760"
@@ -63,10 +64,12 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Job bar (DESIGN §4): current job, progress, time left, pause; "Ready" when idle, hidden when idle in the editor. -->
<ui:JobBar Text="{Binding JobText}" Progress="{Binding JobProgress}" IsActive="{Binding IsJobActive}" IsIndeterminate="{Binding IsJobIndeterminate}"
<!-- Job bar (DESIGN §4): current job, progress, time left, pause; "Ready" when idle, hidden when idle in the editor.
Screen readers hear which job starts and when the queue empties, not its progress ticks. -->
<ui:JobBar x:Name="JobBar" Text="{Binding JobText}" Progress="{Binding JobProgress}" IsActive="{Binding IsJobActive}" IsIndeterminate="{Binding IsJobIndeterminate}"
StopCommand="{Binding StopJobCommand}" StopToolTip="{l:Loc Tooltips.Shell.PauseJob}" StopName="{l:Loc Shell.JobBar.Pause}" ActionGlyph="{StaticResource Icon.Pause}"
Visibility="{Binding IsJobBarVisible, Converter={StaticResource BoolToVisibility}}" />
Visibility="{Binding IsJobBarVisible, Converter={StaticResource BoolToVisibility}}"
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding JobAnnouncement}" />
<ContentControl Grid.Row="1" Content="{Binding Current}" Focusable="False" />
@@ -76,7 +79,8 @@
<TextBlock Text="{Binding SequencesText}" Margin="0,0,18,0" VerticalAlignment="Center" />
<TextBlock Text="{Binding PhotosText}" Margin="0,0,18,0" VerticalAlignment="Center" />
<TextBlock Text="{Binding StorageText}" Margin="0,0,18,0" VerticalAlignment="Center" />
<TextBlock x:Name="Connection" Text="{Binding ConnectionText}" Margin="0,0,18,0" VerticalAlignment="Center" />
<TextBlock x:Name="Connection" Text="{Binding ConnectionText}" Margin="0,0,18,0" VerticalAlignment="Center"
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding ConnectionText}" />
<TextBlock Text="{Binding JobsText}" VerticalAlignment="Center" />
</StackPanel>
</Border>
+16 -2
View File
@@ -16,6 +16,7 @@ public sealed class ShellViewModel : LocalizedViewModel
private SectionViewModel _current;
private bool _isRailCollapsed;
private string? _jobText;
private string? _jobName;
private double _jobProgress;
private bool _jobActive;
private bool _jobIndeterminate;
@@ -184,14 +185,25 @@ public sealed class ShellViewModel : LocalizedViewModel
/// <summary>Pauses the job the bar shows.</summary>
public ICommand? StopJobCommand => Jobs.PauseCurrentCommand;
/// <summary>Updates the global job bar (and the taskbar progress through the window).</summary>
public void SetJob(string? text, double progress, bool indeterminate = false)
/// <summary>
/// What screen readers hear from the job bar: the job when one starts, the idle line when the last one ends; not its
/// progress, speed or time left, which change every second.
/// </summary>
public string JobAnnouncement => _jobActive && _jobName is not null ? _jobName : JobText;
/// <summary>
/// Updates the global job bar (and the taskbar progress through the window). <paramref name="name"/> says which job
/// it is without its progress ("Render: Harbour sunset"); null reads <paramref name="text"/>.
/// </summary>
public void SetJob(string? text, double progress, bool indeterminate = false, string? name = null)
{
_jobText = text;
_jobName = text is null ? null : name ?? text;
IsJobActive = text is not null;
JobProgress = progress;
IsJobIndeterminate = indeterminate;
OnPropertyChanged(nameof(JobText));
OnPropertyChanged(nameof(JobAnnouncement));
}
// ---- Status strip ----
@@ -227,6 +239,7 @@ public sealed class ShellViewModel : LocalizedViewModel
_queuedCount = queued;
OnPropertyChanged(nameof(JobsText));
OnPropertyChanged(nameof(JobText));
OnPropertyChanged(nameof(JobAnnouncement));
}
public void Navigate(SectionKey key)
@@ -262,6 +275,7 @@ public sealed class ShellViewModel : LocalizedViewModel
ShowToast(new Toast
{
Title = ErrorText.For(ex),
IsError = true,
ActionText = Loc.L("Common.OpenLogs"),
ActionToolTip = Loc.L("Tooltips.Common.OpenLogs"),
ActionCommand = new RelayCommand(() => ShellActions.Reveal(Services.Environment.LogDirectory)),
+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");
}
}