feat(editor): open server sequences with proxies, hero frame to the index, export sync and saved copies
Server sequences that are not in the local index open through a RemoteSequenceSource: proxies from the cache, project from the server's settings with their version (a 409 merges again), analysis report from the server, analyses and renders posted as server jobs (one per preset) and followed through the server's events. Set hero now reaches the index (SequenceEdit.HeroFrameId) so the Library card shows it. The Export tab gains the Sync option (remembered in the project) and restores "Save both" copies through undo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
36 files changed
+1307
-116
No files matched your search
@@ -1,6 +1,7 @@
|
||||
using Titano.Core.Model;
|
||||
using Titano.Core.Naming;
|
||||
using Titano.Data;
|
||||
using Titano.Data.Jobs;
|
||||
using Titano.Data.Repositories;
|
||||
using Titano.Protocol;
|
||||
using Titano.Server.Jobs;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Data.Jobs;
|
||||
using Titano.Protocol;
|
||||
|
||||
namespace Titano.Server.Api;
|
||||
@@ -48,43 +48,3 @@ public static class Dto
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Wire names of job kinds, states and priorities: kebab-case (<c>deep-analyse</c>) and lower-case (<c>running</c>).</summary>
|
||||
public static class JobWire
|
||||
{
|
||||
public static string Kind(JobKind kind)
|
||||
{
|
||||
var name = kind.ToString();
|
||||
var sb = new StringBuilder(name.Length + 4);
|
||||
for (var i = 0; i < name.Length; i++)
|
||||
{
|
||||
if (i > 0 && char.IsUpper(name[i])) sb.Append('-');
|
||||
sb.Append(char.ToLowerInvariant(name[i]));
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static bool TryParseKind(string? text, out JobKind kind) => TryParse(text, Kind, out kind);
|
||||
|
||||
public static string State(JobState state) => state.ToString().ToLowerInvariant();
|
||||
|
||||
public static bool TryParseState(string? text, out JobState state) => TryParse(text, State, out state);
|
||||
|
||||
public static string Priority(JobPriority priority) => priority.ToString().ToLowerInvariant();
|
||||
|
||||
public static bool TryParsePriority(string? text, out JobPriority priority) => TryParse(text, Priority, out priority);
|
||||
|
||||
private static bool TryParse<T>(string? text, Func<T, string> name, out T value) where T : struct, Enum
|
||||
{
|
||||
foreach (var candidate in Enum.GetValues<T>())
|
||||
{
|
||||
if (string.Equals(name(candidate), text, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
value = candidate;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
value = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Text.Json;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Data;
|
||||
using Titano.Data.Jobs;
|
||||
using Titano.Data.Processing;
|
||||
using Titano.Protocol;
|
||||
using Titano.Server.Jobs;
|
||||
|
||||
@@ -35,6 +35,7 @@ public static class SequenceEndpoints
|
||||
sequences.MapGet("/{id:guid}/manifest", ManifestAsync).Requires(Permissions.Read);
|
||||
sequences.MapGet("/{id:guid}/frames", FramesAsync).Requires(Permissions.Read);
|
||||
sequences.MapGet("/{id:guid}/analysis", AnalysisAsync).Requires(Permissions.Read);
|
||||
sequences.MapGet("/{id:guid}/analysis/report", ReportAsync).Requires(Permissions.Read);
|
||||
sequences.MapGet("/{id:guid}/stats", StatsAsync).Requires(Permissions.Read);
|
||||
sequences.MapGet("/{id:guid}/renders", RendersAsync).Requires(Permissions.Read);
|
||||
// Renders made on a client, sent on request (BRIEF §14.5); chunks go through /uploads.
|
||||
@@ -123,7 +124,15 @@ public static class SequenceEndpoints
|
||||
if (request.SettingsJson is not null && !IsJson(request.SettingsJson)) return ApiErrors.BadRequest(context, "invalid_settings");
|
||||
|
||||
var expected = request.ExpectedSettingsVersion ?? IfMatchVersion(context);
|
||||
var edit = new SequenceEdit { Title = request.Title, Tags = request.Tags, Rating = request.Rating, Notes = request.Notes, SettingsJson = request.SettingsJson };
|
||||
var edit = new SequenceEdit
|
||||
{
|
||||
Title = request.Title,
|
||||
Tags = request.Tags,
|
||||
Rating = request.Rating,
|
||||
Notes = request.Notes,
|
||||
SettingsJson = request.SettingsJson,
|
||||
HeroFrameId = request.HeroFrameId,
|
||||
};
|
||||
var result = await db.Sequences.EditAsync(id, edit, expected, context.RequestAborted);
|
||||
switch (result.Outcome)
|
||||
{
|
||||
@@ -212,6 +221,18 @@ public static class SequenceEndpoints
|
||||
_ => ApiErrors.NotFound(context, "analysis"),
|
||||
};
|
||||
|
||||
/// <summary>The full deep-analysis report (<c>.titano/analysis.json</c>) a client's editor shows for a server sequence.</summary>
|
||||
private static async Task<IResult> ReportAsync(HttpContext context, Guid id, TitanoDatabase db, ServerArchive archive)
|
||||
{
|
||||
if (await db.Sequences.GetAsync(id, context.RequestAborted) is not { } sequence) return ApiErrors.NotFound(context, "sequence");
|
||||
if (string.IsNullOrEmpty(sequence.Folder)) return ApiErrors.NotFound(context, "analysis");
|
||||
var path = new Core.Archiving.ArchivePaths(archive.Root).Sequence(sequence.Folder).AnalysisPath;
|
||||
var file = new FileInfo(path);
|
||||
if (!file.Exists || file.LinkTarget is not null || !ArchivePathGuard.IsInside(archive.Root, path)) return ApiErrors.NotFound(context, "analysis");
|
||||
var etag = string.Create(CultureInfo.InvariantCulture, $"a-{file.Length}-{file.LastWriteTimeUtc.Ticks}");
|
||||
return FileResponses.Serve(context, file, 0, file.Length, "application/json; charset=utf-8", "no-cache", etag) ?? ApiErrors.NotFound(context, "analysis");
|
||||
}
|
||||
|
||||
private static async Task<IResult> StatsAsync(HttpContext context, Guid id, TitanoDatabase db)
|
||||
{
|
||||
if (await db.Sequences.GetAsync(id, context.RequestAborted) is not { } s) return ApiErrors.NotFound(context, "sequence");
|
||||
|
||||
Reference in new issue
Block a user