feat: owner review 2 phase 5b: the server as a project home (#17)
CI / Build and test (push) Successful in 9m58s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 14m8s
CI / PostgreSQL 16 integration (push) Successful in 8m55s
CI / PostgreSQL 17 integration (push) Successful in 8m50s
CI / Docker image (push) Successful in 57s
Release / Server image (push) Successful in 1m22s
CI / Build and test (push) Successful in 9m58s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 14m8s
CI / PostgreSQL 16 integration (push) Successful in 8m55s
CI / PostgreSQL 17 integration (push) Successful in 8m50s
CI / Docker image (push) Successful in 57s
Release / Server image (push) Successful in 1m22s
A Chronos Server keeps its sequences' projects, as a PC's archive does: Main and named projects with versions under /api/v1/sequences/{id}/projects, the projects capability and the projectChanged event. The desktop opens a server's sequences in the workspace (proxies downloaded, hash-checked, resumable) with Save version, Sync, conflicts, History, Restore and the project actions against the server. Renders can be of a project version. The admin panel lists a sequence's projects and versions. Strings in all 38 languages.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #17.
This commit is contained in:
1 parent
255e149087
commit
81c303f484
325 files changed
+11477
-516
No files matched your search
@@ -14,8 +14,10 @@ using Chronos.Core.Imaging;
|
||||
using Chronos.Core.Imaging.Decoders;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Data;
|
||||
using Chronos.Data.Jobs;
|
||||
using Chronos.Data.Projects;
|
||||
using Chronos.Data.Sync;
|
||||
using Chronos.Protocol.Client;
|
||||
using Chronos.Ui.Mvvm;
|
||||
@@ -27,9 +29,11 @@ namespace Chronos.App.Sections;
|
||||
/// Server screen or its own picker chose into an <see cref="EditorViewModel"/>. A sequence of this PC's archive opens as a
|
||||
/// project of the workspace (owner review 2, R8: editing never happens inside the library): the project of that sequence
|
||||
/// opened last here; else, after "Open in workspace" asked which project (Main, another of its home, or a new one) and
|
||||
/// which media, the project is checked out and its media copied by a job, and it opens once they are here. A server
|
||||
/// sequence opens with this PC's proxies (the workspace takes server homes in phase 5b), and a capture (sample data
|
||||
/// without an engine) opens the library as before. The next sequence is read first; only then does the open one close,
|
||||
/// which media, the project is checked out and its media copied by a job, and it opens once they are here. A sequence of
|
||||
/// a server that keeps projects opens the same way as a project whose home is that server (phase 5b: its media downloaded
|
||||
/// into the workspace; a project already there opens from it, the server reachable or not); one of an older server opens
|
||||
/// with this PC's proxies, and a capture (sample data without an engine) opens the library as before. The next sequence
|
||||
/// is read first; only then does the open one close,
|
||||
/// after its last edit is stored. Without a sequence, or after Change sequence, it shows the picker (the editor stays
|
||||
/// open behind it until another sequence opens). A server sequence whose proxies are missing or out of date fetches them
|
||||
/// first and opens once they are here, the open sequence staying open meanwhile; a workspace copy is followed the same
|
||||
@@ -540,9 +544,10 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
|
||||
/// <summary>
|
||||
/// Where <paramref name="sequenceId"/> lives: this PC's index (opened as a workspace project,
|
||||
/// <see cref="OpenWorkspaceAsync"/>; in a capture, the library itself), else a sequence of the signed-in server whose
|
||||
/// proxies this PC keeps (Server screen, "Open with proxies"), edited through the server (BRIEF §14.5), or only shown
|
||||
/// when the account may not change it. Null when it cannot open yet: its proxies are being fetched
|
||||
/// <see cref="OpenWorkspaceAsync"/>; in a capture, the library itself), else a server's sequence: a workspace project
|
||||
/// whose home is that server (<see cref="OpenServerWorkspaceAsync"/>), or, for a server that keeps no projects, one
|
||||
/// whose proxies this PC keeps (Server screen, "Open with proxies"), edited through the server (BRIEF §14.5), or only
|
||||
/// shown when the account may not change it. Null when it cannot open yet: its proxies are being fetched
|
||||
/// (<see cref="FetchProxiesAsync"/>), its workspace copy runs, or the user closed "Open in workspace".
|
||||
/// </summary>
|
||||
private async Task<(ISequenceSource Source, string Title)?> OpenSourceAsync(AppServices services, Guid sequenceId)
|
||||
@@ -557,14 +562,19 @@ 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).
|
||||
// A workspace project of this PC's archive 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)
|
||||
&& await services.Workspace.FindAsync(projectId) is { IsServerHome: false })
|
||||
{
|
||||
_requested = null;
|
||||
throw new InvalidOperationException(Loc.L("Errors.Workspace.SequenceGone"));
|
||||
}
|
||||
// A server sequence (owner review 2, R8, phase 5b): a project of it in the workspace opens from there, the server
|
||||
// reachable or not; one of a server that keeps projects is checked out (asked which); an older server's opens with
|
||||
// proxies as before.
|
||||
if (services.Workspace.IsEnabled && await OpenServerWorkspaceAsync(services, services.Workspace, db, decoder, sequenceId) is { } project)
|
||||
return project.Opened;
|
||||
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"));
|
||||
@@ -610,7 +620,7 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
// with Remove local copy for a damaged one, when nothing else could be chosen (Main asked for, or the home has no
|
||||
// other project); otherwise "Open in workspace" lists Main as it is, disabled, and offers the others.
|
||||
WorkspaceEntry? unreadableMain = null;
|
||||
if (entry is null && request?.ProjectId is null && await UnreadableMainAsync(workspace, row.Id) is { } main)
|
||||
if (entry is null && request?.ProjectId is null && await UnreadableMainAsync(workspace, WorkspaceHost.ArchiveHome(row.Id)) is { } main)
|
||||
{
|
||||
if (request is { Main: true } || (await workspace.HomeProjectsAsync(row.Id)).All(p => p.IsMain))
|
||||
{
|
||||
@@ -664,10 +674,10 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>The workspace's copy of the sequence's Main when this Chronos cannot read it (damaged, or a newer Chronos's); null otherwise.</summary>
|
||||
private static async Task<WorkspaceEntry?> UnreadableMainAsync(WorkspaceHost workspace, Guid sequenceId)
|
||||
/// <summary>The workspace's copy of the Main of <paramref name="home"/>'s sequence when this Chronos cannot read it (damaged, or a newer Chronos's); null otherwise.</summary>
|
||||
private static async Task<WorkspaceEntry?> UnreadableMainAsync(WorkspaceHost workspace, BundleHome home)
|
||||
{
|
||||
if ((await workspace.HomeProjectsAsync(sequenceId)).FirstOrDefault(p => p.IsMain) is not { } main) return null;
|
||||
if ((await workspace.HomeProjectsAsync(home)).FirstOrDefault(p => p.IsMain) is not { } main) return null;
|
||||
return await workspace.FindAsync(main.Id) is { IsReadable: false } copy ? copy : null;
|
||||
}
|
||||
|
||||
@@ -689,22 +699,137 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// "Open in workspace": the projects of the sequence's home, the media, what their copy writes and the room the
|
||||
/// workspace's drive has; null when closed without a choice. <paramref name="unreadableMain"/>, the copy of Main here
|
||||
/// this Chronos cannot read, is listed disabled, why in its tooltip.
|
||||
/// A sequence of a server opens as a project of the workspace whose home is that server (phase 5b): the project asked
|
||||
/// for, else the one of the sequence opened last here. One the workspace holds the media of opens from there, whether
|
||||
/// this PC can reach the server or not (its sync, analyses and renders wait for it). Otherwise, signed in to a server
|
||||
/// that keeps projects, the project is checked out, after "Open in workspace" asked which (when the sequence has none
|
||||
/// here), and its media downloaded by a job; it opens once they are here. A copy this Chronos cannot read is refused as
|
||||
/// for this PC's archive. Null when the server keeps no projects, or this PC is not signed in to it: the sequence then
|
||||
/// opens with proxies as before (or says to connect).
|
||||
/// </summary>
|
||||
private async Task<OpenChoice?> AskProjectAsync(WorkspaceHost workspace, Sequence row, WorkspaceEntry? unreadableMain = null)
|
||||
private async Task<ServerOpen?> OpenServerWorkspaceAsync(AppServices services, WorkspaceHost workspace, ChronosDatabase db, ImageDecoder decoder, Guid remoteId)
|
||||
{
|
||||
var projects = await workspace.HomeProjectsAsync(row.Id);
|
||||
WorkspaceCopyFacts? copy = null;
|
||||
var request = _requested is { } asked && asked.SequenceId == remoteId ? asked : null;
|
||||
var entry = request switch
|
||||
{
|
||||
{ ProjectId: { } id } => await workspace.FindAsync(id) is { IsServerHome: true } found && found.SequenceId == remoteId ? found : null,
|
||||
{ Main: true } => (await workspace.ProjectsOfAsync(remoteId)).FirstOrDefault(p => p is { IsMain: true, IsServerHome: true }),
|
||||
_ => await workspace.LastUsedAsync(remoteId) is { IsServerHome: true } last ? last : null,
|
||||
};
|
||||
var sync = services.Sync;
|
||||
if (entry is { IsReadable: false } unreadable)
|
||||
{
|
||||
TakeRequest(remoteId);
|
||||
throw WorkspaceHost.Unreadable(unreadable);
|
||||
}
|
||||
if (entry is { HasMedia: true })
|
||||
{
|
||||
TakeRequest(remoteId);
|
||||
workspace.Remember(remoteId, entry.ProjectId);
|
||||
// Its analyses and renders travel on a connection of the signed-in session, when that is the project's server:
|
||||
// made again whenever the sign-in changes, so a project opened signed out renders once signed in.
|
||||
var server = entry.Home.Server;
|
||||
var editorHome = new WorkspaceServerHome(() => string.Equals(sync.Server, server, StringComparison.OrdinalIgnoreCase) ? sync.ConnectEditor() : null,
|
||||
() => sync.Session);
|
||||
return new ServerOpen((new WorkspaceSequenceSource(workspace.Sync, entry.ProjectId, db, decoder, services.Engine, editorHome), entry.SequenceTitle));
|
||||
}
|
||||
// An account that may not edit checks nothing out: it is shown with proxies, read-only, as on an older server.
|
||||
if (!sync.Policy.CanEdit || sync.ServerHome(remoteId) is not { } home) return null;
|
||||
TakeRequest(remoteId);
|
||||
try
|
||||
{
|
||||
copy = await workspace.CopyFactsAsync(row.Id);
|
||||
var reached = workspace.Reachable(home);
|
||||
var title = (await Task.Run(() => reached.SequenceAsync(CancellationToken.None))).Sequence.Title ?? entry?.SequenceTitle ?? string.Empty;
|
||||
// No project of the sequence here opens and its Main here cannot be read: refused, or listed disabled, as for this PC's archive.
|
||||
WorkspaceEntry? unreadableMain = null;
|
||||
if (entry is null && request?.ProjectId is null && await UnreadableMainAsync(workspace, home) is { } main)
|
||||
{
|
||||
if (request is { Main: true } || (await workspace.HomeProjectsAsync(home)).All(p => p.IsMain))
|
||||
{
|
||||
RefuseUnreadable(main);
|
||||
_afterOpen = null;
|
||||
Shell.KeepSequence(OpenSequenceId);
|
||||
return new ServerOpen(null);
|
||||
}
|
||||
unreadableMain = main;
|
||||
}
|
||||
var projectId = entry?.ProjectId ?? request?.ProjectId;
|
||||
string? newName = null;
|
||||
if (entry is null && projectId is { } wanted && (await workspace.HomeProjectsAsync(home)).All(p => p.Id != wanted))
|
||||
{
|
||||
// A project the server does not have (deleted there, or another server's): the sequence's Main opens instead.
|
||||
Log.Info("workspace", $"Project {wanted} is not a project of server sequence {remoteId}; its Main opens instead");
|
||||
projectId = null;
|
||||
if (_afterOpen is { } pending && pending.Request.SequenceId == remoteId) _afterOpen = (ProjectRequest.MainOf(remoteId), pending.Action);
|
||||
}
|
||||
else if (entry is null && projectId is null && request is not { Main: true })
|
||||
{
|
||||
if (await AskProjectAsync(workspace, home, title, unreadableMain) is not { } choice)
|
||||
{
|
||||
_afterOpen = null;
|
||||
Shell.KeepSequence(OpenSequenceId);
|
||||
return new ServerOpen(null);
|
||||
}
|
||||
(projectId, newName) = (choice.ProjectId, choice.NewName);
|
||||
}
|
||||
WorkspaceCheckout checkout;
|
||||
try
|
||||
{
|
||||
checkout = await workspace.CheckoutAsync(home, projectId, newName);
|
||||
}
|
||||
catch (WorkspaceException ex) when (ex.FolderRefused)
|
||||
{
|
||||
// Nothing was written: the way on is another workspace folder, offered from the refusal.
|
||||
Log.Info("workspace", $"Server sequence {remoteId} not checked out: {ex.Message}");
|
||||
Shell.Notify(Loc.L("Editor.Workspace.OpenFailed"), ex.Message, Loc.L("Editor.Workspace.ChooseFolder"), Loc.L("Tooltips.Editor.Workspace.ChooseFolder"),
|
||||
() => _ = WorkspaceFolderChange.ChooseAsync(Shell), isError: true);
|
||||
_afterOpen = null;
|
||||
Shell.KeepSequence(OpenSequenceId);
|
||||
return new ServerOpen(null);
|
||||
}
|
||||
await FollowCopyAsync(remoteId, title, checkout.Project.Id, checkout.Copy);
|
||||
return new ServerOpen(null);
|
||||
}
|
||||
catch (Exception ex) when (ex is System.IO.IOException or System.IO.InvalidDataException or InvalidOperationException or DatabaseException or UnauthorizedAccessException)
|
||||
catch (ProjectException ex) when (ex.Reason == ProjectError.SequenceNotFound)
|
||||
{
|
||||
// Only shown: the copy measures again before it writes.
|
||||
Log.Info("workspace", $"The copy of sequence {row.Id} could not be measured: {ex.Message}");
|
||||
throw new InvalidOperationException(Loc.L("Editor.Error.Missing"), ex);
|
||||
}
|
||||
catch (ProjectException ex) when (ex.Reason == ProjectError.SequenceEmpty)
|
||||
{
|
||||
throw new InvalidOperationException(Loc.L("Editor.Error.Empty"), ex);
|
||||
}
|
||||
catch (HomeUnavailableException ex)
|
||||
{
|
||||
// Said of the server, not of this PC's library.
|
||||
throw new WorkspaceException(WorkspaceText.ForHome("Errors.Workspace.Offline", server: true), ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>"Open in workspace" for a sequence of this PC's archive; null when closed without a choice.</summary>
|
||||
private Task<OpenChoice?> AskProjectAsync(WorkspaceHost workspace, Sequence row, WorkspaceEntry? unreadableMain = null) =>
|
||||
AskProjectAsync(workspace, WorkspaceHost.ArchiveHome(row.Id), row.DisplayTitle, unreadableMain);
|
||||
|
||||
/// <summary>
|
||||
/// "Open in workspace" for a sequence of <paramref name="home"/> (this PC's archive, or a server): its projects, the
|
||||
/// media, and for this PC's archive what their copy writes and the room the workspace's drive has; null when closed
|
||||
/// without a choice. <paramref name="unreadableMain"/>, the copy of Main here this Chronos cannot read, is listed
|
||||
/// disabled, why in its tooltip.
|
||||
/// </summary>
|
||||
private async Task<OpenChoice?> AskProjectAsync(WorkspaceHost workspace, BundleHome home, string title, WorkspaceEntry? unreadableMain)
|
||||
{
|
||||
var projects = await workspace.HomeProjectsAsync(home);
|
||||
WorkspaceCopyFacts? copy = null;
|
||||
if (home.IsArchive)
|
||||
{
|
||||
try
|
||||
{
|
||||
copy = await workspace.CopyFactsAsync(home.SequenceId);
|
||||
}
|
||||
catch (Exception ex) when (ex is System.IO.IOException or System.IO.InvalidDataException or InvalidOperationException or DatabaseException or UnauthorizedAccessException)
|
||||
{
|
||||
// Only shown: the copy measures again before it writes.
|
||||
Log.Info("workspace", $"The copy of sequence {home.SequenceId} could not be measured: {ex.Message}");
|
||||
}
|
||||
}
|
||||
var unreadable = unreadableMain is { } main
|
||||
? new Dictionary<Guid, string>
|
||||
@@ -712,7 +837,7 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
[main.ProjectId] = Loc.L(main.Newer ? "Tooltips.Editor.Workspace.State.NewerCopy" : "Tooltips.Editor.Workspace.State.DamagedCopy"),
|
||||
}
|
||||
: null;
|
||||
var dialog = new OpenInWorkspaceDialogViewModel(row.DisplayTitle, projects, d => CloseDialog(d), copy: copy, unreadable: unreadable);
|
||||
var dialog = new OpenInWorkspaceDialogViewModel(title, projects, d => CloseDialog(d), copy: copy, unreadable: unreadable, server: !home.IsArchive);
|
||||
// The picker or the open sequence shows behind the dialog meanwhile, not the progress bar.
|
||||
IsLoading = false;
|
||||
OpenDialog(dialog);
|
||||
@@ -888,6 +1013,9 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>What the open of a server sequence as a workspace project came to: its source, or null while it waits (its copy runs, the dialog was closed).</summary>
|
||||
private sealed record ServerOpen((ISequenceSource Source, string Title)? Opened);
|
||||
|
||||
/// <summary>
|
||||
/// A job an open waits on, with its engine subscription: a server sequence's proxy download, or the workspace copy of a
|
||||
/// project's media (<see cref="ProjectId"/>: the project that opens when it is done).
|
||||
|
||||
Reference in new issue
Block a user