feat: owner review 2 phase 5c: originals, local render, clean-up and the workspace settings (#18)
CI / Build and test (push) Successful in 9m26s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 8s
Release / Build, test and publish (push) Successful in 14m31s
CI / PostgreSQL 16 integration (push) Successful in 9m53s
CI / PostgreSQL 17 integration (push) Successful in 9m22s
CI / Docker image (push) Successful in 44s
Release / Server image (push) Successful in 1m36s
CI / Build and test (push) Successful in 9m26s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 8s
Release / Build, test and publish (push) Successful in 14m31s
CI / PostgreSQL 16 integration (push) Successful in 9m53s
CI / PostgreSQL 17 integration (push) Successful in 9m22s
CI / Docker image (push) Successful in 44s
Release / Server image (push) Successful in 1m36s
Originals in the workspace, local render and send home with provenance, the workspace clean-up, size limit and trash, moving the workspace folder, and the complete Settings › Workspace page (owner review 2, R8, phase 5c). One adversarial review round (35 findings, 32 fixed), a copy-cancel race fixed, 184 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 #18.
This commit is contained in:
1 parent
81c303f484
commit
db389a54f2
364 files changed
+17417
-595
No files matched your search
@@ -608,12 +608,20 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
ImageDecoder decoder, Sequence row)
|
||||
{
|
||||
var request = TakeRequest(row.Id);
|
||||
var entry = request switch
|
||||
WorkspaceEntry? entry;
|
||||
if (request is { ProjectId: { } id }) entry = await workspace.FindAsync(id);
|
||||
else if (request is { Main: true }) entry = (await workspace.ProjectsOfAsync(row.Id)).FirstOrDefault(p => p.IsMain);
|
||||
else
|
||||
{
|
||||
{ ProjectId: { } id } => await workspace.FindAsync(id),
|
||||
{ Main: true } => (await workspace.ProjectsOfAsync(row.Id)).FirstOrDefault(p => p.IsMain),
|
||||
_ => await workspace.LastUsedAsync(row.Id),
|
||||
};
|
||||
var (cancelled, chosen) = await PolicyEntryAsync(services, workspace, row.Id, row.DisplayTitle, _ => true);
|
||||
if (cancelled)
|
||||
{
|
||||
_afterOpen = null;
|
||||
Shell.KeepSequence(OpenSequenceId);
|
||||
return null;
|
||||
}
|
||||
entry = chosen;
|
||||
}
|
||||
// This Chronos cannot read its working state (damaged, or a newer Chronos's): nothing is checked out over it.
|
||||
if (entry is { IsReadable: false } unreadable) throw WorkspaceHost.Unreadable(unreadable);
|
||||
// No project of the sequence here opens, and its Main here is such a copy (never among its projects): said at once,
|
||||
@@ -634,10 +642,12 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
if (entry is { HasMedia: true })
|
||||
{
|
||||
workspace.Remember(row.Id, entry.ProjectId);
|
||||
workspace.RecordOpened(entry.ProjectId);
|
||||
return (new WorkspaceSequenceSource(workspace.Sync, entry.ProjectId, db, decoder, services.Engine), row.DisplayTitle);
|
||||
}
|
||||
var projectId = entry?.ProjectId ?? request?.ProjectId;
|
||||
string? newName = null;
|
||||
var media = DefaultMedia(services);
|
||||
if (entry is null && projectId is { } wanted && (await workspace.HomeProjectsAsync(row.Id)).All(p => p.Id != wanted))
|
||||
{
|
||||
// A project file of a project this home does not have (another PC's workspace): its sequence's Main takes it.
|
||||
@@ -653,12 +663,12 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
Shell.KeepSequence(OpenSequenceId);
|
||||
return null;
|
||||
}
|
||||
(projectId, newName) = (choice.ProjectId, choice.NewName);
|
||||
(projectId, newName, media) = (choice.ProjectId, choice.NewName, choice.Media);
|
||||
}
|
||||
WorkspaceCheckout checkout;
|
||||
try
|
||||
{
|
||||
checkout = await workspace.CheckoutAsync(row.Id, projectId, newName);
|
||||
checkout = await workspace.CheckoutAsync(row.Id, projectId, newName, media);
|
||||
}
|
||||
catch (WorkspaceException ex) when (ex.FolderRefused)
|
||||
{
|
||||
@@ -710,12 +720,20 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
private async Task<ServerOpen?> OpenServerWorkspaceAsync(AppServices services, WorkspaceHost workspace, ChronosDatabase db, ImageDecoder decoder, Guid remoteId)
|
||||
{
|
||||
var request = _requested is { } asked && asked.SequenceId == remoteId ? asked : null;
|
||||
var entry = request switch
|
||||
WorkspaceEntry? entry;
|
||||
if (request is { ProjectId: { } id }) entry = await workspace.FindAsync(id) is { IsServerHome: true } found && found.SequenceId == remoteId ? found : null;
|
||||
else if (request is { Main: true }) entry = (await workspace.ProjectsOfAsync(remoteId)).FirstOrDefault(p => p is { IsMain: true, IsServerHome: true });
|
||||
else
|
||||
{
|
||||
{ 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 (cancelled, chosen) = await PolicyEntryAsync(services, workspace, remoteId, null, p => p.IsServerHome);
|
||||
if (cancelled)
|
||||
{
|
||||
_afterOpen = null;
|
||||
Shell.KeepSequence(OpenSequenceId);
|
||||
return new ServerOpen(null);
|
||||
}
|
||||
entry = chosen;
|
||||
}
|
||||
var sync = services.Sync;
|
||||
if (entry is { IsReadable: false } unreadable)
|
||||
{
|
||||
@@ -726,6 +744,7 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
{
|
||||
TakeRequest(remoteId);
|
||||
workspace.Remember(remoteId, entry.ProjectId);
|
||||
workspace.RecordOpened(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;
|
||||
@@ -755,6 +774,7 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
}
|
||||
var projectId = entry?.ProjectId ?? request?.ProjectId;
|
||||
string? newName = null;
|
||||
var media = DefaultMedia(services);
|
||||
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.
|
||||
@@ -770,12 +790,12 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
Shell.KeepSequence(OpenSequenceId);
|
||||
return new ServerOpen(null);
|
||||
}
|
||||
(projectId, newName) = (choice.ProjectId, choice.NewName);
|
||||
(projectId, newName, media) = (choice.ProjectId, choice.NewName, choice.Media);
|
||||
}
|
||||
WorkspaceCheckout checkout;
|
||||
try
|
||||
{
|
||||
checkout = await workspace.CheckoutAsync(home, projectId, newName);
|
||||
checkout = await workspace.CheckoutAsync(home, projectId, newName, media);
|
||||
}
|
||||
catch (WorkspaceException ex) when (ex.FolderRefused)
|
||||
{
|
||||
@@ -811,25 +831,23 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
|
||||
/// <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
|
||||
/// media (Settings › Workspace › Media chosen first), 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
|
||||
{
|
||||
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}");
|
||||
}
|
||||
copy = await workspace.CopyFactsAsync(home);
|
||||
}
|
||||
catch (Exception ex) when (ex is System.IO.IOException or System.IO.InvalidDataException or InvalidOperationException or DatabaseException
|
||||
or UnauthorizedAccessException or ChronosApiException or System.Net.Http.HttpRequestException)
|
||||
{
|
||||
// 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>
|
||||
@@ -837,7 +855,8 @@ 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(title, projects, d => CloseDialog(d), copy: copy, unreadable: unreadable, server: !home.IsArchive);
|
||||
var dialog = new OpenInWorkspaceDialogViewModel(title, projects, d => CloseDialog(d), copy: copy, unreadable: unreadable, server: !home.IsArchive,
|
||||
defaultMedia: DefaultMedia(Shell.Services));
|
||||
// The picker or the open sequence shows behind the dialog meanwhile, not the progress bar.
|
||||
IsLoading = false;
|
||||
OpenDialog(dialog);
|
||||
@@ -851,6 +870,36 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The media a checkout copies unless "Open in workspace" chose: Settings › Workspace › Media.</summary>
|
||||
private static string DefaultMedia(AppServices services) => services.Settings.EffectiveDefaultMedia;
|
||||
|
||||
/// <summary>
|
||||
/// The project of the sequence Edit opens when none was asked for (phase 5c, Settings › Workspace › Open project): the
|
||||
/// one opened last, Main, or the one chosen in "Open which project?" when the workspace holds several (Cancelled: closed
|
||||
/// without a choice). Only projects <paramref name="fits"/> takes count; none here: null.
|
||||
/// </summary>
|
||||
private async Task<(bool Cancelled, WorkspaceEntry? Entry)> PolicyEntryAsync(AppServices services, WorkspaceHost workspace, Guid sequenceId, string? title,
|
||||
Func<WorkspaceEntry, bool> fits)
|
||||
{
|
||||
var last = await workspace.LastUsedAsync(sequenceId) is { } used && fits(used) ? used : null;
|
||||
var policy = services.Settings.EffectiveOpenPolicy;
|
||||
if (policy == WorkspaceOpenPolicy.LastUsed) return (false, last);
|
||||
var here = (await workspace.ProjectsOfAsync(sequenceId)).Where(p => fits(p) && p.IsReadable).ToList();
|
||||
if (policy == WorkspaceOpenPolicy.Main) return (false, here.FirstOrDefault(p => p.IsMain) ?? last);
|
||||
if (here.Count < 2) return (false, last ?? here.FirstOrDefault());
|
||||
var dialog = new OpenProjectDialogViewModel(title ?? here[0].SequenceTitle, here, last?.ProjectId, d => CloseDialog(d));
|
||||
IsLoading = false;
|
||||
OpenDialog(dialog);
|
||||
try
|
||||
{
|
||||
return await dialog.Choice is { } chosen ? (false, chosen) : (true, null);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsLoading = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The project the next open of <paramref name="sequenceId"/> takes, taken once; null when none was asked for.</summary>
|
||||
private ProjectRequest? TakeRequest(Guid sequenceId)
|
||||
{
|
||||
@@ -1071,6 +1120,8 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
if (section.Shell.Services.Database is not { } db || await db.Sequences.GetAsync(sequenceId) is not { } row) return;
|
||||
if (section.Shell.Library.Items.FirstOrDefault(i => i.Id == row.Id) is { } item) item.Update(row);
|
||||
}
|
||||
|
||||
public void ShowJobs() => section.Shell.Navigate(SectionKey.Jobs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user