Files
Chronos/tests/Titano.App.Tests/Jobs/JobsScreenSmokeTests.cs
T
Alby96andClaude Opus 5.5 43b6871cdc feat: jobs run one at a time, parallelism per photo and a priority queue
Owner review 1, phase 2 (docs/requests/2026-10-15-owner-review-1.md, R2).

Jobs now run one at a time on the desktop and on the server. Parallelism
(Settings > Rendering, TITANO_PARALLELISM) is how many photos the running
job processes at once: thumbnail and proxy passes draw that many photos
together and still write the pack and checkpoints in frame order, decode
tiers are probed that many at a time, the deep analysis measures that many
frames and a render decodes that many ahead. Wherever originals are
developed whole (TIFF, PNG, RAW without a usable preview), fewer run at
once within the memory budget, which the running job now has whole; the
server's frame window is sized to the host instead of 1 GiB.

A new job waits its turn and pausing the running job starts the next one.
An optional priority queue gives each job kind a level (renders, imports
and downloads high, verifies and proxies low by default): a queued job of
a higher level pauses the running one without asking, and that job goes
back to the queue with its checkpoint and resumes by itself afterwards.
Jobs of the same level, and a job's own follow-ups, never interrupt it.
The Jobs screen and the admin panel show the parallelism and the queue;
Settings > Rendering and the admin panel's Settings set them, at once.

TITANO_WORKERS and the Workers key of server.json still set the
parallelism (1 to 64, with a warning at start for the variable).
Titano.Tools gains i18n prune, which removed the renamed keys from the 36
machine-translated languages; the new strings are translated in all 38.

Found while testing: uploads and imports failed when a pass read the
sidecar while they wrote it (atomic writes now retry the rename while a
reader holds the file, and never for a read-only one), and taking a lease
just released while another process read it failed on Windows (the create
now waits for the reader). Five adversarial review rounds checked the
phase before this commit.

Also updates BRIEF (12.8, 14.6, 14.8, 14.9, 24), DECISIONS, CHANGELOG,
ARCHITECTURE, STATUS, the request file and the compose/Unraid templates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 14:56:24 +02:00

106 lines
5.2 KiB
C#

using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using Titano.App.Infrastructure;
using Titano.App.Jobs;
using Titano.App.Sections;
using Titano.App.Shell;
using Titano.App.Tests.Windows;
using Titano.Core.Localization;
using Titano.Testing;
using Titano.Ui.Controls;
namespace Titano.App.Tests.Jobs;
/// <summary>The Jobs screen on the capture sample: keyboard reach, names for screen readers, counts and the table's columns.</summary>
[WindowsOnly]
[Serial]
[Timeout(300_000)]
public sealed class JobsScreenSmokeTests
{
[Test]
public Task RowsAreReachableNamedAndLinedUpWithTheHeader() => ScreenHost.RunAsync(async () =>
{
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
var shell = app.Shell;
await app.Sample.FillAsync();
await shell.Jobs.ReloadAsync();
shell.Navigate(SectionKey.Jobs);
await app.ExpectAsync<JobsView>("jobs");
var jobs = shell.Jobs;
// The rail badge, the status strip and the Running chip count the same jobs.
var running = jobs.Chips.Single(c => c.Filter == JobFilter.Running).Count;
Assert.Greater(running, 0);
Assert.Equal(running, jobs.Badge);
Assert.Equal(Loc.Plural("Shell.Status.Jobs", running), shell.JobsText);
// The capture engine runs no jobs: there is no "8 photos at once" to show.
Assert.False(jobs.HasEngine);
// Tab reaches every row button: the rows take no focus, the list passes Tab on to their content.
var list = app.FindAll<ListBox>().Single(l => l.Name == "JobList");
Assert.Equal(KeyboardNavigationMode.Continue, KeyboardNavigation.GetTabNavigation(list));
var items = app.FindAll<ListBoxItem>().Where(i => i.DataContext is JobRowViewModel && i.IsVisible).ToList();
Assert.True(items.Count > 3, "several rows are on screen");
foreach (var item in items)
{
var row = (JobRowViewModel)item.DataContext;
// A row reads as its job and state; its buttons and its log toggle name the job.
Assert.Equal(row.AccessibleName, AutomationProperties.GetName(item));
Assert.Equal(row.StateText, AutomationProperties.GetItemStatus(item));
var buttons = Descendants<Button>(item).Where(b => b.IsVisible).ToList();
Assert.True(buttons.All(b => b.Focusable && b.IsTabStop), "every row button is a tab stop");
Assert.True(buttons.All(b => AutomationProperties.GetName(b).Contains(row.AccessibleName, StringComparison.Ordinal)), $"buttons of {row.AccessibleName} name it");
var state = Descendants<StatusGlyph>(item).Single();
Assert.Equal(AutomationLiveSetting.Polite, AutomationProperties.GetLiveSetting(state));
// Right to left: numbers stay right-aligned in both reading directions.
var percent = Descendants<TextBlock>(item).First(t => t.Text == row.PercentText);
Assert.True(percent.FlowDirection == FlowDirection.LeftToRight && percent.TextAlignment == TextAlignment.Right, "the percentage stays right-aligned");
}
// Header and rows share their columns: same padding, one actions column for all, the scroll-bar gutter kept.
var rows = items.Select(i => (Row: (JobRowViewModel)i.DataContext, Item: i)).ToList();
var kindHeader = Text(app, Loc.L("Jobs.Column.Kind"));
var stateHeader = Text(app, Loc.L("Jobs.Column.State"));
foreach (var (row, item) in rows)
{
Assert.Approximately(Left(kindHeader), Left(Descendants<TextBlock>(item).First(t => t.Text == row.Kind)), 1.5, $"Kind of {row.AccessibleName}");
Assert.Approximately(Left(stateHeader), Left(Descendants<StatusGlyph>(item).Single()), 1.5, $"State of {row.AccessibleName}");
}
var actionColumns = rows.Select(r => Left(Descendants<ItemsControl>(r.Item).Last())).ToList();
Assert.True(actionColumns.Max() - actionColumns.Min() < 1, "the actions column starts at the same x in every row");
// A language switch reaches the job bar at once, not at the job's next progress report.
var bar = shell.JobText;
Assert.True(shell.IsJobActive, "the sample runs a job");
UiLanguage.Apply("it");
try
{
Assert.NotEqual(bar, shell.JobText, "the job bar follows the language");
}
finally
{
UiLanguage.Apply("en");
}
Assert.Equal(bar, shell.JobText);
});
private static TextBlock Text(ScreenSmokeTests.SampleApp app, string text) => app.FindAll<TextBlock>().First(t => t.Text == text && t.IsVisible);
/// <summary>The left edge of an element in window coordinates.</summary>
private static double Left(FrameworkElement element) => element.TranslatePoint(new Point(0, 0), Window.GetWindow(element)).X;
private static IEnumerable<T> Descendants<T>(DependencyObject node)
where T : DependencyObject
{
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(node); i++)
{
var child = VisualTreeHelper.GetChild(node, i);
if (child is T match) yield return match;
foreach (var nested in Descendants<T>(child)) yield return nested;
}
}
}