feat: owner review 2 phase 5a: workspace and projects with a local home (#14)
CI / Build and test (push) Successful in 9m43s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 27s
CI / PostgreSQL 16 integration (push) Failing after 8m41s
CI / PostgreSQL 17 integration (push) Successful in 12m37s
CI / Docker image (push) Successful in 56s
Release / Build, test and publish (push) Successful in 14m59s
Release / Server image (push) Successful in 1m51s

Edit opens a sequence as a project of a workspace folder outside the library. Projects have linear version histories kept as sidecars in .chronos/projects/, Main mirrors the sequence's settings, and sync merges setting by setting. Migration 0009, JobKind.WorkspaceCopy = 20, Settings › Workspace, and 241 new strings in 38 languages.

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 #14.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-11-04 09:22:08 +01:00
1 parent efa87f68ce
commit 9b24cf74fc
370 files changed
+29237 -287

No files matched your search

@@ -48,8 +48,12 @@ internal sealed class RenderJobHandler(ChronosDatabase db, ProcessingOptions opt
if (!SequenceFolders.Holds(folder, sequence.Id)) throw new InvalidOperationException(Loc.L("Errors.Archive.FolderMoved"));
// A server writes only inside its archive (BRIEF §14.2): an export folder chosen on a client means nothing there.
if (options.Host == EncoderHost.Server) export = export with { Folder = null };
var project = (parameters.SettingsJson is { } embedded ? ProjectStore.Parse(embedded) : ProjectStore.Read(sequence, folder)) with { Export = export };
var embedded = parameters.SettingsJson ?? await VersionSettingsAsync(parameters, sequence, cancellation).ConfigureAwait(false);
var frames = await SequenceFrames.LoadAsync(db, archive, sequence, parameters.UseProxies, options.Archive.Decoder, cancellation).ConfigureAwait(false);
var aliases = embedded is not null ? await Projects.HomePhotos.AliasesAsync(db, sequence.Id, cancellation).ConfigureAwait(false) : [];
var project = (embedded is not null ? ProjectStore.Parse(Placed(embedded, frames, aliases)) : ProjectStore.Read(sequence, folder)) with { Export = export };
var settingsJson = project.ToJson();
var (projectId, projectVersionId) = await ProvenanceAsync(parameters, sequence, cancellation).ConfigureAwait(false);
using var names = new OutputNames();
var all = Targets(export, parameters.PresetName);
@@ -71,7 +75,6 @@ internal sealed class RenderJobHandler(ChronosDatabase db, ProcessingOptions opt
var targets = all.Select((t, i) => (i, t)).Where(t => !done.Contains(t.i)).Select(t => (t.i, adapt(t.t))).ToList();
if (targets.Count == 0) return;
var frames = await SequenceFrames.LoadAsync(db, archive, sequence, parameters.UseProxies, options.Archive.Decoder, cancellation).ConfigureAwait(false);
var companions = await GprCompanions.FindAsync(db, archive, frames.Frames, cancellation).ConfigureAwait(false);
IReadOnlyList<TargetOutcome> outcomes;
await using (var render = new SequenceRender(frames, project, SequenceAnalyser.ReadReport(folder, frames), options, originals: !parameters.UseProxies,
@@ -88,6 +91,8 @@ internal sealed class RenderJobHandler(ChronosDatabase db, ProcessingOptions opt
{
Id = RenderId(context.Job.Id, index),
OutputPath = Stored(paths, result.OutputPath),
ProjectId = projectId,
ProjectVersionId = projectVersionId,
};
await db.Renders.InsertAsync(entity, CancellationToken.None).ConfigureAwait(false);
done.Add(index);
@@ -120,6 +125,59 @@ internal sealed class RenderJobHandler(ChronosDatabase db, ProcessingOptions opt
throw new InvalidOperationException(failed.Count == 1 ? failed[0].Error : Loc.L("Errors.Render.Failed", failed.Count, outcomes.Count));
}
/// <summary>
/// The settings of the project version a job names without embedding them (owner review 2, R8); null when it names none.
/// </summary>
/// <exception cref="InvalidOperationException">The version is not one of the sequence's projects'.</exception>
private async Task<string?> VersionSettingsAsync(Protocol.RenderJobParameters parameters, Sequence sequence, CancellationToken cancellationToken)
{
if (parameters.ProjectVersionId is not { } versionId) return null;
return await db.Projects.GetVersionAsync(versionId, cancellationToken).ConfigureAwait(false) is { } version
&& await db.Projects.GetAsync(version.ProjectId, cancellationToken).ConfigureAwait(false) is { } owner && owner.SequenceId == sequence.Id
? version.SettingsJson
: throw new InvalidOperationException(Loc.L("Errors.Render.ProjectVersion"));
}
/// <summary>
/// The project and the version a render records (owner review 2, R8: a render never names a version whose settings it
/// did not use, nor one the index does not hold): the project when it is one of the sequence's; the version when the index
/// holds it, for that project of the sequence, with the content hash of the settings the job embeds. A job naming a
/// version the home never received (one saved on a PC and sent later under another id) records the project alone.
/// </summary>
private async Task<(Guid? Project, Guid? Version)> ProvenanceAsync(Protocol.RenderJobParameters parameters, Sequence sequence, CancellationToken cancellationToken)
{
Guid? project = parameters.ProjectId is { } id && await db.Projects.GetAsync(id, cancellationToken).ConfigureAwait(false) is { } owner
&& owner.SequenceId == sequence.Id
? id
: null;
if (parameters.ProjectVersionId is not { } versionId
|| await db.Projects.GetVersionAsync(versionId, cancellationToken).ConfigureAwait(false) is not { } version
|| (project is { } named && version.ProjectId != named)
|| await db.Projects.GetAsync(version.ProjectId, cancellationToken).ConfigureAwait(false) is not { } of || of.SequenceId != sequence.Id
|| (parameters.SettingsJson is { } embedded && !ProjectContent.Verifies(embedded, version.ContentHash)))
return (project, null);
return (version.ProjectId, versionId);
}
/// <summary>
/// Settings whose positions wait for their photos (a project version's portable form, settings synced from another copy)
/// with them placed on the frames rendered, a photo parked on an encoding a conversion replaced since found through
/// <paramref name="aliases"/> (the sequence's tombstones of reason "replaced"); others as they are.
/// </summary>
internal static string Placed(string settingsJson, SequenceFrames frames, IReadOnlyList<PhotoAlias>? aliases = null)
{
if (!settingsJson.Contains("pendingFrames", StringComparison.OrdinalIgnoreCase)) return settingsJson;
try
{
return ProjectContent.Place(settingsJson, new FramePhotos(frames.Frames.Select(f => (f.Index, new FramePhoto(f.Sha256, f.Size, f.CapturedAt))), aliases));
}
catch (System.Text.Json.JsonException)
{
// Not a project: reading it says so.
return settingsJson;
}
}
/// <summary>The job's preset, then every other preset of the batch with its own values.</summary>
internal static List<ExportTarget> Targets(ExportSettings export, string presetName) =>
[
+34 -1
View File
@@ -41,6 +41,35 @@ public static class ProcessingJobs
JsonSerializer.Serialize(parameters, ProtocolJson.Default.RenderJobParameters), JobPriority.User);
}
/// <summary>
/// <see cref="JobKind.Render"/> of a project version (owner review 2, R8) on the sequence's home: the version's portable
/// settings, placed on the sequence's frames by the render, with <paramref name="export"/> as their export section; the
/// render records the project and the version. One job per preset, as <see cref="RenderEach"/>.
/// </summary>
public static IReadOnlyList<ArchiveJobRequest> RenderVersion(Sequence sequence, ProjectVersion version, ExportSettings export, int sourceWidth, int sourceHeight,
bool useProxies = false)
{
ArgumentNullException.ThrowIfNull(sequence);
ArgumentNullException.ThrowIfNull(version);
ArgumentNullException.ThrowIfNull(export);
return
[
VersionJob(sequence, version, export with { Batch = [] }, sourceWidth, sourceHeight, useProxies),
.. BatchPresets(export).Select(id => VersionJob(sequence, version, BatchExport(export, id), sourceWidth, sourceHeight, useProxies)),
];
}
private static ArchiveJobRequest VersionJob(Sequence sequence, ProjectVersion version, ExportSettings export, int sourceWidth, int sourceHeight, bool useProxies)
{
var parameters = Parameters(export, sourceWidth, sourceHeight, version.SettingsJson, useProxies) with
{
ProjectId = version.ProjectId,
ProjectVersionId = version.Id,
};
return new ArchiveJobRequest(JobKind.Render, [sequence.Id], RenderLabel(sequence.DisplayTitle, parameters.PresetName),
JsonSerializer.Serialize(parameters, ProtocolJson.Default.RenderJobParameters), JobPriority.User);
}
/// <summary>
/// The label of a render job, "Harbour sunset → 4K HEVC". It is stored as written, in the language of the moment like
/// the preset name: its arrow points from the sequence to the preset in that language's reading direction.
@@ -64,7 +93,11 @@ public static class ProcessingJobs
return
[
parameters with { PresetJson = JsonSerializer.Serialize(export with { Batch = [] }, ProcessingJson.Default.ExportSettings) },
.. batch.Select(id => Parameters(BatchExport(export, id), sourceWidth, sourceHeight, parameters.SettingsJson, parameters.UseProxies)),
.. batch.Select(id => Parameters(BatchExport(export, id), sourceWidth, sourceHeight, parameters.SettingsJson, parameters.UseProxies) with
{
ProjectId = parameters.ProjectId,
ProjectVersionId = parameters.ProjectVersionId,
}),
];
}