fix(jobs): leave a followed render's toast to the editor and bound Open on large jobs
The Jobs screen's flush could take a render's end before the editor that followed it had seen it, and announce it without the output file. It now yields while the open editor follows that render (FollowsRender); an editor closed in between still says it once, without the output. Open on a job over more sequences than a Library page (a maintenance run over a whole archive) now opens the Library as it is instead of looking every target up and paging through the list to select them all. Selecting many cards (Open's selection, Clear selection) counts the selection once instead of once per card over every card. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
5 files changed
+164
-22
No files matched your search
@@ -5,6 +5,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Shell;
|
||||
using Titano.App.Editor;
|
||||
using Titano.App.Infrastructure;
|
||||
using Titano.App.Library;
|
||||
using Titano.App.Sections;
|
||||
using Titano.App.Settings;
|
||||
using Titano.App.Shell;
|
||||
@@ -398,9 +399,58 @@ public sealed class ShellNotificationTests
|
||||
Assert.Equal(shell.Archive.Health.Count(h => !h.IsOk), shell.Archive.Badge);
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// The Jobs screen's flush can take a render's end before the editor that followed the render has seen it: it leaves
|
||||
/// the toast to the editor, which says it once with its output, and once without it when it closed in between.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public Task TheEditorSaysTheRenderItFollowedAlsoWhenTheJobsScreenSeesItsEndFirst() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
var shell = app.Shell;
|
||||
shell.CompleteWelcome();
|
||||
await JobsLoadedAsync(shell);
|
||||
var jobs = shell.Jobs;
|
||||
var raised = new List<Toast>();
|
||||
shell.PendingToasts.CollectionChanged += (_, e) => raised.AddRange(e.NewItems?.Cast<Toast>() ?? []);
|
||||
var content = EditorFixture.Content(EditorFixture.Sunset);
|
||||
var source = new FakeSequenceSource(EditorFixture.Sunset, content);
|
||||
var editor = new EditorViewModel(shell, new EditorSession(source, content, []), [], EncoderHost.Client);
|
||||
shell.Sequence.Attach(editor);
|
||||
|
||||
foreach (var closes in new[] { false, true })
|
||||
{
|
||||
raised.Clear();
|
||||
var render = Job(JobKind.Render, JobState.Running, content.Sequence.Id);
|
||||
source.Report(render);
|
||||
jobs.OnJobChanged(render);
|
||||
await UntilAsync(() => editor.FollowsRender(render.Id));
|
||||
jobs.Flush();
|
||||
|
||||
// The end reaches the Jobs screen first; the editor's own callback runs after its flush.
|
||||
jobs.OnJobChanged(render with { State = JobState.Done });
|
||||
jobs.Flush();
|
||||
Assert.False(raised.Any(t => t.Title == Loc.L("Shell.Job.Done")), "the Jobs screen leaves the end of a followed render to the editor");
|
||||
source.Report(render with { State = JobState.Done });
|
||||
if (closes)
|
||||
{
|
||||
await shell.Sequence.CloseAsync();
|
||||
Assert.Null(shell.Sequence.Editor);
|
||||
}
|
||||
await UntilAsync(() => raised.Any(t => t.Title == Loc.L("Editor.Render.Done")));
|
||||
jobs.Flush();
|
||||
var finished = Assert.Contains(raised, t => t.Title == Loc.L("Editor.Render.Done"));
|
||||
Assert.Equal(1, raised.Count(t => t.Title == Loc.L("Editor.Render.Done")), "said once");
|
||||
Assert.False(raised.Any(t => t.Title == Loc.L("Shell.Job.Done")), "and never by the Jobs screen as well");
|
||||
if (closes) Assert.Null(finished.ActionCommand, "a closed editor does not read the sequence again for the output");
|
||||
}
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// Open on a job that worked on several sequences (a deep analysis of a Library selection) shows every one of them
|
||||
/// selected in the Library, also those a search hid; a job on an archive opens the Archive screen.
|
||||
/// selected in the Library: also those a search hides, whether it is still pending or applied, and those beyond the
|
||||
/// pages read so far. A job over more sequences than a page leaves the Library as it is; a job on an archive opens
|
||||
/// the Archive screen.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public Task OpenOnAJobOverSeveralSequencesSelectsThemAllInTheLibrary() => ScreenHost.RunAsync(async () =>
|
||||
@@ -414,15 +464,60 @@ public sealed class ShellNotificationTests
|
||||
await library.RefreshAsync();
|
||||
var ids = (await db.Sequences.ListAsync(new SequenceQuery { Sort = SequenceSort.Oldest, Limit = 3 })).Items.Select(s => s.Id).ToList();
|
||||
Assert.Count(3, ids);
|
||||
library.SearchText = "no such sequence";
|
||||
bool Listed(Guid id) => library.Items.Any(i => i.Sequence.Id == id);
|
||||
Job Analysis(IReadOnlyList<Guid> targets) =>
|
||||
Job(JobKind.DeepAnalyse, JobState.Done, targets[0]) with { TargetIds = targets, TargetLabel = Loc.Plural("Library.Selection.Count", targets.Count) };
|
||||
|
||||
var analysis = Job(JobKind.DeepAnalyse, JobState.Done, ids[0]) with { TargetIds = ids, TargetLabel = Loc.Plural("Library.Selection.Count", ids.Count) };
|
||||
await shell.Jobs.OpenTargetAsync(analysis);
|
||||
// A search still waiting to apply.
|
||||
library.SearchText = "no such sequence";
|
||||
await shell.Jobs.OpenTargetAsync(Analysis(ids));
|
||||
Assert.Equal(SectionKey.Library, shell.Current.Key);
|
||||
Assert.Equal(string.Empty, library.SearchText, "the search that hid them is cleared");
|
||||
Assert.Equal(ids.Count, library.SelectionCount, "every sequence the job worked on, not only the first");
|
||||
Assert.SequenceEqual(ids.Order(), library.SelectedItems().Select(i => i.Sequence.Id).Order());
|
||||
|
||||
// A search applied: the list no longer holds them.
|
||||
library.SearchText = "no such sequence";
|
||||
await UntilAsync(() => !ids.Any(Listed));
|
||||
Assert.False(ids.Any(Listed), "the search hides them");
|
||||
await shell.Jobs.OpenTargetAsync(Analysis(ids));
|
||||
Assert.Equal(string.Empty, library.SearchText);
|
||||
Assert.SequenceEqual(ids.Order(), library.SelectedItems().Select(i => i.Sequence.Id).Order());
|
||||
|
||||
// More sequences than a page: those beyond the first page are read until each is listed.
|
||||
var archiveId = Assert.NotNull(await db.Sequences.GetAsync(ids[0])).ArchiveId;
|
||||
var bulk = new List<Guid>();
|
||||
for (var i = 0; i < LibraryPager.DefaultPageSize + 10; i++)
|
||||
{
|
||||
var sequence = new Sequence
|
||||
{
|
||||
Id = Guid.CreateVersion7(),
|
||||
ArchiveId = archiveId,
|
||||
Folder = $"2021/2021-03-01 Bulk {i:000}",
|
||||
Title = $"Bulk {i:000}",
|
||||
FirstCapture = new DateTime(2021, 3, 1).AddHours(i),
|
||||
LastCapture = new DateTime(2021, 3, 1).AddHours(i + 1),
|
||||
FrameCount = 10,
|
||||
UpdatedAt = DateTimeOffset.UtcNow,
|
||||
};
|
||||
await db.Sequences.UpsertAsync(sequence);
|
||||
bulk.Add(sequence.Id);
|
||||
}
|
||||
await library.RefreshAsync();
|
||||
var beyond = bulk.Where(id => !Listed(id)).Take(3).ToList();
|
||||
Assert.Count(3, beyond);
|
||||
await shell.Jobs.OpenTargetAsync(Analysis(beyond));
|
||||
Assert.Greater(library.Items.Count, LibraryPager.DefaultPageSize, "the next pages were read");
|
||||
Assert.SequenceEqual(beyond.Order(), library.SelectedItems().Select(i => i.Sequence.Id).Order());
|
||||
|
||||
// A job over more sequences than a page (a maintenance run over the archive) opens the Library as it is.
|
||||
shell.Navigate(SectionKey.Jobs);
|
||||
library.SearchText = "Bulk";
|
||||
await shell.Jobs.OpenTargetAsync(Analysis(bulk));
|
||||
Assert.Equal(SectionKey.Library, shell.Current.Key);
|
||||
Assert.Equal("Bulk", library.SearchText, "its search is not cleared");
|
||||
Assert.SequenceEqual(beyond.Order(), library.SelectedItems().Select(i => i.Sequence.Id).Order(), "nor its selection replaced");
|
||||
|
||||
await shell.Jobs.OpenTargetAsync(Job(JobKind.Verify, JobState.Done, Guid.CreateVersion7()));
|
||||
Assert.Equal(SectionKey.Archive, shell.Current.Key);
|
||||
// The Archive screen reads its figures when it opens: let that end before the app closes.
|
||||
|
||||
Reference in new issue
Block a user