diff --git a/i18n/en/Admin.resx b/i18n/en/Admin.resx
index 019960a6..08b9c1ad 100644
--- a/i18n/en/Admin.resx
+++ b/i18n/en/Admin.resx
@@ -1193,4 +1193,57 @@
Show the videos of every sequence; the other filters stayVideos folderWhere Copy to folder puts videos (the /videos volume in Docker); empty turns copying off
+ Listing folders
+ Checking
+ Indexing
+ Indexing photo {0} of {1}
+ Verifying
+ Verifying photo {0} of {1}
+ Drawing thumbnails
+ Thumbnail {0} of {1}
+ Making proxies
+ Proxy {0} of {1}
+ Analysing
+ Analysing photo {0} of {1}
+ Converting
+ Converting photo {0} of {1}
+ Replacing photos
+ Replacing photo {0} of {1}
+ Reorganizing
+ Copying photos
+ Copying photo {0} of {1}
+ Copying proxies
+ Copying proxy {0} of {1}
+ Copying originals
+ Copying original {0} of {1}
+ Copying video
+ Encoding
+ Encoding frame {0} of {1}
+ Uploading
+ Uploading photo {0} of {1}
+ Downloading
+ Downloading photo {0} of {1}
+ Erasing
+ Copying the index
+ Cleaning up
+ Maintenance
+ Queueing follow-ups
+ Processing
+ Processing photo {0} of {1}
+ Clearing stale leases
+ Removing temporary files
+ Compacting thumbnails
+ Flagging duplicates
+ Compacting the index
+ sequence {0} of {1}
+ folder {0} of {1}
+ video {0} of {1}
+ entry {0} of {1}
+ step {0} of {1}
+ {0} of {1}
+ Stopped at {0}
+ {0} fps
+ {0}/s
+ {0}/s
+ {0} left
diff --git a/i18n/en/Jobs.resx b/i18n/en/Jobs.resx
index 53258a0a..007992f3 100644
--- a/i18n/en/Jobs.resx
+++ b/i18n/en/Jobs.resx
@@ -207,4 +207,53 @@
no media to removejust copiedCopy videos
+ Listing folders
+ Checking
+ Indexing
+ Indexing photo {0} of {1}
+ Verifying
+ Verifying photo {0} of {1}
+ Drawing thumbnails
+ Thumbnail {0} of {1}
+ Making proxies
+ Proxy {0} of {1}
+ Analysing
+ Analysing photo {0} of {1}
+ Converting
+ Converting photo {0} of {1}
+ Replacing photos
+ Replacing photo {0} of {1}
+ Reorganizing
+ Copying photos
+ Copying photo {0} of {1}
+ Copying proxies
+ Copying proxy {0} of {1}
+ Copying originals
+ Copying original {0} of {1}
+ Copying video
+ Encoding
+ Encoding frame {0} of {1}
+ Uploading
+ Uploading photo {0} of {1}
+ Downloading
+ Downloading photo {0} of {1}
+ Erasing
+ Copying the index
+ Cleaning up
+ Maintenance
+ Queueing follow-ups
+ Processing
+ Processing photo {0} of {1}
+ Clearing stale leases
+ Removing temporary files
+ Compacting thumbnails
+ Flagging duplicates
+ Compacting the index
+ sequence {0} of {1}
+ folder {0} of {1}
+ video {0} of {1}
+ entry {0} of {1}
+ step {0} of {1}
+ {0} of {1}
+ Stopped at {0}
diff --git a/i18n/en/Server.resx b/i18n/en/Server.resx
index 16dd7563..986c389d 100644
--- a/i18n/en/Server.resx
+++ b/i18n/en/Server.resx
@@ -129,6 +129,8 @@
The current password is wrong.longThis upload belongs to a render job.longServers found
+ Job not changed
+ Server jobsKeep proxies offlineAccountServer
diff --git a/i18n/en/Tooltips.resx b/i18n/en/Tooltips.resx
index 3be6f60e..4a8fba67 100644
--- a/i18n/en/Tooltips.resx
+++ b/i18n/en/Tooltips.resx
@@ -692,6 +692,8 @@
SHA-256 fingerprint of the server certificateForget this certificate; the next connection asks againServers found on this network and used before
+ What runs or waits paused on the server now; pause, resume or cancel any of them
+ What runs or waits paused on the server now; only an account that manages the archive can pause or cancel themKeep the proxies of the server sequences you opened with proxies up to date on this PC, to edit without the originals; uses space in the cache folderlongKeep trusting this certificateClose without signing in · Esc
diff --git a/i18n/it/Admin.it.resx b/i18n/it/Admin.it.resx
index e7032d65..96ebc21d 100644
--- a/i18n/it/Admin.it.resx
+++ b/i18n/it/Admin.it.resx
@@ -1185,4 +1185,57 @@
Mostra i video di tutte le sequenze; gli altri filtri restanoCartella videoDove Copia in cartella mette i video (il volume /videos in Docker); vuota disattiva la copia
+ Elenco cartelle
+ Controllo
+ Indicizzazione
+ Indicizzazione foto {0} di {1}
+ Verifica
+ Verifica foto {0} di {1}
+ Creazione miniature
+ Miniatura {0} di {1}
+ Creazione proxy
+ Proxy {0} di {1}
+ Analisi
+ Analisi foto {0} di {1}
+ Conversione
+ Conversione foto {0} di {1}
+ Sostituzione foto
+ Sostituzione foto {0} di {1}
+ Riorganizzazione
+ Copia foto
+ Copia foto {0} di {1}
+ Copia proxy
+ Copia proxy {0} di {1}
+ Copia originali
+ Copia originale {0} di {1}
+ Copia video
+ Codifica
+ Codifica fotogramma {0} di {1}
+ Invio
+ Invio foto {0} di {1}
+ Download
+ Download foto {0} di {1}
+ Eliminazione
+ Copia dell'indice
+ Pulizia
+ Manutenzione
+ Accodamento seguiti
+ Elaborazione
+ Elaborazione foto {0} di {1}
+ Pulizia lease scaduti
+ Rimozione file temporanei
+ Compattazione miniature
+ Marcatura duplicati
+ Compattazione indice
+ sequenza {0} di {1}
+ cartella {0} di {1}
+ video {0} di {1}
+ voce {0} di {1}
+ passo {0} di {1}
+ {0} di {1}
+ Fermo a {0}
+ {0} fps
+ {0}/s
+ {0}/s
+ {0} rimanenti
diff --git a/i18n/it/Jobs.it.resx b/i18n/it/Jobs.it.resx
index 7a70891f..2fd006cd 100644
--- a/i18n/it/Jobs.it.resx
+++ b/i18n/it/Jobs.it.resx
@@ -205,4 +205,53 @@
nessun media da rimuovereappena copiatoCopia video
+ Elenco cartelle
+ Controllo
+ Indicizzazione
+ Indicizzazione foto {0} di {1}
+ Verifica
+ Verifica foto {0} di {1}
+ Creazione miniature
+ Miniatura {0} di {1}
+ Creazione proxy
+ Proxy {0} di {1}
+ Analisi
+ Analisi foto {0} di {1}
+ Conversione
+ Conversione foto {0} di {1}
+ Sostituzione foto
+ Sostituzione foto {0} di {1}
+ Riorganizzazione
+ Copia foto
+ Copia foto {0} di {1}
+ Copia proxy
+ Copia proxy {0} di {1}
+ Copia originali
+ Copia originale {0} di {1}
+ Copia video
+ Codifica
+ Codifica fotogramma {0} di {1}
+ Invio
+ Invio foto {0} di {1}
+ Download
+ Download foto {0} di {1}
+ Eliminazione
+ Copia dell'indice
+ Pulizia
+ Manutenzione
+ Accodamento seguiti
+ Elaborazione
+ Elaborazione foto {0} di {1}
+ Pulizia lease scaduti
+ Rimozione file temporanei
+ Compattazione miniature
+ Marcatura duplicati
+ Compattazione indice
+ sequenza {0} di {1}
+ cartella {0} di {1}
+ video {0} di {1}
+ voce {0} di {1}
+ passo {0} di {1}
+ {0} di {1}
+ Fermo a {0}
diff --git a/i18n/it/Server.it.resx b/i18n/it/Server.it.resx
index 7002d187..264fc26b 100644
--- a/i18n/it/Server.it.resx
+++ b/i18n/it/Server.it.resx
@@ -127,6 +127,8 @@
La password attuale è errata.Questo caricamento appartiene a un job di rendering.Server trovati
+ Lavoro non modificato
+ Lavori del serverProxy disponibili offlineAccountServer
diff --git a/i18n/it/Tooltips.it.resx b/i18n/it/Tooltips.it.resx
index 4a6a5ca8..bdcb1a80 100644
--- a/i18n/it/Tooltips.it.resx
+++ b/i18n/it/Tooltips.it.resx
@@ -762,6 +762,8 @@
Impronta SHA-256 del certificato del serverDimentica questo certificato; alla prossima connessione verrà chiesto di nuovoServer trovati in questa rete e usati in precedenza
+ Ciò che il server esegue o tiene in pausa ora; metti in pausa, riprendi o annulla qualsiasi lavoro
+ Ciò che il server esegue o tiene in pausa ora; solo un account che gestisce l'archivio può metterli in pausa o annullarliMantieni aggiornati su questo PC i proxy delle sequenze del server aperte con i proxy, per lavorare senza gli originali; usa spazio nella cartella cacheContinua a considerare attendibile questo certificatoChiude senza accedere · Esc
diff --git a/src/Chronos.App/Archive/MaintenanceReports.cs b/src/Chronos.App/Archive/MaintenanceReports.cs
index 06ac494a..527a94ad 100644
--- a/src/Chronos.App/Archive/MaintenanceReports.cs
+++ b/src/Chronos.App/Archive/MaintenanceReports.cs
@@ -3,6 +3,7 @@ using Chronos.App.Jobs;
using Chronos.Core.Localization;
using Chronos.Core.Model;
using Chronos.Data.Archiving;
+using Chronos.Data.Jobs;
using Chronos.Data.Repositories;
using Chronos.Ui.Controls;
@@ -30,9 +31,15 @@ public enum OrphanKind
/// One line of the orphans report and the target of its fix.
public sealed record OrphanRow(OrphanKind Kind, string Title, string Detail, Guid? SequenceId);
-/// A line of "Recent maintenance": date, operation and outcome.
-public sealed record MaintenanceRow(Guid JobId, string DateText, string Text, string StateText, JobState State)
+///
+/// A line of "Recent maintenance": date, operation and outcome; , the muted second line of a running
+/// job (what it does now) or of a paused or failed one (where it stopped), owner review 5, #65; empty otherwise, with
+/// the line whole plus the speed and time left.
+///
+public sealed record MaintenanceRow(Guid JobId, string DateText, string Text, string StateText, JobState State, string Detail = "", string DetailToolTip = "")
{
+ public bool HasDetail => Detail.Length > 0;
+
/// The outcome's glyph and colour, as on the Jobs screen (paired with the word, never colour alone).
public StatusKind StateKind => State switch
{
@@ -102,18 +109,23 @@ public static class MaintenanceReports
return rows;
}
- public static IReadOnlyList Recent(IEnumerable jobs, int count) =>
+ ///
+ /// The latest jobs as "Recent maintenance" lines; a running one shows its percentage and what it
+ /// does now from its progress when there is some (owner review 5, #65), else from its stored snapshot.
+ ///
+ public static IReadOnlyList Recent(IEnumerable jobs, int count, IReadOnlyDictionary? live = null) =>
[
.. jobs.OrderByDescending(j => j.Finished ?? j.Started ?? j.Created).Take(count).Select(j =>
{
var when = j.Finished ?? j.Started ?? j.Created;
var text = string.IsNullOrWhiteSpace(j.TargetLabel) ? JobText.Kind(j.Kind) : Loc.L("Archive.Recent.Line", JobText.Kind(j.Kind), j.TargetLabel);
+ var entry = new JobEntry(j) { Live = j.State == JobState.Running ? live?.GetValueOrDefault(j.Id) : null };
var state = j.State switch
{
- JobState.Running when j.ProgressTotal > 0 => Formatting.Percent(j.ProgressDone / (double)j.ProgressTotal),
+ JobState.Running when entry.Fraction is { } fraction => Formatting.Percent(fraction),
_ => Loc.L("Jobs.State." + j.State),
};
- return new MaintenanceRow(j.Id, Formatting.Date(when), text, state, j.State);
+ return new MaintenanceRow(j.Id, Formatting.Date(when), text, state, j.State, JobText.RowStatus(entry), JobText.RowStatusToolTip(entry));
}),
];
}
diff --git a/src/Chronos.App/DesignTime/SampleJobDetails.cs b/src/Chronos.App/DesignTime/SampleJobDetails.cs
new file mode 100644
index 00000000..83129e2c
--- /dev/null
+++ b/src/Chronos.App/DesignTime/SampleJobDetails.cs
@@ -0,0 +1,36 @@
+using Chronos.Core.Model;
+
+namespace Chronos.App.DesignTime;
+
+///
+/// What the sample's running and paused jobs do now (owner review 5, #65), for the design view, the screenshots and the
+/// visual tests: a pass over many photos says which photo of which sequence; a job of another kind, or one that is queued or
+/// finished, is left as it is.
+///
+public static class SampleJobDetails
+{
+ /// with the sample detail of its kind while it runs or is paused; unchanged otherwise.
+ public static Job Apply(Job job)
+ {
+ ArgumentNullException.ThrowIfNull(job);
+ if (job.State is not (JobState.Running or JobState.Paused) || job.Detail is not null) return job;
+ var title = string.IsNullOrWhiteSpace(job.TargetLabel) ? null : job.TargetLabel;
+ JobDetail? detail = job.Kind switch
+ {
+ JobKind.Scan or JobKind.Rebuild => new JobDetail(JobStep.Index, "2024/2024-09-27 Harbour sunset", 1_240, 3_600, 12, 340, JobPartUnit.Folder),
+ JobKind.Verify => new JobDetail(JobStep.Verify, "Harbour sunset", 812, 2_400, 3, 41, JobPartUnit.Sequence),
+ JobKind.Thumbs => new JobDetail(JobStep.Thumbs, title, 1_240, 3_600, 2, 7, JobPartUnit.Sequence),
+ JobKind.Proxies => new JobDetail(JobStep.Proxies, title, 1_240, 3_600, 2, 7, JobPartUnit.Sequence),
+ JobKind.LightAnalyse => new JobDetail(JobStep.Analyse, title, Part: 120, Parts: 4_812, PartUnit: JobPartUnit.Sequence),
+ JobKind.DeepAnalyse => new JobDetail(JobStep.Analyse, title, job.ProgressDone, job.ProgressTotal),
+ JobKind.Render or JobKind.WorkspaceRender => new JobDetail(JobStep.Encode, null, job.ProgressDone, job.ProgressTotal),
+ JobKind.Convert => new JobDetail(JobStep.Convert, title, 412, 1_200, 4, 9, JobPartUnit.Sequence),
+ JobKind.Import => new JobDetail(JobStep.CopyPhoto, "IMG_4812.CR3", 1_240, 4_812),
+ JobKind.UploadCommit => new JobDetail(JobStep.Upload, title, job.ProgressDone, job.ProgressTotal),
+ JobKind.Download => new JobDetail(JobStep.Download, title, job.ProgressDone, job.ProgressTotal),
+ JobKind.Maintenance => new JobDetail(JobStep.Maintenance, "packs", Part: 3, Parts: 5, PartUnit: JobPartUnit.Step),
+ _ => null,
+ };
+ return detail is null ? job : job with { Detail = detail };
+ }
+}
diff --git a/src/Chronos.App/DesignTime/SampleServerJobs.cs b/src/Chronos.App/DesignTime/SampleServerJobs.cs
new file mode 100644
index 00000000..938ca1f2
--- /dev/null
+++ b/src/Chronos.App/DesignTime/SampleServerJobs.cs
@@ -0,0 +1,89 @@
+using System.Runtime.CompilerServices;
+using Chronos.App.Server;
+using Chronos.Core.Model;
+using Chronos.Data.Jobs;
+using Chronos.Protocol;
+
+namespace Chronos.App.DesignTime;
+
+///
+/// The sample server's jobs for the Server section's job list (owner review 5, #65), for the screenshots: empty until
+/// , then a verification and a thumbnail pass running with what each does now, and a proxy pass paused.
+/// Pause, resume and cancel change the list; no event ever comes. Thread-safe; disposing it does nothing, so it can be reused.
+///
+public sealed class SampleServerJobs : IServerJobsApi
+{
+ private readonly Lock _gate = new();
+ private List _jobs = [];
+
+ /// The sample's running and paused jobs.
+ public void Fill()
+ {
+ var now = SampleData.Now;
+ lock (_gate)
+ {
+ _jobs =
+ [
+ Job(JobKind.Verify, "Harbour sunset", JobState.Running, 812, 2_400, 38.5, 41, now.AddMinutes(-6),
+ new JobDetail(JobStep.Verify, "Harbour sunset", 812, 2_400, 3, 41, JobPartUnit.Sequence)),
+ Job(JobKind.Thumbs, "Sunrise over Superga", JobState.Running, 1_240, 3_600, 52.0, 45, now.AddMinutes(-3),
+ new JobDetail(JobStep.Thumbs, "Sunrise over Superga", 1_240, 3_600, 2, 7, JobPartUnit.Sequence)),
+ Job(JobKind.Proxies, "Alpine lake, winter", JobState.Paused, 300, 1_800, null, null, now.AddMinutes(-40),
+ new JobDetail(JobStep.Proxies, "Alpine lake, winter", 300, 1_800, 1, 2, JobPartUnit.Sequence)),
+ ];
+ }
+ }
+
+ /// Nothing runs on the server again.
+ public void Clear()
+ {
+ lock (_gate) _jobs = [];
+ }
+
+ public Task> ListJobsAsync(string state, string? cursor, CancellationToken cancellationToken)
+ {
+ lock (_gate)
+ {
+ var items = _jobs.Where(j => j.State == state).ToList();
+ return Task.FromResult(new Page(items, null, items.Count));
+ }
+ }
+
+ public Task GetJobAsync(Guid id, CancellationToken cancellationToken)
+ {
+ lock (_gate) return Task.FromResult(_jobs.Single(j => j.Id == id));
+ }
+
+ public Task PauseJobAsync(Guid id, CancellationToken cancellationToken) => SetState(id, JobState.Paused);
+
+ public Task ResumeJobAsync(Guid id, CancellationToken cancellationToken) => SetState(id, JobState.Running);
+
+ public Task CancelJobAsync(Guid id, CancellationToken cancellationToken) => SetState(id, JobState.Cancelled);
+
+ public async IAsyncEnumerable EventsAsync([EnumeratorCancellation] CancellationToken cancellationToken)
+ {
+ await Task.Delay(Timeout.Infinite, cancellationToken).ConfigureAwait(false);
+ yield break;
+ }
+
+ public void Dispose()
+ {
+ }
+
+ private Task SetState(Guid id, JobState state)
+ {
+ lock (_gate)
+ {
+ var index = _jobs.FindIndex(j => j.Id == id);
+ var job = _jobs[index] with { State = JobWire.State(state) };
+ if (state is JobState.Running or JobState.Paused) _jobs[index] = job;
+ else _jobs.RemoveAt(index);
+ return Task.FromResult(job);
+ }
+ }
+
+ private static JobDto Job(JobKind kind, string target, JobState state, long done, long total, double? rate, double? eta, DateTimeOffset started,
+ JobDetail detail) =>
+ new(Guid.NewGuid(), JobWire.Kind(kind), [Guid.NewGuid()], target, JobWire.State(state), JobWire.Priority(JobPriority.Background), done, total,
+ rate, eta, null, null, 1, null, started, started, null, null, JobWire.Detail(detail));
+}
diff --git a/src/Chronos.App/Editor/EditorText.cs b/src/Chronos.App/Editor/EditorText.cs
index 273f2af3..ce5e6998 100644
--- a/src/Chronos.App/Editor/EditorText.cs
+++ b/src/Chronos.App/Editor/EditorText.cs
@@ -44,7 +44,10 @@ public static class EditorText
};
}
- /// "Render running on Studio NAS · 1,240 / 3,600 · 11.3 fps · 3 min left"; "Render waiting on Studio NAS".
+ ///
+ /// "Render running on Studio NAS · 1,240 / 3,600 · 11.3 fps · 3 min left"; with what the job does now in place of the
+ /// counter ("… · Encoding frame 1,240 of 3,600 · 11.3 fps · 3 min left", owner review 5, #65); "Render waiting on Studio NAS".
+ ///
public static string ServerJobDetail(Job job, string server)
{
ArgumentNullException.ThrowIfNull(job);
@@ -55,7 +58,8 @@ public static class EditorText
_ => "Tooltips.Editor.ServerJob",
};
var parts = new List { Loc.L(key, JobText.Kind(job.Kind), server) };
- if (JobText.Counter(job.ProgressDone, job.ProgressTotal) is { Length: > 0 } counter) parts.Add(counter);
+ if (job.State == JobState.Running && JobText.Status(job.Detail) is { Length: > 0 } status) parts.Add(status);
+ else if (JobText.Counter(job.Kind, job.ProgressDone, job.ProgressTotal) is { Length: > 0 } counter) parts.Add(counter);
if (JobText.Speed(job.Kind, job.ItemsPerSecond) is { Length: > 0 } speed) parts.Add(speed);
if (job.Eta is { } eta) parts.Add(Loc.L("Editor.ServerJob.Left", Formatting.Duration(eta)));
return string.Join(Separator, parts);
diff --git a/src/Chronos.App/Editor/ServerJobs.cs b/src/Chronos.App/Editor/ServerJobs.cs
index 90f779c1..cbad697c 100644
--- a/src/Chronos.App/Editor/ServerJobs.cs
+++ b/src/Chronos.App/Editor/ServerJobs.cs
@@ -180,6 +180,8 @@ internal sealed class ServerJobs : IAsyncDisposable
ProgressTotal = progress.Total,
ItemsPerSecond = progress.ItemsPerSecond,
Eta = JobEta.FromSeconds(progress.EtaSeconds),
+ // What it does now (owner review 5, #65); an older server sends none, and the last one stays.
+ Detail = JobWire.FromDto(progress.Detail) ?? job.Detail,
});
break;
case JobProgressEvent:
diff --git a/src/Chronos.App/Jobs/JobListModel.cs b/src/Chronos.App/Jobs/JobListModel.cs
index 34f91ecc..fe87772b 100644
--- a/src/Chronos.App/Jobs/JobListModel.cs
+++ b/src/Chronos.App/Jobs/JobListModel.cs
@@ -32,6 +32,12 @@ public sealed class JobEntry(Job job)
public TimeSpan? Eta => Live?.Eta ?? Job.Eta;
public string? Message => Live?.Message;
+ ///
+ /// What the job does now (owner review 5, #65): the live detail while it runs, else the one stored with its last saved
+ /// progress (where a paused or failed job stopped); null when its handler reports none.
+ ///
+ public JobDetail? Detail => Live?.Detail ?? Job.Detail;
+
/// 0…1, or null while the total is unknown.
public double? Fraction => Total > 0 ? Math.Clamp((double)Done / Total, 0, 1) : null;
diff --git a/src/Chronos.App/Jobs/JobRowViewModel.cs b/src/Chronos.App/Jobs/JobRowViewModel.cs
index 4d7e3f53..459522cf 100644
--- a/src/Chronos.App/Jobs/JobRowViewModel.cs
+++ b/src/Chronos.App/Jobs/JobRowViewModel.cs
@@ -36,6 +36,17 @@ public sealed class JobRowViewModel : ObservableObject
public string Target => _entry.Job.TargetLabel ?? string.Empty;
+ ///
+ /// What a running job does now, or where a paused or failed job stopped (owner review 5, #65), under the target; empty
+ /// otherwise. Not announced: a screen reader hears state changes only (DECISIONS row 158).
+ ///
+ public string StatusText => JobText.RowStatus(_entry);
+
+ public bool HasStatus => StatusText.Length > 0;
+
+ /// The status line whole, then the speed and time left of a running job.
+ public string StatusToolTip => JobText.RowStatusToolTip(_entry);
+
/// A schedule queued the job (owner review 2, R10): the row shows a "Scheduled" pill.
public bool IsScheduled => _entry.Job.ScheduleId is not null;
@@ -136,6 +147,9 @@ public sealed class JobRowViewModel : ObservableObject
return;
}
OnPropertyChanged(nameof(Progress));
+ OnPropertyChanged(nameof(StatusText));
+ OnPropertyChanged(nameof(HasStatus));
+ OnPropertyChanged(nameof(StatusToolTip));
OnPropertyChanged(nameof(PercentText));
OnPropertyChanged(nameof(SpeedText));
OnPropertyChanged(nameof(LeftText));
diff --git a/src/Chronos.App/Jobs/JobText.cs b/src/Chronos.App/Jobs/JobText.cs
index d748456b..c6064590 100644
--- a/src/Chronos.App/Jobs/JobText.cs
+++ b/src/Chronos.App/Jobs/JobText.cs
@@ -29,6 +29,141 @@ public static class JobText
public static string Counter(long done, long total) =>
total > 0 ? Loc.L("Jobs.Counter", Formatting.Count(done), Formatting.Count(total)) : string.Empty;
+ /// "1,240 / 3,600", or "52 GB / 1.1 TB" for a job that counts bytes; empty while the total is unknown.
+ public static string Counter(JobKind kind, long done, long total) => total <= 0 ? string.Empty
+ : CountsBytes(kind) ? Loc.L("Jobs.Counter", Formatting.Bytes(done), Formatting.Bytes(total))
+ : Counter(done, total);
+
+ /// The longest status line the job bar shows (); the item goes first, the full line is in the Jobs table.
+ public const int BarStatusLength = 60;
+
+ ///
+ /// What a job does now (owner review 5, #65), from its : the step ("Verifying photo 812 of 2,400"),
+ /// the item ("Harbour sunset", a folder kept left to right) and the part ("sequence 3 of 41"), each left out when empty;
+ /// a clean-up or maintenance sub-step names itself in place of the step. A step this build does not know (a newer server)
+ /// shows its counts only. Empty for no detail.
+ ///
+ public static string Status(JobDetail? detail) => Status(detail, int.MaxValue);
+
+ ///
+ /// in at most characters: a longer line drops the item
+ /// first, then is cut with an ellipsis.
+ ///
+ public static string Status(JobDetail? detail, int maxLength)
+ {
+ if (detail is null) return string.Empty;
+ var (step, consumed) = StepPhrase(detail);
+ var item = consumed ? null : ItemText(detail.Item);
+ var part = PartPhrase(detail);
+ var full = JoinParts(step, item, part);
+ if (full.Length <= maxLength) return full;
+ if (item is not null && JoinParts(step, null, part) is { Length: > 0 } shorter) full = shorter;
+ return Cut(full, maxLength);
+ }
+
+ ///
+ /// The status line of a Jobs row: what a running job does now; "Stopped at …" with where a paused or failed job stopped;
+ /// empty for queued and finished jobs, and for a job whose handler reports no detail.
+ ///
+ public static string RowStatus(JobEntry entry)
+ {
+ ArgumentNullException.ThrowIfNull(entry);
+ return entry.State switch
+ {
+ JobState.Running => Status(entry.Detail),
+ JobState.Paused or JobState.Failed when Status(entry.Job.Detail) is { Length: > 0 } status => Loc.L("Jobs.Detail.StoppedAt", status),
+ _ => string.Empty,
+ };
+ }
+
+ /// The tooltip of a row's status line: the line whole, then the speed and the time left while the job runs.
+ public static string RowStatusToolTip(JobEntry entry)
+ {
+ ArgumentNullException.ThrowIfNull(entry);
+ var parts = new List(3);
+ if (RowStatus(entry) is { Length: > 0 } status) parts.Add(status);
+ if (entry.State == JobState.Running)
+ {
+ if (Speed(entry.Job.Kind, entry.ItemsPerSecond) is { Length: > 0 } speed) parts.Add(speed);
+ if (entry.Eta is { } eta) parts.Add(Loc.L("Jobs.Bar.Left", Formatting.Duration(eta)));
+ }
+ return string.Join(Loc.Separator, parts);
+ }
+
+ ///
+ /// The step phrase, counted when the item is ("Verifying photo 812 of 2,400"), and whether it took the item's place (the
+ /// named sub-step of a clean-up or maintenance).
+ ///
+ private static (string? Phrase, bool ConsumedItem) StepPhrase(JobDetail detail)
+ {
+ var counted = detail.ItemTotal > 0;
+ var done = Formatting.Count(Math.Clamp(detail.ItemDone, 0, detail.ItemTotal));
+ var total = Formatting.Count(detail.ItemTotal);
+ var counts = counted ? Loc.L("Jobs.Detail.Count", done, total) : null;
+ // A clean-up step ("job-history") and a maintenance step ("packs") name themselves.
+ var named = detail.Step switch
+ {
+ JobStep.Cleanup => Known("Jobs.Schedule.Step." + Pascal(detail.Item)),
+ JobStep.Maintenance => Known("Jobs.Maintenance.Step." + Pascal(detail.Item)),
+ _ => null,
+ };
+ if (named is not null) return (JoinParts(Loc.L(named), counts, null), true);
+ if (detail.Step == JobStep.None) return (counts, false);
+ var key = "Jobs.Step." + detail.Step;
+ // The item of a clean-up or maintenance step is a key, not data: one this build does not know is never shown.
+ if (detail.Step is JobStep.Cleanup or JobStep.Maintenance) return (JoinParts(Known(key) is { } step ? Loc.L(step) : null, counts, null), true);
+ if (counted && Known(key + ".Count") is { } countKey) return (Loc.L(countKey, done, total), false);
+ if (Known(key) is null) return (counts, false);
+ return (JoinParts(Loc.L(key), counts, null), false);
+ }
+
+ /// "sequence 3 of 41" when the job has more than one part; null otherwise.
+ private static string? PartPhrase(JobDetail detail)
+ {
+ if (detail.Parts <= 1) return null;
+ var part = Formatting.Count(Math.Clamp(detail.Part, 0, detail.Parts));
+ var parts = Formatting.Count(detail.Parts);
+ return detail.PartUnit != JobPartUnit.None && Known("Jobs.Part." + detail.PartUnit) is { } key
+ ? Loc.L(key, part, parts)
+ : Loc.L("Jobs.Detail.Count", part, parts);
+ }
+
+ /// The item as data: a folder or a path kept left to right inside right-to-left text (DECISIONS row 218).
+ private static string? ItemText(string? item)
+ {
+ if (string.IsNullOrWhiteSpace(item)) return null;
+ return item.Contains('/') || item.Contains('\\') ? Formatting.LeftToRight(item) : item;
+ }
+
+ /// "job-history" → "JobHistory"; null for a key that is not one (data from a newer peer).
+ private static string? Pascal(string? key)
+ {
+ if (string.IsNullOrEmpty(key) || key.Length > 40 || !key.All(c => char.IsAsciiLetterOrDigit(c) || c is '-' or '_')) return null;
+ return string.Concat(key.Split('-', '_', StringSplitOptions.RemoveEmptyEntries).Select(p => char.ToUpperInvariant(p[0]) + p[1..]));
+ }
+
+ /// The key when the catalog has it (the step, unit or sub-step of a newer peer may have none); null otherwise.
+ private static string? Known(string? key) => key is not null && !key.EndsWith('.') && Loc.Get(key, Loc.Culture) is not null ? key : null;
+
+ private static string JoinParts(string? a, string? b, string? c)
+ {
+ var pieces = new List(3);
+ if (!string.IsNullOrEmpty(a)) pieces.Add(a);
+ if (!string.IsNullOrEmpty(b)) pieces.Add(b);
+ if (!string.IsNullOrEmpty(c)) pieces.Add(c);
+ return string.Join(Loc.Separator, pieces);
+ }
+
+ /// Cuts to characters with an ellipsis, closing a left-to-right island it cut into.
+ private static string Cut(string text, int max)
+ {
+ if (text.Length <= max) return text;
+ var length = Math.Max(1, max - 1);
+ if (char.IsHighSurrogate(text[length - 1])) length--;
+ var cut = text[..length] + "…";
+ return cut.Count(c => c == '') > cut.Count(c => c == '') ? cut + "" : cut;
+ }
+
///
/// The "Left" column: time left while running, "after n" while queued, the finish time of the history.
///
@@ -71,13 +206,17 @@ public static class JobText
}
///
- /// Job bar line (DESIGN §4): "Render · Harbour sunset · 2,232 / 3,600 · 11.3 fps · 2 min left".
+ /// Job bar line (DESIGN §4): "Render · Harbour sunset · 2,232 / 3,600 · 11.3 fps · 2 min left"; with a detail, what the
+ /// job does now in place of the counter ("Scan · Archive 2024 · Indexing photo 1,240 of 3,600 · folder 12 of 340 · 41/s ·
+ /// 3 min left", at most characters of it); a job that counts bytes shows sizes.
///
public static string Bar(JobEntry entry)
{
+ ArgumentNullException.ThrowIfNull(entry);
var parts = new List(5) { Kind(entry.Job.Kind) };
if (!string.IsNullOrWhiteSpace(entry.Job.TargetLabel)) parts.Add(entry.Job.TargetLabel!);
- if (Counter(entry.Done, entry.Total) is { Length: > 0 } counter) parts.Add(counter);
+ if (Status(entry.Detail, BarStatusLength) is { Length: > 0 } status) parts.Add(status);
+ else if (Counter(entry.Job.Kind, entry.Done, entry.Total) is { Length: > 0 } counter) parts.Add(counter);
if (Speed(entry.Job.Kind, entry.ItemsPerSecond) is { Length: > 0 } speed) parts.Add(speed);
if (entry.Eta is { } eta) parts.Add(Loc.L("Jobs.Bar.Left", Formatting.Duration(eta)));
return string.Join(Loc.Separator, parts);
diff --git a/src/Chronos.App/Sections/ArchiveView.xaml b/src/Chronos.App/Sections/ArchiveView.xaml
index 79fa8630..063e4275 100644
--- a/src/Chronos.App/Sections/ArchiveView.xaml
+++ b/src/Chronos.App/Sections/ArchiveView.xaml
@@ -299,14 +299,20 @@
-
+
-
+
+
+
+
+
diff --git a/src/Chronos.App/Sections/ArchiveViewModel.cs b/src/Chronos.App/Sections/ArchiveViewModel.cs
index 56cc369d..14c5c6ad 100644
--- a/src/Chronos.App/Sections/ArchiveViewModel.cs
+++ b/src/Chronos.App/Sections/ArchiveViewModel.cs
@@ -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 _formats = [];
private IReadOnlyList _health = [];
private IReadOnlyList _recent = [];
+
+ /// The jobs behind , their running ones' latest progress, and the ids whose progress counts here.
+ private IReadOnlyList _recentJobs = [];
+ private readonly Dictionary _recentLive = [];
+ private readonly System.Collections.Concurrent.ConcurrentDictionary _recentPending = new();
+ private HashSet _recentRunning = [];
+ private CoalescingThrottle? _recentThrottle;
private IReadOnlyList? _duplicates;
private IReadOnlyList? _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;
}
+ /// Progress of a running job of "Recent maintenance" (any thread): kept until the next flush.
+ private void OnProgress(JobProgressInfo progress)
+ {
+ if (!Volatile.Read(ref _recentRunning).Contains(progress.JobId)) return;
+ _recentPending[progress.JobId] = progress;
+ _recentThrottle?.Signal();
+ }
+
+ /// The running Recent lines with their latest progress (UI thread).
+ 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);
+ }
+
///
/// 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.
diff --git a/src/Chronos.App/Sections/JobsView.xaml b/src/Chronos.App/Sections/JobsView.xaml
index d0586c09..35b2a686 100644
--- a/src/Chronos.App/Sections/JobsView.xaml
+++ b/src/Chronos.App/Sections/JobsView.xaml
@@ -187,13 +187,20 @@
ui:ButtonIcon.Glyph="{StaticResource Icon.ChevronRight}" Command="{Binding ToggleLogCommand}"
ToolTip="{Binding ToggleToolTip}" AutomationProperties.Name="{Binding ToggleName}" />
-
+
-
+
+
+
+
diff --git a/src/Chronos.App/Sections/ServerView.xaml b/src/Chronos.App/Sections/ServerView.xaml
index 3e039e1c..2f8b9af0 100644
--- a/src/Chronos.App/Sections/ServerView.xaml
+++ b/src/Chronos.App/Sections/ServerView.xaml
@@ -42,9 +42,10 @@
-
+
+
@@ -166,8 +167,11 @@
+
+
+
-
+
diff --git a/src/Chronos.App/Sections/ServerViewModel.cs b/src/Chronos.App/Sections/ServerViewModel.cs
index c2d33220..3ca37e84 100644
--- a/src/Chronos.App/Sections/ServerViewModel.cs
+++ b/src/Chronos.App/Sections/ServerViewModel.cs
@@ -14,7 +14,8 @@ namespace Chronos.App.Sections;
///
/// Server (BRIEF §12.7, Server.html): address with LAN-discovered servers, connect with trust-on-first-use and login,
/// status (name, version, latency, certificate), account and quota, sign out, the options of this PC (render node,
-/// proxies kept offline, automatic project sync, uploads paused on metered networks) and the sync table ().
+/// proxies kept offline, automatic project sync, uploads paused on metered networks), the server's running and paused jobs
+/// () and the sync table ().
/// The rail badge counts the settings conflicts waiting for a choice.
///
public sealed class ServerViewModel : SectionViewModel
@@ -41,11 +42,19 @@ public sealed class ServerViewModel : SectionViewModel
Sync = new SyncTableViewModel(shell);
_conflicts = Sync.Chips.Single(c => c.Filter == SyncFilter.Conflicts);
_conflicts.PropertyChanged += OnConflictsChanged;
+ Jobs = new ServerJobsViewModel(() => ServerJobsViewModel.AccountOf(Session), () => JobsConnection(Session), SynchronizationContext.Current,
+ (title, message) => Shell.Notify(title, message, isError: true));
}
/// Sequences of this PC and of the server, where they stand and what can be done.
public SyncTableViewModel Sync { get; }
+ /// The server's running and paused jobs, live (owner review 5, #65).
+ public ServerJobsViewModel Jobs { get; }
+
+ /// Opens the job list's connection for a session; the screenshots put the sample server's jobs here.
+ internal Func JobsConnection { get; set; } = ServerJobsViewModel.ConnectionOf;
+
public ShellViewModel Shell { get; }
private ServerSession Session => _session ?? Shell.Services.Server;
@@ -212,6 +221,7 @@ public sealed class ServerViewModel : SectionViewModel
if (!Shell.Services.Environment.IsCapture) _session.StartDiscovery();
Shell.Settings.Encoders.CollectionChanged += OnEncodersChanged;
Sync.Attach();
+ Jobs.Refresh();
await _session.RestoreAsync();
if (_session.Flow.Error is not ConnectError.None and var error && !_session.IsConnected) ErrorText = ServerSession.ErrorText(error, _session.Flow.Address);
}
@@ -222,6 +232,7 @@ public sealed class ServerViewModel : SectionViewModel
if (_session is not null) _session.PropertyChanged -= OnSessionChanged;
Shell.Settings.Encoders.CollectionChanged -= OnEncodersChanged;
Sync.Dispose();
+ Jobs.Dispose();
base.Dispose();
}
@@ -278,6 +289,7 @@ public sealed class ServerViewModel : SectionViewModel
{
OnAllPropertiesChanged();
CommandManager.InvalidateRequerySuggested();
+ Jobs.Refresh();
}
/// The name of a server role, or null for a role this build does not know.
diff --git a/src/Chronos.App/Server/ServerJobsApi.cs b/src/Chronos.App/Server/ServerJobsApi.cs
new file mode 100644
index 00000000..769aacd5
--- /dev/null
+++ b/src/Chronos.App/Server/ServerJobsApi.cs
@@ -0,0 +1,44 @@
+using Chronos.Protocol;
+using Chronos.Protocol.Client;
+
+namespace Chronos.App.Server;
+
+///
+/// What the Server section's job list needs from the signed-in server (owner review 5, #65): its jobs by state, one job,
+/// pause, resume and cancel, and its events (, ). Owns its connection.
+///
+public interface IServerJobsApi : IDisposable
+{
+ /// A page of the server's jobs in (a wire name: running, paused…), newest first.
+ Task> ListJobsAsync(string state, string? cursor, CancellationToken cancellationToken);
+
+ Task GetJobAsync(Guid id, CancellationToken cancellationToken);
+
+ Task PauseJobAsync(Guid id, CancellationToken cancellationToken);
+
+ Task ResumeJobAsync(Guid id, CancellationToken cancellationToken);
+
+ Task CancelJobAsync(Guid id, CancellationToken cancellationToken);
+
+ /// Server events until cancelled or the socket closes.
+ IAsyncEnumerable EventsAsync(CancellationToken cancellationToken);
+}
+
+/// over a signed-in , which it owns.
+public sealed class ChronosServerJobsApi(ChronosClient client) : IServerJobsApi
+{
+ public Task> ListJobsAsync(string state, string? cursor, CancellationToken cancellationToken) =>
+ client.ListJobsAsync(state, null, cursor, cancellationToken);
+
+ public Task GetJobAsync(Guid id, CancellationToken cancellationToken) => client.GetJobAsync(id, cancellationToken);
+
+ public Task PauseJobAsync(Guid id, CancellationToken cancellationToken) => client.PauseJobAsync(id, cancellationToken);
+
+ public Task ResumeJobAsync(Guid id, CancellationToken cancellationToken) => client.ResumeJobAsync(id, cancellationToken);
+
+ public Task CancelJobAsync(Guid id, CancellationToken cancellationToken) => client.CancelJobAsync(id, cancellationToken);
+
+ public IAsyncEnumerable EventsAsync(CancellationToken cancellationToken) => client.EventsAsync(cancellationToken);
+
+ public void Dispose() => client.Dispose();
+}
diff --git a/src/Chronos.App/Server/ServerJobsView.xaml b/src/Chronos.App/Server/ServerJobsView.xaml
new file mode 100644
index 00000000..6f9245a2
--- /dev/null
+++ b/src/Chronos.App/Server/ServerJobsView.xaml
@@ -0,0 +1,119 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Chronos.App/Server/ServerJobsView.xaml.cs b/src/Chronos.App/Server/ServerJobsView.xaml.cs
new file mode 100644
index 00000000..a925b224
--- /dev/null
+++ b/src/Chronos.App/Server/ServerJobsView.xaml.cs
@@ -0,0 +1,9 @@
+using System.Windows.Controls;
+
+namespace Chronos.App.Server;
+
+/// The Server section's list of the server's running and paused jobs ().
+public partial class ServerJobsView : UserControl
+{
+ public ServerJobsView() => InitializeComponent();
+}
diff --git a/src/Chronos.App/Server/ServerJobsViewModel.cs b/src/Chronos.App/Server/ServerJobsViewModel.cs
new file mode 100644
index 00000000..71fb74f1
--- /dev/null
+++ b/src/Chronos.App/Server/ServerJobsViewModel.cs
@@ -0,0 +1,491 @@
+using System.Collections.ObjectModel;
+using System.Net.Http;
+using System.Text.Json;
+using Chronos.App.Infrastructure;
+using Chronos.App.Jobs;
+using Chronos.Core.Diagnostics;
+using Chronos.Core.Localization;
+using Chronos.Core.Model;
+using Chronos.Data.Jobs;
+using Chronos.Protocol;
+using Chronos.Protocol.Client;
+using Chronos.Ui.Controls;
+using Chronos.Ui.Mvvm;
+
+namespace Chronos.App.Server;
+
+///
+/// Who is signed in, as the Server section's job list sees it: names the session (a new sign-in is another
+/// list), whether the account may pause, resume and cancel any of the server's jobs.
+///
+public sealed record ServerJobsAccount(string Key, bool CanControl);
+
+///
+/// The jobs running or paused on the signed-in server, live (owner review 5, #65 and the owner's answer to Q2): read from the
+/// server's jobs API, then followed through its events ( with what each job does now,
+/// ), at most four updates a second, and read again whenever the event socket comes back after a
+/// loss (with a growing delay; nothing that fails on the way ends it). Queued jobs are the admin panel's (a busy server
+/// queues thumbnails by the thousand). Pause, Resume and Cancel are offered only to an account with the right to manage
+/// the archive, which the server requires to act on a job someone else started; otherwise the list is read-only. Empty and
+/// idle while signed out or without the right to read. UI thread, except where said.
+///
+public sealed class ServerJobsViewModel : ObservableObject, IDisposable
+{
+ private static readonly TimeSpan FlushInterval = TimeSpan.FromMilliseconds(250);
+ private static readonly TimeSpan MinBackoff = TimeSpan.FromSeconds(2);
+ private static readonly TimeSpan MaxBackoff = TimeSpan.FromMinutes(1);
+ private static readonly string[] ListedStates = [JobWire.State(JobState.Running), JobWire.State(JobState.Paused)];
+
+ private readonly JobListModel _model = new();
+ private readonly Updates _updates = new();
+ private readonly Dictionary _rows = [];
+ private readonly Func _account;
+ private readonly Func _connect;
+ private readonly Action? _failed;
+ private readonly CoalescingThrottle _throttle;
+ private Watch? _watch;
+ private bool _canControl;
+ private bool _disposed;
+
+ /// The signed-in account; null while signed out or without the right to read the server's jobs.
+ /// A connection for the signed-in session; null when there is none.
+ /// Where updates are applied (the UI); null applies them on a timer thread.
+ /// Says that an action failed: a title and the reason.
+ public ServerJobsViewModel(Func account, Func connect, SynchronizationContext? context, Action? failed = null)
+ {
+ ArgumentNullException.ThrowIfNull(account);
+ ArgumentNullException.ThrowIfNull(connect);
+ _account = account;
+ _connect = connect;
+ _failed = failed;
+ _throttle = new CoalescingThrottle(FlushInterval, context, Flush);
+ }
+
+ /// The account of : none while signed out or without the Read right; control with ManageArchive.
+ public static ServerJobsAccount? AccountOf(ServerSession session)
+ {
+ ArgumentNullException.ThrowIfNull(session);
+ if (session.User is not { } user || session.Flow.Address is not { } address || session.Flow.Token is not { } token) return null;
+ var permissions = (Permissions)user.Permissions;
+ if (!permissions.HasFlag(Permissions.Read)) return null;
+ return new ServerJobsAccount($"{ServerAddress.Display(address)}|{user.Id}|{token}", permissions.HasFlag(Permissions.ManageArchive));
+ }
+
+ /// A connection over for , pinned to its trusted certificates; null while signed out.
+ public static IServerJobsApi? ConnectionOf(ServerSession session)
+ {
+ ArgumentNullException.ThrowIfNull(session);
+ return session.IsConnected && session.Flow is { Address: { } address, Token: { } token }
+ ? new ChronosServerJobsApi(new ChronosClient(address, new CertificatePinning(session.Fingerprints), $"Chronos ({Environment.MachineName})") { Token = token })
+ : null;
+ }
+
+ /// Raised after the listener posted an update (any thread; tests wait on it).
+ internal event Action? Posted;
+
+ /// The running jobs first (oldest start first), then the paused ones.
+ public ObservableCollection Rows { get; } = [];
+
+ /// The list shows: a session is followed and the server runs or holds something.
+ public bool HasRows => Rows.Count > 0;
+
+ /// The account may pause, resume and cancel the server's jobs; without it the list is read-only.
+ public bool CanControl => _canControl;
+
+ /// What the list shows, and whether the account can act on it.
+ public string TitleToolTip => Loc.L(_canControl ? "Tooltips.Server.Jobs" : "Tooltips.Server.Jobs.ReadOnly");
+
+ /// A session is being followed.
+ internal bool IsWatching => _watch is not null;
+
+ /// Follows the signed-in session, or stops when it ended or changed (call when the session changes).
+ public void Refresh()
+ {
+ if (_disposed) return;
+ var account = _account();
+ if (account?.CanControl != _canControl)
+ {
+ _canControl = account?.CanControl ?? false;
+ foreach (var row in _rows.Values) row.Refresh();
+ OnPropertyChanged(nameof(CanControl));
+ OnPropertyChanged(nameof(TitleToolTip));
+ }
+ if (_watch?.Key == account?.Key) return;
+ Stop();
+ if (account is not null && _connect() is { } api)
+ {
+ _watch = new Watch(account.Key, api, new CancellationTokenSource());
+ var watch = _watch;
+ watch.Listening = Task.Run(() => ListenAsync(watch), CancellationToken.None);
+ }
+ }
+
+ /// Reads the server's running and paused jobs again (a picture of the list as it is now).
+ public async Task ReloadAsync()
+ {
+ if (_watch is not { } watch) return;
+ await LoadAsync(watch.Api, watch.Stopping.Token);
+ Flush();
+ }
+
+ /// Applies what the listener collected since the last flush (UI thread).
+ internal void Flush()
+ {
+ var (reset, jobs, removed, progress) = _updates.Drain();
+ if (reset is not null)
+ {
+ var listed = reset.Select(j => j.Id).ToHashSet();
+ foreach (var entry in _model.Ordered().Where(e => !listed.Contains(e.Id)).ToList()) _model.Remove(entry.Id);
+ foreach (var job in reset) _model.Apply(job);
+ }
+ foreach (var job in jobs)
+ {
+ if (IsListed(job.State)) _model.Apply(job);
+ else _model.Remove(job.Id);
+ }
+ foreach (var id in removed) _model.Remove(id);
+ foreach (var p in progress) _model.Apply(p);
+ SyncRows();
+ }
+
+ public void Dispose()
+ {
+ if (_disposed) return;
+ _disposed = true;
+ Stop();
+ _throttle.Dispose();
+ }
+
+ private static bool IsListed(JobState state) => state is JobState.Running or JobState.Paused;
+
+ private void Stop()
+ {
+ if (Interlocked.Exchange(ref _watch, null) is not { } watch) return;
+ watch.Stopping.Cancel();
+ // The listener disposes its connection once it has stopped.
+ _updates.Reset([]);
+ Flush();
+ }
+
+ ///
+ /// Lists the jobs, then follows the events until stopped; after a loss, waits with a growing delay and lists again
+ /// (events missed meanwhile are in that list). Nothing that fails on the way ends it. Disposes the connection at the end.
+ ///
+ private async Task ListenAsync(Watch watch)
+ {
+ var ct = watch.Stopping.Token;
+ var failures = 0;
+ try
+ {
+ while (!ct.IsCancellationRequested)
+ {
+ try
+ {
+ await LoadAsync(watch.Api, ct).ConfigureAwait(false);
+ await foreach (var e in watch.Api.EventsAsync(ct).ConfigureAwait(false))
+ {
+ failures = 0;
+ await OnEventAsync(watch.Api, e, ct).ConfigureAwait(false);
+ }
+ }
+ catch (Exception ex) when (ex is not OutOfMemoryException)
+ {
+ if (ct.IsCancellationRequested) return;
+ Log.Info("server", $"Jobs of the server lost: {ex.Message}");
+ }
+ var delay = Math.Min(MaxBackoff.Ticks, MinBackoff.Ticks << Math.Min(failures++, 10));
+ await Task.Delay(TimeSpan.FromTicks(delay), ct).ConfigureAwait(false);
+ }
+ }
+ catch (OperationCanceledException) when (ct.IsCancellationRequested)
+ {
+ }
+ finally
+ {
+ watch.Api.Dispose();
+ watch.Stopping.Dispose();
+ }
+ }
+
+ /// Every running and paused job of the server, all pages (any thread).
+ private async Task LoadAsync(IServerJobsApi api, CancellationToken ct)
+ {
+ var jobs = new List();
+ foreach (var state in ListedStates)
+ {
+ string? cursor = null;
+ do
+ {
+ var page = await api.ListJobsAsync(state, cursor, ct).ConfigureAwait(false);
+ jobs.AddRange(page.Items.Select(JobWire.FromDto).OfType().Where(j => IsListed(j.State)));
+ cursor = page.NextCursor;
+ }
+ while (cursor is not null);
+ }
+ _updates.Reset(jobs);
+ Signal();
+ }
+
+ private async Task OnEventAsync(IServerJobsApi api, ServerEvent e, CancellationToken ct)
+ {
+ switch (e)
+ {
+ case JobProgressEvent p:
+ // Kind and target come from the listed job; what matters here is the count, the pace and the detail.
+ _updates.Post(new JobProgressInfo(p.JobId, default, null, p.Done, p.Total, p.ItemsPerSecond, JobEta.FromSeconds(p.EtaSeconds), null,
+ JobWire.FromDto(p.Detail)));
+ Signal();
+ break;
+ case JobStateEvent s when JobWire.TryParseState(s.State, out var state) && IsListed(state):
+ await FetchAsync(api, s.JobId, ct).ConfigureAwait(false);
+ break;
+ case JobStateEvent s:
+ // Queued again, finished or of a state this build does not know: it leaves the list.
+ _updates.Remove(s.JobId);
+ Signal();
+ break;
+ }
+ }
+
+ private async Task FetchAsync(IServerJobsApi api, Guid jobId, CancellationToken ct)
+ {
+ try
+ {
+ if (JobWire.FromDto(await api.GetJobAsync(jobId, ct).ConfigureAwait(false)) is { } job) _updates.Post(job);
+ else _updates.Remove(jobId);
+ Signal();
+ }
+ catch (Exception ex) when (ex is ChronosApiException or HttpRequestException or JsonException
+ || (ex is OperationCanceledException && !ct.IsCancellationRequested))
+ {
+ Log.Info("server", $"Job {jobId} of the server could not be read: {ex.Message}");
+ }
+ }
+
+ private void Signal()
+ {
+ _throttle.Signal();
+ Posted?.Invoke();
+ }
+
+ /// Pauses, resumes or cancels a job on the server; what the server answers shows at once (UI thread).
+ internal async Task ActAsync(Guid jobId, Func> action)
+ {
+ if (_watch is not { } watch || !_canControl) return;
+ try
+ {
+ var dto = await action(watch.Api, jobId, watch.Stopping.Token);
+ if (JobWire.FromDto(dto) is { } job) _updates.Post(job);
+ else _updates.Remove(jobId);
+ Flush();
+ }
+ catch (Exception ex) when (ex is ChronosApiException or HttpRequestException or JsonException or OperationCanceledException or ObjectDisposedException)
+ {
+ if (watch.Stopping.IsCancellationRequested) return;
+ Log.Info("server", $"Job {jobId} of the server not changed: {ex.Message}");
+ // The server words its refusal in this PC's language (Accept-Language); anything else is a lost connection.
+ _failed?.Invoke(Loc.L("Server.Jobs.NotChanged"),
+ ex is ChronosApiException { Error.Message: { Length: > 0 } reason } ? reason : Loc.L("Server.Error.Unreachable"));
+ }
+ }
+
+ /// Brings to the model's order with moves.
+ private void SyncRows()
+ {
+ var ordered = _model.Ordered();
+ var wanted = ordered.Select(e => e.Id).ToHashSet();
+ for (var i = Rows.Count - 1; i >= 0; i--)
+ {
+ if (wanted.Contains(Rows[i].Id)) continue;
+ _rows.Remove(Rows[i].Id);
+ Rows.RemoveAt(i);
+ }
+ for (var i = 0; i < ordered.Count; i++)
+ {
+ var entry = ordered[i];
+ if (!_rows.TryGetValue(entry.Id, out var row))
+ {
+ row = new ServerJobRowViewModel(entry, this);
+ _rows[entry.Id] = row;
+ }
+ else
+ {
+ row.Update(entry);
+ }
+ if (i < Rows.Count && ReferenceEquals(Rows[i], row)) continue;
+ var existing = Rows.IndexOf(row);
+ if (existing >= 0) Rows.Move(existing, i);
+ else Rows.Insert(i, row);
+ }
+ OnPropertyChanged(nameof(HasRows));
+ }
+
+ /// The session followed: its key, its connection and what stops its listener.
+ private sealed class Watch(string key, IServerJobsApi api, CancellationTokenSource stopping)
+ {
+ public string Key { get; } = key;
+ public IServerJobsApi Api { get; } = api;
+ public CancellationTokenSource Stopping { get; } = stopping;
+ public Task? Listening { get; set; }
+ }
+
+ ///
+ /// What the listener collected for the next flush (thread-safe): a new list, which drops everything collected before it;
+ /// then per job its newest snapshot or its removal, and its newest progress.
+ ///
+ private sealed class Updates
+ {
+ private readonly Lock _gate = new();
+ private IReadOnlyList? _reset;
+ private Dictionary _jobs = [];
+ private HashSet _removed = [];
+ private Dictionary _progress = [];
+
+ public void Reset(IReadOnlyList jobs)
+ {
+ lock (_gate)
+ {
+ _reset = jobs;
+ _jobs = [];
+ _removed = [];
+ _progress = [];
+ }
+ }
+
+ public void Post(Job job)
+ {
+ lock (_gate)
+ {
+ _jobs[job.Id] = job;
+ _removed.Remove(job.Id);
+ _progress.Remove(job.Id);
+ }
+ }
+
+ public void Remove(Guid id)
+ {
+ lock (_gate)
+ {
+ _jobs.Remove(id);
+ _progress.Remove(id);
+ _removed.Add(id);
+ }
+ }
+
+ public void Post(JobProgressInfo progress)
+ {
+ lock (_gate) _progress[progress.JobId] = progress;
+ }
+
+ public (IReadOnlyList? Reset, IReadOnlyCollection Jobs, IReadOnlyCollection Removed, IReadOnlyCollection Progress) Drain()
+ {
+ lock (_gate)
+ {
+ var drained = (_reset, (IReadOnlyCollection)_jobs.Values, (IReadOnlyCollection)_removed, (IReadOnlyCollection)_progress.Values);
+ _reset = null;
+ _jobs = [];
+ _removed = [];
+ _progress = [];
+ return drained;
+ }
+ }
+ }
+}
+
+///
+/// One job of the server as the Server section lists it: kind, target with what it does now (or where a paused one stopped),
+/// progress, speed, time left, state, and Pause / Resume / Cancel when the account may.
+///
+public sealed class ServerJobRowViewModel : ObservableObject
+{
+ private readonly ServerJobsViewModel _owner;
+ private JobEntry _entry;
+
+ internal ServerJobRowViewModel(JobEntry entry, ServerJobsViewModel owner)
+ {
+ _entry = entry;
+ _owner = owner;
+ }
+
+ public Guid Id => _entry.Id;
+
+ public JobEntry Entry => _entry;
+
+ public string Kind => JobText.Kind(_entry.Job.Kind);
+
+ public string Target => _entry.Job.TargetLabel ?? string.Empty;
+
+ /// "Verify · Harbour sunset": the row's name for screen readers.
+ public string AccessibleName => JobText.Name(_entry.Job);
+
+ /// What it does now ("Verifying photo 812 of 2,400 · Harbour sunset · sequence 3 of 41"), or "Stopped at …".
+ public string StatusText => JobText.RowStatus(_entry);
+
+ public bool HasStatus => StatusText.Length > 0;
+
+ public string StatusToolTip => JobText.RowStatusToolTip(_entry);
+
+ public double Progress => _entry.Fraction ?? 0;
+
+ public bool IsIndeterminate => _entry.State == JobState.Running && _entry.Fraction is null;
+
+ public string PercentText => _entry.Fraction is { } f ? Formatting.Percent(f) : "—";
+
+ public string SpeedText => _entry.State == JobState.Running ? Blank(JobText.Speed(_entry.Job.Kind, _entry.ItemsPerSecond)) : "—";
+
+ public string LeftText => Blank(JobText.Left(_entry, 0));
+
+ public string StateText => JobText.State(_entry);
+
+ public StatusKind StateKind => _entry.State == JobState.Paused ? StatusKind.Paused : StatusKind.Running;
+
+ public string StateToolTip => string.Join(Loc.Separator, StateText, Loc.L("Tooltips.Jobs.State." + _entry.State));
+
+ /// "Verify · Harbour sunset: running": what a screen reader announces when the state changes (not progress).
+ public string StateAnnouncement => Loc.L("Jobs.Row.State", AccessibleName, StateText);
+
+ /// Pause and Cancel while it runs, Resume and Cancel while paused; none for a read-only account.
+ public IReadOnlyList Actions
+ {
+ get
+ {
+ if (!_owner.CanControl) return [];
+ var id = _entry.Id;
+ return _entry.State == JobState.Paused
+ ? [Action("Jobs.Action.Resume", "Tooltips.Jobs.Resume", (api, job, ct) => api.ResumeJobAsync(job, ct)),
+ Action("Jobs.Action.Cancel", "Tooltips.Jobs.Cancel", (api, job, ct) => api.CancelJobAsync(job, ct))]
+ : [Action("Jobs.Action.Pause", "Tooltips.Jobs.Pause", (api, job, ct) => api.PauseJobAsync(job, ct)),
+ Action("Jobs.Action.Cancel", "Tooltips.Jobs.Cancel", (api, job, ct) => api.CancelJobAsync(job, ct))];
+
+ JobAction Action(string textKey, string toolTipKey, Func> run)
+ {
+ var text = Loc.L(textKey);
+ return new JobAction(text, Loc.L(toolTipKey), Loc.L("Jobs.ActionFor", text, AccessibleName),
+ new AsyncRelayCommand(() => _owner.ActAsync(id, run)));
+ }
+ }
+ }
+
+ internal void Update(JobEntry entry)
+ {
+ var stateChanged = entry.State != _entry.State;
+ _entry = entry;
+ if (stateChanged)
+ {
+ OnAllPropertiesChanged();
+ return;
+ }
+ OnPropertyChanged(nameof(StatusText));
+ OnPropertyChanged(nameof(HasStatus));
+ OnPropertyChanged(nameof(StatusToolTip));
+ OnPropertyChanged(nameof(Progress));
+ OnPropertyChanged(nameof(IsIndeterminate));
+ OnPropertyChanged(nameof(PercentText));
+ OnPropertyChanged(nameof(SpeedText));
+ OnPropertyChanged(nameof(LeftText));
+ }
+
+ internal void Refresh() => OnAllPropertiesChanged();
+
+ private static string Blank(string text) => text.Length == 0 ? "—" : text;
+}
diff --git a/src/Chronos.App/Server/SyncText.cs b/src/Chronos.App/Server/SyncText.cs
index 087ba193..e51b6e8d 100644
--- a/src/Chronos.App/Server/SyncText.cs
+++ b/src/Chronos.App/Server/SyncText.cs
@@ -2,6 +2,7 @@ using System.Globalization;
using System.Text.Json;
using System.Text.Json.Nodes;
using Chronos.App.Infrastructure;
+using Chronos.App.Jobs;
using Chronos.Core.Localization;
using Chronos.Core.Model;
using Chronos.Data.Projects;
@@ -143,8 +144,10 @@ public static class SyncText
{
JobState.Paused => (StatusKind.Paused, Loc.L("Server.Sync.State.Paused"), Loc.L("Tooltips.Server.Sync.State.Paused")),
JobState.Queued => (StatusKind.Queued, Loc.L("Server.Sync.State.Waiting"), Loc.L("Tooltips.Server.Sync.State.Waiting")),
+ // What the transfer does now (owner review 5, #65: "Uploading photo 812 of 2,400") follows in the tooltip.
_ => (StatusKind.Running, Loc.L(upload ? "Server.Sync.State.Uploading" : "Server.Sync.State.Downloading"),
- Loc.L(upload ? "Tooltips.Server.Sync.State.Uploading" : "Tooltips.Server.Sync.State.Downloading")),
+ Join([Loc.L(upload ? "Tooltips.Server.Sync.State.Uploading" : "Tooltips.Server.Sync.State.Downloading"),
+ .. JobText.Status(job.Detail) is { Length: > 0 } status ? [status] : Array.Empty()])),
};
}
if (entry.Link?.Error is { } error) return (StatusKind.Warning, Loc.L("Server.Sync.State.Failed"), Loc.L("Tooltips.Server.Sync.State.Failed", error));
diff --git a/src/Chronos.App/Shell/MainWindow.xaml b/src/Chronos.App/Shell/MainWindow.xaml
index f8666ac4..15ee5f2c 100644
--- a/src/Chronos.App/Shell/MainWindow.xaml
+++ b/src/Chronos.App/Shell/MainWindow.xaml
@@ -92,7 +92,7 @@
-
diff --git a/src/Chronos.App/Shell/ScreenCapture.cs b/src/Chronos.App/Shell/ScreenCapture.cs
index 2062d953..0c4d546d 100644
--- a/src/Chronos.App/Shell/ScreenCapture.cs
+++ b/src/Chronos.App/Shell/ScreenCapture.cs
@@ -24,7 +24,7 @@ namespace Chronos.App.Shell;
///
/// Chronos.exe --capture <dir>: renders every client screen at 1440×900 in the dark and light themes to
/// <screen>-<theme>.png from (first run on an empty index, then a populated
-/// one, then the Videos section, then the sync table with transfers, a conflict and its confirmation, then the sequence editor on an archive
+/// one, then the Videos section, then the sync table with transfers, a conflict and its confirmation, then the server's jobs, then the sequence editor on an archive
/// sequence and on a server sequence with proxies, its server job and a read-only account), plus the Library, the
/// editor's Exposure tab and the import plan in Arabic (*-rtl-dark.png, right to left), for visual review,
/// the pixel diff against tests/visual/baselines and phase reports (BRIEF §20.2), then exits. The pictures are
@@ -53,6 +53,10 @@ public static class ScreenCapture
window.ShowInTaskbar = false;
window.Show();
+ // The Server section's job list reads the sample server's jobs, none until its own scene.
+ var serverJobs = new SampleServerJobs();
+ shell.Server.JobsConnection = _ => serverJobs;
+
// First run: empty index, nothing connected, the welcome dialog over the empty Library.
await sample.OpenEmptyAsync();
await shell.StartAsync();
@@ -164,6 +168,19 @@ public static class ScreenCapture
SelectSyncFilter(shell, SyncFilter.All);
}
+ // The server's jobs running and paused above the sync table, with what each does now (owner review 5, #65); the
+ // sample account is an editor, so the list is read-only.
+ serverJobs.Fill();
+ await shell.Server.Jobs.ReloadAsync();
+ foreach (var theme in Themes)
+ {
+ ThemeManager.Apply(theme);
+ shell.Navigate(SectionKey.Server);
+ written += await SaveAsync(window, directory, "server-jobs", theme);
+ }
+ serverJobs.Clear();
+ await shell.Server.Jobs.ReloadAsync();
+
written += await CaptureEditorAsync(window, shell, sample, directory);
written += await CaptureRemoteEditorAsync(window, shell, sample, directory);
Log.Info("capture", $"{written} screenshot(s) written to {Path.GetFullPath(directory)}");
diff --git a/src/Chronos.Server/Admin/web/admin.css b/src/Chronos.Server/Admin/web/admin.css
index 3da0f6c8..5f1e5705 100644
--- a/src/Chronos.Server/Admin/web/admin.css
+++ b/src/Chronos.Server/Admin/web/admin.css
@@ -185,6 +185,10 @@ svg.chart .label { fill: var(--text-muted); }
.progress-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.progress-cell svg.bar { flex: 1 1 0; min-width: 16px; }
.progress-cell span { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+/* A job's target with what it does now under it, inside the 52 px row (owner review 5, #65). */
+.target-cell { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
+.target-cell > span { display: block; }
+.progress-detail { font-size: 12px; line-height: 16px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
/* Tables: ARIA rows laid out as subgrids of one grid, so every column fits its widest cell; 52 px rows in the admin. */
.table { display: grid; column-gap: 12px; min-width: 0; }
diff --git a/src/Chronos.Server/Admin/web/jobs.js b/src/Chronos.Server/Admin/web/jobs.js
index 60b49962..2a03da3d 100644
--- a/src/Chronos.Server/Admin/web/jobs.js
+++ b/src/Chronos.Server/Admin/web/jobs.js
@@ -1,8 +1,13 @@
// Job and node labels shared by the dashboard and the Jobs page.
import { t, has } from "./i18n.js";
-import { escapeHtml, attr, bar } from "./ui.js";
+import { escapeHtml, attr, bar, formatNumber, formatBytes, formatDuration } from "./ui.js";
const CODECS = { h264: "H.264", hevc: "HEVC", av1: "AV1" };
+// The kinds whose pace is frames per second and those whose counts are bytes, as on the desktop (JobText).
+const FRAME_KINDS = new Set(["render", "proxies", "thumbs", "deep-analyse", "workspace-render"]);
+const BYTE_KINDS = new Set(["verify", "import"]);
+/** The longest status line a row shows; the whole line is its tooltip. */
+const STATUS_LENGTH = 90;
/** Hardware encoder families as users know them, recognised in the Media Foundation encoder names. */
const VENDORS = [[/nvidia|nvenc/i, "NVENC"], [/intel|quick ?sync|qsv/i, "QSV"], [/amd|radeon|amf/i, "AMF"]];
@@ -33,6 +38,99 @@ export function progressCell(job) {
return `
${bar(fraction)}${Math.floor(fraction * 100)} %
`;
}
+/**
+ * What a job does now (owner review 5, #65), from its detail: the step ("Verifying photo 812 of 2,400"), the item and the
+ * part ("sequence 3 of 41"), each left out when empty; a clean-up or maintenance sub-step names itself in place of the
+ * step; a step this panel does not know shows its counts only. Empty without a detail.
+ */
+export function statusText(detail) {
+ if (!detail) return "";
+ const counted = detail.itemTotal > 0;
+ const done = formatNumber(Math.min(Math.max(detail.itemDone, 0), detail.itemTotal));
+ const total = formatNumber(detail.itemTotal);
+ const counts = counted ? t("Admin.Job.Detail.Count", done, total) : "";
+ const named = detail.step === "cleanup" ? known(`Admin.Schedules.Step.${pascal(detail.item ?? "")}`)
+ : detail.step === "maintenance" ? known(`Admin.Job.Maintenance.Step.${pascal(detail.item ?? "")}`) : null;
+ let step;
+ let item = detail.item ?? "";
+ if (named) {
+ step = join(t(named), counts);
+ item = "";
+ } else if (detail.step === "cleanup" || detail.step === "maintenance") {
+ // The item of these steps is a key, not data: one this panel does not know is never shown.
+ const key = `Admin.Job.Step.${pascal(detail.step)}`;
+ step = join(known(key) ? t(key) : "", counts);
+ item = "";
+ } else if (!detail.step || detail.step === "none") {
+ step = counts;
+ } else {
+ const key = `Admin.Job.Step.${pascal(detail.step)}`;
+ step = counted && known(`${key}.Count`) ? t(`${key}.Count`, done, total) : known(key) ? join(t(key), counts) : counts;
+ }
+ let part = "";
+ if (detail.parts > 1) {
+ const unit = detail.partUnit ? known(`Admin.Job.Part.${pascal(detail.partUnit)}`) : null;
+ const at = formatNumber(Math.min(Math.max(detail.part, 0), detail.parts));
+ part = t(unit ?? "Admin.Job.Detail.Count", at, formatNumber(detail.parts));
+ }
+ return join(step, item, part);
+}
+
+/** The status line of a row: what a running job does now, "Stopped at …" for a paused or failed one, empty otherwise. */
+export function rowStatus(job) {
+ const status = statusText(job.detail);
+ if (!status) return "";
+ if (job.state === "running") return status;
+ return job.state === "paused" || job.state === "failed" ? t("Admin.Job.Detail.StoppedAt", status) : "";
+}
+
+/** "11.3 fps", "57 MB/s" or "41/s"; empty when unknown. */
+export function speedText(kind, rate) {
+ if (!(rate > 0)) return "";
+ if (BYTE_KINDS.has(kind)) return t("Admin.Job.Speed.Bytes", formatBytes(rate));
+ const value = formatNumber(Math.round(rate * 10) / 10);
+ return t(FRAME_KINDS.has(kind) ? "Admin.Job.Speed.Fps" : "Admin.Job.Speed.PerSecond", value);
+}
+
+/** "3 min left"; empty when unknown. */
+export function leftText(seconds) {
+ return seconds > 0 ? t("Admin.Job.Left", formatDuration(seconds)) : "";
+}
+
+/**
+ * The target cell's content: the target, and under it the status line (muted, cut to fit; its tooltip the whole line,
+ * then the speed and time left of a running job). Items are data and read in their own direction.
+ */
+export function targetCell(job) {
+ const target = job.targetLabel ?? "";
+ return `${escapeHtml(target)}${statusLine(job)}`;
+}
+
+/** The muted status line of a job's target cell; empty when it says nothing. */
+export function statusLine(job) {
+ const status = rowStatus(job);
+ if (!status) return "";
+ const tip = job.state === "running" ? join(status, speedText(job.kind, job.itemsPerSecond), leftText(job.etaSeconds)) : status;
+ const shown = status.length > STATUS_LENGTH ? `${status.slice(0, STATUS_LENGTH - 1)}…` : status;
+ return `${escapeHtml(shown)}`;
+}
+
+/** Redraws the status line of a row already drawn (a progress event), leaving the rest of the row as it is. */
+export function updateStatus(row, job) {
+ const cell = row?.querySelector(".target-cell");
+ if (!cell) return;
+ cell.querySelector(".progress-detail")?.remove();
+ cell.insertAdjacentHTML("beforeend", statusLine(job));
+}
+
+function known(key) {
+ return has(key) ? key : null;
+}
+
+function join(...pieces) {
+ return pieces.filter((p) => p).join(" · ");
+}
+
export function stateCell(state) {
const glyph = { running: "◐", queued: "○", paused: "❚❚", done: "●", failed: "✕", cancelled: "○" }[state] ?? "";
return `${glyph} ${escapeHtml(stateLabel(state))}`;
diff --git a/src/Chronos.Server/Admin/web/pages/dashboard.js b/src/Chronos.Server/Admin/web/pages/dashboard.js
index f297369c..d2e27f83 100644
--- a/src/Chronos.Server/Admin/web/pages/dashboard.js
+++ b/src/Chronos.Server/Admin/web/pages/dashboard.js
@@ -1,7 +1,7 @@
// Dashboard (mockup Admin.html, BRIEF §14.8): storage, archive, jobs, render nodes, charts, activity, active jobs.
import { t, plural, applyStrings, culture } from "../i18n.js";
import { escapeHtml, attr, formatBytes, formatNumber, formatTime, formatDuration, bar, storageTip, writeVolumeLine, columns, toast, errorText, emptyState, redraw, fitColumns, PROXY_WARNING } from "../ui.js";
-import { kindLabel, nodeLabel, progressCell, stateCell, stateLabel, encoders } from "../jobs.js";
+import { kindLabel, nodeLabel, progressCell, stateCell, stateLabel, encoders, targetCell, updateStatus } from "../jobs.js";
import { activityText } from "../audit.js";
const SCAN_BUTTON = ``;
@@ -23,6 +23,8 @@ function archiveProblemChip(problem) {
export async function render(root, { api, setMeta, actions, onEvent }) {
let timer = null;
+ // The active jobs drawn, by id, so a progress event updates the bar and the status line in place.
+ let activeJobs = new Map();
const refresh = () => {
clearTimeout(timer);
timer = setTimeout(load, 1500);
@@ -53,6 +55,7 @@ export async function render(root, { api, setMeta, actions, onEvent }) {
const uploads = lastThirtyDays(d.uploads);
const totalUploads = uploads.reduce((s, u) => s + u.value, 0);
const peak = Math.max(0, ...uploads.map((u) => u.value));
+ activeJobs = new Map(d.activeJobs.map((j) => [j.id, j]));
root.innerHTML = `