diff --git a/src/Chronos.App/Library/LibraryActions.cs b/src/Chronos.App/Library/LibraryActions.cs index 93c1cf16..bc3ea4d8 100644 --- a/src/Chronos.App/Library/LibraryActions.cs +++ b/src/Chronos.App/Library/LibraryActions.cs @@ -48,7 +48,7 @@ public sealed class LibraryActions(ShellViewModel shell) { if (sequences is [{ Origin: SequenceOrigin.Server, SyncState: SyncState.RemoteOnly } remote]) { - await PostAsync(() => Task.FromResult(new CreateJobRequest(DeepAnalyseKind, [remote.Id], null)), JobKind.DeepAnalyse, remote.DisplayTitle); + await PostAsync(() => Task.FromResult(new CreateJobRequest(DeepAnalyseKind, [remote.Id], null)), JobKind.DeepAnalyse, remote.DisplayTitle); return; } await QueueAsync(ProcessingJobs.DeepAnalysis([.. sequences.Select(s => s.Id)], Label(sequences))); @@ -83,7 +83,14 @@ public sealed class LibraryActions(ShellViewModel shell) await PostAsync(async () => { var (project, width, height) = await RemoteProjectAsync(remote, sequence.Id); - return new CreateJobRequest(RenderKind, [sequence.Id], ProcessingJobs.Render(sequence, project.Export with { Batch = [] }, width, height).ParametersJson); + var export = project.Export with { Batch = [] }; + // As the editor's Render: settings or proportions an older server would render otherwise are not posted. + if (ServerCannotRender(project, export, width, height, Services.Sync.SettingsFormat) is { } newer) + { + shell.Notify(Loc.L("Library.Post.Failed"), newer); + return null; + } + return new CreateJobRequest(RenderKind, [sequence.Id], ProcessingJobs.Render(sequence, export, width, height, project).ParametersJson); }, JobKind.Render, sequence.DisplayTitle); return; } @@ -196,7 +203,15 @@ public sealed class LibraryActions(ShellViewModel shell) } /// Posts a job to the signed-in server, which runs it or hands it to a render node (BRIEF §14.6, §14.7). - private async Task PostAsync(Func> build, JobKind kind, string label) + /// + /// Why a server that reads settings up to cannot render with + /// as this Chronos would (), localised; null when it can. + /// + internal static string? ServerCannotRender(ProjectSettings project, ExportSettings export, int sourceWidth, int sourceHeight, int serverFormat) => + Editor.ServerJobs.NeedsNewerServer(ProcessingJobs.RequiredFormat(project, export, sourceWidth, sourceHeight), serverFormat); + + /// Posts the job gives; nothing when it gives none (it said why). + private async Task PostAsync(Func> build, JobKind kind, string label) { var session = Services.Server; if (!CanPost || session.Flow is not { Address: { } address, Token: { } token }) @@ -206,7 +221,7 @@ public sealed class LibraryActions(ShellViewModel shell) } try { - var request = await build(); + if (await build() is not { } request) return; using var client = new ChronosClient(address, new CertificatePinning(session.Fingerprints), $"Chronos ({Environment.MachineName})") { Token = token }; await client.CreateJobAsync(request); shell.Notify(Loc.L("Library.QueuedServer", JobText.Kind(kind), label)); diff --git a/tests/Chronos.App.Tests/Library/LibraryRenderGateTests.cs b/tests/Chronos.App.Tests/Library/LibraryRenderGateTests.cs new file mode 100644 index 00000000..1442fb51 --- /dev/null +++ b/tests/Chronos.App.Tests/Library/LibraryRenderGateTests.cs @@ -0,0 +1,30 @@ +using Chronos.App.Library; +using Chronos.Core.Localization; +using Chronos.Core.Project; +using Chronos.Testing; + +namespace Chronos.App.Tests.Library; + +/// +/// The Library's Render on a remote card is held to the editor's rule (owner review 1, phase 4): settings or proportions a +/// server of an older settings format would render otherwise are not posted to it. +/// +public sealed class LibraryRenderGateTests +{ + private static ExportSettings Uhd() => new() { Preset = new Auto().WithManual("4k-h264") }; + + [Test] + public void AnOlderServerIsNotSentARenderItWouldGetWrong() + { + var plain = new ProjectSettings { Export = Uhd() }; + var turned = plain with { Camera = new CameraSettings { Rotate = 90 } }; + var portrait = plain with { Camera = new CameraSettings { Aspect = new Auto().WithManual("9:16") } }; + var newer = Loc.L("Tooltips.Server.NeedsNewerServer"); + + Assert.Null(LibraryActions.ServerCannotRender(plain, plain.Export, 6000, 4000, ProjectSettings.BaseVersion)); + Assert.Equal(newer, LibraryActions.ServerCannotRender(turned, turned.Export, 6000, 4000, ProjectSettings.BaseVersion)); + Assert.Equal(newer, LibraryActions.ServerCannotRender(portrait, portrait.Export, 6000, 4000, ProjectSettings.BaseVersion), "the proportions win only on a newer server"); + Assert.Null(LibraryActions.ServerCannotRender(turned, turned.Export, 6000, 4000, ProjectSettings.CurrentVersion)); + Assert.Null(LibraryActions.ServerCannotRender(portrait, portrait.Export, 6000, 4000, ProjectSettings.CurrentVersion)); + } +}