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 <noreply@anthropic.com>
This commit is contained in:
1 parent
eeaddc2d14
commit
e188cf7de6
2 files changed
+49
-4
No files matched your search
@@ -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<CreateJobRequest?>(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)
|
||||
}
|
||||
|
||||
/// <summary>Posts a job to the signed-in server, which runs it or hands it to a render node (BRIEF §14.6, §14.7).</summary>
|
||||
private async Task PostAsync(Func<Task<CreateJobRequest>> build, JobKind kind, string label)
|
||||
/// <summary>
|
||||
/// Why a server that reads settings up to <paramref name="serverFormat"/> cannot render <paramref name="project"/> with
|
||||
/// <paramref name="export"/> as this Chronos would (<see cref="ProcessingJobs.RequiredFormat"/>), localised; null when it can.
|
||||
/// </summary>
|
||||
internal static string? ServerCannotRender(ProjectSettings project, ExportSettings export, int sourceWidth, int sourceHeight, int serverFormat) =>
|
||||
Editor.ServerJobs.NeedsNewerServer(ProcessingJobs.RequiredFormat(project, export, sourceWidth, sourceHeight), serverFormat);
|
||||
|
||||
/// <summary>Posts the job <paramref name="build"/> gives; nothing when it gives none (it said why).</summary>
|
||||
private async Task PostAsync(Func<Task<CreateJobRequest?>> 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));
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using Chronos.App.Library;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Testing;
|
||||
|
||||
namespace Chronos.App.Tests.Library;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public sealed class LibraryRenderGateTests
|
||||
{
|
||||
private static ExportSettings Uhd() => new() { Preset = new Auto<string>().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<string>().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));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user