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,530 @@
using System.ComponentModel;
using System.Net;
using System.Windows.Input;
using System.Windows.Threading;
using Chronos.App.Editor;
using Chronos.App.Infrastructure;
using Chronos.App.Library;
using Chronos.App.Shell;
using Chronos.Core.Diagnostics;
using Chronos.Core.Export;
using Chronos.Core.Imaging.Decoders;
using Chronos.Core.Localization;
using Chronos.Core.Model;
using Chronos.Data.Jobs;
using Chronos.Data.Sync;
using Chronos.Protocol.Client;
using Chronos.Ui.Mvvm;
namespace Chronos.App.Sections;
/// <summary>
/// The Edit section (BRIEF §12.3; owner review 1, R7, formerly Sequence): opens the sequence the Library, Jobs, the
/// Server screen or its own picker chose into an <see cref="EditorViewModel"/> (from this PC's archive, or a server
/// sequence with this PC's proxies). The next sequence is read first; only then does the open one close, after its
/// last edit is stored. Without a sequence, or after Change sequence, it shows the picker (the editor stays open behind
/// it until another sequence opens). A server sequence whose proxies are missing or out of date fetches them first and
/// opens once they are here, the open sequence staying open meanwhile. A failed open is reported once and leaves the
/// open sequence open; an edit that cannot be saved is never dropped without the user's confirmation, and never written
/// after they chose to drop it. The step each sequence showed is kept for the rest of the run.
/// </summary>
public sealed class SequenceViewModel : SectionViewModel
{
private readonly Dispatcher _dispatcher = Dispatcher.CurrentDispatcher;
private readonly Dictionary<Guid, StepMemory> _steps = [];
private EditorViewModel? _editor;
private Guid? _openId;
private bool _isLoading;
private bool _isPicking;
private bool _showsPicker = true;
/// <summary>The shell's <see cref="ShellViewModel.SequenceRequests"/> this section has answered.</summary>
private int _seenRequests;
private Task _switch = Task.CompletedTask;
private ProxyFetch? _fetch;
public SequenceViewModel(ShellViewModel shell)
: base(SectionKey.Edit, "Icon.Sequence")
{
Shell = shell;
Picker = new SequencePickerViewModel(this);
OpenImportCommand = new RelayCommand(() => Shell.Navigate(SectionKey.Import));
OpenJobsCommand = new RelayCommand(() => Shell.Navigate(SectionKey.Jobs));
ChangeSequenceCommand = new RelayCommand(() => IsPicking = true, () => _editor is not null && !_isLoading && !_isPicking);
CancelPickCommand = new RelayCommand(KeepOpenSequence, () => CanCancelPick);
shell.PropertyChanged += OnShellChanged;
}
public ShellViewModel Shell { get; }
/// <summary>The list the next sequence is chosen from.</summary>
public SequencePickerViewModel Picker { get; }
/// <summary>Import, from the picker of an empty library.</summary>
public ICommand OpenImportCommand { get; }
/// <summary>The Jobs screen, from the picker's line about proxies on their way.</summary>
public ICommand OpenJobsCommand { get; }
/// <summary>
/// Shows the picker over the open sequence (Ctrl+O, the title's ▾, Next on the last step); the editor is not closed and
/// its changes keep being saved as usual.
/// </summary>
public ICommand ChangeSequenceCommand { get; }
/// <summary>Hides the picker again, back to the open sequence (Esc); a server sequence chosen meanwhile no longer opens over it.</summary>
public ICommand CancelPickCommand { get; }
/// <summary>The open sequence; null shows the picker.</summary>
public EditorViewModel? Editor
{
get => _editor;
private set
{
if (!Set(ref _editor, value)) return;
// A sequence that opens ends the choice.
if (value is not null)
{
_isPicking = false;
OnPropertyChanged(nameof(IsPicking));
Picker.SearchText = string.Empty;
}
OnPropertyChanged(nameof(Title));
OnPickerChanged();
}
}
/// <summary>The id of the open sequence; null when none is open.</summary>
public Guid? OpenSequenceId => _editor is null ? null : _openId;
public bool IsLoading
{
get => _isLoading;
private set
{
if (Set(ref _isLoading, value)) OnPickerChanged();
}
}
/// <summary>The picker shows over the open sequence, which stays laid out behind it.</summary>
public bool IsPicking
{
get => _isPicking;
private set
{
if (!Set(ref _isPicking, value)) return;
OnPropertyChanged(nameof(Title));
OnPickerChanged();
}
}
/// <summary>The picker is on screen: no sequence is open, or another is being chosen.</summary>
public bool ShowsPicker => _showsPicker;
/// <summary>An open sequence waits behind the picker, so Cancel (Esc) goes back to it; not while a switch is under way.</summary>
public bool CanCancelPick => _isPicking && _editor is not null && !_isLoading;
public string? CancelPickToolTip => _editor is { } editor ? Loc.L("Tooltips.Editor.Picker.Cancel", editor.Title) : null;
/// <summary>The server sequence whose proxies are on their way before it opens; null when none.</summary>
public string? FetchingTitle => _fetch?.Title;
/// <summary>"Getting the proxies · Harbour sunset".</summary>
public string? FetchingText => _fetch is { } fetch ? string.Join(Loc.Separator, Loc.L("Editor.Proxies.Fetching"), fetch.Title) : null;
/// <summary>The open sequence has an edit not stored yet (the save follows each change after a moment, and retries after a failure).</summary>
public bool HasPendingSave => _editor?.Session.HasPendingSave == true;
/// <summary>"Chronos — Harbour sunset" while a sequence is open and shown; the section's name while choosing one.</summary>
public override string Title => !_isPicking && _editor is { } editor ? editor.Title : Label;
/// <summary>Opens <paramref name="sequenceId"/> (the editor of another sequence is saved and closed first).</summary>
/// <param name="reload">Opens it again even when it is the open one (its proxies were fetched again).</param>
public Task OpenAsync(Guid sequenceId, bool reload = false)
{
_switch = SwitchAsync(_switch, sequenceId, reload);
return _switch;
}
/// <summary>
/// Shows <paramref name="sequenceId"/> in the editor, as the Library does, and returns its editor once open; null
/// when it did not open (the reason was reported, or the open sequence's unsaved edit was kept) or waits for its
/// proxies.
/// </summary>
public async Task<EditorViewModel?> ShowAsync(Guid sequenceId)
{
Shell.OpenSequence(sequenceId);
// Already the sequence asked for but not open (the shell did not change, so nothing started): opening it again is
// what is asked now, unless its proxies are on their way (it opens when they are here).
if (_openId != sequenceId && _switch.IsCompleted && Shell.CurrentSequenceId == sequenceId && !Fetching(sequenceId)) _ = OpenAsync(sequenceId);
await Settled(_switch);
if (_openId != sequenceId) return null;
// Asking for the open sequence ends a choice of another.
IsPicking = false;
return Editor;
}
/// <summary>
/// Opens the sequence chosen in the picker: the open one simply shows again; another opens once it is read, after the
/// open one's last edit is stored (or the user chose to discard it). Keeping an edit that cannot be stored keeps the
/// open sequence; a server sequence whose proxies are not here yet leaves the picker on screen while they arrive.
/// </summary>
public async Task PickAsync(SequenceItem item)
{
ArgumentNullException.ThrowIfNull(item);
if (_editor is not null && item.Id == _openId)
{
KeepOpenSequence();
return;
}
await ShowAsync(item.Id);
}
/// <summary>
/// Fetches the proxies of server sequence <paramref name="remoteId"/> into this PC's cache (a download job, shown in
/// the job bar and on the Jobs screen) and opens it in the editor once they are here, if it is still the sequence
/// asked for.
/// </summary>
public async Task FetchProxiesAsync(Guid remoteId, string title)
{
var services = Shell.Services;
var sync = services.Sync;
if (sync.Server is not { } server || sync.Service is not { } service) throw new InvalidOperationException(Loc.L("Editor.Error.SignedOut"));
if (services.Engine is not { } engine || services.Database is not { } db) throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"));
var followed = _fetch is { } current && current.RemoteId == remoteId ? current.JobId : Guid.Empty;
StopFetch();
var fetch = new ProxyFetch(remoteId, title, engine);
fetch.Handler = job => _dispatcher.BeginInvoke(() => OnFetchChanged(fetch, job));
engine.JobChanged += fetch.Handler;
_fetch = fetch;
OnFetchingChanged();
Job job;
try
{
job = await service.EnqueueDownloadAsync(engine, server, remoteId, title, SyncDownloadMode.Proxies, null);
}
catch
{
// Nothing is on its way: the picker's line about it goes, and asking for the sequence again tries again.
if (ReferenceEquals(_fetch, fetch)) StopFetch();
throw;
}
fetch.JobId = job.Id;
// The download already followed (the same sequence asked for again) is not announced twice.
if (job.Id != followed)
Shell.Notify(Loc.L("Editor.Proxies.Fetching"), title, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"), () => Shell.Navigate(SectionKey.Jobs));
// A download that ended before its id was known here is handled now.
if (await db.Jobs.GetAsync(job.Id) is { State: JobState.Done or JobState.Failed or JobState.Cancelled } ended) OnFetchChanged(fetch, ended);
}
/// <summary>
/// Stores the open sequence's last edit. When the save fails (archive offline, read-only, busy), asks whether to
/// discard the edit (BRIEF §12.1: modals only for destructive confirmations). No retry runs while the question is
/// open, so the answer holds: Discard drops the edit unwritten, Keep editing lets the retries go on.
/// </summary>
/// <returns>True when the editor may close: everything is stored or the user chose to discard.</returns>
public async Task<bool> ConfirmCloseAsync()
{
if (Editor is not { } editor || await editor.Session.FlushAsync()) return true;
var session = editor.Session;
if (!await session.HoldPendingAsync())
{
// A retry stored it meanwhile: nothing to ask.
session.KeepPending();
return true;
}
var discard = Shell.Services.Dialogs.Confirm(new ConfirmRequest
{
Heading = Loc.L("Editor.Unsaved.Title"),
Message = Loc.L("Editor.Unsaved.Message", editor.Title, session.LastSaveError?.Message ?? string.Empty),
SafeText = Loc.L("Editor.Unsaved.Keep"),
SafeToolTip = Loc.L("Tooltips.Editor.Unsaved.Keep"),
ActionText = Loc.L("Editor.Unsaved.Discard"),
ActionToolTip = Loc.L("Tooltips.Editor.Unsaved.Discard"),
IsDestructive = true,
});
if (discard) session.DiscardPending();
else session.KeepPending();
return discard;
}
/// <summary>Closes the open sequence (after <see cref="ConfirmCloseAsync"/>, which stores its last edit).</summary>
public async Task CloseAsync()
{
await Settled(_switch);
if (Editor is not { } editor) return;
Remember(editor);
Editor = null;
_openId = null;
await editor.DisposeAsync();
}
/// <summary>Shows <paramref name="editor"/>, which the caller opened over a source of its own (tests), as the open sequence.</summary>
internal void Attach(EditorViewModel editor)
{
_openId = editor.Session.Content.Sequence.Id;
if (_steps.TryGetValue(editor.Session.Content.Sequence.Id, out var memory)) editor.RestoreSteps(memory);
Editor = editor;
}
public override void Dispose()
{
Shell.PropertyChanged -= OnShellChanged;
StopFetch();
Editor?.Dispose();
Picker.Dispose();
base.Dispose();
}
protected override void OnActivated()
{
OpenRequested();
ShowRequested();
if (_showsPicker) _ = Picker.ReloadAsync();
}
/// <summary>Opens the sequence the shell asks for when it is not the open one (nor one whose proxies are on their way).</summary>
private void OpenRequested()
{
if (Shell.CurrentSequenceId is { } id && id != _openId && !Fetching(id)) _ = OpenAsync(id);
}
/// <summary>
/// Asking for the open sequence again (the Library, Jobs, a project file, also while Edit is on screen) ends a choice of
/// another; coming back to Edit alone leaves the choice on screen.
/// </summary>
private void ShowRequested()
{
if (Shell.SequenceRequests == _seenRequests) return;
_seenRequests = Shell.SequenceRequests;
if (_editor is not null && Shell.CurrentSequenceId == _openId) KeepOpenSequence();
}
/// <summary>
/// Back to the open sequence (Cancel, Esc, or the open sequence chosen again): it is again the one asked for, and a
/// server sequence still waiting for its proxies no longer opens over it when they arrive (its download goes on).
/// </summary>
private void KeepOpenSequence()
{
if (_fetch is { } pending && pending.RemoteId != _openId) StopFetch();
Shell.KeepSequence(_openId);
IsPicking = false;
}
/// <summary>The proxies of server sequence <paramref name="sequenceId"/> are on their way: it opens when they are here.</summary>
private bool Fetching(Guid sequenceId) => _fetch?.RemoteId == sequenceId;
/// <summary>
/// Whether the picker shows changed (a sequence opened or failed to, Change sequence, Cancel): it reads the list again
/// each time it appears on screen.
/// </summary>
private void OnPickerChanged()
{
OnPropertyChanged(nameof(CanCancelPick));
OnPropertyChanged(nameof(CancelPickToolTip));
var shows = !_isLoading && (_editor is null || _isPicking);
if (shows != _showsPicker)
{
_showsPicker = shows;
OnPropertyChanged(nameof(ShowsPicker));
if (shows && IsSelected) _ = Picker.ReloadAsync();
}
CommandManager.InvalidateRequerySuggested();
}
private void OnFetchingChanged()
{
OnPropertyChanged(nameof(FetchingTitle));
OnPropertyChanged(nameof(FetchingText));
}
/// <summary>Keeps the step <paramref name="editor"/> shows and the steps visited, for when its sequence opens again in this run.</summary>
private void Remember(EditorViewModel editor) => _steps[editor.Session.Content.Sequence.Id] = editor.StepMemory();
private void OnShellChanged(object? sender, PropertyChangedEventArgs e)
{
if (!IsSelected) return;
if (e.PropertyName == nameof(ShellViewModel.CurrentSequenceId)) OpenRequested();
else if (e.PropertyName == nameof(ShellViewModel.SequenceRequests)) ShowRequested();
}
/// <summary>
/// Where <paramref name="sequenceId"/> lives: this PC's index, else a sequence of the signed-in server whose proxies
/// this PC keeps (Server screen, "Open with proxies"), edited through the server (BRIEF §14.5), or only shown when the
/// account may not change it. Null when the proxies are not here yet: they are being fetched (<see cref="FetchProxiesAsync"/>).
/// </summary>
private async Task<(ISequenceSource Source, string Title)?> OpenSourceAsync(AppServices services, Guid sequenceId)
{
if (services.Database is not { } db) throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"));
var processing = services.Processing?.Options;
var decoder = processing?.Archive.Decoder ?? DecoderFactory.CreateClient(null);
if (await db.Sequences.GetAsync(sequenceId) is { } row)
{
var local = new LocalSequenceSource(db, sequenceId, decoder, services.Engine, processing?.Archive);
local.HeroChanged += OnHeroChanged;
return (local, row.DisplayTitle);
}
var sync = services.Sync;
if (sync.Server is not { } server || sync.Service is not { } service || sync.ConnectEditor() is not { } api)
throw new InvalidOperationException(Loc.L("Editor.Error.SignedOut"));
// The proxy cache's index and files are read off the UI thread.
if (await Task.Run(() => service.OpenRemote(server, sequenceId)) is { } remote)
return (new RemoteSequenceSource(remote, api, decoder, readOnly: !sync.Policy.CanEdit), remote.Sequence.DisplayTitle);
using (api)
{
string title;
try
{
title = (await api.GetSequenceAsync(sequenceId, CancellationToken.None)).DisplayTitle;
}
catch (ChronosApiException ex) when (ex.Status == HttpStatusCode.NotFound)
{
throw new InvalidOperationException(Loc.L("Editor.Error.Missing"), ex);
}
await FetchProxiesAsync(sequenceId, title);
return null;
}
}
/// <summary>The proxy download for an open waiting on it moved: opens the sequence once it is done, says why not when it failed.</summary>
private void OnFetchChanged(ProxyFetch fetch, Job job)
{
if (!ReferenceEquals(fetch, _fetch) || job.Id != fetch.JobId || job.State is not (JobState.Done or JobState.Failed or JobState.Cancelled)) return;
StopFetch();
switch (job.State)
{
// Opened only when it is still the sequence asked for; otherwise the next visit opens it from the cache.
case JobState.Done when Shell.CurrentSequenceId == fetch.RemoteId && IsSelected:
_ = OpenAsync(fetch.RemoteId, reload: true);
break;
case JobState.Failed:
Shell.Notify(Loc.L("Editor.Proxies.Failed"), job.Error ?? fetch.Title, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"),
() => Shell.Navigate(SectionKey.Jobs), isError: true);
break;
}
}
private void StopFetch()
{
if (_fetch is not { } fetch) return;
_fetch = null;
if (fetch.Handler is { } handler) fetch.Engine.JobChanged -= handler;
OnFetchingChanged();
}
/// <summary>Set hero changed the frame the Library shows (any thread): its card loads the new thumbnail.</summary>
private void OnHeroChanged(Sequence row) => _dispatcher.BeginInvoke(() =>
{
if (Shell.Library.Items.FirstOrDefault(i => i.Id == row.Id) is { } item) item.Update(row);
});
/// <summary>Waits for <paramref name="task"/>; its failure was reported where it happened.</summary>
private static async Task Settled(Task task)
{
try
{
await task;
}
catch (Exception ex) when (ex is not OutOfMemoryException)
{
Log.Debug("editor", $"An earlier open of the editor failed: {ex.Message}");
}
}
private async Task SwitchAsync(Task previous, Guid sequenceId, bool reload)
{
await Settled(previous);
if (sequenceId == _openId && !reload) return;
// Asked for again while its proxies are on their way (the next visit, a second pick): it opens when they are here.
if (!reload && Fetching(sequenceId)) return;
var services = Shell.Services;
// The progress bar shows until the switch ends; the picker, its Cancel and the editor are hidden meanwhile.
IsLoading = true;
ISequenceSource? source = null;
try
{
// The next sequence is read first: the open one stays open when this one cannot open now.
if (await OpenSourceAsync(services, sequenceId) is not { } opened) return;
source = opened.Source;
SequenceContent content;
try
{
content = await source.LoadAsync(CancellationToken.None);
}
catch (ProxiesOutdatedException)
{
// The server's frames are no longer these proxies: fetch them again, then open.
await source.DisposeAsync();
source = null;
await FetchProxiesAsync(sequenceId, opened.Title);
return;
}
// Only now does the open sequence close: its last edit is stored first, or discarded on the user's word. Keeping
// it keeps the open sequence as the one asked for, so the next visit to Edit does not ask once more.
if (!await ConfirmCloseAsync())
{
Shell.KeepSequence(_openId);
IsPicking = false;
return;
}
// A server sequence that was waiting for its proxies is no longer the one asked for.
if (_fetch is { } pending && pending.RemoteId != sequenceId) StopFetch();
if (Editor is { } old)
{
Remember(old);
Editor = null;
_openId = null;
await old.DisposeAsync();
}
var processing = services.Processing?.Options;
var encoders = processing?.Encoders ?? [];
var session = new EditorSession(source, content, [.. encoders.SelectMany(e => e.Capabilities)]);
// The session owns the source from here on.
source = null;
EditorViewModel editor;
try
{
editor = new EditorViewModel(Shell, session, encoders, processing?.Host ?? EncoderHost.Client);
}
catch
{
await session.DisposeAsync();
throw;
}
if (_steps.TryGetValue(sequenceId, out var memory)) editor.RestoreSteps(memory);
_openId = sequenceId;
Editor = editor;
services.Settings.LastEditedSequence = sequenceId;
services.SavePreferences();
await editor.AttachJobsAsync();
}
catch (Exception ex) when (ex is not OutOfMemoryException)
{
// Whatever failed (index, decoder set-up, advisor, the job list), the section stays usable: the sequence open
// before (or the one that has just opened) stays open and is again the one asked for, so coming back to Edit
// neither tries nor reports it again; choosing the sequence again does.
Log.Warning("editor", $"Sequence {sequenceId} could not be opened", ex);
Shell.ReportError(ex);
Shell.KeepSequence(OpenSequenceId);
}
finally
{
if (source is not null) await source.DisposeAsync();
IsLoading = false;
}
}
/// <summary>A proxy download an open waits on, with its engine subscription.</summary>
private sealed class ProxyFetch(Guid remoteId, string title, JobEngine engine)
{
public Guid RemoteId { get; } = remoteId;
public string Title { get; } = title;
public JobEngine Engine { get; } = engine;
public Guid JobId { get; set; }
public Action<Job>? Handler { get; set; }
}
}