feat(app): workspace projects whose home is a server, pushed and pulled like this PC's archive

Owner review 2, R8, phase 5b (client part), ported onto the final phase 5a.
A Chronos Server with the "projects" capability is now the home of
workspace projects. A server sequence is edited in the workspace like a
local one, not inside the library, and its versions sync with the server
"like git".

- Data: ServerProjectHome is an IProjectHome over ChronosClient.
  - These are HomeUnavailableException, so the workspace shows Offline: a
    server out of reach, an expired sign-in, a 503 (lease, offline archive,
    projects_unreadable), a 409 folder_in_use, and a server without projects.
  - 404 sequence/project/version and refused names are ProjectException;
    other refusals keep their meaning.
  - A deleted project's head is 404 project, so final 5a's HeadAsync NotFound
    rule reads it as Gone. The original 5b's IsLiveAsync and
    WorkspaceStatus.Gone are dropped. IProjectHome gains rename and delete.
- Data: WorkspaceJobs.CopyFromServer downloads into the workspace, through
  the desktop's session, the proxies of one frames version (or the
  thumbnails standing in for them), with the aliases of the server's
  conversions. It is rebuilt on final 5a's copy handler:
  - the copy:frame:fv:folder checkpoint, EnsureSpace (from the server's proxy
    sizes), WritingMedia, and the cancelled-copy clean-up;
  - the editor's current file is never overwritten;
  - each file is hashed as it arrives and checked on disk, four at a time.
  It never writes this PC's archive. Originals are still refused until 5c.
- Data: SyncAgent passes on the server's projectChanged events, and after a
  lost event stream it reports that changes may have been missed.
- App: SyncHost gives the server home over one session client. The Server
  screen offers Open in workspace, disabled with its reason on older
  servers, whose sequences keep opening with proxies.
- App: Edit opens or checks out server projects with final 5a's refusals:
  unreadable copies, a disabled damaged or newer Main, a refused folder. The
  "sequence left the index" refusal now applies only to projects of this
  PC's archive.
- App: the picker and the chip follow projectChanged (Server newer, Not on
  server). Every state, conflict, delete, remove and failure text uses its
  ".Server" form when one exists (WorkspaceText.ForHome). That includes 5a's
  newer-format conflict, the save conflict, the taken-values toast, Gone and
  version-too-large.
- App: a render of a server project first offers to send what is not on the
  server, then renders the version the server holds. Offline, Gone, Damaged
  and missing media hold the render. Analyses and renders run as server jobs
  (ServerJobs, shared with RemoteSequenceSource).
- Pruning keeps final 5a's rule: a version is pruned only after HoldsAsync
  reads it back.
- Strings in en and it; ARCHITECTURE, DECISIONS and CHANGELOG.

Tests:
- ServerProjectHome error mapping, using a fake handler.
- Against the in-process server:
  - two workspaces on one project: fast-forward, replay and merge, keep mine,
    take server, save both, restore;
  - the copy job verifying, resuming and following new frames;
  - a project deleted on the server (Gone from its head; a push sends
    nothing);
  - an offline server.
- SyncAgent project events.
- App tests for the host, the project menu and renders of a server home.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-04 11:45:06 +01:00
1 parent e2ecc409a3
commit 26bab759fe
48 files changed
+3243 -409

No files matched your search

+74 -28
View File
@@ -53,6 +53,7 @@ public static class ProjectNames
public sealed class OpenInWorkspaceDialogViewModel : ArchiveDialogViewModel
{
private readonly TaskCompletionSource<OpenChoice?> _choice = new(TaskCreationOptions.RunContinuationsAsynchronously);
private readonly bool _server;
private ProjectOption? _selected;
private bool _isNew;
@@ -61,10 +62,12 @@ public sealed class OpenInWorkspaceDialogViewModel : ArchiveDialogViewModel
/// <param name="unreadable">
/// The projects whose copy here this Chronos cannot read (damaged, or a newer Chronos's), with why: listed, never chosen.
/// </param>
/// <param name="server">The sequence's home is a server (phase 5b): the texts name the server.</param>
public OpenInWorkspaceDialogViewModel(string sequenceTitle, IReadOnlyList<SequenceProject> projects, Action<ArchiveDialogViewModel> close,
IReadOnlyList<string>? taken = null, WorkspaceCopyFacts? copy = null, IReadOnlyDictionary<Guid, string>? unreadable = null)
IReadOnlyList<string>? taken = null, WorkspaceCopyFacts? copy = null, IReadOnlyDictionary<Guid, string>? unreadable = null, bool server = false)
: base(close)
{
_server = server;
SequenceTitle = sequenceTitle;
Copy = copy;
CopyFacts = copy is null ? []
@@ -138,6 +141,12 @@ public sealed class OpenInWorkspaceDialogViewModel : ArchiveDialogViewModel
public EditableField NewName { get; }
public string ExistingToolTip => WorkspaceText.ForHome("Tooltips.Editor.OpenWorkspace.Existing", _server);
public string ProjectsToolTip => WorkspaceText.ForHome("Tooltips.Editor.OpenWorkspace.Projects", _server);
public string ProxiesToolTip => WorkspaceText.ForHome("Tooltips.Editor.OpenWorkspace.Proxies", _server);
/// <summary>The proxies, the only media this phase copies.</summary>
public bool IsProxies => true;
@@ -176,13 +185,17 @@ public sealed class OpenInWorkspaceDialogViewModel : ArchiveDialogViewModel
public sealed class ProjectNameDialogViewModel : ArchiveDialogViewModel
{
private readonly Func<string, Task> _save;
private readonly bool _server;
/// <param name="others">The names of the sequence's other projects (each name is used once).</param>
public ProjectNameDialogViewModel(bool rename, string name, IEnumerable<string> others, Func<string, Task> save, Action<ArchiveDialogViewModel> close)
/// <param name="server">The project's home is a server (phase 5b): the texts name the server.</param>
public ProjectNameDialogViewModel(bool rename, string name, IEnumerable<string> others, Func<string, Task> save, Action<ArchiveDialogViewModel> close,
bool server = false)
: base(close)
{
IsRename = rename;
_save = save;
_server = server;
var taken = others.ToList();
Name = new EditableField(name, n => ProjectNames.Validate(n, taken), _ => { }, () => Loc.L("Tooltips.Editor.ProjectName.Name"));
Name.PropertyChanged += (_, _) =>
@@ -203,7 +216,7 @@ public sealed class ProjectNameDialogViewModel : ArchiveDialogViewModel
public ICommand SaveCommand { get; }
public string SaveToolTip => Name.Error ?? Loc.L(IsRename ? "Tooltips.Editor.ProjectName.Apply" : "Tooltips.Editor.ProjectName.Create");
public string SaveToolTip => Name.Error ?? WorkspaceText.ForHome(IsRename ? "Tooltips.Editor.ProjectName.Apply" : "Tooltips.Editor.ProjectName.Create", _server);
private async Task SaveAsync()
{
@@ -217,7 +230,7 @@ public sealed class ProjectNameDialogViewModel : ArchiveDialogViewModel
catch (Exception ex) when (ex is not OutOfMemoryException)
{
Log.Warning("workspace", "Naming a project failed", ex);
ShowMessage(WorkspaceText.Failure(ex), ex.Message);
ShowMessage(WorkspaceText.Failure(ex, _server), ex.Message);
}
finally
{
@@ -233,13 +246,16 @@ public sealed class SaveVersionDialogViewModel : ArchiveDialogViewModel
public const int MaxNoteLength = 200;
private readonly Func<string?, Task> _save;
private readonly bool _server;
private string _note = string.Empty;
public SaveVersionDialogViewModel(string projectName, Func<string?, Task> save, Action<ArchiveDialogViewModel> close)
/// <param name="server">The project's home is a server (phase 5b): the texts name the server.</param>
public SaveVersionDialogViewModel(string projectName, Func<string?, Task> save, Action<ArchiveDialogViewModel> close, bool server = false)
: base(close)
{
ProjectName = projectName;
_save = save;
_server = server;
SaveCommand = new AsyncRelayCommand(SaveAsync, () => !IsBusy);
}
@@ -247,6 +263,8 @@ public sealed class SaveVersionDialogViewModel : ArchiveDialogViewModel
public string Heading => Loc.L("Editor.SaveVersion.Title", ProjectName);
public string SaveToolTip => WorkspaceText.ForHome("Tooltips.Editor.SaveVersion.Save", _server);
public string Note
{
get => _note;
@@ -267,7 +285,7 @@ public sealed class SaveVersionDialogViewModel : ArchiveDialogViewModel
catch (Exception ex) when (ex is not OutOfMemoryException)
{
Log.Warning("workspace", "Saving a version failed", ex);
ShowMessage(WorkspaceText.Failure(ex), ex.Message);
ShowMessage(WorkspaceText.Failure(ex, _server), ex.Message);
}
finally
{
@@ -277,10 +295,13 @@ public sealed class SaveVersionDialogViewModel : ArchiveDialogViewModel
}
/// <summary>A version in the History flyout: number, author, time, note, what made it, and Compare and Restore.</summary>
public sealed class HistoryRowViewModel(ProjectVersion version, bool unsent, bool isCurrent, ICommand compare, ICommand restore) : ObservableObject
public sealed class HistoryRowViewModel(ProjectVersion version, bool unsent, bool isCurrent, ICommand compare, ICommand restore, bool server = false) : ObservableObject
{
public ProjectVersion Version { get; } = version;
/// <summary>"Saved here, waiting to be sent to the library" (the server, for a server's project).</summary>
public string NotSentToolTip => WorkspaceText.ForHome("Tooltips.Editor.History.NotSent", server);
public string Number => Formatting.Count(Version.Number);
public string Author => WorkspaceText.Author(Version);
@@ -317,17 +338,20 @@ public sealed class HistoryDialogViewModel : ArchiveDialogViewModel
{
private readonly Func<ProjectVersion, Task<IReadOnlyList<string>>> _compare;
private readonly Func<ProjectVersion, Task> _restore;
private readonly bool _server;
private string? _comparedTitle;
private IReadOnlyList<string> _compared = [];
private bool _isLoaded;
/// <param name="server">The project's home is a server (phase 5b): the texts name the server.</param>
public HistoryDialogViewModel(string projectName, Func<ProjectVersion, Task<IReadOnlyList<string>>> compare, Func<ProjectVersion, Task> restore,
Action<ArchiveDialogViewModel> close)
Action<ArchiveDialogViewModel> close, bool server = false)
: base(close)
{
ProjectName = projectName;
_compare = compare;
_restore = restore;
_server = server;
}
public string ProjectName { get; }
@@ -339,6 +363,11 @@ public sealed class HistoryDialogViewModel : ArchiveDialogViewModel
/// <summary>The home could not be asked: only this PC's versions are listed.</summary>
public bool IsOffline { get; private set; }
/// <summary>"Library offline", or "Server offline" for a server's project.</summary>
public string OfflineText => WorkspaceText.ForHome("Editor.History.Offline", _server);
public string OfflineToolTip => WorkspaceText.ForHome("Tooltips.Editor.History.Offline", _server);
public bool IsEmpty => _isLoaded && Rows.Count == 0;
/// <summary>"Version 3 → now" over the comparison; null before one.</summary>
@@ -355,7 +384,7 @@ public sealed class HistoryDialogViewModel : ArchiveDialogViewModel
{
var current = currentHash is not null && string.Equals(version.ContentHash, currentHash, StringComparison.OrdinalIgnoreCase);
Rows.Add(new HistoryRowViewModel(version, history.Unsent.Contains(version.Id), current,
new AsyncRelayCommand(() => CompareAsync(version), () => !IsBusy), new AsyncRelayCommand(() => RestoreAsync(version), () => !IsBusy)));
new AsyncRelayCommand(() => CompareAsync(version), () => !IsBusy), new AsyncRelayCommand(() => RestoreAsync(version), () => !IsBusy), _server));
}
IsOffline = history.Offline;
_isLoaded = true;
@@ -369,7 +398,7 @@ public sealed class HistoryDialogViewModel : ArchiveDialogViewModel
ArgumentNullException.ThrowIfNull(ex);
_isLoaded = true;
OnPropertyChanged(nameof(IsEmpty));
ShowMessage(WorkspaceText.Failure(ex), ex.Message);
ShowMessage(WorkspaceText.Failure(ex, _server), ex.Message);
}
public async Task CompareAsync(ProjectVersion version)
@@ -385,7 +414,7 @@ public sealed class HistoryDialogViewModel : ArchiveDialogViewModel
catch (Exception ex) when (ex is not OutOfMemoryException)
{
Log.Warning("workspace", $"Version {version.Number} could not be compared", ex);
ShowMessage(WorkspaceText.Failure(ex), ex.Message);
ShowMessage(WorkspaceText.Failure(ex, _server), ex.Message);
}
}
@@ -403,7 +432,7 @@ public sealed class HistoryDialogViewModel : ArchiveDialogViewModel
catch (Exception ex) when (ex is not OutOfMemoryException)
{
Log.Warning("workspace", $"Version {version.Number} could not be restored", ex);
ShowMessage(WorkspaceText.Failure(ex), ex.Message);
ShowMessage(WorkspaceText.Failure(ex, _server), ex.Message);
IsBusy = false;
}
}
@@ -418,10 +447,12 @@ public sealed class HistoryDialogViewModel : ArchiveDialogViewModel
public sealed class ConflictDialogViewModel : ArchiveDialogViewModel
{
private readonly Func<ConflictChoice, Task> _resolve;
private readonly bool _server;
/// <param name="newerFormat">The library holds a newer Chronos's settings: nothing is merged, Save both is the only choice.</param>
/// <param name="server">The project's home is a server (phase 5b): "Take server's", and the texts name the server.</param>
public ConflictDialogViewModel(string projectName, string siblingName, IReadOnlyList<string> differences, Func<ConflictChoice, Task> resolve,
Action<ArchiveDialogViewModel> close, bool newerFormat = false)
Action<ArchiveDialogViewModel> close, bool newerFormat = false, bool server = false)
: base(close)
{
ProjectName = projectName;
@@ -430,6 +461,7 @@ public sealed class ConflictDialogViewModel : ArchiveDialogViewModel
// The format's number says nothing to the user: the line names the cause.
Differences = newerFormat ? [Loc.L("Editor.Workspace.Conflict.NewerFormat")] : differences;
_resolve = resolve;
_server = server;
KeepMineCommand = new AsyncRelayCommand(() => ResolveAsync(ConflictChoice.KeepMine), () => !IsBusy && CanMerge);
TakeHomeCommand = new AsyncRelayCommand(() => ResolveAsync(ConflictChoice.TakeServer), () => !IsBusy && CanMerge);
SaveBothCommand = new AsyncRelayCommand(() => ResolveAsync(ConflictChoice.SaveBoth), () => !IsBusy);
@@ -446,13 +478,13 @@ public sealed class ConflictDialogViewModel : ArchiveDialogViewModel
/// <summary>The project Save both makes for this workspace's versions.</summary>
public string SiblingName { get; }
public string Heading => Loc.L("Editor.Workspace.Conflict.Title");
public string Heading => WorkspaceText.ForHome("Editor.Workspace.Conflict.Title", _server);
public string Message => Loc.L(IsNewerFormat ? "Editor.Workspace.Conflict.NewerMessage" : "Editor.Workspace.Conflict.Message", ProjectName);
public string Message => WorkspaceText.ForHome(IsNewerFormat ? "Editor.Workspace.Conflict.NewerMessage" : "Editor.Workspace.Conflict.Message", _server, ProjectName);
public IReadOnlyList<string> Differences { get; }
public string DifferencesToolTip => Loc.L(IsNewerFormat ? "Tooltips.Editor.Workspace.NewerFormat" : "Tooltips.Editor.Workspace.Differences");
public string DifferencesToolTip => WorkspaceText.ForHome(IsNewerFormat ? "Tooltips.Editor.Workspace.NewerFormat" : "Tooltips.Editor.Workspace.Differences", _server);
public ICommand KeepMineCommand { get; }
@@ -460,7 +492,14 @@ public sealed class ConflictDialogViewModel : ArchiveDialogViewModel
public ICommand SaveBothCommand { get; }
public string SaveBothToolTip => Loc.L(IsNewerFormat ? "Tooltips.Editor.Workspace.SaveBothNewer" : "Tooltips.Editor.Workspace.SaveBoth", SiblingName);
/// <summary>"Take library's", or "Take server's" for a server's project.</summary>
public string TakeHomeText => WorkspaceText.ForHome("Editor.Workspace.Conflict.TakeHome", _server);
public string TakeHomeToolTip => WorkspaceText.ForHome("Tooltips.Editor.Workspace.TakeHome", _server);
public string KeepMineToolTip => WorkspaceText.ForHome("Tooltips.Editor.Workspace.KeepMine", _server);
public string SaveBothToolTip => WorkspaceText.ForHome(IsNewerFormat ? "Tooltips.Editor.Workspace.SaveBothNewer" : "Tooltips.Editor.Workspace.SaveBoth", _server, SiblingName);
private async Task ResolveAsync(ConflictChoice choice)
{
@@ -475,7 +514,7 @@ public sealed class ConflictDialogViewModel : ArchiveDialogViewModel
catch (Exception ex) when (ex is not OutOfMemoryException)
{
Log.Warning("workspace", $"The conflict of '{ProjectName}' could not be settled ({choice})", ex);
ShowMessage(WorkspaceText.Failure(ex), ex.Message);
ShowMessage(WorkspaceText.Failure(ex, _server), ex.Message);
IsBusy = false;
}
}
@@ -493,15 +532,19 @@ public sealed class RemoveCopyDialogViewModel : ArchiveDialogViewModel
private readonly Func<bool, Task> _remove;
private readonly Func<Task> _sendFirst;
private readonly Func<bool> _confirmDiscard;
private readonly bool _server;
/// <param name="confirmDiscard">The typed confirmation Discard changes asks first (<see cref="ConfirmDiscard"/>); true when the user confirmed.</param>
public RemoveCopyDialogViewModel(WorkspaceRemovalPlan plan, Func<bool, Task> remove, Func<Task> sendFirst, Func<bool> confirmDiscard, Action<ArchiveDialogViewModel> close)
/// <param name="server">The project's home is a server (phase 5b): the texts name the server.</param>
public RemoveCopyDialogViewModel(WorkspaceRemovalPlan plan, Func<bool, Task> remove, Func<Task> sendFirst, Func<bool> confirmDiscard, Action<ArchiveDialogViewModel> close,
bool server = false)
: base(close)
{
Plan = plan;
_remove = remove;
_sendFirst = sendFirst;
_confirmDiscard = confirmDiscard;
_server = server;
Facts =
[
new DialogFact(Loc.L("Editor.RemoveCopy.Files"), Formatting.Count(plan.Files)),
@@ -532,19 +575,22 @@ public sealed class RemoveCopyDialogViewModel : ArchiveDialogViewModel
public ICommand DiscardCommand { get; }
/// <summary>What happens to the copy and the project, worded for the project's home.</summary>
public string Message => WorkspaceText.ForHome("Editor.RemoveCopy.Message", _server);
public string RemoveToolTip => Plan.Damaged ? Loc.L("Errors.Workspace.Damaged")
: Plan.Gone ? Loc.L("Errors.Workspace.ProjectGone")
: !Plan.IsSafe ? Loc.L("Errors.Workspace.Unsent")
: Plan.Offline ? Loc.L("Errors.Workspace.Offline")
: Loc.L("Tooltips.Editor.RemoveCopy.Remove");
: Plan.Gone ? WorkspaceText.ForHome("Errors.Workspace.ProjectGone", _server)
: !Plan.IsSafe ? WorkspaceText.ForHome("Errors.Workspace.Unsent", _server)
: Plan.Offline ? WorkspaceText.ForHome("Errors.Workspace.Offline", _server)
: WorkspaceText.ForHome("Tooltips.Editor.RemoveCopy.Remove", _server);
public string SendFirstToolTip => Plan.Damaged ? Loc.L("Errors.Workspace.Damaged")
: Plan.Gone ? Loc.L("Errors.Workspace.ProjectGone")
: Plan.Gone ? WorkspaceText.ForHome("Errors.Workspace.ProjectGone", _server)
: Plan.Conflict ? Loc.L("Errors.Workspace.Conflict")
: Plan.Offline ? Loc.L("Errors.Workspace.Offline")
: Loc.L("Tooltips.Editor.RemoveCopy.SendFirst");
: Plan.Offline ? WorkspaceText.ForHome("Errors.Workspace.Offline", _server)
: WorkspaceText.ForHome("Tooltips.Editor.RemoveCopy.SendFirst", _server);
public string DiscardToolTip => Loc.L("Tooltips.Editor.RemoveCopy.Discard");
public string DiscardToolTip => WorkspaceText.ForHome("Tooltips.Editor.RemoveCopy.Discard", _server);
/// <summary>
/// The typed confirmation of Discard changes (the plan's cross-cutting rule for what Chronos cannot bring back): the
@@ -614,7 +660,7 @@ public sealed class RemoveCopyDialogViewModel : ArchiveDialogViewModel
catch (Exception ex) when (ex is not OutOfMemoryException)
{
Log.Warning("workspace", $"The local copy of project {Plan.ProjectId} was not removed", ex);
ShowMessage(WorkspaceText.Failure(ex), ex.Message);
ShowMessage(WorkspaceText.Failure(ex, _server), ex.Message);
IsBusy = false;
}
}