feat(P8): integrate phase 5 (workspace stills, strings, prune)
Wire the phase 5 parcels into one working whole. - Save frame works in a workspace project. WorkspaceSequenceSource now makes still jobs (IProjectStills) routed like its renders: with the originals on this PC, a WorkspaceRender still into exports/; with proxies only, the home's still job with the portable settings and the project id. The tooltip for a source that saves no frames is now a real string. - The Export footer has Save project file again for library sequences; workspace projects keep it in their project menu only. - Sync render downloads are hashed and compared with the server's sha256 (one retry, then the job fails without filing the file), and uploads and downloads carry the render kind, so a saved frame no longer counts as a recent preset. - Add the missing en/it strings: still frame out of the sequence (Core and both job handlers), keyframes not applicable, workspace stills, Videos refresh / clear sequence / play-from-server tips, the videos-folder creation error, and the admin panel kind labels, play and trash tips. - Delete the export history, batch and card strings no longer used from English and prune them from every culture. - Videos: the sequence chip clears only the sequence filter (desktop and admin panel), the desktop remembers cards or list, and a Refresh button. Refs #21 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c4924c122e
commit
6d87a1bc6d
111 files changed
+459
-754
No files matched your search
@@ -1,4 +1,8 @@
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using Chronos.App.Editor;
|
||||
using Chronos.App.Shell;
|
||||
using Chronos.App.Tests.Windows;
|
||||
@@ -35,10 +39,12 @@ public sealed class ExportTabTests
|
||||
Assert.True(ExportRules.HasRateControl(VideoCodec.H264));
|
||||
Assert.True(ExportRules.HasRateControl(VideoCodec.Hevc));
|
||||
Assert.Null(ExportRules.RateControlBlocked(VideoCodec.Av1));
|
||||
Assert.Null(ExportRules.KeyframesBlocked(VideoCodec.Hevc));
|
||||
foreach (var managed in new[] { VideoCodec.Mjpeg, VideoCodec.Gif, VideoCodec.Apng, VideoCodec.PngSequence, VideoCodec.JpegSequence })
|
||||
{
|
||||
Assert.False(ExportRules.HasRateControl(managed), $"{managed} has no rate control");
|
||||
Assert.NotNull(ExportRules.RateControlBlocked(managed), $"{managed}: the tooltip says why");
|
||||
Assert.Equal(Loc.L("Tooltips.Export.KeyframesNA", Loc.L("Export.Codec." + managed)), ExportRules.KeyframesBlocked(managed), $"{managed}: no keyframe interval");
|
||||
Assert.NotNull(ExportRules.BFramesBlocked(managed, CodecProfile.Auto), $"{managed} takes no B-frames");
|
||||
Assert.Empty(ExportRules.Profiles(managed, 8));
|
||||
Assert.NotNull(ExportRules.ProfileBlocked(managed, 8));
|
||||
@@ -244,9 +250,35 @@ public sealed class ExportTabTests
|
||||
Assert.Equal("Batch (1)", export.BatchText);
|
||||
Assert.Equal(Loc.L("Export.Footer.Videos", content.Renders.Count.ToString("N0", Loc.Culture)), export.VideosText);
|
||||
Assert.NotNull(export.FooterSummary);
|
||||
|
||||
// A library sequence saves its .chronos project file from the footer; a workspace project has it in its project ▾ menu.
|
||||
var panel = new ContentControl { Content = export };
|
||||
panel.Resources.MergedDictionaries.Add(new ResourceDictionary
|
||||
{
|
||||
Source = new Uri("pack://application:,,,/Chronos;component/Editor/EditorPanels.xaml", UriKind.Absolute),
|
||||
});
|
||||
panel.Measure(new Size(420, 4000));
|
||||
panel.Arrange(new Rect(0, 0, 420, 4000));
|
||||
panel.UpdateLayout();
|
||||
var save = Assert.NotNull(Descendants<Button>(panel).SingleOrDefault(b => ReferenceEquals(b.Command, export.SaveProjectCommand)));
|
||||
Assert.False(editor.HasProject);
|
||||
Assert.Equal(Visibility.Visible, save.Visibility);
|
||||
Assert.Equal("Editor.HasProject", BindingOperations.GetBinding(save, UIElement.VisibilityProperty)?.Path.Path);
|
||||
Assert.True(export.SaveProjectCommand.CanExecute(null));
|
||||
}
|
||||
});
|
||||
|
||||
private static IEnumerable<T> Descendants<T>(DependencyObject root)
|
||||
where T : DependencyObject
|
||||
{
|
||||
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(root); i++)
|
||||
{
|
||||
var child = VisualTreeHelper.GetChild(root, i);
|
||||
if (child is T match) yield return match;
|
||||
foreach (var nested in Descendants<T>(child)) yield return nested;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A Videos section as the shell would hold it.</summary>
|
||||
private sealed class FakeVideos() : SectionViewModel(SectionKey.Jobs, "Icon.Jobs"), IVideosSection
|
||||
{
|
||||
|
||||
@@ -131,7 +131,8 @@ public sealed class RenderMenuTests
|
||||
Assert.Null(ServerJobs.StillNeedsNewerServer(RenderRules.StillFormat), "a format-3 server takes still jobs");
|
||||
Assert.Equal(older, RenderMenu.SaveFrameBlockedReason(false, "Studio NAS", false, true, true, older, null));
|
||||
Assert.Equal(Loc.L("Tooltips.Editor.Render.NameError", "bad"), RenderMenu.SaveFrameBlockedReason(false, null, false, true, true, null, "bad"));
|
||||
Assert.NotNull(RenderMenu.SaveFrameBlockedReason(false, null, false, true, sourceSavesFrames: false, null, null), "a workspace project saves no frame yet");
|
||||
Assert.Equal(Loc.L("Tooltips.Export.StillWorkspace"), RenderMenu.SaveFrameBlockedReason(false, null, false, true, sourceSavesFrames: false, null, null),
|
||||
"a source that renders elsewhere without still jobs of its own");
|
||||
Assert.Null(RenderMenu.SaveFrameBlockedReason(false, null, false, true, true, null, null));
|
||||
|
||||
// In the menu: Save frame › and its formats are disabled and say why.
|
||||
|
||||
@@ -50,6 +50,11 @@ public sealed class VideoSourcesTests
|
||||
Assert.True(merged.Single(e => e.Id == server[1].Id) is { IsLocal: false, IsOnServer: true, LocalPath: null });
|
||||
Assert.True(merged.Single(e => e.Id == local[1].Id) is { IsLocal: true, IsUnsent: false });
|
||||
Assert.True(merged.Single(e => e.Id == unsent.Id).IsUnsent);
|
||||
|
||||
// Play says why it waits: only on the server, or gone from this PC.
|
||||
Assert.Equal(Loc.L("Tooltips.Videos.Play"), VideoText.PlayToolTip(twin));
|
||||
Assert.Equal(Loc.L("Tooltips.Videos.PlayServer"), VideoText.PlayToolTip(merged.Single(e => e.Id == server[1].Id)));
|
||||
Assert.Equal(Loc.L("Tooltips.Videos.Missing"), VideoText.PlayToolTip(local[1] with { Missing = true }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -263,6 +268,13 @@ public sealed class VideosSectionTests(TestContext context)
|
||||
section.SearchText = "comet";
|
||||
Assert.True(section.Rows[0].IsSelected);
|
||||
Assert.True(section.HasSelection);
|
||||
// The chip's × clears the sequence only: the search and the order stay.
|
||||
Assert.True(section.ClearSequenceCommand.CanExecute(null));
|
||||
section.ClearSequenceCommand.Execute(null);
|
||||
Assert.False(section.IsSequenceFiltered);
|
||||
Assert.Equal("comet", section.SearchText);
|
||||
Assert.Equal(VideoSorts.Largest, section.SelectedSort.Value);
|
||||
Assert.False(section.ClearSequenceCommand.CanExecute(null));
|
||||
});
|
||||
|
||||
[Test]
|
||||
@@ -370,8 +382,12 @@ public sealed class VideosSectionTests(TestContext context)
|
||||
await section.RefreshAsync();
|
||||
var view = new VideosView { DataContext = section };
|
||||
Layout(view);
|
||||
Assert.Equal(LibraryLayout.Grid, shell.Services.Settings.VideosLayout);
|
||||
section.LayoutIndex = 1;
|
||||
Assert.Equal(LibraryLayout.List, shell.Services.Settings.VideosLayout, "the list is kept for the next run");
|
||||
Assert.Equal(1, new VideosViewModel(shell).LayoutIndex, "and a new section opens on it");
|
||||
section.Rows[0].IsSelected = true;
|
||||
Assert.Equal(Loc.L("Tooltips.Videos.Play"), section.PlayToolTip);
|
||||
Assert.True(section.PlayCommand.CanExecute(null));
|
||||
section.PlayCommand.Execute(null);
|
||||
var player = Assert.NotNull(section.Player);
|
||||
|
||||
@@ -8,6 +8,7 @@ using Chronos.Core.Imaging.Decoders;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Core.Video;
|
||||
using Chronos.Data.Processing;
|
||||
using Chronos.Data.Workspaces;
|
||||
using Chronos.Protocol.Client;
|
||||
@@ -65,6 +66,20 @@ public sealed class WorkspaceLocalRenderTests(TestContext context)
|
||||
var (render, _) = ProcessingJobs.ReadRender(parameters.RenderJson);
|
||||
Assert.NotNull(render.SettingsJson, "the portable settings travel with the job");
|
||||
|
||||
// Save frame: a still job on this PC too, with the frame, its photo and the portable settings.
|
||||
Assert.True(session.CanSaveFrames, "a workspace project saves frames");
|
||||
var still = Assert.NotNull(session.StillRequests(Mjpeg, VideoCodec.PngSequence, 1)).Single();
|
||||
Assert.Equal(JobKind.WorkspaceRender, still.Kind);
|
||||
var stillJob = Assert.NotNull(WorkspaceJobs.RenderParameters(new Job { Id = Guid.CreateVersion7(), Kind = still.Kind, ParametersJson = still.ParametersJson }));
|
||||
Assert.Equal((projectId, Server), (stillJob.ProjectId, stillJob.Server));
|
||||
var (frame, _) = ProcessingJobs.ReadRender(stillJob.RenderJson);
|
||||
Assert.True(frame.IsStill);
|
||||
Assert.Equal(1, frame.StillFrame);
|
||||
Assert.Equal(content.Frames[1].Sha256?.ToLowerInvariant(), frame.StillPhoto);
|
||||
Assert.Equal(("pngsequence", projectId), (frame.Codec, frame.ProjectId));
|
||||
Assert.NotNull(frame.SettingsJson, "the portable settings travel with the still");
|
||||
Assert.Null(frame.ProjectVersionId, "another export than the saved one: no version holds these settings");
|
||||
|
||||
// Queued on this PC's engine and listed beside the server's jobs (the render itself is the Data tests': this bed decodes nothing).
|
||||
var jobId = await source.SubmitAsync(request, bed.Ct);
|
||||
var queued = Assert.NotNull(await bed.Db.Jobs.GetAsync(jobId, bed.Ct));
|
||||
|
||||
@@ -170,7 +170,7 @@ public sealed class PlaybackRenderTests
|
||||
{
|
||||
var source = Source(4);
|
||||
var error = await Assert.ThrowsAsync<RenderException>(() => Pipeline().RenderAsync(Input(source), new RenderTarget(Preset("png-sequence"), "x.png", 4)));
|
||||
Assert.Equal("Tooltips.Export.StillNeedsFrame", error.ReasonKey);
|
||||
Assert.Equal("Export.Render.StillMissing", error.ReasonKey);
|
||||
Assert.Throws<RenderException>(() => Pipeline().Setup(Input(source), new RenderTarget(Preset("png-sequence"), "x.png", -1)));
|
||||
}
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ internal sealed class FakeSyncRemote : ISyncRemote
|
||||
{
|
||||
var sequence = Find(sequenceId);
|
||||
if (sequence.Renders.Any(r => r.Id == request.RenderId)) return null;
|
||||
var render = new FakeRender(request.RenderId, request.FileName, request.PresetName, bytes);
|
||||
var render = new FakeRender(request.RenderId, request.FileName, request.PresetName, bytes, request.Kind);
|
||||
sequence.Renders.Add(render);
|
||||
return render.Dto();
|
||||
}
|
||||
@@ -367,9 +367,13 @@ internal sealed class FakeSequence
|
||||
public FrameDto FrameDto(FakeFrame frame) => frame.Dto(Id, Frames.IndexOf(frame), Unhashed);
|
||||
}
|
||||
|
||||
internal sealed record FakeRender(Guid Id, string FileName, string PresetName, byte[] Bytes)
|
||||
/// <param name="Recorded">The SHA-256 the server records (its file's when null; empty: none, as before migration 0010).</param>
|
||||
internal sealed record FakeRender(Guid Id, string FileName, string PresetName, byte[] Bytes, string? Kind = null, string? Recorded = null)
|
||||
{
|
||||
public RenderDto Dto() => new(Id, PresetName, "hevc", 3840, 2160, 30, 12, Bytes.Length, new DateTimeOffset(2026, 9, 20, 21, 0, 0, TimeSpan.Zero), "Studio NAS");
|
||||
public string Sha256 => Recorded ?? Convert.ToHexStringLower(SHA256.HashData(Bytes));
|
||||
|
||||
public RenderDto Dto() => new(Id, PresetName, "hevc", 3840, 2160, 30, 12, Bytes.Length, new DateTimeOffset(2026, 9, 20, 21, 0, 0, TimeSpan.Zero), "Studio NAS",
|
||||
Sha256: Sha256.Length == 0 ? null : Sha256, Kind: Kind);
|
||||
}
|
||||
|
||||
internal sealed record FakeFrame(Guid Id, string FileName, byte[] Bytes, DateTime? CapturedAt)
|
||||
|
||||
@@ -633,10 +633,13 @@ public sealed class SyncTransferTests(TestContext context)
|
||||
var remote = f.Remote.Add("Star trails", photos);
|
||||
var render = new FakeRender(Guid.CreateVersion7(), "Star trails 4K.mp4", "4K HEVC", [.. Enumerable.Range(0, 5000).Select(i => (byte)i)]);
|
||||
remote.Renders.Add(render);
|
||||
var still = new FakeRender(Guid.CreateVersion7(), "Star trails - 0002.png", "PNG", [.. Enumerable.Range(0, 700).Select(i => (byte)(i * 5))], RenderKind.Still,
|
||||
Recorded: string.Empty);
|
||||
remote.Renders.Add(still);
|
||||
await f.Sync.LinkAsync(f.Server, remote.Id, local.Id, f.Ct);
|
||||
await f.RefreshAsync();
|
||||
var entry = await f.EntryAsync("Star trails");
|
||||
Assert.Equal((SyncStatus.InSync, 1, 5000L), (entry.Status, entry.Link!.ExportsToGet, entry.Link.ExportsToGetBytes));
|
||||
Assert.Equal((SyncStatus.InSync, 2, 5700L), (entry.Status, entry.Link!.ExportsToGet, entry.Link.ExportsToGetBytes));
|
||||
var engine = await f.StartEngineAsync();
|
||||
|
||||
var job = await f.Sync.EnqueueDownloadAsync(engine, f.Server, remote.Id, "Star trails", SyncDownloadMode.Exports, null);
|
||||
@@ -647,7 +650,43 @@ public sealed class SyncTransferTests(TestContext context)
|
||||
var file = f.Archive.Paths.FromRelative(fetched.OutputPath);
|
||||
Assert.Equal(Path.Combine(f.Archive.Paths.Sequence(local.Folder).Exports, "Star trails 4K.mp4"), file);
|
||||
Assert.SequenceEqual(render.Bytes, await File.ReadAllBytesAsync(file, f.Ct));
|
||||
Assert.Equal((render.Sha256, (string?)null), (fetched.Sha256, fetched.Kind), "the server's hash, checked on arrival");
|
||||
// A still the server has not hashed: its kind, and the hash of what arrived.
|
||||
var saved = Assert.Contains(await f.Db.Renders.ListBySequenceAsync(local.Id, f.Ct), r => r.Id == still.Id);
|
||||
Assert.Equal((Convert.ToHexStringLower(System.Security.Cryptography.SHA256.HashData(still.Bytes)), RenderKind.Still), (saved.Sha256, saved.Kind));
|
||||
Assert.Equal(0, (await f.EntryAsync("Star trails")).Link!.ExportsToGet);
|
||||
|
||||
// A file unlike the hash the server records is fetched again, then refused: nothing is filed.
|
||||
var damaged = new FakeRender(Guid.CreateVersion7(), "Star trails 1080p.mp4", "1080p", [1, 2, 3, 4], Recorded: new string('a', 64));
|
||||
remote.Renders.Add(damaged);
|
||||
remote.UpdatedAt = DateTimeOffset.UtcNow.AddSeconds(1);
|
||||
job = await f.Sync.EnqueueDownloadAsync(engine, f.Server, remote.Id, "Star trails", SyncDownloadMode.Exports, null);
|
||||
var failed = await f.Archive.WaitForAsync(job.Id, JobState.Failed);
|
||||
Assert.Equal(Loc.L("Errors.Sync.Hash", "Star trails 1080p.mp4"), failed.Error);
|
||||
Assert.Null(await f.Db.Renders.GetAsync(damaged.Id, f.Ct));
|
||||
Assert.False(File.Exists(Path.Combine(f.Archive.Paths.Sequence(local.Folder).Exports, "Star trails 1080p.mp4")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ASentRenderKeepsItsKind()
|
||||
{
|
||||
await using var f = await SyncFixture.CreateAsync(context);
|
||||
var photos = f.NewPhotos(2);
|
||||
var local = await f.LocalAsync("Harbour", photos);
|
||||
var remote = f.Remote.Add("Harbour", photos);
|
||||
await f.Sync.LinkAsync(f.Server, remote.Id, local.Id, f.Ct);
|
||||
var exports = f.Archive.Paths.Sequence(local.Folder).Exports;
|
||||
Directory.CreateDirectory(exports);
|
||||
byte[] bytes = [.. Enumerable.Range(0, 900).Select(i => (byte)(i * 11))];
|
||||
await File.WriteAllBytesAsync(Path.Combine(exports, "Harbour - 0001.png"), bytes, f.Ct);
|
||||
var still = await AddRenderAsync(f, local, "Harbour - 0001.png", bytes.Length, RenderKind.Still);
|
||||
await f.RefreshAsync();
|
||||
var engine = await f.StartEngineAsync();
|
||||
|
||||
var job = await f.Sync.EnqueueSendExportsAsync(engine, f.Server, local);
|
||||
await f.Archive.WaitForAsync(job.Id, JobState.Done);
|
||||
var sent = Assert.Contains(remote.Renders, r => r.Id == still.Id);
|
||||
Assert.Equal(RenderKind.Still, sent.Kind);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -1016,7 +1055,7 @@ public sealed class SyncTransferTests(TestContext context)
|
||||
Assert.Contains(Loc.L("Archive.Log.ProxiesSent", 3, 0), done.LogTail);
|
||||
}
|
||||
|
||||
private static async Task<Render> AddRenderAsync(SyncFixture f, Sequence local, string name, long bytes)
|
||||
private static async Task<Render> AddRenderAsync(SyncFixture f, Sequence local, string name, long bytes, string? kind = null)
|
||||
{
|
||||
var render = new Render
|
||||
{
|
||||
@@ -1032,6 +1071,7 @@ public sealed class SyncTransferTests(TestContext context)
|
||||
Bytes = bytes,
|
||||
Created = DateTimeOffset.UtcNow,
|
||||
ProducedBy = "studio",
|
||||
Kind = kind,
|
||||
};
|
||||
await f.Db.Renders.InsertAsync(render, f.Ct);
|
||||
return render;
|
||||
|
||||
Reference in new issue
Block a user