fix(sync): resolve conflicts against the versions shown, isolate failures, renders on request

- Conflicts are settled against the versions the user was shown; a later change on
  either side refuses the choice and compares again. Title, tags, rating and notes
  changed differently on both sides are a conflict too (no silent tag union).
- Links are written under the engine's gate and forgotten only after a 404; linked
  local copies are read by id; unlinked copies with the same originals are linked
  by content.
- A failure on one sequence is recorded on its link; the others are still compared.
- Downloads hash unverified local copies first and restore originals missing here.
- Background proxy downloads give way to the user's requests; "Keep proxies offline"
  refreshes the caches of sequences opened with proxies, checks free space and backs
  off after a failure.
- Renders travel on request: Send exports (chunked, hash-verified upload keeping the
  render id; new POST /sequences/{id}/renders endpoints) and Get exports.
- Server screen: stable row buttons, mockup column grid, Tab through rows, conflict
  rows first on the card colour, localised conflict detail, Save both confirmation,
  Pause metered uploads, culture switch, Library one-word sync glyphs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-03 10:26:56 +00:00
1 parent 3601e0a47f
commit 2d40a613b9
48 files changed
+2498 -465

No files matched your search

@@ -175,6 +175,46 @@ public sealed class TitanoClient : IDisposable
.ConfigureAwait(false);
}
/// <summary>
/// Sends a render of <paramref name="sequenceId"/> made on this PC in resumable chunks; the server verifies the
/// SHA-256 in <paramref name="request"/> and files it under the sequence's exports with the same id. Null when the
/// server already has that render.
/// </summary>
public async Task<RenderDto?> UploadRenderAsync(Guid sequenceId, string path, RenderUploadRequest request, IProgress<UploadProgress>? progress = null,
CancellationToken ct = default)
{
var length = new FileInfo(path).Length;
if (length != request.Size) throw new ArgumentException("The render size does not match the file.", nameof(request));
var start = await RetryAsync(() => SendAsync(HttpMethod.Post, $"api/v1/sequences/{sequenceId}/renders", request,
ProtocolJson.Default.RenderUploadRequest, ProtocolJson.Default.StartUploadResponse, ct), ct).ConfigureAwait(false);
if (start.AlreadyExists) return null;
var uploadId = start.UploadId ?? throw new InvalidOperationException("Server returned no upload id.");
await SendChunksAsync(path, length, uploadId, start.ChunkSize, start.Received, progress, ct).ConfigureAwait(false);
return await RetryAsync(() => SendAsync<RenderDto>(HttpMethod.Post, $"api/v1/sequences/{sequenceId}/renders/{uploadId}/complete",
ProtocolJson.Default.RenderDto, ct), ct).ConfigureAwait(false);
}
/// <summary>
/// Streams a render's file to <paramref name="destination"/>, resuming with Range from its current length; returns
/// the file name the server gives it.
/// </summary>
public async Task<string?> DownloadRenderAsync(Guid renderId, Stream destination, CancellationToken ct = default)
{
using var request = new HttpRequestMessage(HttpMethod.Get, $"api/v1/renders/{renderId}/file");
if (destination.CanSeek && destination.Length > 0)
{
destination.Seek(0, SeekOrigin.End);
request.Headers.Range = new RangeHeaderValue(destination.Length, null);
}
using var response = await _http.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, ct).ConfigureAwait(false);
await EnsureSuccessAsync(response, ct).ConfigureAwait(false);
if (response.StatusCode == HttpStatusCode.OK && destination.CanSeek) destination.SetLength(0);
await using var body = await response.Content.ReadAsStreamAsync(ct).ConfigureAwait(false);
await body.CopyToAsync(destination, ct).ConfigureAwait(false);
var disposition = response.Content.Headers.ContentDisposition;
return (disposition?.FileNameStar ?? disposition?.FileName)?.Trim('"');
}
/// <summary>Sends every chunk the server does not have yet; each PUT is idempotent and retried on transient errors.</summary>
private async Task SendChunksAsync(string path, long length, Guid uploadId, int chunkSize, IReadOnlyList<int> alreadyReceived,
IProgress<UploadProgress>? progress, CancellationToken ct)
+1
View File
@@ -56,6 +56,7 @@ namespace Titano.Protocol;
[JsonSerializable(typeof(JobPriorityRequest))]
[JsonSerializable(typeof(RenderJobParameters))]
[JsonSerializable(typeof(RenderResultRequest))]
[JsonSerializable(typeof(RenderUploadRequest))]
[JsonSerializable(typeof(NodeJobFailure))]
[JsonSerializable(typeof(ServerSettingsDto))]
[JsonSerializable(typeof(LogFileDto))]
+20
View File
@@ -16,3 +16,23 @@ public sealed record CompleteUploadResponse(Guid FrameId, Guid SequenceId, int I
/// <summary><c>GET /api/v1/uploads/{id}</c>: resume state.</summary>
public sealed record UploadState(Guid UploadId, string FileName, long Size, string Sha256, int ChunkSize, IReadOnlyList<int> Received, string State);
/// <summary>
/// <c>POST /api/v1/sequences/{id}/renders</c>: a client offers one of its renders of the sequence (BRIEF §14.5,
/// renders are uploaded on request). The render keeps its id on the server, so both sides recognise it; when the
/// server already has that id it answers 200 with <see cref="StartUploadResponse.AlreadyExists"/>. Chunks go to
/// <c>/uploads/{uploadId}/chunks/{n}</c>; <c>POST /sequences/{id}/renders/{uploadId}/complete</c> verifies the SHA-256
/// and files the render under the sequence's exports.
/// </summary>
public sealed record RenderUploadRequest(
Guid RenderId,
string FileName,
long Size,
string Sha256,
string PresetName,
string? Codec,
int Width,
int Height,
double Fps,
double DurationSeconds,
string? ProducedBy);