Files
Chronos/src/Chronos.App/Sections/AboutViewModel.cs
T
Alby96andClaude Opus 5.5 f2b58522b9
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
refactor!: rename Titano to Chronos and move CI and releases to Gitea (#6)
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>
2026-10-23 12:45:18 +02:00

154 lines
7.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Input;
using Chronos.App.About;
using Chronos.App.Infrastructure;
using Chronos.App.Shell;
using Chronos.Core.Localization;
using Chronos.Ui.Controls;
using Chronos.Ui.Mvvm;
namespace Chronos.App.Sections;
/// <summary>
/// About (BRIEF §12.9): version and build, licence link, third-party notice (none), translation notice,
/// diagnostics bundle and the update notice of <see cref="UpdateFlow"/> (BRIEF §18), which Settings › Updates shows too.
/// </summary>
public sealed class AboutViewModel : SectionViewModel
{
private readonly UpdateFlow _update;
public AboutViewModel(ShellViewModel shell)
: base(SectionKey.About, "Icon.About")
{
Shell = shell;
var environment = shell.Services.Environment;
_update = new UpdateFlow(new UpdateHost(UpdateCheck.RunningVersion(Version), environment.IsCapture, environment.IsPortable,
ct => Shell.Services.CheckForUpdateAsync(ct), (release, progress, ct) => Shell.Services.DownloadUpdateAsync(release, progress, ct),
ShellActions.OpenUrl, ShellActions.Reveal)
{ RunningIsPrerelease = UpdateCheck.IsPrerelease(Version) });
_update.Changed += RaiseUpdate;
ShowPackageCommand = new RelayCommand(() =>
{
if (_update.PackagePath is { } path) ShellActions.Reveal(path);
}, () => _update.PackagePath is not null);
CancelDownloadCommand = new RelayCommand(_update.CancelDownload, () => IsDownloading);
OpenReleasesCommand = new RelayCommand(() => ShellActions.OpenUrl(ProductLinks.Releases));
OpenLicenceCommand = new RelayCommand(() => ShellActions.OpenUrl(ProductLinks.Licence));
ReviewTranslationCommand = new RelayCommand(() => ShellActions.OpenUrl(ProductLinks.Issues));
OpenDataFolderCommand = new RelayCommand(() => ShellActions.Reveal(DataFolder));
DiagnosticsCommand = new AsyncRelayCommand(DiagnosticsAsync);
}
public ShellViewModel Shell { get; }
public string Version => AppServices.VersionText;
/// <summary>File version and processor architecture.</summary>
public string Build =>
(typeof(App).Assembly.GetCustomAttribute<AssemblyFileVersionAttribute>()?.Version ?? Version) + Loc.Separator + RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();
public string Runtime => RuntimeInformation.FrameworkDescription;
public string OperatingSystem => RuntimeInformation.OSDescription;
public string DataFolder => Shell.Services.Environment.DataDirectory;
/// <summary>Every language but English is machine-translated and open to review (BRIEF §16).</summary>
public bool IsTranslated => !Loc.Culture.TwoLetterISOLanguageName.Equals("en", StringComparison.OrdinalIgnoreCase);
public ICommand CheckCommand => _update.Check;
public ICommand DownloadCommand => _update.Download;
public ICommand ShowPackageCommand { get; }
public ICommand CancelDownloadCommand { get; }
public ICommand OpenReleasesCommand { get; }
public ICommand OpenLicenceCommand { get; }
public ICommand ReviewTranslationCommand { get; }
public ICommand OpenDataFolderCommand { get; }
public ICommand DiagnosticsCommand { get; }
/// <summary>"Up to date", "Chronos 0.2.0 available", …; null before the first check.</summary>
public string? UpdateText => _update.State switch
{
UpdateState.Checking => Loc.L("About.Update.Checking"),
UpdateState.UpToDate => Loc.L("About.Update.Current"),
UpdateState.Available when _update.Release is { } r => Loc.L("About.Update.Available", UpdateCheck.Display(r.Version)),
UpdateState.Failed => Loc.L("About.Update.Failed"),
UpdateState.Downloading => Loc.L("About.Update.Downloading", _update.Downloaded),
UpdateState.Downloaded when _update.Release is { } r => Loc.L("About.Update.Ready", UpdateCheck.Display(r.Version)),
UpdateState.DownloadFailed => Loc.L("About.Update.DownloadFailed"),
UpdateState.NotVerified => Loc.L("About.Update.NotVerified"),
_ => null,
};
/// <summary>What screen readers announce: each new state, not each percent of a download.</summary>
public string? UpdateAnnouncement => _update.State == UpdateState.Downloading ? Loc.L("About.Update.InProgress") : UpdateText;
public StatusKind UpdateKind => _update.State switch
{
UpdateState.Checking or UpdateState.Downloading => StatusKind.Running,
UpdateState.UpToDate or UpdateState.Downloaded => StatusKind.Done,
UpdateState.Available => StatusKind.Warning,
_ => StatusKind.Error,
};
public bool HasUpdateText => UpdateText is not null;
/// <summary>Download is offered: a newer release exists and no verified package is waiting (a failed download can be retried).</summary>
public bool IsUpdateAvailable => _update.IsDownloadOffered;
/// <summary>The verified setup or portable zip is in the temporary folder.</summary>
public bool IsPackageReady => _update.State == UpdateState.Downloaded;
public bool IsDownloading => _update.State == UpdateState.Downloading;
/// <summary>What Download does here: fetch and verify the setup or the portable zip (with its size), or open the release page.</summary>
public string DownloadToolTip => _update.Package is { } package
? Loc.L(_update.IsPortable ? "Tooltips.About.DownloadPortable" : "Tooltips.About.Download", Formatting.Bytes(package.Size))
: Loc.L("Tooltips.About.DownloadPage");
public string ShowPackageToolTip => Loc.L(_update.IsPortable ? "Tooltips.About.ShowPortable" : "Tooltips.About.ShowSetup");
/// <summary>Starts the update check on start when allowed (opt-out, BRIEF §18); never in a capture run.</summary>
public void Attach() => _ = NotifyAsync();
/// <summary>Sets a result without the network (capture, tests).</summary>
internal void SetResult(ReleaseInfo? release, bool failed = false) => _update.SetResult(release, failed);
private async Task NotifyAsync()
{
if (await _update.CheckOnStartAsync(Shell.Services.Settings.CheckForUpdates) is not { } newer) return;
Shell.Notify(Loc.L("About.Update.Available", UpdateCheck.Display(newer.Version)), actionText: Loc.L("About.Update.Download"),
actionToolTip: DownloadToolTip, action: () => DownloadCommand.Execute(null));
}
private async Task DiagnosticsAsync()
{
var folder = Shell.Services.Dialogs.PickFolder(Loc.L("Settings.Advanced.DiagnosticsTitle"));
if (folder is null) return;
try
{
var path = await DiagnosticsBundle.CreateAsync(Shell.Services, folder);
Shell.Notify(Loc.L("Settings.Advanced.DiagnosticsDone"), Path.GetFileName(path), Loc.L("Library.Export.Show"), Loc.L("Tooltips.Library.ShowExport"), () => ShellActions.Reveal(path));
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or Chronos.Data.DatabaseException)
{
Shell.ReportError(ex);
}
}
private void RaiseUpdate()
{
OnPropertyChanged(nameof(UpdateText));
OnPropertyChanged(nameof(UpdateAnnouncement));
OnPropertyChanged(nameof(UpdateKind));
OnPropertyChanged(nameof(HasUpdateText));
OnPropertyChanged(nameof(IsUpdateAvailable));
OnPropertyChanged(nameof(IsPackageReady));
OnPropertyChanged(nameof(IsDownloading));
OnPropertyChanged(nameof(DownloadToolTip));
CommandManager.InvalidateRequerySuggested();
}
}