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
@@ -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