feat(37): expose the staged-scene factory reset

App Settings can now restore only the staged canonical scene. The VM saves
pending edits first, resets that scene, reloads immediately, and keeps the same
scene staged. Other scene edits survive; the action is disabled while live or
recording. 615 tests green, clean build with 0 warnings.

Reference: OBS Scene Collections keep scene/source sets distinct:
https://obsproject.com/kb/scene-collections
This commit is contained in:
2026-11-10 18:09:16 -08:00
parent 41064bdd13
commit e6c6913994
4 changed files with 57 additions and 1 deletions
@@ -51,4 +51,42 @@ public sealed class LayoutResetIntegrationTests
try { File.Delete(tempDb); } catch { /* best-effort cleanup */ }
}
});
[Fact]
public void SettingsRestoreStagedScene_LeavesOtherSceneEditsAndSelectionIntact() => _app.Run(() =>
{
var tempDb = Path.Combine(Path.GetTempPath(), $"ytLlive-layout-reset-{Guid.NewGuid():N}.db");
MainViewModel.LayoutPathOverride = tempDb;
MainViewModel? vm = null;
try
{
vm = new MainViewModel();
var starting = vm.Scenes.Single(scene => SceneCatalog.Is(scene.Name, SceneCatalog.Starting));
var brb = vm.Scenes.Single(scene => SceneCatalog.Is(scene.Name, SceneCatalog.Brb));
starting.Elements.Add(new Source { Name = "Keep this edit", Type = SourceType.TextOverlay });
brb.Elements.Add(new Source { Name = "Reset this edit", Type = SourceType.TextOverlay });
vm.SaveLayoutNow();
vm.StagedScene = brb;
Assert.True(vm.RestoreStagedSceneDefaultsCommand.CanExecute(null));
vm.RestoreStagedSceneDefaultsCommand.Execute(null);
Assert.Contains(vm.Scenes.Single(scene => SceneCatalog.Is(scene.Name, SceneCatalog.Starting))
.Elements.OfType<Source>(), source => source.Name == "Keep this edit");
Assert.DoesNotContain(vm.Scenes.Single(scene => SceneCatalog.Is(scene.Name, SceneCatalog.Brb))
.Elements.OfType<Source>(), source => source.Name == "Reset this edit");
Assert.True(SceneCatalog.Is(vm.StagedScene?.Name, SceneCatalog.Brb));
var settingsXaml = SourceAssert.Text("Controls", "SettingsDrawer.xaml");
Assert.Contains("Content=\"Restore staged scene\"", settingsXaml);
Assert.Contains("Command=\"{Binding RestoreStagedSceneDefaultsCommand}\"", settingsXaml);
}
finally
{
vm?.Shutdown();
MainViewModel.LayoutPathOverride = null;
SqliteConnection.ClearAllPools();
try { File.Delete(tempDb); } catch { /* best-effort cleanup */ }
}
});
}