fix(blur): the (+) menu entry re-evaluates — CanAddBlur was never re-notified

The Blur item's Visibility is bound to CanAddBlur, which depends on the staged scene. The scene
setter never raised it, so the binding evaluated once (collapsed) and stayed collapsed for the
session — build 1082: the option simply wasn't there.

StagedScene now notifies CanAddBlur, with a test that pins both halves: Live true, Chat false,
and a notification on every staged-scene change.
This commit is contained in:
2026-11-01 13:17:40 -08:00
parent 9b44a32054
commit da508f0a14
2 changed files with 56 additions and 0 deletions
+5
View File
@@ -33,6 +33,11 @@ public partial class MainViewModel
foreach (var s in Scenes)
s.IsStaged = s == value;
// Scene-scoped menu affordances: the (+) menu's Blur entry is Live-only, and a
// binding that is never re-notified stays collapsed for the rest of the session
// (build 1082: the option vanished after the first layout load).
OnPropertyChanged(nameof(CanAddBlur));
SelectedElement = null;
if (value != null)
{
+51
View File
@@ -0,0 +1,51 @@
using System;
using System.IO;
using System.Linq;
using Xunit;
using ytLive.Models;
using ytLive.ViewModels;
namespace ytLive.Tests;
/// <summary>
/// The (+) menu's Blur entry is Live-scene only, and it is bound — so the view model has to
/// re-notify `CanAddBlur` whenever the staged scene changes. It did not, and the option stayed
/// collapsed for the rest of the session (build 1082: "it no longer appears as an option").
/// </summary>
[Collection("MainViewModelLayoutPath")]
public class BlurMenuAvailabilityTests
{
private static MainViewModel NewVm(out string dbPath)
{
dbPath = Path.Combine(Path.GetTempPath(), $"llamacasty-blurmenu-{Guid.NewGuid():N}.db");
MainViewModel.LayoutPathOverride = dbPath;
return new MainViewModel();
}
[Fact]
public void Blur_is_offered_on_the_live_scene_only_and_the_flag_is_re_notified()
{
var vm = NewVm(out var dbPath);
try
{
var live = vm.Scenes.First(s => SceneCatalog.Is(s.Name, SceneCatalog.Live));
var chat = vm.Scenes.First(s => SceneCatalog.Is(s.Name, SceneCatalog.Chat));
vm.StagedScene = live;
Assert.True(vm.CanAddBlur, "the Live scene must offer the blur layer");
vm.StagedScene = chat;
Assert.False(vm.CanAddBlur, "other scenes must not offer a desktop blur");
// The regression: a bound property with no notification never re-evaluates.
var notified = 0;
vm.PropertyChanged += (_, e) => { if (e.PropertyName == nameof(MainViewModel.CanAddBlur)) notified++; };
vm.StagedScene = live;
Assert.True(notified > 0, "changing the staged scene must re-notify CanAddBlur");
}
finally
{
MainViewModel.LayoutPathOverride = null;
try { File.Delete(dbPath); } catch (IOException) { }
}
}
}