From da508f0a14c22f17234c0c970b8f6c0a8e6c0214 Mon Sep 17 00:00:00 2001 From: gramps Date: Sun, 1 Nov 2026 13:17:40 -0800 Subject: [PATCH] =?UTF-8?q?fix(blur):=20the=20(+)=20menu=20entry=20re-eval?= =?UTF-8?q?uates=20=E2=80=94=20CanAddBlur=20was=20never=20re-notified?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- ViewModels/MainViewModel.Scenes.cs | 5 +++ ytLive.Tests/BlurMenuAvailabilityTests.cs | 51 +++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 ytLive.Tests/BlurMenuAvailabilityTests.cs diff --git a/ViewModels/MainViewModel.Scenes.cs b/ViewModels/MainViewModel.Scenes.cs index f5173ab..e95bcad 100644 --- a/ViewModels/MainViewModel.Scenes.cs +++ b/ViewModels/MainViewModel.Scenes.cs @@ -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) { diff --git a/ytLive.Tests/BlurMenuAvailabilityTests.cs b/ytLive.Tests/BlurMenuAvailabilityTests.cs new file mode 100644 index 0000000..f07521e --- /dev/null +++ b/ytLive.Tests/BlurMenuAvailabilityTests.cs @@ -0,0 +1,51 @@ +using System; +using System.IO; +using System.Linq; +using Xunit; +using ytLive.Models; +using ytLive.ViewModels; + +namespace ytLive.Tests; + +/// +/// 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"). +/// +[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) { } + } + } +}