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:
Claude committed 2026-10-12 15:53:58 +00:00
1 parent 14bf5e753a
commit 789c2dae3e
5 files changed
+174 -31

No files matched your search

+22 -7
View File
@@ -937,7 +937,8 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
else OnServerJobChanged();
LearnAnalysisSpeed(job);
if (!wasActive) return;
if (job.State == JobState.Done) _ = ReloadAsync(job.Kind == JobKind.Render ? job : null);
// A render this editor followed to its end is said here, with its output, unless the Jobs screen said it first.
if (job.State == JobState.Done) _ = ReloadAsync(job.Kind == JobKind.Render && Shell.Jobs.ClaimRenderToast(job.Id) ? job : null);
else if (IsRemote && job.State is JobState.Failed or JobState.Cancelled) ReportServerJobEnded(job);
});
}
@@ -1010,23 +1011,37 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
if (job is { Kind: JobKind.DeepAnalyse, State: JobState.Done, ItemsPerSecond: > 0 and var speed }) _analysisSecondsPerFrame = 1 / speed;
}
/// <summary>Reads the sequence again after a job; a finished render offers its follow-ups (BRIEF §11.5).</summary>
/// <summary>
/// Reads the sequence again after a job. A finished render whose toast this editor took (<see cref="Sections.JobsViewModel.ClaimRenderToast"/>)
/// is said in any case, also when the editor closed meanwhile: with its output and follow-ups (BRIEF §11.5) once the
/// sequence is read again, without them when that failed.
/// </summary>
private async Task ReloadAsync(Job? render)
{
var reloaded = false;
try
{
await Session.ReloadAsync();
reloaded = true;
}
catch (Exception ex) when (ex is System.IO.IOException or System.IO.InvalidDataException or InvalidOperationException or UnauthorizedAccessException
or System.Net.Http.HttpRequestException or Protocol.Client.TitanoApiException or OperationCanceledException)
or System.Net.Http.HttpRequestException or Protocol.Client.TitanoApiException or OperationCanceledException
or Data.DatabaseException)
{
// A server that does not answer in time cancels the request (OperationCanceledException).
Shell.ReportError(ex);
return;
}
if (render is null || _disposed) return;
// A server's render stays on the server: nothing to show in Explorer.
var output = Session.Content.Renders.FirstOrDefault(r => render.Started is not { } started || r.Created >= started)?.OutputPath is { Length: > 0 } path
finally
{
if (render is not null) AnnounceRender(render, reloaded);
}
}
/// <summary>"Render finished" with the output file and Show in folder; <paramref name="read"/>: the sequence was read again after the render.</summary>
private void AnnounceRender(Job render, bool read)
{
// A server's render stays on the server: nothing to show in Explorer. Before a read the renders are the old ones.
var output = read && Session.Content.Renders.FirstOrDefault(r => render.Started is not { } started || r.Created >= started)?.OutputPath is { Length: > 0 } path
? path
: null;
Shell.ShowToast(new Toast
+34 -9
View File
@@ -63,6 +63,10 @@ public sealed class JobsViewModel : SectionViewModel
private readonly Dictionary<Guid, JobRowViewModel> _rows = [];
private readonly HashSet<Guid> _unseenFailures = [];
private readonly JobEndings _endings = new();
/// <summary>Finished renders whose toast was taken (<see cref="ClaimRenderToast"/>).</summary>
private readonly HashSet<Guid> _renderToasts = [];
private readonly JobActions _actions;
private CoalescingThrottle? _throttle;
private IJobQueue? _queue;
@@ -250,10 +254,17 @@ public sealed class JobsViewModel : SectionViewModel
if (job.State != JobState.Failed) _unseenFailures.Remove(job.Id);
else if (before != JobState.Failed && !IsSelected) _unseenFailures.Add(job.Id);
var notice = JobNotices.For(before, job);
if (notice == JobNotice.Done && EditorAnnounces(job)) return;
if (notice == JobNotice.Done && job.Kind == JobKind.Render && !ClaimRenderToast(job.Id)) return;
_endings.Add(notice, job);
}
/// <summary>
/// Takes the toast of a finished render, which is said once (UI thread): true for the first caller only, which then
/// raises it. The editor of the render's sequence takes it when it sees the render end, and says it with the output
/// file even when the sequence cannot be read again; a render the editor did not follow is said here.
/// </summary>
internal bool ClaimRenderToast(Guid jobId) => _renderToasts.Add(jobId);
/// <summary>
/// The toast of a job that ended, with one action (BRIEF §12.1, §0.2 rule 6). Several endings at once (a batch
/// finished, or failed together) say how many and lead to this screen. Clicking the Windows notification of a
@@ -311,11 +322,6 @@ public sealed class JobsViewModel : SectionViewModel
};
}
/// <summary>A finished render of the sequence open in the editor: the editor says it, with its output file.</summary>
private bool EditorAnnounces(Job job) =>
job is { Kind: JobKind.Render, State: JobState.Done } && Shell.Sequence.Editor is { IsRemote: false } editor
&& job.TargetIds.Contains(editor.Session.Content.Sequence.Id);
/// <summary>A job changed state (any thread; tests feed it too): buffered until the next flush.</summary>
internal void OnJobChanged(Job job)
{
@@ -403,13 +409,32 @@ public sealed class JobsViewModel : SectionViewModel
SyncRows();
}
/// <summary>Opens what a job worked on inside Titano: its sequence in the editor, or the Archive screen.</summary>
/// <summary>
/// Opens what a job worked on inside Titano: its sequence in the editor; several sequences (a deep analysis of a
/// Library selection) in the Library, every one of them selected; else the Archive screen.
/// </summary>
internal async Task OpenTargetAsync(Job job)
{
var db = Shell.Services.Database;
if (db is null || job.TargetIds.Count == 0) return;
if (await db.Sequences.GetAsync(job.TargetIds[0]) is { } sequence) Shell.OpenSequence(sequence.Id);
else Shell.Navigate(SectionKey.Archive);
var sequences = new List<Guid>();
foreach (var id in job.TargetIds.Distinct())
{
if (await db.Sequences.GetAsync(id) is { } sequence) sequences.Add(sequence.Id);
}
switch (sequences.Count)
{
case 0:
Shell.Navigate(SectionKey.Archive);
break;
case 1:
Shell.OpenSequence(sequences[0]);
break;
default:
Shell.Navigate(SectionKey.Library);
await Shell.Library.ShowSelectedAsync(sequences);
break;
}
}
/// <summary>Shows the folder of what a job worked on in Explorer.</summary>
+41 -1
View File
@@ -581,6 +581,37 @@ public sealed class LibraryViewModel : SectionViewModel
RaiseMass();
}
/// <summary>
/// Shows the sequences of <paramref name="ids"/> selected, under the mass actions bar (Open on a job over several
/// sequences). Search and filters go when one of them would be hidden or is still being applied, pages are read until
/// each is listed, and the first comes into sight. Ids not in the index are left out.
/// </summary>
public async Task ShowSelectedAsync(IReadOnlyCollection<Guid> ids)
{
if (_pager is null) return;
var wanted = ids.ToHashSet();
if (_searchDelay.IsEnabled || _pager.IsLoading || !Lists(wanted))
{
ResetFilters();
await ReloadAsync();
while (!Lists(wanted) && _pager is { HasMore: true })
{
var listed = Items.Count;
await LoadMoreAsync();
if (Items.Count == listed) break;
}
}
SequenceItem? first = null;
foreach (var item in Items)
{
var chosen = wanted.Contains(item.Sequence.Id);
if (item.IsSelected != chosen) item.IsSelected = chosen;
if (chosen) first ??= item;
}
OnSelectionChanged();
if (first is not null) ScrollRequested?.Invoke(first);
}
/// <summary>Opens Tags on the selection (capture, tests).</summary>
public void OpenRetag() => OpenRetag(Targets(MassAction.Tag));
@@ -850,6 +881,13 @@ public sealed class LibraryViewModel : SectionViewModel
}
private void ClearFilters()
{
ResetFilters();
Reload();
}
/// <summary>Search and filters back to "any", without reading the list again.</summary>
private void ResetFilters()
{
_suppressReload = true;
_searchDelay.Stop();
@@ -863,9 +901,11 @@ public sealed class LibraryViewModel : SectionViewModel
_timelineMonth = null;
_scrollToMonth = false;
_suppressReload = false;
Reload();
}
/// <summary>Every sequence of <paramref name="ids"/> is in the list on screen.</summary>
private bool Lists(HashSet<Guid> ids) => ids.IsSubsetOf(Items.Select(i => i.Sequence.Id));
/// <summary>Shows a saved view: its search, filters and sort, at once.</summary>
private void Apply(SavedView view)
{