feat(editor): open server sequences with proxies, hero frame to the index, export sync and saved copies
Server sequences that are not in the local index open through a RemoteSequenceSource: proxies from the cache, project from the server's settings with their version (a 409 merges again), analysis report from the server, analyses and renders posted as server jobs (one per preset) and followed through the server's events. Set hero now reaches the index (SequenceEdit.HeroFrameId) so the Library card shows it. The Export tab gains the Sync option (remembered in the project) and restores "Save both" copies through undo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
36 files changed
+1307
-116
No files matched your search
@@ -45,8 +45,14 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Style="{StaticResource Button.IconSubtle}" ui:ButtonIcon.Glyph="{StaticResource Icon.Back}" Command="{Binding BackCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Editor.Back}" AutomationProperties.Name="{l:Loc Editor.Back}" Margin="-6,0,0,0" />
|
||||
<TextBlock Grid.Column="1" Text="{Binding Title}" Style="{StaticResource Text.Title}" VerticalAlignment="Center" Margin="6,0,12,0" MaxWidth="320"
|
||||
TextTrimming="CharacterEllipsis" />
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center" Margin="6,0,12,0">
|
||||
<TextBlock Text="{Binding Title}" Style="{StaticResource Text.Title}" VerticalAlignment="Center" MaxWidth="320" TextTrimming="CharacterEllipsis" />
|
||||
<!-- A server sequence edited with proxies: where it lives, and its analysis or render running on the server. -->
|
||||
<ui:StatusGlyph Kind="Remote" Text="{Binding RemoteText}" ToolTip="{Binding RemoteToolTip}" FontSize="13" Margin="12,0,0,0" VerticalAlignment="Center"
|
||||
Visibility="{Binding IsRemote, Converter={StaticResource BoolToVisibility}}" />
|
||||
<ui:StatusGlyph Kind="Running" Text="{Binding ServerJobText}" ToolTip="{Binding ServerJobToolTip}" FontSize="13" Margin="12,0,0,0" VerticalAlignment="Center"
|
||||
Typography.NumeralAlignment="Tabular" Visibility="{Binding ServerJobText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Column="2" Text="{Binding Summary}" Style="{StaticResource Text.Secondary}" FontSize="{StaticResource Size.Body}" VerticalAlignment="Center"
|
||||
TextTrimming="CharacterEllipsis" Typography.NumeralAlignment="Tabular" ToolTip="{Binding Summary}" />
|
||||
<StackPanel Grid.Column="3" Orientation="Horizontal" VerticalAlignment="Center" Margin="12,0,0,0">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using Titano.App.Editor;
|
||||
using Titano.App.Infrastructure;
|
||||
using Titano.App.Shell;
|
||||
@@ -7,18 +8,20 @@ using Titano.Core.Diagnostics;
|
||||
using Titano.Core.Export;
|
||||
using Titano.Core.Imaging.Decoders;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Data.Archiving;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Ui.Mvvm;
|
||||
|
||||
namespace Titano.App.Sections;
|
||||
|
||||
/// <summary>
|
||||
/// The Sequence section (BRIEF §12.3): opens the sequence the Library (or Jobs) chose into an <see cref="EditorViewModel"/>
|
||||
/// and closes the previous one after saving it; without a sequence it shows the empty state. A failed open is reported
|
||||
/// and leaves the section usable; an edit that cannot be saved is never dropped without the user's confirmation.
|
||||
/// The Sequence section (BRIEF §12.3): opens the sequence the Library, Jobs or the Server screen chose into an
|
||||
/// <see cref="EditorViewModel"/> (from this PC's archive, or a server sequence with this PC's proxies) and closes the
|
||||
/// previous one after saving it; without a sequence it shows the empty state. A failed open is reported and leaves the
|
||||
/// section usable; an edit that cannot be saved is never dropped without the user's confirmation.
|
||||
/// </summary>
|
||||
public sealed class SequenceViewModel : SectionViewModel
|
||||
{
|
||||
private readonly Dispatcher _dispatcher = Dispatcher.CurrentDispatcher;
|
||||
private EditorViewModel? _editor;
|
||||
private Guid? _openId;
|
||||
private bool _isLoading;
|
||||
@@ -112,6 +115,35 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
if (e.PropertyName == nameof(ShellViewModel.CurrentSequenceId) && IsSelected) OnActivated();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Where <paramref name="sequenceId"/> lives: this PC's index, 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).
|
||||
/// </summary>
|
||||
private async Task<ISequenceSource> OpenSourceAsync(AppServices services, Guid sequenceId)
|
||||
{
|
||||
if (services.Database is not { } db) throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"));
|
||||
var processing = services.Processing?.Options;
|
||||
var decoder = processing?.Archive.Decoder ?? DecoderFactory.CreateClient(null);
|
||||
if (await db.Sequences.GetAsync(sequenceId) is not null)
|
||||
{
|
||||
var local = new LocalSequenceSource(db, sequenceId, decoder, services.Engine, processing?.Archive);
|
||||
local.HeroChanged += OnHeroChanged;
|
||||
return local;
|
||||
}
|
||||
var sync = services.Sync;
|
||||
if (sync.Server is not { } server || sync.Service?.OpenRemote(server, sequenceId) is not { } remote) throw new InvalidOperationException(Loc.L("Editor.Error.Missing"));
|
||||
// An editor whose saves the server refuses would only lose edits.
|
||||
if (!sync.Policy.CanEdit) throw new InvalidOperationException(Loc.L("Editor.Error.RemoteReadOnly"));
|
||||
var api = sync.ConnectEditor() ?? throw new InvalidOperationException(Loc.L("Editor.Error.Missing"));
|
||||
return new RemoteSequenceSource(remote, api, decoder);
|
||||
}
|
||||
|
||||
/// <summary>Set hero changed the frame the Library shows (any thread): its card loads the new thumbnail.</summary>
|
||||
private void OnHeroChanged(Sequence row) => _dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
if (Shell.Library.Items.FirstOrDefault(i => i.Id == row.Id) is { } item) item.Update(row);
|
||||
});
|
||||
|
||||
/// <summary>Waits for <paramref name="task"/>; its failure was reported where it happened.</summary>
|
||||
private static async Task Settled(Task task)
|
||||
{
|
||||
@@ -142,11 +174,18 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
await old.DisposeAsync();
|
||||
}
|
||||
_openId = sequenceId;
|
||||
if (services.Database is not { } db) throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"));
|
||||
var source = await OpenSourceAsync(services, sequenceId);
|
||||
SequenceContent content;
|
||||
try
|
||||
{
|
||||
content = await source.LoadAsync(CancellationToken.None);
|
||||
}
|
||||
catch
|
||||
{
|
||||
await source.DisposeAsync();
|
||||
throw;
|
||||
}
|
||||
var processing = services.Processing?.Options;
|
||||
var source = new LocalSequenceSource(db, sequenceId, processing?.Archive.Decoder ?? DecoderFactory.CreateClient(null), services.Engine,
|
||||
processing?.Archive);
|
||||
var content = await source.LoadAsync(CancellationToken.None);
|
||||
var encoders = processing?.Encoders ?? [];
|
||||
var session = new EditorSession(source, content, [.. encoders.SelectMany(e => e.Capabilities)]);
|
||||
var editor = new EditorViewModel(Shell, session, encoders, processing?.Host ?? EncoderHost.Client);
|
||||
|
||||
Reference in new issue
Block a user