feat: owner review 2 phase 5a: workspace and projects with a local home (#14)
CI / Build and test (push) Successful in 9m43s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 27s
CI / PostgreSQL 16 integration (push) Failing after 8m41s
CI / PostgreSQL 17 integration (push) Successful in 12m37s
CI / Docker image (push) Successful in 56s
Release / Build, test and publish (push) Successful in 14m59s
Release / Server image (push) Successful in 1m51s

Edit opens a sequence as a project of a workspace folder outside the library. Projects have linear version histories kept as sidecars in .chronos/projects/, Main mirrors the sequence's settings, and sync merges setting by setting. Migration 0009, JobKind.WorkspaceCopy = 20, Settings › Workspace, and 241 new strings in 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 #14.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-11-04 09:22:08 +01:00
1 parent efa87f68ce
commit 9b24cf74fc
370 files changed
+29237 -287

No files matched your search

@@ -0,0 +1,86 @@
using System.IO;
using Chronos.App.Editor;
using Chronos.App.Infrastructure;
using Chronos.App.Shell;
using Chronos.Core.Diagnostics;
using Chronos.Core.Localization;
namespace Chronos.App.Workspace;
/// <summary>
/// Choosing another workspace folder (owner review 2, R8): Settings › Workspace › Change, and the refusal of a folder
/// inside a library, where Edit cannot be used until one is chosen. The folder is picked, its plan shown and confirmed
/// (the projects the folder in use keeps, those the new one holds), a workspace project open in the editor closes (its
/// last edit stored first), and only then does the setting change. Nothing is moved or deleted: the projects of the
/// folder left stay there, listed again once it is chosen back. Moving a workspace with its projects comes in phase 5c.
/// </summary>
public static class WorkspaceFolderChange
{
/// <summary>The shell's flow: its folder picker and confirmation, its editor, its toasts.</summary>
public static async Task<bool> ChooseAsync(ShellViewModel shell)
{
ArgumentNullException.ThrowIfNull(shell);
var changed = await ChooseAsync(shell.Services.Workspace, shell.Services.Dialogs, async () =>
{
if (shell.Sequence.Editor?.Session.Source is not WorkspaceSequenceSource) return true;
if (!await shell.Sequence.ConfirmCloseAsync()) return false;
await shell.Sequence.CloseAsync();
shell.KeepSequence(null);
return true;
}, message => shell.Notify(Loc.L("Settings.Workspace.NotChanged"), message, isError: true));
if (changed) shell.Notify(Loc.L("Settings.Workspace.Changed"), shell.Services.Workspace.Root);
return changed;
}
/// <summary>
/// Picks a folder through <paramref name="dialogs"/>, confirms its plan, lets <paramref name="closeProject"/> close a
/// workspace project open in the editor (false keeps everything as it is), then makes it the workspace's folder.
/// <paramref name="failed"/> hears why a folder was refused. True when the folder changed.
/// </summary>
public static async Task<bool> ChooseAsync(WorkspaceHost host, IAppDialogs dialogs, Func<Task<bool>> closeProject, Action<string> failed)
{
ArgumentNullException.ThrowIfNull(host);
ArgumentNullException.ThrowIfNull(dialogs);
ArgumentNullException.ThrowIfNull(closeProject);
ArgumentNullException.ThrowIfNull(failed);
if (dialogs.PickFolder(Loc.L("Settings.Workspace.ChooseTitle"), Directory.Exists(host.Root) ? host.Root : null) is not { } folder) return false;
try
{
var plan = await host.PlanFolderAsync(folder);
if (plan.IsSame) return false;
if (plan.InsideLibrary)
{
failed(Loc.L("Errors.Workspace.InsideLibraryFolder", plan.Folder));
return false;
}
if (!dialogs.Confirm(Request(plan))) return false;
if (!await closeProject()) return false;
await host.UseFolderAsync(plan.Folder);
return true;
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or ArgumentException or WorkspaceException)
{
Log.Warning("workspace", $"The workspace folder was not changed to {folder}", ex);
failed(ex is WorkspaceException ? ex.Message : Loc.L("Errors.Workspace.FolderUnusable", folder));
return false;
}
}
/// <summary>The plan as a confirmation: where Edit's projects come from now, and what stays where it is.</summary>
public static ConfirmRequest Request(WorkspaceFolderPlan plan)
{
ArgumentNullException.ThrowIfNull(plan);
return new ConfirmRequest
{
Heading = Loc.L("Settings.Workspace.ChangeTitle"),
Message = Loc.L("Settings.Workspace.ChangeMessage", plan.Folder, plan.Current),
Detail = string.Join(Environment.NewLine, Loc.L("Settings.Workspace.ProjectsLeft", Formatting.Count(plan.ProjectsLeft)),
Loc.L("Settings.Workspace.ProjectsFound", Formatting.Count(plan.ProjectsFound))),
IsDetailMonospaced = false,
SafeText = Loc.L("Archive.Dialog.Cancel"),
SafeToolTip = Loc.L("Tooltips.Settings.KeepWorkspace"),
ActionText = Loc.L("Settings.Workspace.Use"),
ActionToolTip = Loc.L("Tooltips.Settings.UseWorkspace"),
};
}
}