fix(jobs): announce every finished render once and open every target
A finished render's toast is claimed once (JobsViewModel.ClaimRenderToast): the editor that followed the render to its end says it with its output, also when the sequence cannot be read again (then without Show in folder) or the editor closed meanwhile; any other render is said by the Jobs screen. Before, the Jobs screen stayed silent whenever an editor had the sequence open, so a failed reload or a render the editor did not follow ended without a completion toast. Open on a job over several sequences (toast, Windows notification, Jobs row) shows the Library with every one of them selected, clearing a search or filter that hides one and reading pages until each is listed, instead of opening the first in the editor. 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
+174
-31
No files matched your search
@@ -1,11 +1,15 @@
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Shell;
|
||||
using Titano.App.Editor;
|
||||
using Titano.App.Infrastructure;
|
||||
using Titano.App.Sections;
|
||||
using Titano.App.Settings;
|
||||
using Titano.App.Shell;
|
||||
using Titano.App.Tests.Editor;
|
||||
using Titano.Core.Export;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Data.Repositories;
|
||||
@@ -133,26 +137,40 @@ public sealed class ShellNotificationTests
|
||||
Assert.Equal(badge, jobs.Badge);
|
||||
Assert.NotEqual(TaskbarItemProgressState.Error, shell.TaskbarState);
|
||||
|
||||
// The editor announces the renders of its own sequence, with their output: the shell says nothing then.
|
||||
var id = await app.Sample.FillEditorAsync();
|
||||
shell.OpenSequence(id);
|
||||
await shell.Sequence.OpenAsync(id);
|
||||
Assert.NotNull(shell.Sequence.Editor);
|
||||
// The editor says the renders it followed to their end, with their output: the shell says nothing then. It says them
|
||||
// also when the sequence cannot be read again (that error is said too), without Show in folder then.
|
||||
var content = EditorFixture.Content(EditorFixture.Sunset);
|
||||
var source = new FakeSequenceSource(EditorFixture.Sunset, content);
|
||||
var editor = new EditorViewModel(shell, new EditorSession(source, content, []), [], EncoderHost.Client);
|
||||
await using (editor)
|
||||
{
|
||||
foreach (var readable in new[] { true, false })
|
||||
{
|
||||
raised.Clear();
|
||||
var render = Job(JobKind.Render, JobState.Running, content.Sequence.Id);
|
||||
source.Report(render);
|
||||
jobs.OnJobChanged(render);
|
||||
await UntilAsync(() => editor.IsBusy);
|
||||
jobs.Flush();
|
||||
if (!readable) source.FailNextLoad = new IOException("The specified network name is no longer available.");
|
||||
source.Report(render with { State = JobState.Done });
|
||||
jobs.OnJobChanged(render with { State = JobState.Done });
|
||||
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.False(raised.Any(t => t.Title == Loc.L("Shell.Job.Done")), "the editor's own render toast is not doubled");
|
||||
Assert.Equal(readable ? 0 : 1, raised.Count(t => t.IsError), "a failed read is said beside the render's end");
|
||||
if (!readable) Assert.Null(finished.ActionCommand, "without the sequence read again, there is no output to show");
|
||||
}
|
||||
}
|
||||
// A render the editor did not follow (of another sequence) is the shell's to announce.
|
||||
raised.Clear();
|
||||
var render = Job(JobKind.Render, JobState.Running, id);
|
||||
jobs.OnJobChanged(render);
|
||||
jobs.Flush();
|
||||
jobs.OnJobChanged(render with { State = JobState.Done });
|
||||
jobs.Flush();
|
||||
Assert.False(raised.Any(t => t.Title == Loc.L("Shell.Job.Done")), "the editor's own render toast is not doubled");
|
||||
// A render of another sequence is the shell's to announce.
|
||||
var other = Job(JobKind.Render, JobState.Running, Guid.CreateVersion7());
|
||||
jobs.OnJobChanged(other);
|
||||
jobs.Flush();
|
||||
jobs.OnJobChanged(other with { State = JobState.Done });
|
||||
jobs.Flush();
|
||||
Assert.Equal(1, raised.Count(t => t.Title == Loc.L("Shell.Job.Done")));
|
||||
await shell.Sequence.CloseAsync();
|
||||
|
||||
// Server › Upload all: the batch speaks once, when its last upload ends.
|
||||
raised.Clear();
|
||||
@@ -380,6 +398,43 @@ public sealed class ShellNotificationTests
|
||||
Assert.Equal(shell.Archive.Health.Count(h => !h.IsOk), shell.Archive.Badge);
|
||||
});
|
||||
|
||||
/// <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.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public Task OpenOnAJobOverSeveralSequencesSelectsThemAllInTheLibrary() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
var shell = app.Shell;
|
||||
shell.CompleteWelcome();
|
||||
await app.Sample.FillAsync();
|
||||
var db = Assert.NotNull(shell.Services.Database);
|
||||
var library = shell.Library;
|
||||
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";
|
||||
|
||||
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);
|
||||
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());
|
||||
|
||||
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.
|
||||
await shell.Archive.LoadAsync();
|
||||
});
|
||||
|
||||
/// <summary>Lets the dispatcher run what was posted to it (the editor's job events and reload) until <paramref name="done"/> holds.</summary>
|
||||
private static async Task UntilAsync(Func<bool> done)
|
||||
{
|
||||
for (var i = 0; i < 250 && !done(); i++) await Task.Delay(20);
|
||||
}
|
||||
|
||||
/// <summary>The Jobs screen read its first page (it would set the job bar and the badge again).</summary>
|
||||
private static async Task JobsLoadedAsync(ShellViewModel shell)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user