fix: owner review 3 phase 1: server ports for clients, screenshot baselines (#16)
CI / Build and test (push) Successful in 9m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 9s
Release / Build, test and publish (push) Successful in 14m4s
CI / PostgreSQL 16 integration (push) Successful in 8m26s
CI / PostgreSQL 17 integration (push) Successful in 8m43s
CI / Docker image (push) Successful in 50s
Release / Server image (push) Successful in 1m23s
CI / Build and test (push) Successful in 9m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 9s
Release / Build, test and publish (push) Successful in 14m4s
CI / PostgreSQL 16 integration (push) Successful in 8m26s
CI / PostgreSQL 17 integration (push) Successful in 8m43s
CI / Docker image (push) Successful in 50s
Release / Server image (push) Successful in 1m23s
Clients could not reach a server in a container whose ports are published as other host ports: the panel showed the container's ports, the template had no public HTTP port, and a bare host meant port 443. Public ports become panel settings, the panel shows the client address, both clients default to 8443, and an address that answers as another service is named as not a Chronos server (its certificate never offered for trust). The screenshot baselines are captured on the development PC and committed; measured values are fixed while the capture runs. 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 #16.
This commit is contained in:
1 parent
30a5b03f37
commit
255e149087
306 files changed
+2023
-206
No files matched your search
@@ -98,7 +98,7 @@ public static class ImportPlans
|
||||
plan.Items.Count(i => i.ExistingFrameId is not null),
|
||||
plan.Items.Count(i => i.Action == ImportAction.SkipImported),
|
||||
plan.Problems.Count,
|
||||
plan.AvailableBytes is { } free ? free - plan.CopyBytes : null,
|
||||
Infrastructure.AppClock.ShownFree(plan.AvailableBytes) is { } free ? free - plan.CopyBytes : null,
|
||||
Estimate(plan.CopyBytes, verify));
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -3,15 +3,31 @@ namespace Chronos.App.Infrastructure;
|
||||
/// <summary>
|
||||
/// Today's date for screens that lay themselves out around it (the Library timeline's years, the months of the
|
||||
/// Archive heatmap). <c>--capture</c> freezes it at the sample's moment, so the screenshots draw the same pixels on
|
||||
/// any day and the pixel diff against their baselines stays meaningful.
|
||||
/// any day and the pixel diff against their baselines stays meaningful. While frozen, what the screens measure on this
|
||||
/// machine (free space, a server's latency, when a comparison ran) is shown as fixed sample values too.
|
||||
/// </summary>
|
||||
public static class AppClock
|
||||
{
|
||||
private static DateTimeOffset? _frozen;
|
||||
|
||||
/// <summary>Free space every volume shows while frozen.</summary>
|
||||
public const long FrozenFreeBytes = 1_200_000_000_000;
|
||||
|
||||
/// <summary>The local date: the frozen moment's while frozen, the computer's otherwise.</summary>
|
||||
public static DateTime Today => (_frozen?.ToLocalTime().DateTime ?? DateTime.Now).Date;
|
||||
|
||||
/// <summary>True while frozen (screenshots).</summary>
|
||||
public static bool IsFrozen => _frozen is not null;
|
||||
|
||||
/// <summary>When something happened, as shown: the frozen moment while frozen.</summary>
|
||||
public static DateTimeOffset Shown(DateTimeOffset moment) => _frozen ?? moment;
|
||||
|
||||
/// <summary>A measured duration as shown: <paramref name="sample"/> while frozen.</summary>
|
||||
public static TimeSpan Shown(TimeSpan measured, TimeSpan sample) => _frozen is null ? measured : sample;
|
||||
|
||||
/// <summary>Measured free bytes as shown: <see cref="FrozenFreeBytes"/> while frozen (unknown stays unknown).</summary>
|
||||
public static long? ShownFree(long? measured) => _frozen is null || measured is null ? measured : FrozenFreeBytes;
|
||||
|
||||
/// <summary>Stops the clock at <paramref name="moment"/> for the rest of the process (screenshots only).</summary>
|
||||
public static void Freeze(DateTimeOffset moment) => _frozen = moment;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public static class ArchiveLocations
|
||||
var root = Path.GetPathRoot(Path.GetFullPath(path));
|
||||
if (string.IsNullOrEmpty(root)) return null;
|
||||
var drive = new DriveInfo(root);
|
||||
return drive.IsReady ? drive.AvailableFreeSpace : null;
|
||||
return AppClock.ShownFree(drive.IsReady ? drive.AvailableFreeSpace : null);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or ArgumentException or NotSupportedException)
|
||||
{
|
||||
|
||||
@@ -107,7 +107,8 @@ public sealed class ServerViewModel : SectionViewModel
|
||||
{
|
||||
if (!IsConnected || Session.Flow.Info is not { } info) return null;
|
||||
var parts = new List<string> { info.Name, Loc.L("Server.Version", info.Version) };
|
||||
if (Session.Flow.Latency is { } latency) parts.Add(Loc.L("Server.Latency", Math.Max(1, (int)Math.Round(latency.TotalMilliseconds))));
|
||||
if (Session.Flow.Latency is { } measured && AppClock.Shown(measured, TimeSpan.FromMilliseconds(12)) is var latency)
|
||||
parts.Add(Loc.L("Server.Latency", Math.Max(1, (int)Math.Round(latency.TotalMilliseconds))));
|
||||
return string.Join(Loc.Separator, parts);
|
||||
}
|
||||
}
|
||||
@@ -212,7 +213,7 @@ public sealed class ServerViewModel : SectionViewModel
|
||||
Shell.Settings.Encoders.CollectionChanged += OnEncodersChanged;
|
||||
Sync.Attach();
|
||||
await _session.RestoreAsync();
|
||||
if (_session.Flow.Error is not ConnectError.None and var error && !_session.IsConnected) ErrorText = ServerSession.ErrorText(error);
|
||||
if (_session.Flow.Error is not ConnectError.None and var error && !_session.IsConnected) ErrorText = ServerSession.ErrorText(error, _session.Flow.Address);
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
@@ -253,7 +254,7 @@ public sealed class ServerViewModel : SectionViewModel
|
||||
Address = ServerAddress.Display(Session.SavedAddress);
|
||||
return;
|
||||
}
|
||||
if (Session.Flow.Error is not ConnectError.None and var error) ErrorText = ServerSession.ErrorText(error);
|
||||
if (Session.Flow.Error is not ConnectError.None and var error) ErrorText = ServerSession.ErrorText(error, Session.Flow.Address);
|
||||
}
|
||||
|
||||
private async Task SignOutAsync()
|
||||
|
||||
@@ -269,6 +269,7 @@ public sealed class ConnectFlow(IServerApiFactory factory, ITrustStore trust) :
|
||||
internal static ConnectError? Classify(Exception ex, CancellationToken ct) => ex switch
|
||||
{
|
||||
UntrustedCertificateException => ConnectError.Untrusted,
|
||||
NotChronosServerException => ConnectError.NotChronos,
|
||||
ChronosApiException { Status: HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden } => ConnectError.BadCredentials,
|
||||
ChronosApiException { Status: HttpStatusCode.NotFound } => ConnectError.NotChronos,
|
||||
ChronosApiException api when api.IsTransient => ConnectError.Unreachable,
|
||||
@@ -283,19 +284,11 @@ public sealed class ConnectFlow(IServerApiFactory factory, ITrustStore trust) :
|
||||
/// <summary>Server addresses as typed in the address field.</summary>
|
||||
public static class ServerAddress
|
||||
{
|
||||
/// <summary>Accepts "nas.local:8443" (https assumed) or a full http(s) URL; the result is the API base, ending with "/".</summary>
|
||||
public static bool TryParse(string? text, out Uri uri)
|
||||
{
|
||||
uri = null!;
|
||||
if (string.IsNullOrWhiteSpace(text)) return false;
|
||||
var trimmed = text.Trim();
|
||||
if (!trimmed.Contains("://", StringComparison.Ordinal)) trimmed = "https://" + trimmed;
|
||||
if (!Uri.TryCreate(trimmed, UriKind.Absolute, out var parsed) || parsed.Scheme is not ("https" or "http") || parsed.Host.Length == 0) return false;
|
||||
var builder = new UriBuilder(parsed) { Query = string.Empty, Fragment = string.Empty };
|
||||
if (!builder.Path.EndsWith('/')) builder.Path += "/";
|
||||
uri = builder.Uri;
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Accepts "nas.local" (https on port 8443 assumed), "nas.local:9443" or a full http(s) URL, which keeps its scheme's
|
||||
/// port; the result is the API base, ending with "/" (<see cref="ChronosAddress"/>, shared with the uploader).
|
||||
/// </summary>
|
||||
public static bool TryParse(string? text, out Uri uri) => ChronosAddress.TryParse(text, out uri);
|
||||
|
||||
/// <summary>The address as shown in the field: the base URL without its trailing slash.</summary>
|
||||
public static string Display(Uri uri) => uri.ToString().TrimEnd('/');
|
||||
|
||||
@@ -150,7 +150,7 @@ public sealed class ServerSession : ObservableObject, ITrustStore, IDisposable
|
||||
{
|
||||
var result = await _flow.SignInAsync(user, password, attempt.Token);
|
||||
// An answer the flow dropped (the form was cancelled meanwhile) carries no error of its own.
|
||||
return result == ConnectStep.Connected ? null : ErrorText(_flow.Error is ConnectError.None ? ConnectError.Failed : _flow.Error);
|
||||
return result == ConnectStep.Connected ? null : ErrorText(_flow.Error is ConnectError.None ? ConnectError.Failed : _flow.Error, _flow.Address);
|
||||
});
|
||||
if (signedIn && IsConnected)
|
||||
{
|
||||
@@ -198,8 +198,13 @@ public sealed class ServerSession : ObservableObject, ITrustStore, IDisposable
|
||||
_flow.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>One sentence for a failed step (BRIEF §0.2 rule 6).</summary>
|
||||
public static string ErrorText(ConnectError error) => Loc.L("Server.Error." + error);
|
||||
/// <summary>
|
||||
/// One sentence for a failed step (BRIEF §0.2 rule 6). An address that answers as something else is named, with where
|
||||
/// to read the right one (owner review 3).
|
||||
/// </summary>
|
||||
public static string ErrorText(ConnectError error, Uri? address = null) => error == ConnectError.NotChronos && address is not null
|
||||
? Loc.L("Server.Error.NotChronosAt", Formatting.LeftToRight(ServerAddress.Display(address)))
|
||||
: Loc.L("Server.Error." + error);
|
||||
|
||||
/// <summary>The trust-on-first-use question with the fingerprint split over two lines.</summary>
|
||||
public static ConfirmRequest TrustRequest(string server, string fingerprint) => new()
|
||||
|
||||
@@ -153,7 +153,8 @@ public sealed class SyncTableViewModel : ObservableObject, IDisposable
|
||||
|
||||
/// <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))
|
||||
? Loc.L("Server.Sync.Last", Formatting.TimeOfDay(AppClock.Shown(s.RefreshedAt)),
|
||||
AppClock.Shown(s.Duration, TimeSpan.FromSeconds(0.4)).TotalSeconds.ToString("0.0", Loc.Culture))
|
||||
: null;
|
||||
|
||||
/// <summary>"Server archive 9.4 TB · 412 sequences".</summary>
|
||||
|
||||
Reference in new issue
Block a user