feat(app): .titano project files that open their sequence with its settings

Setup registered .titano with Titano.exe "%1", but nothing wrote such a file
and Titano ignored the argument (BRIEF §18).

- Core ProjectBundle: versioned UTF-8 JSON ("titano-project", format 1) with
  the archive (id, name, path), the sequence (id, folder, title, frame
  count) and the project settings as project.json holds them; newer or
  foreign files are refused, frame positions apply only to the frames they
  were saved for, saving never replaces an earlier file.
- Data ProjectBundles: the file for a sequence of the index, and the sequence
  a file names (by id, else the same folder of the same archive).
- Editor: "Save project file" on the Export tab (sequences of this PC's
  archives); opening a file shows its sequence and applies the settings as
  one undo step with an Undo toast, or says in one sentence why not (not in
  the library, unreadable, a job runs).
- Titano.exe opens its file argument once the index is open and runs once
  per data folder: a later launch hands its file over a current-user named
  pipe, lets the running window come to the front and exits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-12 10:29:37 +00:00
1 parent 4f6bbfba5d
commit 2ffc0268a7
15 files changed
+877 -4

No files matched your search

@@ -0,0 +1,42 @@
using Titano.Core.Model;
using Titano.Core.Project;
namespace Titano.Data.Processing;
/// <summary>
/// <c>.titano</c> project files (BRIEF §18) against this index: the file for a sequence of one of its archives, and
/// the sequence a file names.
/// </summary>
public static class ProjectBundles
{
/// <summary>
/// The project file of <paramref name="sequenceId"/> with <paramref name="project"/> (the editor's current
/// settings), whose frame positions refer to <paramref name="frames"/> frames.
/// </summary>
/// <exception cref="InvalidOperationException">The sequence is not in the index.</exception>
public static async Task<ProjectBundle> CreateAsync(TitanoDatabase db, Guid sequenceId, ProjectSettings project, int frames,
CancellationToken cancellationToken = default)
{
var sequence = await db.Sequences.GetAsync(sequenceId, cancellationToken).ConfigureAwait(false)
?? throw new InvalidOperationException($"Sequence {sequenceId} is not in the index.");
var archive = await db.Archives.GetAsync(sequence.ArchiveId, cancellationToken).ConfigureAwait(false);
return new ProjectBundle(
new BundleArchive(sequence.ArchiveId, archive?.Name ?? string.Empty, archive?.RootPath),
new BundleSequence(sequence.Id, sequence.Folder, sequence.DisplayTitle, frames),
project,
DateTimeOffset.UtcNow);
}
/// <summary>
/// The sequence <paramref name="bundle"/> names: by its id, else the sequence in the same folder of the same
/// archive (an index rebuilt elsewhere, or a folder adopted again, gives it a new id). Null when this index has
/// neither: the archive is not added here, or the sequence was deleted.
/// </summary>
public static async Task<Sequence?> ResolveAsync(TitanoDatabase db, ProjectBundle bundle, CancellationToken cancellationToken = default)
{
if (await db.Sequences.GetAsync(bundle.Sequence.Id, cancellationToken).ConfigureAwait(false) is { } byId) return byId;
var locations = await db.Sequences.ListLocationsAsync(bundle.Archive.Id, cancellationToken).ConfigureAwait(false);
var match = locations.FirstOrDefault(l => string.Equals(l.Folder, bundle.Sequence.Folder, StringComparison.OrdinalIgnoreCase));
return match is null ? null : await db.Sequences.GetAsync(match.Id, cancellationToken).ConfigureAwait(false);
}
}