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

+29
View File
@@ -4,6 +4,7 @@ using System.Windows.Media;
using System.Windows.Threading;
using Titano.App.Infrastructure;
using Titano.App.Jobs;
using Titano.App.Server;
using Titano.App.Shell;
using Titano.Core.Advice;
using Titano.Core.Analysis;
@@ -116,6 +117,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
session.ProjectChanged += OnProjectChanged;
session.ContentChanged += OnContentChanged;
session.SaveFailed += OnSaveFailed;
session.ConflictFound += OnConflictFound;
session.Source.JobChanged += OnJobChanged;
session.Source.ReadOnlyChanged += OnReadOnlyChanged;
shell.Services.Sync.Changed += OnSyncChanged;
@@ -600,6 +602,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
Session.ProjectChanged -= OnProjectChanged;
Session.ContentChanged -= OnContentChanged;
Session.SaveFailed -= OnSaveFailed;
Session.ConflictFound -= OnConflictFound;
Session.Source.JobChanged -= OnJobChanged;
Session.Source.ReadOnlyChanged -= OnReadOnlyChanged;
Shell.Services.Sync.Changed -= OnSyncChanged;
@@ -816,6 +819,32 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
ActionCommand = new RelayCommand(() => _ = Session.FlushAsync()),
});
/// <summary>
/// A save met settings someone changed to other values on the server (BRIEF §14.5 "explicit conflict prompt"): the
/// dialog lists them; Keep mine overwrites the server's, Take server (the safe default, also on Esc) shows theirs as
/// one undoable step. Saving waits until then.
/// </summary>
private void OnConflictFound(ProjectConflictException conflict) => _dispatcher.BeginInvoke(() =>
{
if (_disposed || Session.Conflict is null) return;
var keepMine = Shell.Services.Dialogs.Confirm(ConflictRequest(conflict, Title, ServerName ?? string.Empty));
if (!_disposed) Session.ResolveConflict(keepMine);
});
/// <summary>The conflict prompt: what differs (the editor's value, then the server's) and what each choice replaces.</summary>
internal static ConfirmRequest ConflictRequest(ProjectConflictException conflict, string title, string server) => new()
{
Heading = Loc.L("Editor.Conflict.Title", server),
Message = Loc.L("Editor.Conflict.Message", title, server),
Detail = string.Join(Environment.NewLine, SyncText.Differences(conflict.Differences, 10)),
DetailToolTip = Loc.L("Tooltips.Server.Conflict.Detail"),
SafeText = Loc.L("Server.Sync.Action.TakeServer"),
SafeToolTip = Loc.L("Tooltips.Editor.Conflict.TakeServer", server),
ActionText = Loc.L("Server.Sync.Action.KeepMine"),
ActionToolTip = Loc.L("Tooltips.Editor.Conflict.KeepMine", server),
IsDestructive = true,
};
private void UpdateMarkers()
{
var content = Session.Content;