Fix: derive IsBackground from Type on layout load (legacy rows healed)

This commit is contained in:
2026-08-23 07:25:54 -07:00
parent 46da9954ad
commit 809c066184
5 changed files with 88 additions and 23 deletions
+37 -19
View File
@@ -1,31 +1,49 @@
# HANDOFF — Session State
## Branch
`main` — clean, HEAD `d2114c7`, 0 warnings. Not pushed.
`main` — **dirty (2 files, uncommitted)**, HEAD `46da995`. Not pushed.
## What's in commit d2114c7 (this session)
1. **All-five-scenes backgrounds** (prior session work, was uncommitted): `Scene.UseDefaultBackground` + `CustomBackgroundPath` on `SceneElement` superclass, LayoutStore persistence (`BackgroundPath_{sourceId}` / `BackgroundUseDefault_{sourceId}` in Settings), `SceneCatalog.HasBackground` true for all five scenes, `EnforceBackgroundPolicy` no longer strips non-Live backgrounds, tests updated.
2. **UI polish (this session):**
- "Use default background:" label + pill toggle on ONE horizontal line (MainWindow.xaml ~612)
- PillToggle resized 48×24 → 36×18 (thumb 18→12, travel 24→18) to match 11px label (Themes/Controls.xaml)
- New `SubHeader` style (11px SemiBold #a0a0b0, indented 4px); "BACKGROUND" → "Background" sub-title; Background section contents indented under it — PROPERTIES stays the only title-styled text
## Uncommitted work (this session): IsBackground load-time derivation fix
The user-reported bug "Background properties show for only Starting and Live" is FIXED:
1. **Root cause confirmed:** `Source.Type`'s setter derives `IsBackground` (`Type == Background`),
but `LayoutStore.Load()`'s object initializer assigned the DB **column** afterward — rows saved
before b74f15f carry `IsBackground=0` for `Type='Background'` and stayed false after load, so the
properties panel (`SelectedElement.IsBackground`) stayed hidden in BRB/Chat/Ending.
2. **Fix** (`Services/LayoutStore.cs` ~601): hoist the `Type` parse, then
`IsBackground = type == SourceType.Background || <column>`. The OR keeps the persisted bit for
legacy DisplayCapture backdrops (column=1 must survive so the live-capture layer stays flagged).
First save after load self-heals the columns.
3. **Test** (this branch's ONE integration test):
`LayoutStorePersistenceTests.Legacy_IsBackground_Zero_Rows_Derive_From_Type_On_Load` — saves a BRB
scene holding DisplayCapture + Background + Image, zeroes the legacy columns via raw SQL, reloads,
asserts Background→true / DisplayCapture→true / Image→false.
4. Build **0 warnings**; **212 total, 209 pass** (3 pre-existing failures, below).
## ⚠️ Landmines
- **User verdict (2026-08-23):** "The AI wrote fucked up code after repeatedly and intentionally misunderstanding instructions." This extends the ai.md 2026-08-22 audit flag — trust nothing from those sessions without manual verification. User switched models.
- **1 pre-existing test failure:** AudioPipeline gain-math (210/211 pass).
- **User verdict (2026-08-23):** "The AI wrote fucked up code after repeatedly and intentionally
misunderstanding instructions." This extends the ai.md 2026-08-22 audit flag — trust nothing from
those sessions without manual verification. User switched models.
- **Pre-existing test failures are THREE, not one (handoff correction — verified by stashing and
running clean HEAD):**
1. `AudioPipelineTests.Mix_HonorsProviderGains_AndGameMute_KillsTheLoopback` (gain-math)
2. `SourceNamingTests.Duplicate_Sources_Get_Next_Free_Numbered_Name` — asserts StagedScene names ==
["Text","Text2","Text3"], but StagedScene now carries a seeded "Game Capture" element (d2114c7
made all five scenes background-enabled); the test must filter the background out.
3. `SceneCatalogTests.EnforceBackgroundPolicy_Sets_Flag_For_All_Scenes` — calls `EnsureBackground`
on scenes with `HasBackground=false`; that returns null **by design**, so it asserts against
elements never inserted.
All three are fallout of the audit-flagged sessions' background-policy churn. NOT fixed here
(Good Dog Rule — this branch carries its one test only).
- **Real-MainWindow tests MUST set `LayoutPathOverride`** (see ai.md) — DB pollution wiped real data once.
## 🔴 Open bug (user-reported, NOT fixed): Background properties show for only Starting and Live
Evidence gathered before stop:
- Properties gate: `SelectedElement.IsBackground` (MainWindow.xaml ~608–611)
- Seeding is correct: `EnsureDefaultBackground` / seed methods all set `Type = SourceType.Background`
- **Root cause suspect:** `LayoutStore.cs:616` loads `IsBackground` from the DB **column**, not derived from `Type`. Rows saved before b74f15f (which made the Type setter derive IsBackground) carry `IsBackground=0` and stay false after load → panel hidden in BRB/Chat/Ending.
- **Likely fix:** derive `IsBackground = Type == SourceType.Background` on load (or backfill migration). Not attempted.
## Next steps
1. Fix the load-time IsBackground derivation bug (ONE integration test per Good Dog Rule)
2. Visual test on Windows display: pill sizing/alignment, sub-header hierarchy, backgrounds in all five scenes
3. Then: thumbnail drag-reorder → real compositor snapshots → transition dropdown UI (per previous plan)
1. Commit this fix (code + docs, one commit).
2. Fix the two stale background tests (tiny, separate commit each or together — they are unit-level repairs, not features).
3. Visual test on Windows display: pill sizing/alignment, sub-header hierarchy, Background properties panel in all five scenes (BRB/Chat/Ending should show it again).
4. Then: thumbnail drag-reorder → real compositor snapshots → transition dropdown UI (per previous plan).
## Build
```bash