From e188cf7de675c01adb24053869b28553b8013ae2 Mon Sep 17 00:00:00 2001 From: Alberto Balbo Date: Wed, 4 Nov 2026 21:45:36 +0100 Subject: [PATCH] fix(library): hold the Render quick action to the older-server gate The Library's Render on a remote card posted to the server without the check the editor's Render makes, so a turned project or a proportions-win project was rendered wrong by a server that reads only format 1. It now computes the format the render needs, explains the refusal instead of posting, and sends the project it fetched rather than sizing the job from the card's stale settings. Co-Authored-By: Claude Opus 5.5 --- src/Chronos.App/Library/LibraryActions.cs | 23 +++++++++++--- .../Library/LibraryRenderGateTests.cs | 30 +++++++++++++++++++ 2 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 tests/Chronos.App.Tests/Library/LibraryRenderGateTests.cs 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)); + } +}