feat(jobs): show what mass passes do now on the desktop, the server section and the admin panel
A running job now says what it does now: "Verifying photo 812 of 2,400 · Harbour sunset · sequence 3 of 41". A paused or failed job says where it stopped. The line appears in the Jobs table under the target, in the job bar (at most 60 characters, the item dropped first, the bar text also its tooltip), in the Archive's recent maintenance (refreshed at most twice a second), in the editor's server-job line and in the sync tooltip. Byte jobs now count sizes in the bar. While connected, the Server section lists the server's running and paused jobs, live through the jobs API and the jobProgress events. Pause, Resume and Cancel are offered only to an account that manages the archive, which is what the server requires to act on someone else's job; for any other account the list is read-only. The list hides while nothing runs, and the capture gains a server-jobs scene. The admin panel's Jobs page and dashboard show the same line under the target and update it with every progress event. The steps, parts and sub-steps are in English and Italian, and an unknown step shows its counts only. Refs #65 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ee9505df22
commit
b95bc997d5
36 files changed
+1895
-28
No files matched your search
@@ -34,6 +34,7 @@ namespace Chronos.App.Sections;
|
||||
public sealed class ArchiveViewModel : SectionViewModel
|
||||
{
|
||||
private const int RecentCount = 6;
|
||||
private static readonly TimeSpan RecentInterval = TimeSpan.FromMilliseconds(500);
|
||||
private const int PageSize = 1000;
|
||||
private static readonly TimeSpan ReloadDelay = TimeSpan.FromSeconds(2);
|
||||
|
||||
@@ -72,6 +73,13 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
private IReadOnlyList<ChartItem> _formats = [];
|
||||
private IReadOnlyList<HealthLineViewModel> _health = [];
|
||||
private IReadOnlyList<MaintenanceRow> _recent = [];
|
||||
|
||||
/// <summary>The jobs behind <see cref="Recent"/>, their running ones' latest progress, and the ids whose progress counts here.</summary>
|
||||
private IReadOnlyList<Job> _recentJobs = [];
|
||||
private readonly Dictionary<Guid, JobProgressInfo> _recentLive = [];
|
||||
private readonly System.Collections.Concurrent.ConcurrentDictionary<Guid, JobProgressInfo> _recentPending = new();
|
||||
private HashSet<Guid> _recentRunning = [];
|
||||
private CoalescingThrottle? _recentThrottle;
|
||||
private IReadOnlyList<DuplicateRowViewModel>? _duplicates;
|
||||
private IReadOnlyList<OrphanRowViewModel>? _orphans;
|
||||
private bool _findingDuplicates;
|
||||
@@ -524,7 +532,12 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
{
|
||||
_reloadDelay.Stop();
|
||||
_search?.Cancel();
|
||||
if (_jobEvents && Services.Jobs is { } jobs) jobs.JobChanged -= OnJobChanged;
|
||||
if (_jobEvents && Services.Jobs is { } jobs)
|
||||
{
|
||||
jobs.JobChanged -= OnJobChanged;
|
||||
jobs.Progress -= OnProgress;
|
||||
}
|
||||
_recentThrottle?.Dispose();
|
||||
_waitingReorganize = null;
|
||||
_dialog?.Dispose();
|
||||
base.Dispose();
|
||||
@@ -663,6 +676,10 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
foreach (var kind in MaintenanceReports.MaintenanceKinds)
|
||||
jobs.AddRange((await db.Jobs.ListAsync(null, kind, RecentCount)).Items.Where(j => j.TargetIds.Contains(archive.Id)));
|
||||
if (!IsShowing(archive)) return;
|
||||
_recentJobs = jobs;
|
||||
_recentLive.Clear();
|
||||
_recentPending.Clear();
|
||||
Volatile.Write(ref _recentRunning, [.. jobs.Where(j => j.State == JobState.Running).Select(j => j.Id)]);
|
||||
Recent = MaintenanceReports.Recent(jobs, RecentCount);
|
||||
var scan = jobs.Where(j => j.Kind == JobKind.Scan && j is { State: JobState.Done, Finished: not null, Started: not null })
|
||||
.MaxBy(j => j.Finished);
|
||||
@@ -675,9 +692,33 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
{
|
||||
if (_jobEvents || Services.Jobs is not { } jobs) return;
|
||||
jobs.JobChanged += OnJobChanged;
|
||||
// A running Recent line follows its job (owner review 5, #65), at most twice a second.
|
||||
_recentThrottle = new CoalescingThrottle(RecentInterval, SynchronizationContext.Current, FlushRecent);
|
||||
jobs.Progress += OnProgress;
|
||||
_jobEvents = true;
|
||||
}
|
||||
|
||||
/// <summary>Progress of a running job of "Recent maintenance" (any thread): kept until the next flush.</summary>
|
||||
private void OnProgress(JobProgressInfo progress)
|
||||
{
|
||||
if (!Volatile.Read(ref _recentRunning).Contains(progress.JobId)) return;
|
||||
_recentPending[progress.JobId] = progress;
|
||||
_recentThrottle?.Signal();
|
||||
}
|
||||
|
||||
/// <summary>The running Recent lines with their latest progress (UI thread).</summary>
|
||||
private void FlushRecent()
|
||||
{
|
||||
var changed = false;
|
||||
foreach (var id in _recentPending.Keys)
|
||||
{
|
||||
if (!_recentPending.TryRemove(id, out var progress) || !_recentRunning.Contains(id)) continue;
|
||||
_recentLive[id] = progress;
|
||||
changed = true;
|
||||
}
|
||||
if (changed) Recent = MaintenanceReports.Recent(_recentJobs, RecentCount, _recentLive);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A finished job on this archive or its sequences changes the figures: read them again once the jobs settle (a
|
||||
/// burst of analyses after an import reloads once). Jobs of other archives are none of this screen's business.
|
||||
|
||||
Reference in new issue
Block a user