From 2c15ee0e099f2134dbed744b44b6412eab34ce0a Mon Sep 17 00:00:00 2001 From: Alberto Balbo Date: Fri, 6 Nov 2026 17:52:44 +0100 Subject: [PATCH] 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 --- docs/CHANGELOG.md | 18 ++++++- docs/DECISIONS.md | 5 ++ docs/deploy/docker.md | 10 ++-- i18n/en/Admin.resx | 3 +- i18n/en/Settings.resx | 4 ++ i18n/en/Tooltips.resx | 2 + i18n/it/Admin.it.resx | 3 +- i18n/it/Settings.it.resx | 4 ++ i18n/it/Tooltips.it.resx | 2 + src/Chronos.App/Infrastructure/AppSettings.cs | 6 ++- src/Chronos.App/Sections/SettingsViewModel.cs | 37 ++++++++++---- src/Chronos.App/Sections/VideosView.xaml | 33 ++++++++++++- src/Chronos.App/Videos/VideoSources.cs | 5 +- .../Admin/web/pages/library/shared.js | 12 +++-- src/Chronos.Server/Admin/web/pages/videos.js | 45 +++++++++++++---- src/Chronos.Server/Admin/web/ui.js | 4 +- src/Chronos.Server/Api/SystemEndpoints.cs | 11 ++++- .../Configuration/ServerOptions.cs | 4 +- src/Chronos.Server/Storage/ServerArchive.cs | 22 +++++++-- .../Settings/SettingsScreenSmokeTests.cs | 49 +++++++++++++++++++ .../Videos/VideosSectionTests.cs | 26 +++++++++- .../Workspace/WorkspaceHostTests.cs | 5 +- .../Hosting/AdminVideosTests.cs | 20 ++++++-- .../Hosting/ArchiveStructureStartupTests.cs | 41 ++++++++++++++++ .../Hosting/LoggingTests.cs | 18 +++++++ 25 files changed, 336 insertions(+), 53 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 8b6f11ff..1ec42556 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -24,8 +24,16 @@ commits follow Conventional Commits (release notes are generated from them by `C ### Changed - Video cards start with the preset ("4K archive · HEVC · 0:41 · 1.4 GB"); sizes keep number and unit together with a no-break space, in every culture. -- Typing a folder that is not yet an archive in Settings › Archive now creates the archive there, as Welcome's - *Create* does, instead of doing nothing. +- Typing or picking a folder that is not yet an archive in Settings › Archive now offers to create the archive + there, as Welcome's *Create* does, after a confirmation that names the folder; *Not now* only remembers it. +- Settings › Import keeps this PC's archive folder, like its workspace: another PC's drive letter can name one of this + PC's own folders. +- The admin board always reads the server newest first (*Order* is off there, its tooltip says why); *Published* + counts every render the server holds, *Workspace* those read so far ("+" while more can be read). +- `/health` checks the archive's tree again once its last check is over 10 seconds old, so a fix on the host shows + there without opening the dashboard. +- A server setting out of range stops the start with a message naming its `CHRONOS_*` variable (ports and logs + included). - EULA §4 and BRIEF §21 say Chronos sends nothing about its use; BRIEF §7, §12.10, §14.8 and §14.9 describe the board and the archive's folder tree; §14.9 lists `CHRONOS_TRUSTED_PROXIES`; §19.6 points to the Unraid guide; §24 lists owner review 4 and phase 6. @@ -40,6 +48,12 @@ commits follow Conventional Commits (release notes are generated from them by `C - Creating or adopting an archive where its folders cannot be made fails with a clear, localised reason (drive or share unavailable, permission denied, read-only, a file in the way) instead of a generic error. - Settings files that still carry `AnonymousUsageCounts` load and are saved without it. +- rc.14 review: a sent workspace render whose file left `exports/` no longer shows on the desktop board as *Missing* + (its home holds it); a Shift range on the admin board runs along the lane picked in, as its cards are shown; a + server archive root that lost its `archive.json` (an unmounted disk's empty mount point) gets no folders, the + dashboard warns and `/health` says "missing"; the admin panel's sizes keep number and unit together too; desktop + Board cards put their actions under the text while the player is open, so titles and facts are no longer cut at + the window's smallest width. ## [0.1.0-rc.13] — 2026-11-05 diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index 419f7ad5..2f4d1dbc 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -792,3 +792,8 @@ One line per decision: date · decision · alternative · reason. | 2026-11-06 | The docs describe one update channel (stable releases), pre-releases installed by hand. | Document a pre-release channel | That is what the update check does: it asks for releases with `pre-release=false`. | | 2026-11-06 | `CHRONOS_TRUSTED_PROXIES` is listed in BRIEF §14.9. | Leave it undocumented | The server already reads it and the compose file and Unraid template already offer it. | | 2026-11-06 | rc.14 integration: the BRIEF §24 rows of owner review 4 name the sections actually amended (R1 §12.10, §14.8; R2 §21; R3 §7, §12.8, §14.8, §14.9), and §7, §12.10, §14.8 and the Docker guide gain the board and the archive's folder tree. | Keep the parcels' expected sections | The phase 6 parcel wrote the rows before the feature parcels landed. | +| 2026-11-06 | rc.14 review: Settings › Archive folder makes a folder without an archive one only after a confirmation naming it (*Create archive* / *Not now*, which only remembers the folder); Settings › Import never creates one and keeps this PC's archive folder. Supersedes the row "Settings › Archive folder creates an archive…". | Create silently, as the parcel did | A half-typed path commits on focus loss and an imported path can name the user's own photos: adopting either writes `.chronos` and sidecars there unasked (CLAUDE.md: explicit user action). | +| 2026-11-06 | The server's structure check makes nothing in a root without `archive.json` and reports it unavailable (`/health`: archive "missing"); `/health` re-checks once the last check is over 10 s old (`ServerArchive.HealthRecheck`). | Check only on dashboard reads; create in any existing root | An unmounted disk leaves an empty mount point whose underlying disk must not get `.chronos`; monitoring that only polls `/health` must see a fix without a dashboard read, throttled so a busy health probe stays cheap. | +| 2026-11-06 | The admin board reads the server with `sort=newest` and disables *Order* with a tooltip; *Published* shows the server's total, *Workspace* the loaded count with "+" while a cursor remains; a Shift range runs along the lane picked in (`selectableGrid`'s `order(el)`). | Re-sort the loaded page; one range over every card | The board must show the server's newest renders and honest counts, and a range must cover only the cards seen between the two clicks (a sent render is in both lanes). | +| 2026-11-06 | `CHRONOS_PARALLELISM` out of 1–64 stays clamped; the other range errors at start name the `CHRONOS_*` variable (`ServerOptions.VariableOf`). | Refuse every value out of range | Clamping parallelism is long-standing behaviour the admin panel relies on; the deploy guide documents the exception. | +| 2026-11-06 | Desktop Board cards move their quick actions to a row under the text while the player pane is open. | Stack the lanes; hide the actions | Keeps both lanes side by side and every action on the card; at 1200 px with the player the text column grows from about 80 px to the whole card. | diff --git a/docs/deploy/docker.md b/docs/deploy/docker.md index 9d22af39..7232aba1 100644 --- a/docs/deploy/docker.md +++ b/docs/deploy/docker.md @@ -61,14 +61,18 @@ docker compose up -d - At every start the server lays out the archive's folder tree inside `/archive` (`.chronos/` with `locks`, `journal`, `staging`, `trash`, `trash/photos`, `trash/videos`), making only the missing folders and touching nothing that exists. A folder it cannot make does not stop the start: the log warns, the dashboard shows *Archive incomplete* - (the folder and reason in its tooltip) and `/health` reports archive "incomplete" until it can be made. + (the folder and reason in its tooltip) and `/health` reports archive "incomplete" until it can be made. Both check + again by themselves (the dashboard at each read, `/health` when its last check is over 10 seconds old), so a fix on + the host needs no restart. A root without its `.chronos/archive.json` (an unmounted disk leaves an empty mount + point) gets no folders: the dashboard shows *Archive incomplete* and `/health` reports archive "missing". ## Environment variables Every server setting comes from, in order: its default, `/data/server.json`, then the environment. **A variable that is set fixes its setting:** the admin panel shows the field read-only and its tooltip names the variable. Leave a variable unset to choose the value in the admin panel while the server runs. A value out of range stops the start -with a message naming the variable. +with a message naming the variable, except `CHRONOS_PARALLELISM`, which is held to 1–64. The logs' total +(`CHRONOS_LOG_MAX_TOTAL_MB`) may not be below the log file size (`CHRONOS_LOG_MAX_FILE_MB`), unless it is 0. | Variable | Default | Meaning | |---|---|---| @@ -220,7 +224,7 @@ a newer archive, run Archive › *Scan* so the index catches up with what the ar | *Not a Chronos server* | Another service answers on that host port (on the owner's host 8443 is another service). Use the client address with the right public HTTPS port | | The free space shown is the cache's (Unraid) or too small | A cached share reports its primary storage. Map the share's array view read-only to `/space` and set `CHRONOS_SPACE_PATH=/space` ([unraid.md](unraid.md#free-space-of-the-array)) | | The container restarts at once, log: *… is not writable by PUID:PGID* | Give that user write access to the archive (or the named `.chronos` folder) on the host, or set `PUID`/`PGID` to its owner | -| Dashboard: *Archive incomplete*; `/health`: archive "incomplete" | A folder of the archive's tree cannot be made (share unavailable, permission denied, read-only, a file in the way; the tooltip names it). Fix it on the host; the next dashboard read checks again, no restart needed | +| Dashboard: *Archive incomplete*; `/health`: archive "incomplete" | A folder of the archive's tree cannot be made (share unavailable, permission denied, read-only, a file in the way; the tooltip names it). Fix it on the host; the next dashboard read, or `/health` within 10 seconds, checks again, no restart needed | | Log: *Database not reachable yet … retry* | PostgreSQL is starting, or `CHRONOS_DB_HOST` is wrong. Container names resolve only on a shared user-defined network; on Unraid's default bridge use the host's IP | | A field in the admin panel is read-only | A variable sets it; its tooltip names it. Remove the variable to change it in the panel | | The client asks to trust a new fingerprint | `/data` was replaced or the self-signed certificate was renewed. Compare with the admin panel before accepting | diff --git a/i18n/en/Admin.resx b/i18n/en/Admin.resx index 761e668e..019960a6 100644 --- a/i18n/en/Admin.resx +++ b/i18n/en/Admin.resx @@ -1121,6 +1121,7 @@ All years Sort Order of the videos + The board always shows the newest first; the order applies to the cards and the list Newest Oldest Largest @@ -1134,7 +1135,7 @@ Published Every render this server holds, newest first Workspace - Renders a PC's workspace made and sent here; those not sent yet stay on that PC + Renders a PC's workspace made and sent here, among the videos loaded (+: more to load); those not sent yet stay on that PC Sent Sent from the workspace of {0}{0} a computer's name Version {0}{0} a project version number diff --git a/i18n/en/Settings.resx b/i18n/en/Settings.resx index 1955a4f3..8619d1c8 100644 --- a/i18n/en/Settings.resx +++ b/i18n/en/Settings.resx @@ -65,6 +65,10 @@ stars per megapixel Analysis width px long edge + Create archive + This folder is not an archive yet. Chronos can make it one, with all the archive's folders inside it, and add what it already holds.long + Not now + Create an archive here?long Folders and files already in the archive keep their names.long File names Folders diff --git a/i18n/en/Tooltips.resx b/i18n/en/Tooltips.resx index 92402848..3be6f60e 100644 --- a/i18n/en/Tooltips.resx +++ b/i18n/en/Tooltips.resx @@ -770,6 +770,7 @@ Look for a new release when Chronos starts · no data is sent Delete the cache contents now Delete spilled frames and cached thumbnails; asks first + Make this folder an archive now, create its folders and queue a scan of what it holds Database, settings, logs and caches of this PC Open the data folder in Explorer. OneDrive synchronises it, which can damage the index: exclude it from syncing New cards and folders queue a deep analysis of what they import, in the background; each card can change it @@ -843,6 +844,7 @@ Encode a short synthetic clip with every encoder and report pass or fail and speed · about a minute Speed on the synthetic 1280×720 test clip Always the Microsoft software H.264 encoder; slower, identical everywhere + Remember the folder and leave it as it is Stars per megapixel from which a night frame counts as a star field · Enter applies, Esc reverts Start minimised when you sign in to Windows, so inserted cards are noticed Dark interface (default) diff --git a/i18n/it/Admin.it.resx b/i18n/it/Admin.it.resx index d918b430..e7032d65 100644 --- a/i18n/it/Admin.it.resx +++ b/i18n/it/Admin.it.resx @@ -1113,6 +1113,7 @@ Tutti gli anni Ordina Ordine dei video + La bacheca mostra sempre prima i più recenti; l'ordine vale per le schede e l'elenco Più recenti Meno recenti Più grandi @@ -1126,7 +1127,7 @@ Pubblicati Tutti i render di questo server, dal più recente Spazio di lavoro - Render fatti nello spazio di lavoro di un PC e inviati qui; quelli non ancora inviati restano su quel PC + Render fatti nello spazio di lavoro di un PC e inviati qui, tra i video caricati (+: altri da caricare); quelli non ancora inviati restano su quel PC Inviato Inviato dallo spazio di lavoro di {0} Versione {0} diff --git a/i18n/it/Settings.it.resx b/i18n/it/Settings.it.resx index 2ba19a37..c0bc4322 100644 --- a/i18n/it/Settings.it.resx +++ b/i18n/it/Settings.it.resx @@ -65,6 +65,10 @@ stelle per megapixel Larghezza di analisi px sul lato lungo + Crea archivio + Questa cartella non è ancora un archivio. Chronos può renderla tale, con tutte le cartelle dell'archivio al suo interno, e aggiungere ciò che contiene già. + Non ora + Creare un archivio qui? Le cartelle e i file già nell'archivio mantengono i loro nomi. Nomi dei file Cartelle diff --git a/i18n/it/Tooltips.it.resx b/i18n/it/Tooltips.it.resx index f7a36101..4a6a5ca8 100644 --- a/i18n/it/Tooltips.it.resx +++ b/i18n/it/Tooltips.it.resx @@ -841,6 +841,7 @@ Cerca una nuova versione all'avvio di Chronos · nessun dato viene inviato Elimina adesso il contenuto della cache Elimina fotogrammi temporanei e miniature in cache; prima chiede conferma + Rendi ora questa cartella un archivio, crea le sue cartelle e metti in coda la scansione di ciò che contiene Database, impostazioni, log e cache di questo PC Apri la cartella dati in Esplora file. OneDrive la sincronizza e così può danneggiare l'indice: escludila dalla sincronizzazione Schede e cartelle nuove accodano l'analisi profonda di ciò che importano, in background; ogni scheda può cambiarlo @@ -914,6 +915,7 @@ Codifica una breve clip sintetica con ogni encoder e ne riporta esito e velocità · circa un minuto Velocità sulla clip di prova sintetica 1280×720 Sempre l'encoder software H.264 di Microsoft; più lento, identico ovunque + Ricorda la cartella e lasciala com'è Stelle per megapixel da cui un fotogramma notturno conta come campo stellare · Invio applica, Esc annulla Avvia ridotto a icona all’accesso a Windows, così le schede inserite vengono notate Interfaccia scura (predefinita) diff --git a/src/Chronos.App/Infrastructure/AppSettings.cs b/src/Chronos.App/Infrastructure/AppSettings.cs index d4883c4b..f8abdfe0 100644 --- a/src/Chronos.App/Infrastructure/AppSettings.cs +++ b/src/Chronos.App/Infrastructure/AppSettings.cs @@ -405,12 +405,14 @@ public sealed class AppSettings /// /// Settings › Import: with this PC's own values taken from these settings: the session, the - /// window and its rail, the sequence edited last, the first-run flag, and the workspace (its folder, the projects opened - /// last and when). Changes and returns . + /// window and its rail, the sequence edited last, the first-run flag, the archive folder (another PC's drive letter can + /// name one of this PC's own folders), and the workspace (its folder, the projects opened last and when). Changes and + /// returns . /// public AppSettings KeepLocalIn(AppSettings imported) { ArgumentNullException.ThrowIfNull(imported); + imported.LastArchivePath = LastArchivePath; imported.ProtectedToken = ProtectedToken; imported.ServerUrl = ServerUrl; imported.Window = Window; diff --git a/src/Chronos.App/Sections/SettingsViewModel.cs b/src/Chronos.App/Sections/SettingsViewModel.cs index 39604b3a..baf1c69b 100644 --- a/src/Chronos.App/Sections/SettingsViewModel.cs +++ b/src/Chronos.App/Sections/SettingsViewModel.cs @@ -108,7 +108,7 @@ public sealed class SettingsViewModel : SectionViewModel _s.LastArchivePath = v.Length == 0 ? null : Path.GetFullPath(v); Save(); UpdateArchiveFree(); - _retarget = RetargetArchiveAsync(); + _retarget = RetargetArchiveAsync(offerCreate: true); }, () => Loc.L("Tooltips.Settings.ArchiveRoot")); FolderTemplate = new EditableField(_s.FolderTemplate, v => NamingPreview.Validate(v, isFolder: true), v => { @@ -1166,11 +1166,13 @@ public sealed class SettingsViewModel : SectionViewModel /// /// The archive folder changed: an archive already there is registered as at start (relinked when it moved) and given - /// its rescan, and the rows show its settings; any other folder leaves them with this PC's defaults for new archives. - /// Later edits never reach the archive shown before. Returns the archive registered at that folder (null for none), - /// even when another folder has been chosen since: edits made for this one go there. + /// its rescan, and the rows show its settings. A folder that is no archive yet becomes one in place, with the archive's + /// whole layout (as Welcome's Create), only when and the user confirms it for that folder + /// by name; otherwise the folder is only remembered and the rows keep this PC's defaults for new archives. Later edits + /// never reach the archive shown before. Returns the archive registered at that folder (null for none), even when + /// another folder has been chosen since: edits made for this one go there. /// - private async Task RetargetArchiveAsync() + private async Task RetargetArchiveAsync(bool offerCreate) { _archive = null; var root = _s.LastArchivePath; @@ -1180,8 +1182,8 @@ public sealed class SettingsViewModel : SectionViewModel { var opened = await Task.Run(async () => File.Exists(new ArchivePaths(root).ManifestPath) ? await archives.OpenAsync(root) : null); if (opened is not null) await Shell.Services.QueueScanAsync(opened, full: false); - // A folder that is no archive yet becomes one in place, with the archive's whole layout (as Welcome's Create). - else await Shell.Services.ArchiveSetup.CreateAsync(root); + // Never on its own: a folder the user typed half of, or one of their own folders, would become an archive and be scanned. + else if (offerCreate && ConfirmCreateArchive(root)) await Shell.Services.ArchiveSetup.CreateAsync(root); } catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or NewerFormatException or DatabaseException or ArgumentException or InvalidOperationException) @@ -1193,6 +1195,21 @@ public sealed class SettingsViewModel : SectionViewModel return await LoadArchiveAsync(root); } + /// + /// The archive folder typed or picked holds no archive: the user confirms making it one, the folder named, before any + /// folder or file is written there. Declined, the folder is only remembered. + /// + private bool ConfirmCreateArchive(string root) => Shell.Services.Dialogs.Confirm(new ConfirmRequest + { + Heading = Loc.L("Settings.Archive.CreateTitle"), + Message = Loc.L("Settings.Archive.CreateMessage"), + Detail = root, + SafeText = Loc.L("Settings.Archive.CreateSkip"), + SafeToolTip = Loc.L("Tooltips.Settings.SkipCreateArchive"), + ActionText = Loc.L("Settings.Archive.CreateAction"), + ActionToolTip = Loc.L("Tooltips.Settings.CreateArchiveHere"), + }); + /// /// Archive › Reset section with an archive open writes the defaults into that archive's archive.json, which the server /// and the other PCs share: the user confirms it for that archive by name first. @@ -1756,11 +1773,11 @@ public sealed class SettingsViewModel : SectionViewModel return; } // Everything but the session, the window and its rail, the sequence edited last (another PC's ids mean nothing here), - // the first-run flag and the workspace, which is this PC's (its folder, the projects opened last and when). + // the first-run flag, the archive folder and the workspace, which are this PC's (another PC's drives mean nothing here). ApplyAll(_s.KeepLocalIn(imported)); // Settings of a PC never rewrite the shared archive.json: the imported templates and sizes are the defaults of new - // archives, and the rows show the own settings of the archive at the (possibly imported) archive folder. - _retarget = RetargetArchiveAsync(); + // archives, and the rows show the own settings of this PC's archive. An import never makes a folder an archive. + _retarget = RetargetArchiveAsync(offerCreate: false); Shell.Notify(Loc.L("Settings.Import.Done")); } diff --git a/src/Chronos.App/Sections/VideosView.xaml b/src/Chronos.App/Sections/VideosView.xaml index ac51d371..ccd783d6 100644 --- a/src/Chronos.App/Sections/VideosView.xaml +++ b/src/Chronos.App/Sections/VideosView.xaml @@ -109,6 +109,31 @@ + + + @@ -116,7 +141,11 @@ - + + + + + @@ -125,7 +154,7 @@ - + -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() { diff --git a/tests/Chronos.App.Tests/Workspace/WorkspaceHostTests.cs b/tests/Chronos.App.Tests/Workspace/WorkspaceHostTests.cs index e438e123..218f4e98 100644 --- a/tests/Chronos.App.Tests/Workspace/WorkspaceHostTests.cs +++ b/tests/Chronos.App.Tests/Workspace/WorkspaceHostTests.cs @@ -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); } diff --git a/tests/Chronos.Server.Tests/Hosting/AdminVideosTests.cs b/tests/Chronos.Server.Tests/Hosting/AdminVideosTests.cs index 5fffbfc0..173f6cc2 100644 --- a/tests/Chronos.Server.Tests/Hosting/AdminVideosTests.cs +++ b/tests/Chronos.Server.Tests/Hosting/AdminVideosTests.cs @@ -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: ` (Date.parse(b.created) - Date.parse(a.created))", page); - Assert.Contains(@"return lane(""Published"", newest, false) + lane(""Workspace"", sent, true);", page); - Assert.Contains(@"${escapeHtml(formatNumber(items.length))}", 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); diff --git a/tests/Chronos.Server.Tests/Hosting/ArchiveStructureStartupTests.cs b/tests/Chronos.Server.Tests/Hosting/ArchiveStructureStartupTests.cs index 061e1549..8cb971b9 100644 --- a/tests/Chronos.Server.Tests/Hosting/ArchiveStructureStartupTests.cs +++ b/tests/Chronos.Server.Tests/Hosting/ArchiveStructureStartupTests.cs @@ -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(); + 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 DashboardAsync(HttpClient admin) { using var response = await admin.GetAsync("/api/v1/server/dashboard"); diff --git a/tests/Chronos.Server.Tests/Hosting/LoggingTests.cs b/tests/Chronos.Server.Tests/Hosting/LoggingTests.cs index 6065c5ac..e46caad8 100644 --- a/tests/Chronos.Server.Tests/Hosting/LoggingTests.cs +++ b/tests/Chronos.Server.Tests/Hosting/LoggingTests.cs @@ -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 { ["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(() => 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(() => 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() {