fix: phase 5a fix round 3, desktop: newer copies, readable discard, working-state conflicts, edits kept aside

Owner review 2, R8. Round 2's checkers left five desktop problems:

- A workspace copy whose project.chronos a newer Chronos wrote (a format
  this one does not know) was listed as damaged and offered for Discard.
  It is now listed as "Newer Chronos" with its own tooltip, named from
  what of its file still reads. It never opens, is never checked out
  over, and Remove local copy refuses it with a sentence that says why.
- Discard of any copy moved only the files Chronos knows. It now moves
  every file and folder of the copy aside (only the media are deleted)
  and removes the folder only when nothing else came into it.
- Discarding a damaged copy asked to type its folder's GUID. It now asks
  for the name the copy is still known by (its file, else the library's
  index; the project's name, else the sequence's title), else for the
  number of its files. The heading never shows the id.
- A conflict at a path where the working state had gone back to the base
  value listed the local version's value. The conflict now lists the
  working state's value in every case. Where the working state already
  holds the library's value there is nothing to ask: that path takes the
  library's value in the replayed versions too, so they agree.
- EditorSession.ReloadAsync, ResolveConflict and TakeOverAsync threw
  NewerSettingsException on every reload when an edit was not stored
  yet and the stored project became a newer Chronos's. The edit is now
  kept in versions/.replaced (outside the chain, never sent), a toast
  says so, the pending save is dropped and the newer settings are shown
  read-only. When the edit cannot be kept aside, the editor stays as it
  is and nothing is dropped.

The SequenceViewModel wiring now has a view-model test: the copy's facts
in Open in workspace, the refused-folder toast and its Choose folder
action, and the picker for a newer copy and a damaged one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-03 12:55:13 +01:00
1 parent 488b588ad9
commit e8ea858021
21 files changed
+696 -54

No files matched your search

@@ -150,6 +150,66 @@ public abstract class WorkspaceConflictTests(TestContext context) : DatabaseTest
Assert.Equal(1.0, (await two.OpenAsync(id, fx.Ct)).Working.Exposure.ExposureOffsetEv, "the value listed as this side's is kept");
}
[Test]
public async Task AWorkingStateBackAtTheBaseValueIsListedAndKeptAsItIs()
{
var fx = await FixtureAsync();
var (_, one) = fx.Workspace("one");
var (_, two) = fx.Workspace("two");
var id = (await fx.CheckoutAsync(one)).ProjectId;
await fx.CheckoutAsync(two, id);
var basis = (await two.OpenAsync(id, fx.Ct)).Working.Exposure.ExposureOffsetEv;
await EditAsync(one, id, s => Offset(s, 0.5), fx.Ct);
await one.CommitAsync(id, cancellationToken: fx.Ct);
await one.PushAsync(id, fx.Home, fx.Ct);
// This side saved 0.8 as a version, then went back to the base value without saving.
await EditAsync(two, id, s => Offset(s, 0.8), fx.Ct);
await two.CommitAsync(id, "warmer", cancellationToken: fx.Ct);
await EditAsync(two, id, s => Offset(s, basis), fx.Ct);
var shown = Assert.NotNull((await two.PullAsync(id, fx.Home, fx.Ct)).Status.Conflict);
var difference = shown.Differences.Single();
Assert.Equal(("exposure.exposureOffsetEv", basis, 0.5), (difference.Path, Number(difference.Mine) ?? 0, Number(difference.Theirs)),
"this side's value is the working state's, not the version's 0.8");
var settled = await two.ResolveAsync(id, fx.Home, ConflictChoice.KeepMine, shown: shown, cancellationToken: fx.Ct);
Assert.Null(settled.Status.Conflict, "one answer settles what was shown");
Assert.Equal(basis, (await two.OpenAsync(id, fx.Ct)).Working.Exposure.ExposureOffsetEv, "the value listed as this side's is the one kept");
Assert.True(settled.Status.Modified, "the saved version keeps its own value; the working state's is not saved yet");
Assert.Equal("warmer", two.Unpushed(id).Single().Note);
await two.CommitAsync(id, cancellationToken: fx.Ct);
await two.PushAsync(id, fx.Home, fx.Ct);
Assert.Equal(basis, ProjectSettings.FromJson((await fx.Home.HeadAsync(id, fx.Ct)).SettingsJson).Exposure.ExposureOffsetEv, "the library ends with the value kept");
}
[Test]
public async Task AWorkingStateHoldingTheLibrarysValueIsNoConflictAndItsVersionAgrees()
{
var fx = await FixtureAsync();
var (_, one) = fx.Workspace("one");
var (_, two) = fx.Workspace("two");
var id = (await fx.CheckoutAsync(one)).ProjectId;
await fx.CheckoutAsync(two, id);
await EditAsync(one, id, s => Offset(s, 0.5), fx.Ct);
await one.CommitAsync(id, cancellationToken: fx.Ct);
await one.PushAsync(id, fx.Home, fx.Ct);
// This side saved 0.8 and a stack as a version, then set the offset to the library's own 0.5 without saving.
await EditAsync(two, id, s => Stack(Offset(s, 0.8), StackSetting.Mean), fx.Ct);
await two.CommitAsync(id, "local", cancellationToken: fx.Ct);
await EditAsync(two, id, s => Offset(s, 0.5), fx.Ct);
var pulled = await two.PullAsync(id, fx.Home, fx.Ct);
Assert.Null(pulled.Status.Conflict, "nothing to choose: the working state holds the library's value");
var working = (await two.OpenAsync(id, fx.Ct)).Working;
Assert.Equal((0.5, StackSetting.Mean), (working.Exposure.ExposureOffsetEv, working.Stack.Mode), "the working state is unchanged");
var replayed = ProjectSettings.FromJson(two.Unpushed(id).Single().SettingsJson);
Assert.Equal((0.5, StackSetting.Mean), (replayed.Exposure.ExposureOffsetEv, replayed.Stack.Mode), "the replayed version agrees with the working state");
Assert.True(pulled.Status is { State: WorkspaceState.Ahead, Modified: false }, "nothing left unsaved");
await two.PushAsync(id, fx.Home, fx.Ct);
var head = ProjectSettings.FromJson((await fx.Home.HeadAsync(id, fx.Ct)).SettingsJson);
Assert.Equal((0.5, StackSetting.Mean), (head.Exposure.ExposureOffsetEv, head.Stack.Mode));
}
private static double? Number(string? json) => json is null ? null : double.Parse(json, System.Globalization.CultureInfo.InvariantCulture);
[Test]