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:
Claude committed 2026-10-03 16:43:47 +00:00
1 parent 51fb84700e
commit 9cbfaae10d
17 files changed
+151 -67

No files matched your search

+27 -24
View File
@@ -46,13 +46,15 @@ public sealed class RemoteSequenceSource : ISequenceSource
private int _version;
private int _disposed;
public RemoteSequenceSource(RemoteSequence remote, IRemoteSequenceApi api, ImageDecoder decoder)
/// <param name="readOnly">The account may look at the sequence but not change it (no Edit right on the server).</param>
public RemoteSequenceSource(RemoteSequence remote, IRemoteSequenceApi api, ImageDecoder decoder, bool readOnly = false)
{
ArgumentNullException.ThrowIfNull(remote);
ArgumentNullException.ThrowIfNull(api);
ArgumentNullException.ThrowIfNull(decoder);
_remote = remote;
_api = api;
IsReadOnly = readOnly;
_frames = remote.OpenFrames(decoder);
_pixels = (IFrameSource)_frames;
var stopping = _stopping.Token;
@@ -61,6 +63,8 @@ public sealed class RemoteSequenceSource : ISequenceSource
public bool IsRemote => true;
public bool IsReadOnly { get; }
public event Action<Job>? JobChanged;
/// <summary>The server sequence's id.</summary>
@@ -126,6 +130,7 @@ public sealed class RemoteSequenceSource : ISequenceSource
var stored = _stored ?? throw new InvalidOperationException("LoadAsync first.");
var merged = ProjectMerge.SameValues(stored, basis) ? project : ProjectMerge.Merge(basis, project, stored);
if (ProjectMerge.SameValues(merged, stored)) return merged;
if (IsReadOnly) throw new InvalidOperationException(Loc.L("Editor.Error.RemoteReadOnly"));
var hero = merged.HeroFrame == stored.HeroFrame ? (Guid?)null : HeroFrameId(merged);
try
{
@@ -175,33 +180,30 @@ public sealed class RemoteSequenceSource : ISequenceSource
private async Task ListenAsync(CancellationToken cancellationToken)
{
var failures = 0;
while (!cancellationToken.IsCancellationRequested)
try
{
try
while (true)
{
await foreach (var e in _api.EventsAsync(cancellationToken).ConfigureAwait(false))
try
{
failures = 0;
await OnEventAsync(e, cancellationToken).ConfigureAwait(false);
await foreach (var e in _api.EventsAsync(cancellationToken).ConfigureAwait(false))
{
failures = 0;
await OnEventAsync(e, cancellationToken).ConfigureAwait(false);
}
}
catch (Exception ex) when (ex is not OutOfMemoryException && !cancellationToken.IsCancellationRequested)
{
Log.Info("editor", $"Events of the server lost for {_remote.Sequence.DisplayTitle}: {ex.Message}");
}
var delay = Math.Min(MaxBackoff.Ticks, MinBackoff.Ticks << Math.Min(failures++, 10));
await Task.Delay(TimeSpan.FromTicks(delay), cancellationToken).ConfigureAwait(false);
await RefreshTrackedAsync(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
{
return;
}
catch (Exception ex) when (ex is not OutOfMemoryException)
{
Log.Info("editor", $"Events of the server lost for {_remote.Sequence.DisplayTitle}: {ex.Message}");
}
try
{
await Task.Delay(TimeSpan.FromTicks(Math.Min(MaxBackoff.Ticks, MinBackoff.Ticks << Math.Min(failures++, 10))), cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
return;
}
await RefreshTrackedAsync(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
{
// The editor closed.
}
}
@@ -209,7 +211,8 @@ public sealed class RemoteSequenceSource : ISequenceSource
{
switch (e)
{
case JobProgressEvent progress when _jobs.TryGetValue(progress.JobId, out var job):
// A late progress event never brings a finished job back to running.
case JobProgressEvent progress when _jobs.TryGetValue(progress.JobId, out var job) && job.State is JobState.Queued or JobState.Running:
Publish(job with
{
State = JobState.Running,