Unione di funzione/decoder-hevc in funzione/senza-terzi (catena della 0.3.0)

Porta in senza-terzi tutta la catena: documenti ed esportazione, S4b,
codec delle immagini, H.264 e HEVC. Conflitti risolti tenendo le due parti:
CI e Dockerfile di senza-terzi (solo comandi, Febe processo 1, un carattere)
senza ffmpeg, che il ramo dei video ha tolto; categoria «da fare» di
riepilogo-prove.sh tenuta; decisioni.md con tutte le righe, prima quelle
della catena e poi quelle di C6; CLAUDE.md con le righe della CI di C6
senza ffmpeg; prove della pipeline con tutti e due i controlli.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-25 11:57:34 +01:00
commit e4dbc5ad68
919 files changed
+65484 -1299

No files matched your search

+5 -3
View File
@@ -63,19 +63,21 @@ public sealed class ConnectionApiTests
}
[TestMethod]
public async Task LeavingThePageIsAnnullaInDockerAndOnlyTheEndOfTheHoldOnWindows()
public async Task LeavingThePageLetsGoOfTheBrowserInDockerAndOnlyEndsTheHoldOnWindows()
{
// Docker: the remote view is the page, leaving it gives the browser back to rest.
// Docker: the remote view is the page; leaving it lets go of the browser like closing the window on Windows (the
// session is copied: answer of 25 November 2026), while the button «Annulla» still cancels.
var docker = new RecordingConnection();
await using (var server = await Part2.StartAsync(services: s => s.AddSingleton<IConnectionService>(docker)))
{
var (status, _) = await server.SendJsonAsync(HttpMethod.Post, "/api/connection/cancel", new { pageLeft = true });
Assert.AreEqual(HttpStatusCode.NoContent, status);
await server.SendJsonAsync(HttpMethod.Post, "/api/connection/cancel");
var (showStatus, _) = await server.SendJsonAsync(HttpMethod.Post, "/api/browser/show");
Assert.AreEqual(HttpStatusCode.BadRequest, showStatus, "in Docker the browser is the Browser page");
}
CollectionAssert.AreEqual(new[] { "cancel" }, docker.Calls);
CollectionAssert.AreEqual(new[] { "leave", "cancel" }, docker.Calls);
// Windows (issue #52): the window stays as it is; «Annulla» is still «Annulla»; «Apri il browser» says which page.
var windows = new RecordingConnection();
@@ -61,6 +61,33 @@ public sealed class EngineConnectionStateTests
Assert.AreEqual(JsonValueKind.Null, (await LinkAsync(EngineMode.NotConnected)).GetProperty("username").ValueKind, "Not connected: no name.");
}
[TestMethod]
public async Task NotConnectedTakesCopyMissingFromTheSnapshotWithoutAskingTheBrowser()
{
// Issue #36, S4b: the engine already knows whether the copy for the requests is missing (its headline says
// «Serve «Ho finito»»); every event of the stream must not cost a look at the browser for it.
var connection = new RecordingConnection { Status = new ConnectionStatus(ConnectionState.SessionCopyMissing, null, null, false, null) };
await using var server = await Part2.StartAsync(services: s =>
{
s.AddSingleton<IEngineMonitor>(sp => new FixedModeMonitor(sp.GetRequiredService<IClock>()) { Mode = EngineMode.NotConnected });
s.AddSingleton<IConnectionService>(connection);
});
var monitor = (FixedModeMonitor)server.App.Services.GetRequiredService<IEngineMonitor>();
var reads = connection.StatusReads;
Assert.AreEqual("notConnected", (await server.GetJsonAsync("/api/engine")).GetProperty("connection").Str("state"), "the engine's word, not the connection's");
monitor.CopyMissing = true;
var engine = await server.GetJsonAsync("/api/engine");
Assert.AreEqual("copyMissing", engine.GetProperty("connection").Str("state"));
Assert.IsTrue(engine.GetProperty("snapshot").GetProperty("sessionCopyMissing").GetBoolean());
Assert.AreEqual(reads, connection.StatusReads, "no status asked while the engine runs");
// Only when the engine loop does not run is the connection asked.
monitor.Mode = EngineMode.Off;
Assert.AreEqual("copyMissing", (await server.GetJsonAsync("/api/engine")).GetProperty("connection").Str("state"));
Assert.AreEqual(reads + 1, connection.StatusReads);
}
[TestMethod]
public async Task WithoutEngineAndBrowserTheSidebarSaysNotConnectedEvenIfTuIsKnown()
{
@@ -76,8 +103,10 @@ public sealed class EngineConnectionStateTests
{
public EngineMode Mode { get; set; } = EngineMode.Resting;
public bool CopyMissing { get; set; }
public Task<EngineSnapshot> GetSnapshotAsync(CancellationToken ct = default) =>
Task.FromResult(SnapshotParts.Build(clock, Mode, "Prova", [], "Prova", CautionProfile.Prudent));
Task.FromResult(SnapshotParts.Build(clock, Mode, "Prova", [], "Prova", CautionProfile.Prudent) with { SessionCopyMissing = CopyMissing });
public async IAsyncEnumerable<EngineNotification> SubscribeAsync([EnumeratorCancellation] CancellationToken ct = default)
{
@@ -47,6 +47,13 @@ public sealed class HostingAndSecurityTests
// The text resource is valid JSON with the Italian texts.
using var texts = JsonDocument.Parse(files.ReadText("testi/it.json")!);
Assert.AreEqual("Libreria", texts.RootElement.GetProperty("nav").GetProperty("libreria").GetString());
// A count of one has its singular (t() picks the part before «|» when n is 1): never «1 di questi servono».
var needed = texts.RootElement.GetProperty("impostazioni").GetProperty("collegamento").GetProperty("salvata").GetProperty("servono").GetString()!;
var forms = needed.Split('|');
Assert.HasCount(2, forms, needed);
StringAssert.StartsWith(forms[0], "{n} di questi serve ");
StringAssert.StartsWith(forms[1], "{n} di questi servono ");
}
[TestMethod]
+30 -5
View File
@@ -90,12 +90,12 @@ public sealed class InterfaceTests
await ui.OpenAsync(new Uri(server.Address, "/browser"));
await ui.WaitForAsync(() => connection.Snapshot().Contains("begin:False") && view.Opened.Count == 1, "il browser in uso con la vista aperta");
// Another page from the sidebar: the view closes and the lease of «begin» goes too (like «Annulla»).
// Another page from the sidebar: the view closes and the page lets go of the browser (not «Annulla»: the session is copied).
await ui.EvalAsync("document.querySelector('a[data-nav=libreria]').click()");
await ui.WaitAsync("location.pathname === '/libreria'", "Libreria");
await ui.WaitForAsync(() => connection.Snapshot().Contains("cancel"), "il browser restituito lasciando la pagina");
await ui.WaitForAsync(() => connection.Snapshot().Contains("leave"), "il browser restituito lasciando la pagina");
await ui.WaitForAsync(() => view.Opened.All(v => v.Disposed), "vista remota chiusa");
CollectionAssert.AreEqual(new[] { "begin:False", "cancel" }, connection.Snapshot());
CollectionAssert.AreEqual(new[] { "begin:False", "leave" }, connection.Snapshot());
}
[TestMethod]
@@ -111,7 +111,7 @@ public sealed class InterfaceTests
// The document goes away (tab closed, reload, another site): only the page-hide event is left to say so.
await ui.SendAsync("Page.navigate", new JsonObject { ["url"] = "about:blank" });
await ui.WaitForAsync(() => connection.Snapshot().Contains("cancel"), "il browser restituito chiudendo la scheda");
await ui.WaitForAsync(() => connection.Snapshot().Contains("leave"), "il browser restituito chiudendo la scheda");
}
[TestMethod]
@@ -180,6 +180,31 @@ public sealed class InterfaceTests
Assert.IsFalse((await ui.EvalAsync("document.querySelector('.chi-collegato').textContent.includes('@')")).GetBoolean(), "no «@» without a name");
}
[TestMethod]
public async Task TheIncompleteCopyChoiceIsShownOnlyOnceTheServerSaysWhichOneIsStored()
{
// «Tieni la copia completa» stored; the page must not show «Sostituisci comunque» meanwhile, nor let a choice be
// made that the late answer would then undo.
var saved = new SavedSessionStatus(SavedSessionStatus.Present, null, 3, 7, 7, [], 2, 2, [], 0);
var connection = new RecordingConnection { Status = Connected with { SavedSession = saved } };
await using var server = await DockerAsync(connection, new FakeRemoteViewHost());
await server.Db.Settings.SetAsync(Febe.Core.Collection.Requests.SessionCopySettings.IncompleteCopyKey, Febe.Core.Collection.Requests.SessionCopySettings.KeepCompleteText);
await using var ui = await UiBrowser.StartAsync();
await ui.AddInitScriptAsync(UiBrowser.Requests);
await ui.OpenAsync(new Uri(server.Address, "/libreria"));
await ui.EvalAsync("window.__hold('/api/connection/settings')");
await ui.NavigateAsync("/impostazioni/collegamento");
await ui.WaitAsync("document.querySelector('.sessione-salvata input[value=\"tieni-completa\"]') !== null", "riquadro della sessione salvata");
await ui.WaitAsync("window.__started['/api/connection/settings'] >= 1", "scelta chiesta al server");
Assert.IsTrue((await ui.EvalAsync("[...document.querySelectorAll('.sessione-salvata input[type=radio]')].every((i) => !i.checked && i.disabled)")).GetBoolean(), "neither choice shown nor pickable before the answer " + ui.Report());
await ui.EvalAsync("window.__release('/api/connection/settings')");
await ui.WaitAsync("document.querySelector('.sessione-salvata input[value=\"tieni-completa\"]').checked", "la scelta salvata mostrata");
Assert.IsFalse((await ui.EvalAsync("document.querySelector('.sessione-salvata input[value=\"sostituisci\"]').checked")).GetBoolean());
Assert.IsTrue((await ui.EvalAsync("[...document.querySelectorAll('.sessione-salvata input[type=radio]')].every((i) => !i.disabled)")).GetBoolean(), "pickable once known");
Assert.IsTrue((await ui.EvalAsync("document.querySelector('.scelta-ignota').hidden")).GetBoolean(), "no warning when the choice was read");
}
[TestMethod]
public async Task HoFinitoOnCollegamentoClosesTheRemoteView()
{
@@ -233,7 +258,7 @@ public sealed class InterfaceTests
await ui.NavigateAsync("/libreria");
await ui.WaitAsync("location.pathname === '/libreria'", "Libreria");
await ui.WaitForQuietAsync("richieste della pagina finite");
CollectionAssert.AreEqual(new[] { "begin:False", "finish", "begin:False", "cancel" }, connection.Snapshot(), "leaving the page gives the browser back");
CollectionAssert.AreEqual(new[] { "begin:False", "finish", "begin:False", "leave" }, connection.Snapshot(), "leaving the page gives the browser back");
await ui.WaitForAsync(() => view.Opened.All(v => v.Disposed), "vista remota chiusa");
}
+45
View File
@@ -111,6 +111,8 @@ public sealed class LibraryApiTests
Assert.AreEqual("foto_1.jpg", media[0].Str("fileName"));
Assert.AreEqual(Path.Combine("marta.demo", "post"), media[0].Str("folder"));
Assert.IsFalse(media[1].Bool("available"), "a file missing from disk is said, not hidden");
Assert.IsFalse(media[0].Bool("damaged"), "a whole photo without a thumbnail yet is not damaged");
Assert.IsFalse(media[1].Bool("damaged"));
using (var file = await server.Client.GetAsync($"/api/media/{media[0].Long("id")}/file?download=1"))
{
@@ -149,6 +151,49 @@ public sealed class LibraryApiTests
Assert.AreEqual(JsonValueKind.Null, after.GetProperty("instagramUrl").ValueKind);
}
[TestMethod]
public async Task ADamagedPhotoHasTheNeutralTileTheViewerSaysSoAndItsFileStays()
{
await using var server = await WebTestServer.StartAsync();
var account = await server.Db.Accounts.AddAsync(Make.Account("marta.demo"));
var folder = server.Library.Layout.AccountFolder(account);
Directory.CreateDirectory(Path.Combine(folder, "post"));
var whole = TestImages.Jpeg(TestImages.Scene(7, 240, 180));
var cut = whole[..(whole.Length / 2)];
var png = TestImages.Png(TestImages.Scene(8, 120, 90));
var cutPng = png[..(png.Length / 2)];
await File.WriteAllBytesAsync(Path.Combine(folder, "post", "foto_1.jpg"), cut);
await File.WriteAllBytesAsync(Path.Combine(folder, "post", "foto_2.png"), cutPng);
await File.WriteAllBytesAsync(Path.Combine(folder, "post", "foto_3.jpg"), whole);
var added = await server.Db.Entries.AddAsync(
Make.Entry(account.Id, "1", Make.T0) with { State = EntryState.Downloaded },
[
Make.Stored(Make.Photo(1), Make.Sha(1), "post/foto_1.jpg") with { Bytes = cut.Length },
Make.Stored(Make.Photo(2), Make.Sha(2), "post/foto_2.png") with { Bytes = cutPng.Length },
Make.Stored(Make.Photo(3), Make.Sha(3), "post/foto_3.jpg") with { Bytes = whole.Length },
]);
var id = added.Stored.Entry.Id;
var tile = (await server.GetJsonAsync("/api/library")).Items("tiles").Single();
Assert.AreEqual(JsonValueKind.Null, tile.GetProperty("cover").GetProperty("thumb").ValueKind, "the neutral tile in the mosaic");
var media = (await server.GetJsonAsync($"/api/entries/{id}")).Items("media").ToList();
Assert.IsTrue(media[0].Bool("damaged"), "a JPEG cut in its scan: «File danneggiato o incompleto»");
Assert.IsTrue(media[1].Bool("damaged"), "a PNG cut in its data");
Assert.IsFalse(media[2].Bool("damaged"));
Assert.IsTrue(media.All(m => m.Bool("available")), "the file is in the library: its actions stay");
// The file stays as it came, and can still be downloaded (rule 12: Febe never deletes or replaces it).
using (var file = await server.Client.GetAsync($"/api/media/{media[0].Long("id")}/file?download=1"))
{
Assert.AreEqual(HttpStatusCode.OK, file.StatusCode);
CollectionAssert.AreEqual(cut, await file.Content.ReadAsByteArrayAsync());
}
CollectionAssert.AreEqual(cut, await File.ReadAllBytesAsync(Path.Combine(folder, "post", "foto_1.jpg")));
Assert.AreEqual(MediaState.Downloaded, (await server.Db.Media.GetAsync(media[0].Long("id")))!.State);
}
[TestMethod]
public async Task DeletionCanLetTheEntryComeBack()
{
@@ -69,6 +69,7 @@ internal sealed class FixedProblems(params ConfigurationProblem[] problems) : IC
internal sealed class RecordingConnection : IConnectionService
{
private readonly Lock _gate = new();
private int _statusReads;
public List<string> Calls { get; } = [];
@@ -86,7 +87,14 @@ internal sealed class RecordingConnection : IConnectionService
}
}
public Task<ConnectionStatus> GetStatusAsync(CancellationToken ct) => Task.FromResult(Status);
/// <summary>How many times the status was asked (each one costs the real connection a look at the browser).</summary>
public int StatusReads => Volatile.Read(ref _statusReads);
public Task<ConnectionStatus> GetStatusAsync(CancellationToken ct)
{
Interlocked.Increment(ref _statusReads);
return Task.FromResult(Status);
}
public Task BeginUserDrivingAsync(bool openLogin, CancellationToken ct)
{
@@ -116,6 +124,14 @@ internal sealed class RecordingConnection : IConnectionService
return Task.CompletedTask;
}
/// <summary>Docker: the page of the browser left without «Ho finito» or «Annulla» (not «Annulla»: it copies).</summary>
public Task LeavePageAsync(CancellationToken ct)
{
Record("leave");
Status = Status with { UserIsDriving = false };
return Task.CompletedTask;
}
public Task ReleaseAsync(CancellationToken ct)
{
Record("release");