feat(editor): settings both sides changed on the server ask before anything is overwritten

BRIEF §14.5 asks for an explicit conflict prompt when both sides changed. A save
of a server sequence that meets settings someone changed to other values on the
server now stops (the change stays pending) and the editor asks: Keep mine saves
the editor's values over the server's, Take server (the safe default) shows the
server's values as one undoable step, so Ctrl+Z brings the editor's back. Both
first take in what only the server changed. Settings changed on one side only
still merge silently; a reload after an analysis never merges over a conflicting
pending change. The Export "Sync" box moves under Save to so neither is cut in
longer languages.

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-06 08:02:30 +00:00
1 parent 31c1a2d9c6
commit bda8e1fec2
13 files changed
+311 -32

No files matched your search

+21 -3
View File
@@ -24,8 +24,10 @@ namespace Titano.App.Editor;
/// A server sequence opened with proxies (BRIEF §4.4, §14.5 "edit with proxies, render where the originals are"):
/// frames and thumbnails from this PC's proxy cache (<see cref="RemoteSequence.OpenFrames"/>), the project from the
/// server's settings with their version, the deep analysis from the server's report. Saves send the settings with the
/// version they were made from; a 409 (someone changed them meanwhile) reads the server's settings and merges again as
/// the local archive does (<see cref="ProjectMerge"/>: the editor wins on members both changed). Nothing is written to a
/// version they were made from; a 409 (someone changed them meanwhile) reads the server's settings and merges again
/// (<see cref="ProjectMerge"/>) when the two changes touch different settings. A setting both changed to different
/// values is a conflict the user settles (BRIEF §14.5 "explicit conflict prompt"): <see cref="ProjectConflictException"/>,
/// and nothing is sent until the editor's next save names the server's settings as its basis. Nothing is written to a
/// local archive. Analyses and renders are server jobs; their state and progress come from the server's events.
/// Project settings name frames by position, so the cached frames must be the server's: a load that finds other frames
/// throws <see cref="ProxiesOutdatedException"/>, and frames that change on the server while the sequence is open make
@@ -139,10 +141,13 @@ public sealed class RemoteSequenceSource : ISequenceSource
for (var attempt = 1; ; attempt++)
{
var (stored, version) = Volatile.Read(ref _stored) ?? throw new InvalidOperationException("LoadAsync first.");
var merged = ProjectMerge.SameValues(stored, basis) ? project : ProjectMerge.Merge(basis, project, stored);
var changedThere = !ProjectMerge.SameValues(stored, basis);
var merged = changedThere ? ProjectMerge.Merge(basis, project, stored) : project;
if (ProjectMerge.SameValues(merged, stored)) return merged;
if (IsOutdated) throw new ProxiesOutdatedException(Loc.L("Editor.Error.FramesChanged"));
if (_noEditRight) throw new InvalidOperationException(Loc.L("Editor.Error.RemoteReadOnly"));
if (changedThere && ProjectMerge.Conflicts(basis, project, stored) is { Count: > 0 } conflicts)
throw new ProjectConflictException(Loc.L("Editor.Error.SaveConflict"), stored, conflicts);
var hero = merged.HeroFrame == stored.HeroFrame ? (Guid?)null : HeroFrameId(merged);
try
{
@@ -401,6 +406,19 @@ public sealed class RemoteSequenceSource : ISequenceSource
private sealed record Stored(ProjectSettings Project, int Version);
}
/// <summary>
/// Settings the editor changed were changed to other values on the server meanwhile (BRIEF §14.5): nothing is saved
/// until the user keeps the editor's values or takes the server's (<see cref="EditorSession.ResolveConflict"/>).
/// </summary>
/// <param name="server">The server's project now.</param>
/// <param name="differences">The settings both changed: the editor's value, then the server's.</param>
public sealed class ProjectConflictException(string message, ProjectSettings server, IReadOnlyList<SettingsDifference> differences) : IOException(message)
{
public ProjectSettings Server { get; } = server;
public IReadOnlyList<SettingsDifference> Differences { get; } = differences;
}
/// <summary>
/// The proxies of a server sequence are for frames the server no longer has (added or removed since they were fetched):
/// they must be fetched again before the sequence can be edited.