feat: owner review 2 phase 2: scheduled jobs and log settings (#10)
CI / Build and test (push) Successful in 7m0s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 13m28s
CI / PostgreSQL 16 integration (push) Successful in 5m52s
CI / PostgreSQL 17 integration (push) Successful in 4m50s
CI / Docker image (push) Successful in 1m4s
Release / Server image (push) Successful in 1m35s

- Jobs > Scheduled on the desktop and the admin panel. Every timer that queued work is now a visible system schedule: archive scan, upload clean-up, index backup, job-history and audit clean-ups, desktop housekeeping. New actions: verify, thumbnails, proxies, analysis, maintenance, backup, clean-ups, reports.
- The scheduler: migration 0007, in-house recurrence, compare-and-set claim, catch-up, scan at start.
- Log settings: levels, retention, size parts, total limit, daily or hourly rotation, audit retention, diagnostics share; the server writes Debug/Trace to its files again; logging never fails a job.

Upgrade: CHRONOS_LOG_LEVEL set in an existing container locks both levels; migration 0007 is one-way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #10.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-10-27 11:19:26 +01:00
1 parent 1f089888e8
commit af9eeaab9b
349 files changed
+28341 -1304

No files matched your search

+83 -8
View File
@@ -49,10 +49,11 @@ public sealed class JobFilterChip(JobFilter filter, Action<JobFilter> select) :
}
/// <summary>
/// Jobs (BRIEF §12.6, Jobs.html): queue and history with live progress from the engine (batched to about 10
/// updates a second), filters, queue order, an expandable log tail per job, and the row actions. Also feeds the
/// shell's job bar, the status strip and the rail badge (running jobs, and failures not seen on this screen yet), and
/// raises the toast of a long operation that ends (<see cref="JobNotices"/>), whichever screen started it.
/// Jobs (BRIEF §12.6, Jobs.html), two tabs: Queue, the queue and history with live progress from the engine (batched to
/// about 10 updates a second), filters, queue order, an expandable log tail per job, and the row actions; Scheduled
/// (owner review 2, R10), the schedules of this PC (<see cref="SchedulesViewModel"/>). Also feeds the shell's job bar, the
/// status strip and the rail badge (running jobs, and failures not seen on this screen yet), and raises the toast of a
/// long operation that ends (<see cref="JobNotices"/>), whichever screen started it.
/// </summary>
public sealed class JobsViewModel : SectionViewModel
{
@@ -77,6 +78,7 @@ public sealed class JobsViewModel : SectionViewModel
private bool _hasMore;
private bool _loading;
private bool _hasLoaded;
private int _tabIndex;
public JobsViewModel(ShellViewModel shell)
: base(SectionKey.Jobs, "Icon.Jobs")
@@ -94,10 +96,43 @@ public sealed class JobsViewModel : SectionViewModel
});
LoadMoreCommand = new RelayCommand(() => _ = LoadMoreAsync());
ImportCommand = new RelayCommand(() => Shell.Navigate(SectionKey.Import));
Schedules = new SchedulesViewModel(() => Shell.Services.Scheduler, () => Shell.Services.Database, request => Shell.Services.Dialogs.Confirm(request),
(title, message, isError) => Shell.Notify(title, message, isError: isError), ShowJobAsync);
Schedules.HistoryChanged += () => OnPropertyChanged(nameof(HistoryText));
Schedules.PropertyChanged += (_, e) =>
{
if (e.PropertyName is nameof(SchedulesViewModel.IsContentEnabled) or "" or null) OnPropertyChanged(nameof(IsContentEnabled));
};
}
/// <summary>A row the screen should bring into view and expand (a job shown from Jobs › Scheduled).</summary>
public event Action<JobRowViewModel>? RowRevealRequested;
public ShellViewModel Shell { get; }
/// <summary>Jobs › Scheduled.</summary>
public SchedulesViewModel Schedules { get; }
/// <summary>0 = Queue, 1 = Scheduled (the segmented control's index). Scheduled, shown, reads the actions' availability again.</summary>
public int TabIndex
{
get => _tabIndex;
set
{
if (value is < 0 or > 1 || !Set(ref _tabIndex, value)) return;
OnPropertyChanged(nameof(IsQueue));
OnPropertyChanged(nameof(IsScheduled));
if (IsScheduled) _ = Schedules.RefreshActionsAsync();
}
}
public bool IsQueue => _tabIndex == 0;
public bool IsScheduled => _tabIndex == 1;
/// <summary>The screen behind the schedule editor takes neither clicks nor keyboard focus.</summary>
public bool IsContentEnabled => Schedules.IsContentEnabled;
/// <summary>Rows in display order for the current filter and search.</summary>
public ObservableCollection<JobRowViewModel> Rows { get; } = [];
@@ -141,8 +176,8 @@ public sealed class JobsViewModel : SectionViewModel
/// <summary>The priority queue of Settings › Rendering is on: higher jobs pause the running one.</summary>
public bool IsPriorityQueueOn => HasEngine && Shell.Services.Settings.PriorityQueue;
/// <summary>"History keeps 90 days".</summary>
public string HistoryText => Loc.Plural("Jobs.History", (long)new JobEngineOptions().HistoryRetention.TotalDays);
/// <summary>"History keeps 90 days": the age limit of the housekeeping schedule's job-history step; "Full history kept" without one.</summary>
public string HistoryText => Schedules.HistoryDays is { } days ? Loc.Plural("Jobs.History", days) : Loc.L("Jobs.HistoryKept");
public bool IsEmpty => _hasLoaded && Rows.Count == 0;
@@ -154,9 +189,11 @@ public sealed class JobsViewModel : SectionViewModel
private DateTimeOffset? ClearedAt => Shell.Services.Settings.JobsClearedAt;
/// <summary>Subscribes to the engine and loads the first page of jobs.</summary>
/// <summary>Subscribes to the engine and loads the first page of jobs; the Scheduled tab follows the schedules once they run.</summary>
public void Attach()
{
// Without an index the Scheduled tab says the schedules do not run.
_ = Schedules.AttachAsync(Shell.Services.SchedulerReady);
_queue = Shell.Services.Jobs;
if (_queue is null)
{
@@ -178,6 +215,7 @@ public sealed class JobsViewModel : SectionViewModel
_queue.Progress -= OnProgress;
}
_throttle?.Dispose();
Schedules.Dispose();
base.Dispose();
}
@@ -234,6 +272,7 @@ public sealed class JobsViewModel : SectionViewModel
var before = _model[job.Id]?.State;
_model.Apply(job);
Follow(before, job);
Schedules.OnJob(job);
}
foreach (var p in progress) _model.Apply(p);
foreach (var ending in _endings.Take(_model.IsBusy)) Shell.ShowToast(ToastFor(ending));
@@ -241,9 +280,13 @@ public sealed class JobsViewModel : SectionViewModel
UpdateShell();
}
/// <summary>Failures seen on this screen no longer count on the rail.</summary>
/// <summary>
/// Failures seen on this screen no longer count on the rail; back on Scheduled (from Settings, say), the actions'
/// availability is read again.
/// </summary>
protected override void OnActivated()
{
if (IsScheduled) _ = Schedules.RefreshActionsAsync();
if (_unseenFailures.Count == 0) return;
_unseenFailures.Clear();
UpdateShell();
@@ -344,6 +387,38 @@ public sealed class JobsViewModel : SectionViewModel
private void SelectFilter(JobFilter filter) => Filter = filter;
/// <summary>
/// Shows a job in the Queue tab (from a schedule's last runs): every filter off, its row read when the list has not
/// loaded it yet, expanded with its log, and brought into view.
/// </summary>
internal async Task ShowJobAsync(Guid jobId)
{
TabIndex = 0;
Filter = JobFilter.All;
SearchText = string.Empty;
if (_model[jobId] is null && _queue is not null)
{
var stamp = _model.Stamp;
try
{
if (await _queue.GetAsync(jobId) is { } job) _model.ApplyLoaded(job, stamp);
}
catch (DatabaseException ex)
{
Log.Warning("jobs", $"Job {jobId} could not be read", ex);
}
SyncRows();
}
if (!_rows.TryGetValue(jobId, out var row) || !Rows.Contains(row))
{
// Hidden by Clear done: the history keeps it, the list no longer shows it.
Shell.Notify(Loc.L("Jobs.Schedule.JobHidden"), Loc.L("Tooltips.Jobs.Schedule.JobHidden"));
return;
}
row.IsExpanded = true;
RowRevealRequested?.Invoke(row);
}
/// <summary>Brings <see cref="Rows"/> to the model's order with moves (rows keep their expanded log).</summary>
private void SyncRows()
{