refactor!: rename Titano to Chronos and move CI and releases to Gitea (#6)
CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s

The owner renamed the product and moved the repository to the self-hosted
Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control,
and asked for Actions and a first automatic release with the server package
and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md).

- Chronos everywhere: a byte-exact rename of contents and paths, then a
  per-language review of the forms the old name's ending had dictated.
- Gitea instead of GitHub: the update check, licence, issue and support
  links read ChronosReleasesUrl; the update check takes the highest stable
  version, offers a pre-release build its final release and reports a
  repository it cannot see as a failed check. EULA, security policy and
  Gitea issue forms live at the repository root.
- Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release,
  nightly image and performance gates in the .NET SDK container with git
  checkout and the system SQLite. The release cross-compiles the Windows
  programs, checks their icon, version and DPI manifest, packs installers
  and zips, publishes the Gitea release and pushes the server image
  (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows
  runner (WINDOWS_RUNNER).
- New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the
  docker-exec script, which Gitea's service containers do not allow; the
  throw-away server runs without durability) and pe-check.
- Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR,
  3 on the shared runner; the weekly performance gates keep theirs).

BREAKING CHANGE: programs, settings, data folders, file types, environment
variables and the Docker image use the new name; nothing is migrated from
Titano, which never had a release.

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 #6.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-10-23 12:45:18 +02:00
1 parent c99842cc86
commit f2b58522b9
1801 files changed
+11804 -10676

No files matched your search

@@ -0,0 +1,460 @@
using System.Collections.Concurrent;
using System.Collections.ObjectModel;
using System.IO;
using System.Windows.Input;
using System.Windows.Threading;
using Chronos.App.Infrastructure;
using Chronos.App.Shell;
using Chronos.Core.Diagnostics;
using Chronos.Core.Localization;
using Chronos.Core.Model;
using Chronos.Data.Jobs;
using Chronos.Data.Sync;
using Chronos.Ui.Mvvm;
namespace Chronos.App.Server;
/// <summary>A filter chip of the sync table: "Conflicts · 1".</summary>
public sealed class SyncFilterChip(SyncFilter filter, Action<SyncFilter> select) : ObservableObject
{
private int _count;
private bool _isSelected;
public SyncFilter Filter { get; } = filter;
public string Text => Loc.L("Server.Sync.Filter." + Filter, Formatting.Count(_count));
public string ToolTip => Loc.L("Tooltips.Server.Sync.Filter." + Filter);
public ICommand SelectCommand { get; } = new RelayCommand(() => select(filter));
/// <summary>Conflicts waiting for a choice: the chip is drawn in the warning colour unless it is the selected one.</summary>
public bool NeedsAttention => Filter == SyncFilter.Conflicts && _count > 0;
public bool IsSelected
{
get => _isSelected;
set => Set(ref _isSelected, value);
}
public int Count
{
get => _count;
set
{
if (!Set(ref _count, value)) return;
OnPropertyChanged(nameof(Text));
OnPropertyChanged(nameof(NeedsAttention));
}
}
/// <summary>Texts in the current language.</summary>
public void Relabel()
{
OnPropertyChanged(nameof(Text));
OnPropertyChanged(nameof(ToolTip));
}
}
/// <summary>Why the sync table shows no rows; each case has its one action (BRIEF §0.2 rule 6).</summary>
public enum SyncEmpty
{
None,
SignedOut,
Nothing,
NoMatch,
}
/// <summary>
/// The sync table of the Server screen (BRIEF §12.7, Server.html): every sequence of this PC and of the signed-in
/// server with what each side holds, where it stands and what can be done (upload, download originals, open with
/// proxies, get or send exports, settle a conflict, pause or resume a transfer), filter chips, search, "Upload all
/// local" and the footer (last comparison, server archive, admin panel). Reloads when the sync engine reports a change;
/// transfer progress is applied at most a few times a second. Runs on the UI thread.
/// </summary>
public sealed class SyncTableViewModel : ObservableObject, IDisposable
{
private readonly ShellViewModel _shell;
private readonly IReadOnlyList<SyncFilterChip> _chips;
/// <summary>"Open with proxies" waiting for its proxy download: server id → the job that fills the cache.</summary>
private readonly Dictionary<Guid, Guid> _openWhenCached = [];
private readonly ConcurrentDictionary<Guid, JobProgressInfo> _progress = new();
private readonly SemaphoreSlim _reloading = new(1, 1);
private readonly AsyncRelayCommand _uploadAll;
private IReadOnlyList<SyncEntry> _entries = [];
private SyncFilter _filter = SyncFilter.All;
private string _search = string.Empty;
private int _progressQueued;
private int _reloadQueued;
private bool _attached;
public SyncTableViewModel(ShellViewModel shell)
{
_shell = shell;
_chips = [.. Enum.GetValues<SyncFilter>().Select(f => new SyncFilterChip(f, Select) { IsSelected = f == SyncFilter.All })];
_uploadAll = new AsyncRelayCommand(UploadAllAsync, () => IsActive && Rights.CanUpload && LocalOnly.Any());
OpenAdminCommand = new RelayCommand(() =>
{
if (Host.Server is { } server) ShellActions.OpenUrl(server + "/admin");
});
ClearFiltersCommand = new RelayCommand(() =>
{
_search = string.Empty;
OnPropertyChanged(nameof(SearchText));
Select(SyncFilter.All);
});
ImportCommand = new RelayCommand(() => _shell.Navigate(SectionKey.Import));
}
public ObservableCollection<SyncRow> Rows { get; } = [];
public IReadOnlyList<SyncFilterChip> Chips => _chips;
public ICommand UploadAllCommand => _uploadAll;
public ICommand OpenAdminCommand { get; }
/// <summary>"No sequence matches": back to every sequence.</summary>
public ICommand ClearFiltersCommand { get; }
/// <summary>"Nothing to compare yet": bring photos in.</summary>
public ICommand ImportCommand { get; }
public string SearchText
{
get => _search;
set
{
if (Set(ref _search, value ?? string.Empty)) ApplyFilter(rebuild: true);
}
}
/// <summary>Signed in: the table compares this PC with that server.</summary>
public bool IsActive => Host.Server is not null;
public bool HasRows => Rows.Count > 0;
public SyncEmpty Empty => HasRows ? SyncEmpty.None
: !IsActive ? SyncEmpty.SignedOut
: _entries.Count == 0 ? SyncEmpty.Nothing
: SyncEmpty.NoMatch;
/// <summary>"Not connected to a server", "Nothing to compare yet" or "No sequence matches"; null when rows show.</summary>
public string? EmptyText => Empty switch
{
SyncEmpty.SignedOut => Loc.L("Server.Empty"),
SyncEmpty.Nothing => Loc.L("Server.Sync.Empty"),
SyncEmpty.NoMatch => Loc.L("Server.Sync.NoMatch"),
_ => null,
};
/// <summary>What "Upload all local" sends, or why it is disabled.</summary>
public string UploadAllToolTip =>
!IsActive ? Loc.L("Tooltips.Server.Sync.UploadAll.NotConnected")
: !Rights.CanUpload ? Loc.L("Tooltips.Server.Sync.UploadAll.NoRight")
: !LocalOnly.Any() ? Loc.L("Tooltips.Server.Sync.UploadAll.Nothing")
: Loc.Plural("Tooltips.Server.Sync.UploadAll", LocalOnly.Count(), Formatting.Bytes(LocalOnly.Sum(e => e.Local!.TotalBytes)));
/// <summary>"Last sync 10:15 · manifest diff 0.4 s"; null before the first comparison.</summary>
public string? LastSyncText => Host.Agent?.Snapshot is { } s
? Loc.L("Server.Sync.Last", Formatting.TimeOfDay(s.RefreshedAt), s.Duration.TotalSeconds.ToString("0.0", Loc.Culture))
: null;
/// <summary>"Server archive 9.4 TB · 412 sequences".</summary>
public string? ArchiveText => Host.Agent?.Snapshot is { } s ? Loc.Plural("Server.Sync.Archive", s.ServerSequences, Formatting.Bytes(s.ServerBytes)) : null;
/// <summary>The last comparison failed (it is retried with growing pauses); null when it worked.</summary>
public string? ErrorText => Host.Agent?.LastError is not null ? Loc.L("Server.Sync.Retrying") : null;
public string? ErrorToolTip => Host.Agent?.LastError is { } error ? Loc.L("Tooltips.Server.Sync.Retrying", error.Message) : null;
/// <summary>The server's web admin admits administrators only: the link shows for accounts that manage the archive or users.</summary>
public bool CanOpenAdmin => _shell.Services.Server.User is { } user && IsActive
&& (user.Permissions & (long)(Permissions.ManageArchive | Permissions.ManageUsers)) != 0;
private SyncHost Host => _shell.Services.Sync;
private SyncRights Rights => _shell.Services.Server.User is { } user ? SyncRights.Of(user.Permissions) : default;
private IEnumerable<SyncEntry> LocalOnly => _entries.Where(e => e.Status == SyncStatus.LocalOnly);
/// <summary>Starts following the sync engine, the transfer jobs and the language.</summary>
public void Attach()
{
if (_attached) return;
_attached = true;
Host.Changed += OnChanged;
Loc.CultureChanged += OnCultureChanged;
if (_shell.Services.Jobs is { } jobs)
{
jobs.JobChanged += OnJobChanged;
jobs.Progress += OnProgress;
}
_ = ReloadAsync();
}
/// <summary>Reads the table again; requests made while a pass runs share the next one, which they wait for.</summary>
public async Task ReloadAsync()
{
Interlocked.Exchange(ref _reloadQueued, 1);
await _reloading.WaitAsync();
try
{
while (Interlocked.Exchange(ref _reloadQueued, 0) == 1)
{
_entries = Host is { Service: { } service, Server: { } server } ? await service.ListAsync(server, CancellationToken.None) : [];
Refresh();
}
}
catch (Exception ex) when (ex is Data.DatabaseException or InvalidOperationException)
{
Log.Warning("sync", "The sync table could not be read", ex);
}
finally
{
_reloading.Release();
}
}
public void Dispose()
{
if (!_attached) return;
_attached = false;
Host.Changed -= OnChanged;
Loc.CultureChanged -= OnCultureChanged;
if (_shell.Services.Jobs is { } jobs)
{
jobs.JobChanged -= OnJobChanged;
jobs.Progress -= OnProgress;
}
}
private void Select(SyncFilter filter)
{
_filter = filter;
foreach (var chip in _chips) chip.IsSelected = chip.Filter == filter;
ApplyFilter(rebuild: true);
}
/// <summary>Counts, rows, footer and the Library's sync glyphs after a reload.</summary>
private void Refresh()
{
foreach (var chip in _chips) chip.Count = _entries.Count(e => SyncText.Matches(e, chip.Filter, string.Empty));
ApplyFilter(rebuild: false);
UpdateLibrary();
OnPropertyChanged(nameof(IsActive));
OnPropertyChanged(nameof(UploadAllToolTip));
OnPropertyChanged(nameof(LastSyncText));
OnPropertyChanged(nameof(ArchiveText));
OnPropertyChanged(nameof(ErrorText));
OnPropertyChanged(nameof(ErrorToolTip));
OnPropertyChanged(nameof(CanOpenAdmin));
_uploadAll.RaiseCanExecuteChanged();
}
/// <summary>
/// Shows the entries the filter and search keep. A reload updates the rows in place (scroll position, focus and
/// recycled containers survive); a new filter or search lays the rows out again.
/// </summary>
private void ApplyFilter(bool rebuild)
{
var rights = Rights;
var wanted = _entries.Where(e => SyncText.Matches(e, _filter, _search.Trim())).ToList();
var byId = Rows.ToDictionary(r => r.Id);
if (rebuild)
{
Rows.Clear();
foreach (var entry in wanted) Rows.Add(Row(entry, rights, byId));
}
else
{
for (var i = 0; i < wanted.Count; i++)
{
var entry = wanted[i];
if (i < Rows.Count && Rows[i].Id == entry.Id)
{
Rows[i].Update(entry, rights);
continue;
}
var row = Row(entry, rights, byId);
var at = byId.ContainsKey(entry.Id) ? Rows.IndexOf(row) : -1;
if (at >= 0) Rows.Move(at, i);
else Rows.Insert(i, row);
}
while (Rows.Count > wanted.Count) Rows.RemoveAt(Rows.Count - 1);
}
OnPropertyChanged(nameof(HasRows));
OnPropertyChanged(nameof(Empty));
OnPropertyChanged(nameof(EmptyText));
}
/// <summary>The existing row of an entry, updated, or a new one.</summary>
private SyncRow Row(SyncEntry entry, SyncRights rights, Dictionary<Guid, SyncRow> existing)
{
if (!existing.TryGetValue(entry.Id, out var row)) return new SyncRow(entry, rights, ActAsync);
row.Update(entry, rights);
return row;
}
/// <summary>The Library shows each local copy's sync state: rows it has loaded take the fresh state.</summary>
private void UpdateLibrary()
{
var locals = _entries.Where(e => e.Local is not null).ToDictionary(e => e.Local!.Id, e => e.Local!);
foreach (var item in _shell.Library.Items)
{
if (locals.TryGetValue(item.Id, out var fresh) && fresh.SyncState != item.Sequence.SyncState) item.Update(fresh);
}
}
private async Task ActAsync(SyncRow row, SyncAction action)
{
if (Host is not { Service: { } service, Server: { } server } || _shell.Services.Engine is not { } engine) return;
var entry = row.Entry;
switch (action)
{
case SyncAction.Upload:
await service.EnqueueUploadAsync(engine, server, entry.Local!);
break;
case SyncAction.SendExports:
await service.EnqueueSendExportsAsync(engine, server, entry.Local!);
break;
case SyncAction.DownloadOriginals:
if ((entry.Local?.ArchiveId ?? (await Host.CurrentArchiveAsync())?.Id) is not { } archive)
{
_shell.Notify(Loc.L("Errors.Sync.NoArchive"), isError: true);
return;
}
await service.EnqueueDownloadAsync(engine, server, entry.Id, entry.Title, SyncDownloadMode.Originals, archive);
break;
case SyncAction.GetExports:
await service.EnqueueDownloadAsync(engine, server, entry.Id, entry.Title, SyncDownloadMode.Exports, null);
break;
case SyncAction.OpenWithProxies when entry.Status == SyncStatus.ProxiesOnly && service.OpenRemote(server, entry.Id) is not null:
_shell.OpenSequence(entry.Id);
return;
case SyncAction.OpenWithProxies:
var job = await service.EnqueueDownloadAsync(engine, server, entry.Id, entry.Title, SyncDownloadMode.Proxies, null);
_openWhenCached[entry.Id] = job.Id;
// A download that finished before it was recorded here opens at once.
if (await _shell.Services.Database!.Jobs.GetAsync(job.Id) is { State: JobState.Done or JobState.Failed or JobState.Cancelled } ended)
OpenWhenCached(ended);
break;
case SyncAction.Pause:
await _shell.Services.Jobs!.PauseAsync(entry.Transfer!.Id);
break;
case SyncAction.Resume:
await _shell.Services.Jobs!.ResumeAsync(entry.Transfer!.Id);
break;
case SyncAction.SyncSettings when Host.Remote is { } remote:
await service.SyncSettingsAsync(remote, entry.Id, Host.Policy, CancellationToken.None);
break;
case SyncAction.KeepMine or SyncAction.TakeServer or SyncAction.SaveBoth when Host.Remote is { } remote:
await ResolveAsync(service, remote, entry, action);
break;
}
await ReloadAsync();
}
/// <summary>Settles a conflict once the user confirmed the plan: the settings that differ and what each choice overwrites.</summary>
private async Task ResolveAsync(SyncService service, ISyncRemote remote, SyncEntry entry, SyncAction action)
{
if (!_shell.Services.Dialogs.Confirm(ConflictRequest(entry, action))) return;
var resolution = action switch
{
SyncAction.KeepMine => SyncResolution.KeepMine,
SyncAction.TakeServer => SyncResolution.TakeServer,
_ => SyncResolution.SaveBoth,
};
try
{
if (await service.ResolveAsync(remote, entry.Id, resolution, CancellationToken.None) is { } saved)
{
_shell.Notify(Loc.L("Server.Sync.SavedBoth"), Path.GetFileName(saved), Loc.L("Server.Sync.ShowCopy"), Loc.L("Tooltips.Server.Sync.ShowCopy"),
() => ShellActions.Reveal(saved));
}
}
catch (SyncConflictChangedException ex)
{
// One side changed after the choice was shown: the row now shows the fresh content.
_shell.Notify(ex.Message, isError: true);
}
}
/// <summary>The dry run of a resolution: what is replaced, by which side's values, and where "Save both" keeps this PC's.</summary>
internal static ConfirmRequest ConflictRequest(SyncEntry entry, SyncAction action) => new()
{
Heading = Loc.L("Server.Conflict." + action + ".Title"),
Message = Loc.L("Server.Conflict." + action + ".Message", entry.Title),
Detail = string.Join(Environment.NewLine, SyncText.Conflict(entry, 10)),
DetailToolTip = Loc.L("Tooltips.Server.Conflict.Detail"),
SafeText = Loc.L("Server.Conflict.Cancel"),
SafeToolTip = Loc.L("Tooltips.Server.Conflict.Cancel"),
ActionText = Loc.L("Server.Sync.Action." + action),
ActionToolTip = Loc.L("Tooltips.Server.Sync." + action),
IsDestructive = action != SyncAction.SaveBoth,
};
private async Task UploadAllAsync()
{
if (Host is not { Service: { } service, Server: { } server } || _shell.Services.Engine is not { } engine) return;
var queued = 0;
foreach (var entry in LocalOnly.ToList())
{
await service.EnqueueUploadAsync(engine, server, entry.Local!);
queued++;
}
_shell.Notify(Loc.Plural("Server.Sync.Queued", queued));
await ReloadAsync();
}
private void OnChanged() => Dispatch(() => _ = ReloadAsync());
private void OnCultureChanged(object? sender, EventArgs e) => Dispatch(() =>
{
foreach (var chip in _chips) chip.Relabel();
foreach (var row in Rows) row.Relabel();
OnAllPropertiesChanged();
});
private void OnJobChanged(Job job)
{
if (job.Kind is not (JobKind.UploadCommit or JobKind.Download)) return;
_progress.TryRemove(job.Id, out _);
Dispatch(() =>
{
OpenWhenCached(job);
_ = ReloadAsync();
});
}
/// <summary>
/// "Open with proxies" opens the editor when the download it queued is done, if the Server screen is still the one
/// in front; a failed or cancelled download drops the request.
/// </summary>
private void OpenWhenCached(Job job)
{
if (job.State is not (JobState.Done or JobState.Failed or JobState.Cancelled)) return;
var remoteId = _openWhenCached.FirstOrDefault(p => p.Value == job.Id).Key;
if (!_openWhenCached.Remove(remoteId)) return;
if (job.State == JobState.Done && ReferenceEquals(_shell.Current, _shell.Server)) _shell.OpenSequence(remoteId);
}
/// <summary>Transfer progress ("46 % received") without reading the table again, at most a few times a second.</summary>
private void OnProgress(JobProgressInfo info)
{
if (info.Kind is not (JobKind.UploadCommit or JobKind.Download)) return;
_progress[info.JobId] = info;
if (Interlocked.Exchange(ref _progressQueued, 1) == 1) return;
System.Windows.Application.Current?.Dispatcher.BeginInvoke(DispatcherPriority.Background, async () =>
{
await Task.Delay(250);
Interlocked.Exchange(ref _progressQueued, 0);
foreach (var row in Rows)
{
if (row.Entry.Transfer is { } job && _progress.TryGetValue(job.Id, out var p)) row.UpdateProgress(p.Done, p.Total);
}
});
}
private static void Dispatch(Action action)
{
if (System.Windows.Application.Current?.Dispatcher is not { } dispatcher || dispatcher.CheckAccess()) action();
else dispatcher.BeginInvoke(action);
}
}