fix(ui): notify IsTasksEmptyRepoHintVisible on every list switch

IsTasksEmptyRepoHintVisible reads _currentList?.Kind directly, but Kind
isn't itself observed — the NotifyPropertyChangedFor chain only fires
when IsLetClaudeVisible's value actually changes. Switching from a
Smart list to an empty User list without a WorkingDir changes Kind
while IsLetClaudeVisible (and Has*) stay false in both, so the hint
never notified and stayed stale.
This commit is contained in:
mika kuns
2026-08-21 10:34:46 +02:00
parent 9159f1b55c
commit b997af4423
2 changed files with 34 additions and 0 deletions
@@ -387,6 +387,13 @@ public sealed partial class TasksIslandViewModel : ViewModelBase, IDisposable
if (_currentList is not null) if (_currentList is not null)
_currentList.PropertyChanged += OnCurrentListPropertyChanged; _currentList.PropertyChanged += OnCurrentListPropertyChanged;
// IsTasksEmptyRepoHintVisible reads _currentList?.Kind directly, but Kind isn't itself an
// observed property — the [NotifyPropertyChangedFor] chain only fires when IsLetClaudeVisible's
// *value* changes. Switching between two lists that both resolve IsLetClaudeVisible to the
// same bool (e.g. a Smart list -> an empty User list without a WorkingDir) changes Kind
// without ever notifying, leaving the hint stale. Force it explicitly on every list switch.
OnPropertyChanged(nameof(IsTasksEmptyRepoHintVisible));
Items.Clear(); Items.Clear();
Rows.Clear(); Rows.Clear();
HasOverdue = false; HasOverdue = false;
@@ -109,4 +109,31 @@ public class TasksIslandEmptyStateTests : IDisposable
Assert.False(vm.IsTasksEmptyHintVisible); Assert.False(vm.IsTasksEmptyHintVisible);
Assert.False(vm.IsTasksEmptyRepoHintVisible); Assert.False(vm.IsTasksEmptyRepoHintVisible);
} }
// Regression: switching from an empty Smart list (never eligible for the repo hint) to an
// empty User list without a WorkingDir changes the correct value of
// IsTasksEmptyRepoHintVisible from false to true, but IsLetClaudeVisible stays false in both
// cases (Smart lists are never User) and HasOverdue/HasOpen/HasCompleted stay false in both
// cases (both lists are empty) — so the [NotifyPropertyChangedFor] chain alone never fires.
[Fact]
public async Task IsTasksEmptyRepoHintVisible_notifies_on_switch_from_smart_list_to_empty_user_list_without_working_dir()
{
await using var db = NewContext();
db.Lists.Add(new ListEntity { Id = "L4", Name = "Work", CreatedAt = DateTime.UtcNow });
await db.SaveChangesAsync();
var vm = NewVm();
vm.LoadForList(new ListNavItemViewModel { Id = "smart:important", Name = "Important", Kind = ListKind.Smart, WorkingDir = null });
await vm.LoadTask!;
Assert.False(vm.IsTasksEmptyRepoHintVisible);
var raisedProperties = new List<string?>();
vm.PropertyChanged += (_, e) => raisedProperties.Add(e.PropertyName);
vm.LoadForList(new ListNavItemViewModel { Id = "user:L4", Name = "Work", Kind = ListKind.User, WorkingDir = null });
await vm.LoadTask!;
Assert.Contains(nameof(TasksIslandViewModel.IsTasksEmptyRepoHintVisible), raisedProperties);
Assert.True(vm.IsTasksEmptyRepoHintVisible);
}
} }