feat(editor): accounts without the Edit right open server sequences read-only
The Server screen offers Open with proxies to viewers; the editor now shows the sequence with every change disabled and the reason in the tooltips, the session refuses edits, undo and Optimise, and the source refuses to store a change. Render says when the account may not render on the server. The event listener stops cleanly when the editor closes and a late progress event no longer brings a finished job back to running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
17 files changed
+151
-67
No files matched your search
@@ -86,6 +86,8 @@ internal sealed class FakeSequenceSource(SyntheticSequence sequence, SequenceCon
|
||||
/// <summary>A server sequence: renders become one job per preset.</summary>
|
||||
public bool IsRemote { get; init; }
|
||||
|
||||
public bool IsReadOnly { get; init; }
|
||||
|
||||
/// <summary>Jobs <see cref="ListJobsAsync"/> returns.</summary>
|
||||
public List<Job> Jobs { get; } = [];
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ using Titano.App.Infrastructure;
|
||||
using Titano.App.Sections;
|
||||
using Titano.App.Shell;
|
||||
using Titano.App.Tests.Windows;
|
||||
using Titano.Core.Export;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Core.Project;
|
||||
using Titano.Testing;
|
||||
@@ -197,6 +199,20 @@ public sealed class EditorSmokeTests
|
||||
await editor.RenderAsync(JobPriority.User, batch: false);
|
||||
var queued = Assert.Contains(await editor.Session.Source.ListJobsAsync(CancellationToken.None), _ => true);
|
||||
Assert.Equal(JobKind.Render, queued.Kind);
|
||||
|
||||
// Without the Edit right a server sequence is only shown: every change is disabled and says why.
|
||||
var content = EditorFixture.Content(EditorFixture.Sunset);
|
||||
var looking = new EditorSession(new FakeSequenceSource(EditorFixture.Sunset, content) { IsRemote = true, IsReadOnly = true }, content, []);
|
||||
var viewer = new EditorViewModel(shell, looking, [], EncoderHost.Client);
|
||||
await using (viewer)
|
||||
{
|
||||
Assert.False(viewer.IsEditable);
|
||||
Assert.Equal(Loc.L("Tooltips.Editor.ReadOnly"), viewer.LockedToolTip);
|
||||
Assert.Equal(Loc.L("Tooltips.Editor.ReadOnly"), viewer.Frames.HeroToolTip);
|
||||
Assert.False(viewer.Frames.SetHeroCommand.CanExecute(null));
|
||||
Assert.False(viewer.OptimiseAllCommand.CanExecute(null));
|
||||
Assert.False(viewer.AnalyseCommand.CanExecute(null));
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -148,6 +148,33 @@ public sealed class RemoteSequenceSourceTests(TestContext context)
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AnAccountWithoutTheEditRightOnlyLooks()
|
||||
{
|
||||
var (source, api, _) = Open(readOnly: true);
|
||||
await using (source)
|
||||
{
|
||||
var content = await source.LoadAsync(context.Cancellation);
|
||||
Assert.True(source.IsReadOnly);
|
||||
var session = new EditorSession(source, content, [], TimeSpan.FromMilliseconds(20));
|
||||
await using (session)
|
||||
{
|
||||
Assert.True(session.IsReadOnly);
|
||||
Assert.False(session.Edit(p => p with { Exposure = p.Exposure with { ExposureOffsetEv = 0.5 } }));
|
||||
Assert.False(session.SetHero(3));
|
||||
Assert.Empty(session.OptimiseAll());
|
||||
Assert.False(session.Undo());
|
||||
Assert.True(await session.FlushAsync(), "nothing waits for a save");
|
||||
}
|
||||
|
||||
// The source refuses a change as well; the same project is no change.
|
||||
await Assert.ThrowsAsync<InvalidOperationException>(() =>
|
||||
source.SaveProjectAsync(content.Project with { HeroFrame = 1 }, content.Project, context.Cancellation));
|
||||
Assert.True(ProjectMerge.SameValues(content.Project, await source.SaveProjectAsync(content.Project, content.Project, context.Cancellation)));
|
||||
Assert.Empty(api.Edits);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AnalysesAndRendersArePostedToTheServerOnePerPreset()
|
||||
{
|
||||
@@ -220,6 +247,13 @@ public sealed class RemoteSequenceSourceTests(TestContext context)
|
||||
api.Jobs[other] = api.Job(other, "render", "queued");
|
||||
api.Jobs[foreign] = api.Job(foreign, "render", "queued", Guid.CreateVersion7());
|
||||
Assert.SequenceEqual([other], (await source.ListJobsAsync(context.Cancellation)).Select(j => j.Id), "active jobs of this sequence only");
|
||||
|
||||
// A late progress event of the finished job does not bring it back to running.
|
||||
api.Publish(new JobProgressEvent(id, 19, 20, 2.5, 1));
|
||||
api.Jobs[other] = api.Job(other, "render", "running");
|
||||
api.Publish(new JobStateEvent(other, "running", null));
|
||||
await WaitAsync(() => Last(seen).Id == other);
|
||||
lock (seen) Assert.Equal(JobState.Done, seen.Last(j => j.Id == id).State);
|
||||
}
|
||||
Assert.True(api.Disposed, "closing the editor closes its connection");
|
||||
}
|
||||
@@ -237,11 +271,13 @@ public sealed class RemoteSequenceSourceTests(TestContext context)
|
||||
}
|
||||
}
|
||||
|
||||
private (RemoteSequenceSource Source, FakeRemoteSequenceApi Api, RemoteSequence Remote) Open(int frames = 6, int cached = int.MaxValue) =>
|
||||
Open(EditorFixture.Sequence(frames), cached);
|
||||
private (RemoteSequenceSource Source, FakeRemoteSequenceApi Api, RemoteSequence Remote) Open(int frames = 6, int cached = int.MaxValue,
|
||||
bool readOnly = false) =>
|
||||
Open(EditorFixture.Sequence(frames), cached, readOnly);
|
||||
|
||||
/// <summary>A server sequence whose first <paramref name="cached"/> proxies are on this PC (synthetic JPEGs).</summary>
|
||||
private (RemoteSequenceSource Source, FakeRemoteSequenceApi Api, RemoteSequence Remote) Open(SyntheticSequence sunset, int cached = int.MaxValue)
|
||||
private (RemoteSequenceSource Source, FakeRemoteSequenceApi Api, RemoteSequence Remote) Open(SyntheticSequence sunset, int cached = int.MaxValue,
|
||||
bool readOnly = false)
|
||||
{
|
||||
var folder = context.CreateTempDirectory("proxies");
|
||||
var sequence = new Sequence
|
||||
@@ -265,7 +301,7 @@ public sealed class RemoteSequenceSourceTests(TestContext context)
|
||||
}
|
||||
var remote = new RemoteSequence(Server, sequence, frames, files);
|
||||
var api = new FakeRemoteSequenceApi(sequence) { SettingsJson = new ProjectSettings().ToJson() };
|
||||
return (new RemoteSequenceSource(remote, api, DecoderFactory.CreateClient(null)), api, remote);
|
||||
return (new RemoteSequenceSource(remote, api, DecoderFactory.CreateClient(null), readOnly), api, remote);
|
||||
}
|
||||
|
||||
private static Job Last(List<Job> seen)
|
||||
|
||||
Reference in new issue
Block a user