feat(editor): visual crop, rotate/mirror/flip/straighten, colour looks (owner review 1 phase 4) (#26)
CI / Build and test (push) Successful in 8m19s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 12m9s
CI / PostgreSQL 16 integration (push) Successful in 7m49s
CI / PostgreSQL 17 integration (push) Successful in 7m19s
CI / Docker image (push) Successful in 46s
Release / Server image (push) Successful in 1m14s

Owner review 1 R5 + R6. Camera rotation, mirror, flip, straighten and crop handles locked to the output; an Exposure Look group; Export output size ("proportions win"); settings format 2 with older-node gates. Also fixes project text and hashes differing between Windows and Linux.

Closes #19
Closes #20

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #26.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-11-05 01:09:09 +01:00
1 parent db389a54f2
commit 188b2c2e55
355 files changed
+10549 -1061

No files matched your search

@@ -11,8 +11,10 @@ namespace Chronos.Server.Jobs;
/// Whether a queued render job that needs a platform encoder still waits for a render node (BRIEF §14.7); once it does
/// not, the server's own engine renders it in a managed format. A job waits at least as long as a node may stay silent
/// (<see cref="ServerOptions.NodeTimeoutSeconds"/>), so a node that is restarting or reconnecting takes it back, and
/// then as long as an online node can encode its codec at its size. The server's render handler asks for every queued
/// job it examines, so the online nodes are read at most once a second.
/// then as long as an online node reads the settings format it needs (<see cref="RenderJobParameters.RequiredSettingsFormat"/>)
/// and can encode its codec at its size, both as the job was queued and as its settings route it now (what the claim
/// checks). The server's render handler asks for every queued job it examines, so the online
/// nodes are read at most once a second.
/// </summary>
public sealed class RenderNodeAvailability(ChronosDatabase db, ServerOptions options, TimeProvider time)
{
@@ -34,7 +36,13 @@ public sealed class RenderNodeAvailability(ChronosDatabase db, ServerOptions opt
snapshot = new Snapshot(Stopwatch.GetTimestamp(), [.. online.Select(Dto.Capabilities).OfType<RegisterNodeRequest>()]);
Volatile.Write(ref _snapshot, snapshot);
}
return snapshot.Nodes.Any(node => RenderNodeService.CanEncode(node, parameters));
var candidates = snapshot.Nodes.Where(node => RenderNodeService.Renders(node, parameters)).ToList();
if (candidates.Count == 0) return false;
// The claim also skips a node that cannot render what the job renders now (the sequence's settings may have changed
// since it was queued, a job of an older server carries no settings format): the wait asks the same, or a node that
// never claims the job would hold it here for good.
return await RenderNodeService.RoutedAsync(db, job, parameters, cancellationToken) is not { } routed
|| candidates.Any(node => RenderNodeService.Renders(node, routed));
}
/// <summary>What the online nodes announced, and when it was read (a <see cref="Stopwatch"/> timestamp).</summary>
+43 -6
View File
@@ -6,6 +6,7 @@ using Chronos.Core.Model;
using Chronos.Core.Project;
using Chronos.Data;
using Chronos.Data.Jobs;
using Chronos.Data.Processing;
using Chronos.Data.Projects;
using Chronos.Data.Repositories;
using Chronos.Protocol;
@@ -86,7 +87,10 @@ public sealed class RenderNodeService(
// A render the server's own engine started (it left a checkpoint) resumes there: only it knows that attempt's
// leftovers and the batch entries it recorded.
if (queued.Checkpoint is not null) continue;
if (JobEndpoints.ParseRender(queued.ParametersJson) is not { } parameters || capabilities is null || !CanEncode(capabilities, parameters)) continue;
if (JobEndpoints.ParseRender(queued.ParametersJson) is not { } parameters || capabilities is null || !Renders(capabilities, parameters)) continue;
// What the job renders now decides too (owner review 1, phase 4): the sequence's own settings may have changed
// since it was queued, and a job of an older server carries no settings format.
if (await RoutedAsync(db, queued, parameters, cancellationToken) is { } routed && !Renders(capabilities, routed)) continue;
if (await db.Jobs.TryClaimAsync(queued.Id, NodeKey(node), cancellationToken) is not { } job) continue;
jobs.Publish(job);
if (job.TargetIds.Count != 1 || await db.Sequences.GetAsync(job.TargetIds[0], cancellationToken) is not { } sequence)
@@ -95,7 +99,7 @@ public sealed class RenderNodeService(
continue;
}
await TouchAsync(node, cancellationToken);
if (await SettingsAsync(parameters, sequence, cancellationToken) is not { } settings)
if (await SettingsAsync(db, parameters, sequence, cancellationToken) is not { } settings)
{
await FinishAsync(node, job, JobState.Failed, Loc.L("Errors.Render.ProjectVersion"), cancellationToken);
continue;
@@ -124,7 +128,7 @@ public sealed class RenderNodeService(
/// the frames the node gets), else those of the project version the job names (owner review 2, R8), else the sequence's.
/// Null when the job names a version that is not one of the sequence's projects'.
/// </summary>
private async Task<(string Json, bool Portable)?> SettingsAsync(RenderJobParameters parameters, Sequence sequence, CancellationToken cancellationToken)
private static async Task<(string Json, bool Portable)?> SettingsAsync(ChronosDatabase db, RenderJobParameters parameters, Sequence sequence, CancellationToken cancellationToken)
{
if (parameters.SettingsJson is { } embedded) return (embedded, Waits(embedded));
if (parameters.ProjectVersionId is not { } versionId) return (sequence.SettingsJson ?? "{}", false);
@@ -134,6 +138,28 @@ public sealed class RenderNodeService(
: null;
}
/// <summary>
/// The job's parameters with the output size and settings format of the settings a node would render now
/// (<see cref="ProcessingJobs.Routed"/>); null when they cannot be told (no sequence, settings that cannot be read, a
/// version that is not the sequence's), which the claim reports as it does today. The claim and the server's wait for
/// a node (<see cref="RenderNodeAvailability"/>) both read it, so a node counted as able to take a job does take it.
/// </summary>
internal static async Task<RenderJobParameters?> RoutedAsync(ChronosDatabase db, Job queued, RenderJobParameters parameters, CancellationToken cancellationToken)
{
if (queued.TargetIds is not [var sequenceId] || await db.Sequences.GetAsync(sequenceId, cancellationToken) is not { } sequence) return null;
if (await SettingsAsync(db, parameters, sequence, cancellationToken) is not { } settings || ProcessingJobs.ReadSettings(settings.Json) is not { } read) return null;
try
{
var (width, height) = await JobEndpoints.SourceSizeAsync(db, sequence.Id, parameters, cancellationToken);
return ProcessingJobs.Routed(parameters, read, width, height);
}
catch (InvalidDataException)
{
// Not an export section: the render says so.
return null;
}
}
/// <summary>Settings with positions that wait for their photos (a project version's portable form, settings synced from another copy).</summary>
private static bool Waits(string settingsJson) => settingsJson.Contains("pendingFrames", StringComparison.OrdinalIgnoreCase);
@@ -311,14 +337,25 @@ public sealed class RenderNodeService(
if (state != node.State) events.Publish(new NodeStateEvent(node.Id, node.ClientName, state));
}
/// <summary>
/// The node renders the job as asked: it reads the settings format the job needs (<see cref="RegisterNodeRequest.SettingsFormat"/>,
/// 1 for an older node) and can encode it (<see cref="CanEncode"/>).
/// </summary>
internal static bool Renders(RegisterNodeRequest node, RenderJobParameters job) => job.RequiredSettingsFormat <= node.SettingsFormat && CanEncode(node, job);
/// <summary>
/// The node has an encoder for the job's codec that handles its resolution: the encoder's own limit, else the node's
/// (0 = no announced limit).
/// (0 = no announced limit). A node of settings format 2 or more takes the limit as a long edge × short edge, as its
/// encoders do (<see cref="Core.Export.EncoderSelector.Takes"/>: portrait UHD on a 4096×2304 encoder); an older node
/// would shrink a portrait frame to the limit as announced, so it is held to it.
/// </summary>
internal static bool CanEncode(RegisterNodeRequest node, RenderJobParameters job) =>
node.Encoders.Any(e => string.Equals(e.Codec, job.Codec, StringComparison.OrdinalIgnoreCase)
&& Fits(job.Width, e.MaxWidth > 0 ? e.MaxWidth : node.MaxWidth)
&& Fits(job.Height, e.MaxHeight > 0 ? e.MaxHeight : node.MaxHeight));
&& Fits(job.Width, job.Height, e.MaxWidth > 0 ? e.MaxWidth : node.MaxWidth, e.MaxHeight > 0 ? e.MaxHeight : node.MaxHeight,
eitherWay: node.SettingsFormat >= 2));
private static bool Fits(int width, int height, int maxWidth, int maxHeight, bool eitherWay) =>
(Fits(width, maxWidth) && Fits(height, maxHeight)) || (eitherWay && Fits(height, maxWidth) && Fits(width, maxHeight));
private static bool Fits(int size, int limit) => limit <= 0 || size <= limit;