fix(37): preserve camera choice when restoring default layouts

Build-mismatch restoration now keeps the currently selected webcam identity,
restores default scene placements against that camera, and leaves cameras absent
when none is selected. The integration regression test pins the creator's camera
choice and restored default geometry.
612 tests green, clean build with 0 warnings.
This commit is contained in:
2026-11-10 17:56:24 -08:00
parent c4da06b56b
commit ff1c1965e0
2 changed files with 50 additions and 1 deletions
+9 -1
View File
@@ -246,10 +246,12 @@ public partial class LayoutStore : IDisposable
private void RestoreDefaults(string buildId)
{
var columnsByTable = SnapshotTables.ToDictionary(table => table, ReadColumnNames);
var currentWebcamId = GetCurrentWebcamId();
using var tx = _connection.BeginTransaction();
foreach (var table in SnapshotTables.Reverse())
{
if (table == "Webcam") continue;
using var delete = _connection.CreateCommand();
delete.Transaction = tx;
delete.CommandText = $"DELETE FROM {table};";
@@ -258,10 +260,16 @@ public partial class LayoutStore : IDisposable
foreach (var table in SnapshotTables)
{
if (table == "Webcam" || (table == "WebcamSceneConfig" && currentWebcamId == null)) continue;
var columns = string.Join(", ", columnsByTable[table].Select(QuoteIdentifier));
var values = string.Join(", ", columnsByTable[table].Select(column =>
column == "WebcamId" && table == "WebcamSceneConfig"
? "$webcamId"
: QuoteIdentifier(column)));
using var copy = _connection.CreateCommand();
copy.Transaction = tx;
copy.CommandText = $"INSERT INTO {table} ({columns}) SELECT {columns} FROM Default{table};";
copy.CommandText = $"INSERT INTO {table} ({columns}) SELECT {values} FROM Default{table};";
if (table == "WebcamSceneConfig") copy.Parameters.AddWithValue("$webcamId", currentWebcamId!);
copy.ExecuteNonQuery();
}