fix: address the rc.14 review

Settings no longer makes a folder an archive on its own: a typed or
picked folder without archive.json is made one only after a
confirmation naming it, and Settings > Import keeps this PC's archive
folder and never creates one. A half-typed path or another PC's drive
letter could otherwise get .chronos and sidecars written unasked.

The server's structure check creates nothing in a root that lost its
archive.json (an unmounted disk's empty mount point) and reports it
unavailable; /health re-checks when its last check is over 10 s old,
so a fix on the host shows without a dashboard read.

The admin board reads the server newest first with Order off, counts
Published over the server's total, and a Shift range runs along the
lane picked in. Admin sizes keep number and unit together. A sent
workspace render whose file left exports/ is no longer listed as
missing. Desktop Board cards put their actions under the text while
the player is open. Start-up range errors name the CHRONOS_* variable;
the deploy guide documents the parallelism clamp and the log rule.

Refs #29 #31

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-06 17:52:44 +01:00
1 parent 159a8e6939
commit 2c15ee0e09
25 files changed
+336 -53

No files matched your search

@@ -302,6 +302,55 @@ public sealed class SettingsScreenSmokeTests
Assert.Equal(edited, shell.Services.Settings.FileTemplate);
});
[Test]
public Task AFolderTypedAsTheArchiveFolderBecomesAnArchiveOnlyWhenTheUserConfirms() => ScreenHost.RunAsync(async () =>
{
// Rc.14 review: the folder may be half-typed or one of the user's own; nothing is written there unasked.
var dialogs = new AnsweringDialogs();
await using var app = await ScreenSmokeTests.SampleApp.StartAsync(dialogs: dialogs);
var shell = app.Shell;
var settings = shell.Settings;
shell.Navigate(SectionKey.Settings);
settings.Page = SettingsPage.Archive;
var mine = System.IO.Path.Combine(shell.Services.Environment.DataDirectory, "my-photos");
System.IO.Directory.CreateDirectory(mine);
var manifest = new Chronos.Core.Archiving.ArchivePaths(mine).ManifestPath;
settings.ArchiveRoot.Text = mine;
Assert.True(settings.ArchiveRoot.Commit());
await settings.ArchiveRetarget;
Assert.Count(1, dialogs.Asked);
Assert.Equal(mine, dialogs.Asked[0].Detail);
Assert.False(System.IO.File.Exists(manifest), "declined: the folder stays as it was");
Assert.Empty(System.IO.Directory.EnumerateFileSystemEntries(mine));
Assert.Equal(mine, shell.Services.Settings.LastArchivePath);
dialogs.Answer = true;
settings.ArchiveRoot.Text = string.Empty;
Assert.True(settings.ArchiveRoot.Commit());
await settings.ArchiveRetarget;
settings.ArchiveRoot.Text = mine;
Assert.True(settings.ArchiveRoot.Commit());
await settings.ArchiveRetarget;
Assert.Count(2, dialogs.Asked);
Assert.True(System.IO.File.Exists(manifest), "confirmed: the folder is an archive");
});
/// <summary>Dialogs that record each confirmation and give <see cref="Answer"/>.</summary>
private sealed class AnsweringDialogs : IAppDialogs
{
public bool Answer { get; set; }
public List<ConfirmRequest> Asked { get; } = [];
public string? PickFolder(string title, string? initialFolder = null) => null;
public string? PickJsonFile(string title) => null;
public bool Confirm(ConfirmRequest request)
{
Asked.Add(request);
return Answer;
}
public bool SignIn(string server, string? username, Func<string, string, Task<string?>> signIn) => false;
}
[Test]
public Task TheFirstRunDialogKeepsTheKeyboardInside() => ScreenHost.RunAsync(async () =>
{
@@ -27,7 +27,7 @@ namespace Chronos.App.Tests.Videos;
/// The Videos library's sources (owner review 1, R9; decision 20): this PC's, the server's and the workspace's renders
/// merged by render id, the filters and the orders, the videos folder's checks, the player's fallback, and the copy's toast.
/// </summary>
public sealed class VideoSourcesTests
public sealed class VideoSourcesTests(TestContext context)
{
private static readonly Guid Harbour = Guid.CreateVersion7();
private static readonly Guid Comet = Guid.CreateVersion7();
@@ -261,6 +261,30 @@ public sealed class VideoSourcesTests
Assert.True(VideoSources.FromWorkspace(render.AsFailed("no"), project, @"C:\ws\exports\harbour.mp4", exists: false) is { IsUnsent: true, Missing: true });
}
[Test]
public void ASentRenderWhoseFileLeftTheWorkspaceIsNotListedAsMissing()
{
// Rc.14 review: its home holds it, and the home's entry stands for it; only a render not sent yet can be missing.
var store = new WorkspaceStore(context.CreateTempDirectory("ledger"));
var home = new BundleHome(BundleHome.ArchiveKind, Harbour);
var project = new WorkspaceEntry(Guid.CreateVersion7(), Harbour, "Social cut", false, home, "Harbour sunset", true, DateTimeOffset.UtcNow);
var folder = store.Project(project.ProjectId);
Directory.CreateDirectory(folder.ExportsDirectory);
WorkspaceRenderEntry Render(string file) => new(Guid.CreateVersion7(), Guid.CreateVersion7(), file, new string('a', 64), 8, "Instagram", "h264", 1080, 1920, 30, 12,
project.ProjectId, null, null, DateTimeOffset.UtcNow);
File.WriteAllText(folder.ExportFile("kept.mp4"), "rendered");
var kept = Render("kept.mp4").AsSent(DateTimeOffset.UtcNow);
var gone = Render("gone.mp4").AsSent(DateTimeOffset.UtcNow);
var lost = Render("lost.mp4");
folder.WriteRenders(WorkspaceRenders.Empty.With(kept).With(gone).With(lost));
var entries = VideoSources.ReadWorkspace(store, [project]);
Assert.Count(2, entries);
Assert.True(entries.Single(e => e.Id == kept.RenderId) is { IsWorkspaceSent: true, Missing: false });
Assert.True(entries.Single(e => e.Id == lost.RenderId) is { IsUnsent: true, Missing: true }, "a render not sent yet whose file is gone is missing");
Assert.False(entries.Any(e => e.Id == gone.RenderId));
}
[Test]
public void ACardStartsWithItsPresetAndKeepsSizesWhole()
{
@@ -131,10 +131,13 @@ public sealed class WorkspaceHostTests(TestContext context)
Assert.Equal(at, mine.WorkspaceOpened[project]);
// Import takes another PC's preferences and keeps this PC's projects.
var theirs = new AppSettings { WorkspaceSizeLimitGb = 40, WorkspaceFolder = @"E:\Elsewhere" };
var theirs = new AppSettings { WorkspaceSizeLimitGb = 40, WorkspaceFolder = @"E:\Elsewhere", LastArchivePath = @"D:\Photos" };
theirs.WorkspaceOpened[Guid.CreateVersion7()] = at.AddDays(-3);
mine.LastArchivePath = @"F:\Chronos";
var imported = mine.KeepLocalIn(AppSettings.Parse(theirs.ToJson())!);
Assert.Equal((40, @"D:\Fast\Workspace"), (imported.WorkspaceSizeLimitGb, imported.WorkspaceFolder));
// Another PC's archive folder can name one of this PC's own folders: this PC's stays.
Assert.Equal(@"F:\Chronos", imported.LastArchivePath);
Assert.Equal(at, imported.WorkspaceOpened.Values.Single());
Assert.Count(1, imported.WorkspaceOpened);
}
@@ -116,11 +116,21 @@ public sealed partial class AdminVideosTests(TestContext context)
Assert.Contains(@"data-view=""board"" aria-pressed=""${view === ""board""}"" data-i18n-title=""Admin.Videos.View.Board.Tip""", page);
Assert.Contains(@"return stored === ""list"" || stored === ""board"" ? stored : ""cards"";", page);
Assert.Contains(" board: `<svg", await server.Client.GetStringAsync("/admin/icons.js"));
// Two lanes, newest first whatever the order chosen, each with its count; Workspace holds the renders a PC's workspace
// sent here (a project named, produced by a machine other than this server), marked Sent.
Assert.Contains("const newest = [...rows].sort((a, b) => (Date.parse(b.created) - Date.parse(a.created))", page);
Assert.Contains(@"return lane(""Published"", newest, false) + lane(""Workspace"", sent, true);", page);
Assert.Contains(@"<span class=""pill num"">${escapeHtml(formatNumber(items.length))}</span>", page);
// Two lanes, newest first whatever the order chosen: the board reads the server newest first, with Order off and
// saying why (rc.14 review: re-sorting the page read in another order left the newest out). Published counts the
// server's total; Workspace holds the renders a PC's workspace sent here (a project named, produced by a machine
// other than this server), marked Sent, counted among those read ("+" while more can be read).
Assert.Contains(@"return view === ""board"" ? ""newest"" : filters.sort;", page);
Assert.Contains(@"if (sortShown() !== ""newest"") p.set(""sort"", sortShown());", page);
Assert.Contains(@"sort.disabled = view === ""board"";", page);
Assert.Contains(@"""Admin.Videos.Sort.Board.Tip""", page);
Assert.Contains(@"return lane(""Published"", rows, false, formatNumber(total ?? rows.length))", page);
Assert.Contains(@"+ lane(""Workspace"", sent, true, `${formatNumber(sent.length)}${cursor ? ""+"" : """"}`);", page);
// A Shift range runs along the lane picked in, as its cards are shown.
Assert.Contains(@"order: (el) => view === ""board"" && el?.closest("".board-lane"")", page);
Assert.Contains("if (shift) selection.range(key, order(el));", await server.Client.GetStringAsync("/admin/pages/library/shared.js"));
// Sizes keep their number and unit together, as the desktop's (issue #28).
Assert.Contains(@"format(value)} ${units[unit]}`;", await server.Client.GetStringAsync("/admin/ui.js"));
Assert.Contains("export function boardLane(v, serverName)", page);
Assert.Contains(@"return v.projectId && producer && producer !== String(serverName ?? """") ? ""workspace"" : ""published"";", page);
Assert.Contains(@"${workspace ? sentChip(v) : """"}${stateChips(v)}", page);
@@ -69,6 +69,47 @@ public sealed class ArchiveStructureStartupTests(TestContext context)
Assert.Equal("ok", health.Checks["archive"]);
}
[Test]
public async Task HealthSeesAFixOnTheHostWithoutTheDashboard()
{
await using var server = await TestServer.StartAsync(context);
var archive = server.Services.GetRequiredService<ServerArchive>();
var paths = new ArchivePaths(server.Options.ArchivePath);
Directory.Delete(paths.TrashVideosDirectory);
File.WriteAllText(paths.TrashVideosDirectory, "in the way");
archive.HealthRecheck = TimeSpan.Zero;
var health = Assert.NotNull(await server.Client.GetFromJsonAsync("/health", ProtocolJson.Default.HealthStatus));
Assert.Equal("incomplete", health.Checks["archive"]);
File.Delete(paths.TrashVideosDirectory);
health = Assert.NotNull(await server.Client.GetFromJsonAsync("/health", ProtocolJson.Default.HealthStatus));
Assert.Equal("ok", health.Checks["archive"]);
Assert.True(Directory.Exists(paths.TrashVideosDirectory));
}
[Test]
public async Task ARootThatLostItsArchiveJsonGetsNoFolders()
{
// Rc.14 review: an unmounted disk leaves an empty mount point; nothing is written onto the disk beneath it.
await using var server = await TestServer.StartAsync(context);
var admin = await server.AdminAsync();
var paths = new ArchivePaths(server.Options.ArchivePath);
var manifest = File.ReadAllBytes(paths.ManifestPath);
File.Delete(paths.ManifestPath);
Directory.Delete(paths.TrashDirectory, recursive: true);
var problem = Assert.NotNull((await DashboardAsync(admin)).ArchiveProblem);
Assert.Equal("unavailable", problem.Code);
Assert.False(Directory.Exists(paths.TrashDirectory), "nothing created");
var health = Assert.NotNull(await server.Client.GetFromJsonAsync("/health", ProtocolJson.Default.HealthStatus));
Assert.Equal("missing", health.Checks["archive"]);
// The disk is back: the next look completes the layout.
File.WriteAllBytes(paths.ManifestPath, manifest);
Assert.Null((await DashboardAsync(admin)).ArchiveProblem);
Assert.Empty(ArchiveStructure.Missing(paths));
}
private static async Task<DashboardDto> DashboardAsync(HttpClient admin)
{
using var response = await admin.GetAsync("/api/v1/server/dashboard");
@@ -52,6 +52,24 @@ public sealed partial class LoggingTests(TestContext context)
Assert.Equal((LogLevel.Debug, LogLevel.Warning, Chronos.Core.Diagnostics.LogLevel.Debug), (logging.FileLevel, logging.ConsoleLevel, CoreLog.MinimumLevel));
}
[Test]
public void AValueOutOfRangeIsNamedByItsVariable()
{
// Rc.14 review: the start's message named the setting's property, which the deploy guide never mentions.
ServerOptions Load(params (string Name, string Value)[] variables)
{
var environment = new Dictionary<string, string?> { ["CHRONOS_DATA_PATH"] = context.CreateTempDirectory("ranges"), ["CHRONOS_DB"] = "postgres" };
foreach (var (name, value) in variables) environment[name] = value;
return ServerOptions.Load(environment);
}
var logs = Assert.Throws<InvalidOperationException>(() => Load(("CHRONOS_LOG_MAX_FILE_MB", "50"), ("CHRONOS_LOG_MAX_TOTAL_MB", "10")).Validate());
Assert.True(logs.Message.StartsWith("CHRONOS_LOG_MAX_TOTAL_MB is out of range", StringComparison.Ordinal), logs.Message);
var port = Assert.Throws<InvalidOperationException>(() => Load(("CHRONOS_HTTP_PORT", "70000")).Validate());
Assert.Contains("CHRONOS_HTTP_PORT", port.Message);
// Parallelism alone is held to its range instead.
Assert.Equal(ServerOptions.MaxParallelism, Load(("CHRONOS_PARALLELISM", "128")).Parallelism);
}
[Test]
public async Task TheFileLevelChangesWhileTheServerRuns()
{