refactor(ui): unify list-linked-repo predicate into RepoLinkage

ListsIslandViewModel and SettingsModalViewModel each re-implemented "does
this list have a linked WorkingDir" with different whitespace handling.
RepoLinkage.IsLinked/IsLinkedInDb is now the single definition; both
callers derive from it, closing the whitespace-only WorkingDir gap where
the Settings modal disagreed with the ListsIsland banner.
This commit is contained in:
Mika Kuns
2026-08-24 09:28:20 +02:00
parent 29171b104b
commit 9578c95074
4 changed files with 42 additions and 4 deletions
@@ -187,12 +187,14 @@ public sealed partial class ListsIslandViewModel : ViewModelBase, IDisposable
[ObservableProperty] private ListNavItemViewModel? _selectedList;
/// <summary>True whenever no User list has a linked <c>WorkingDir</c> — drives the no-repo
/// banner. Smart/Virtual lists never count. Recomputed after every load and every
/// list CRUD / list-settings save; never persisted, no dismiss state.</summary>
/// banner. Smart/Virtual lists never count (scope intentionally narrower than
/// SettingsModalViewModel.HasLinkedRepo, which checks all Lists rows in the DB). Recomputed
/// after every load and every list CRUD / list-settings save; never persisted, no dismiss
/// state.</summary>
[ObservableProperty] private bool _hasNoLinkedRepo = true;
private void RecomputeHasNoLinkedRepo() =>
HasNoLinkedRepo = UserLists.All(r => string.IsNullOrWhiteSpace(r.WorkingDir));
HasNoLinkedRepo = UserLists.All(r => !RepoLinkage.IsLinked(r.WorkingDir));
public string UserName { get; } = Environment.UserName;
public string MachineName { get; } = Environment.MachineName;
@@ -56,6 +56,8 @@ public sealed partial class SettingsModalViewModel : ViewModelBase
// True once at least one list has a linked repo (WorkingDir). Drives the repo-hint strip on
// Worktrees/Prime Claude/Session Skills/Berichte — nothing is ever hidden, just annotated.
// Scope intentionally broader than ListsIslandViewModel.HasNoLinkedRepo (all Lists rows in
// the DB, not just UserLists).
[ObservableProperty] private bool _hasLinkedRepo;
// Wired by WindowDialogService to close this modal and open the existing repo-import flow.
@@ -152,7 +154,7 @@ public sealed partial class SettingsModalViewModel : ViewModelBase
General.LoadModelPresets(dto?.ModelPresets, General.MaxTurnsCeiling);
await using var ctx = await _dbFactory.CreateDbContextAsync();
HasLinkedRepo = await ctx.Lists.AnyAsync(l => l.WorkingDir != null && l.WorkingDir != "");
HasLinkedRepo = await ctx.Lists.AnyAsync(RepoLinkage.IsLinkedInDb);
}
finally { IsBusy = false; }
}