fix(workspace): settle only the conflict shown, keep what a choice replaces, desktop gaps of phase 5a

Review 2, phase 5a, fix round 1 (desktop and the engine side of Resolve and Restore).

- Resolve applies Keep mine / Take the library's only to the conflict the dialog listed:
  when the head or what differs moved since, the new conflict is recorded and asked again;
  Sync re-works a pending conflict instead of re-showing a stale list. Take the library's
  first saves uncommitted changes as a version, and the editor takes it as one undo step
  (toast Undo, Ctrl+Z) that brings back only the settings both changed.
- Restore saves unsaved changes as a version also while a conflict waits; a restore that
  changed nothing, or was undone, no longer marks the next version as a Restore.
- The editor's saves and merges of a workspace project merge positions photo by photo
  (portable form) and ask where both sides changed a setting, never deciding for ours.
- Read-only after a pull is signalled, and no save that can never be stored is left behind.
- The chip is read again after edits; a background conflict waits for the open dialog;
  Send first and Delete show the conflict they met; Discard changes needs the typed name.
- Open project... reaches the library's other projects (Save both's sibling, also from
  its toast); copies whose project or sequence is gone read Not in library and can be
  removed from the picker's Workspace rows; a delete whose local copy stays says so.
- A workspace folder inside a library is refused before anything is written.
- Conflict and Compare lines name heroes, exclusions and keyframes; History shows the PC
  name alone, never the program's prefixes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-03 10:22:17 +01:00
1 parent 50e28fd63d
commit 8027d84f7e
28 files changed
+1321 -134

No files matched your search

+70 -1
View File
@@ -54,6 +54,9 @@ public sealed class SequenceViewModel : SectionViewModel
private PendingOpen? _fetch;
private ArchiveDialogViewModel? _dialog;
/// <summary>Dialogs that show once the open one closes (<see cref="OpenDialogWhenFree"/>), oldest first.</summary>
private readonly Queue<ArchiveDialogViewModel> _waiting = new();
/// <summary>The project the next open of its sequence takes (the picker's Workspace group, a project file, the project menu).</summary>
private ProjectRequest? _requested;
@@ -374,6 +377,7 @@ public sealed class SequenceViewModel : SectionViewModel
Shell.PropertyChanged -= OnShellChanged;
StopFetch();
_dialog?.Dispose();
while (_waiting.TryDequeue(out var waiting)) waiting.Dispose();
Editor?.Dispose();
Picker.Dispose();
base.Dispose();
@@ -386,12 +390,65 @@ public sealed class SequenceViewModel : SectionViewModel
Dialog = dialog;
}
/// <summary>Closes <paramref name="dialog"/> if it is still the open one.</summary>
/// <summary>
/// Shows <paramref name="dialog"/> now when no dialog is open, else once the open one (and those waiting before it)
/// closed: what the background found (a conflict an automatic sync met) never replaces what the user is doing.
/// </summary>
internal void OpenDialogWhenFree(ArchiveDialogViewModel dialog)
{
if (_dialog is null) OpenDialog(dialog);
else _waiting.Enqueue(dialog);
}
/// <summary>Closes <paramref name="dialog"/> if it is still the open one; the next one waiting shows (one closed meanwhile is skipped).</summary>
internal void CloseDialog(ArchiveDialogViewModel dialog)
{
if (!ReferenceEquals(_dialog, dialog)) return;
dialog.Dispose();
Dialog = null;
while (_waiting.TryDequeue(out var next))
{
if (next.IsClosed) continue;
OpenDialog(next);
break;
}
}
/// <summary>
/// "Remove local copy" of a project of the picker's Workspace group: the open project's goes through its menu; another,
/// even one that cannot open (its copy failed, or the library no longer has it), gets the same plan and choices here.
/// </summary>
public async Task RemoveProjectCopyAsync(WorkspaceProjectItem item)
{
ArgumentNullException.ThrowIfNull(item);
if (_editor?.Project is { } menu && menu.ProjectId == item.ProjectId)
{
menu.RemoveCopyCommand.Execute(null);
return;
}
var workspace = Shell.Services.Workspace;
var (projectId, name) = (item.ProjectId, item.Name);
try
{
var plan = await workspace.PlanRemovalAsync(projectId);
OpenDialog(new RemoveCopyDialogViewModel(plan, discard => RemoveCopyAsync(projectId, name, discard), async () =>
{
await workspace.SendAllAsync(projectId);
await RemoveCopyAsync(projectId, name, discard: false);
}, () => RemoveCopyDialogViewModel.ConfirmDiscard(_workspaceUi, name), d => CloseDialog(d)));
}
catch (Exception ex) when (ex is not OutOfMemoryException)
{
Log.Warning("workspace", $"The removal of project {projectId} could not be planned", ex);
Shell.Notify(Loc.L("Editor.Workspace.RemoveFailed"), WorkspaceText.Failure(ex), isError: true);
}
async Task RemoveCopyAsync(Guid id, string project, bool discard)
{
await workspace.RemoveLocalCopyAsync(id, discard);
Shell.Notify(Loc.L("Editor.Workspace.Removed"), project);
_ = Picker.ReloadAsync();
}
}
protected override void OnActivated()
@@ -485,6 +542,14 @@ public sealed class SequenceViewModel : SectionViewModel
local.HeroChanged += OnHeroChanged;
return (local, row.DisplayTitle);
}
// A workspace project whose sequence left the index (its trash emptied, its folder gone): not a server's sequence to
// fetch; its local copy can only be removed (the picker's Remove local copy).
if (_requested is { ProjectId: { } projectId } asked && asked.SequenceId == sequenceId && services.Workspace.IsEnabled
&& await services.Workspace.FindAsync(projectId) is not null)
{
_requested = null;
throw new InvalidOperationException(Loc.L("Errors.Workspace.SequenceGone"));
}
var sync = services.Sync;
if (sync.Server is not { } server || sync.Service is not { } service || sync.ConnectEditor() is not { } api)
throw new InvalidOperationException(Loc.L("Editor.Error.SignedOut"));
@@ -758,8 +823,12 @@ public sealed class SequenceViewModel : SectionViewModel
/// <summary>What the project menu of an editor of this section asks of it: its dialogs, the shell's confirmations and toasts, opening and closing projects.</summary>
private sealed class WorkspaceUi(SequenceViewModel section) : IWorkspaceUi
{
public ArchiveDialogViewModel? Dialog => section.Dialog;
public void ShowDialog(ArchiveDialogViewModel dialog) => section.OpenDialog(dialog);
public void ShowDialogWhenFree(ArchiveDialogViewModel dialog) => section.OpenDialogWhenFree(dialog);
public void CloseDialog(ArchiveDialogViewModel dialog) => section.CloseDialog(dialog);
public bool Confirm(ConfirmRequest request) => section.Shell.Services.Dialogs.Confirm(request);