refactor: collapse single-implementation interfaces

Nine interfaces had exactly one implementation and no test double — they existed
only to be named twice in a DI registration: IFindingsStore, IFindingsStoreLocator,
IPrimeScheduleSignal, IRefineRunner, IWeekReportService, IMergeCoordinator,
IMissionControlPane, IOnlineLoginService, ITaskListFilter. Consumers now depend on
the concrete type; the DTO records that shared those files moved next to their
implementation. IInteractiveLaunchSpecService stays — it carries 54 lines of
contract documentation, which is not ceremony.

IMergeCoordinator in particular had a redundant null object: MergeCoordinator with
a null Handler already no-ops, and every test used the real class with Handler set.

Filtering/ collapses from 8 files to 1. ITaskListFilter and TaskListFilterBase were
a double abstraction over four predicates, with MatchesAsContext => false declared
in both. SmartFlagFilter also compiled its expression twice (its own _flag plus the
inherited Matches cache) — it now uses the cache.

StaticTokenAuthProvider was in src but production uses ZitadelAuthProvider; it is
a test double, so it moves to the test project. Its own test goes away with it.
This commit is contained in:
mika kuns
2026-08-26 10:12:23 +02:00
parent 76d836a278
commit 296251e27e
45 changed files with 174 additions and 327 deletions
@@ -1,10 +0,0 @@
namespace ClaudeDo.Ui.Services;
public sealed record OnlineLoginResult(bool Success, string? RefreshToken, string? Error, string? Warning = null);
public interface IOnlineLoginService
{
Task<OnlineLoginResult> LoginAsync(
string authority, string clientId, string scope, string redirectUri,
CancellationToken ct = default);
}
@@ -6,20 +6,12 @@ namespace ClaudeDo.Ui.Services;
/// <summary>
/// Single entry point for handing a conflicting merge to the in-app 3-pane resolver.
/// Replaces the per-VM <c>RequestConflictResolution</c> Func seams that used to be
/// hand-threaded shell → details → merge-section → diff → merge-modal. The shell wires
/// <see cref="MergeCoordinator.Handler"/> once at composition; invokers depend only on
/// this interface (injected via DI).
/// </summary>
public interface IMergeCoordinator
{
Task ResolveConflictAsync(string taskId, string targetBranch);
}
/// <summary>
/// hand-threaded shell → details → merge-section → diff → merge-modal.
///
/// DI singleton holding the resolver entry. The holder breaks the shell↔island construction
/// cycle: islands depend on the interface, the shell sets <see cref="Handler"/> after it is built.
/// cycle: islands depend on this type, the shell sets <see cref="Handler"/> after it is built.
/// </summary>
public sealed class MergeCoordinator : IMergeCoordinator
public sealed class MergeCoordinator
{
/// Set once at composition to the shell's resolver entry. Null (headless/tests) ⇒ no-op.
public Func<string, string, Task>? Handler { get; set; }
@@ -6,7 +6,9 @@ using Duende.IdentityModel.OidcClient.Browser;
namespace ClaudeDo.Ui.Services;
public sealed class OnlineLoginService : IOnlineLoginService
public sealed record OnlineLoginResult(bool Success, string? RefreshToken, string? Error, string? Warning = null);
public sealed class OnlineLoginService
{
public async Task<OnlineLoginResult> LoginAsync(
string authority, string clientId, string scope, string redirectUri,
@@ -21,7 +21,7 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase, IDisposable
private readonly IWorkerClient _worker;
private readonly IServiceProvider _services;
private readonly INotesApi _notesApi;
private readonly IMergeCoordinator _merge;
private readonly MergeCoordinator _merge;
// ── Section view models ───────────────────────────────────────────────────
public AgentConfigEditorViewModel AgentSettings { get; }
@@ -325,7 +325,7 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase, IDisposable
IWorkerClient worker,
IServiceProvider services,
INotesApi notesApi,
IMergeCoordinator merge)
MergeCoordinator merge)
{
_dbFactory = dbFactory;
_worker = worker;
@@ -11,7 +11,7 @@ namespace ClaudeDo.Ui.ViewModels.MissionControl;
/// Claude session, or an ad-hoc/free session in a user-chosen directory (no task, <see cref="TaskId"/>
/// is null — ad-hoc panes are never deduped, unlike task-based ones).
/// </summary>
public sealed partial class ConPtyPaneViewModel : ViewModelBase, IMissionControlPane, IDisposable
public sealed partial class ConPtyPaneViewModel : ViewModelBase, IDisposable
{
public string? TaskId { get; }
@@ -1,11 +0,0 @@
namespace ClaudeDo.Ui.ViewModels.MissionControl;
/// <summary>
/// Common contract for anything hosted as a pane in the Command Center — currently only
/// <see cref="ConPtyPaneViewModel"/>, kept as its own abstraction so the grid/tabs layout
/// toggle binds a pane collection rather than a concrete ConPTY-specific type.
/// </summary>
public interface IMissionControlPane
{
string DisplayTitle { get; }
}
@@ -35,7 +35,7 @@ public sealed partial class MissionControlViewModel : ViewModelBase, IDisposable
// Mirror of ConPtySessions typed as the pane abstraction so the layout toggle (grid/tabs)
// binds one contract rather than a ConPTY-specific type.
public ObservableCollection<IMissionControlPane> Panes { get; } = new();
public ObservableCollection<ConPtyPaneViewModel> Panes { get; } = new();
[ObservableProperty] private int _columnCount = 1;
@@ -43,7 +43,7 @@ public sealed partial class MissionControlViewModel : ViewModelBase, IDisposable
[NotifyPropertyChangedFor(nameof(LayoutToggleLabel))]
private bool _isFocusMode;
[ObservableProperty] private IMissionControlPane? _focusedPane;
[ObservableProperty] private ConPtyPaneViewModel? _focusedPane;
public string LayoutToggleLabel => Loc.T(IsFocusMode ? "missionControl.overviewMode" : "missionControl.focusMode");
@@ -403,7 +403,7 @@ public sealed partial class MissionControlViewModel : ViewModelBase, IDisposable
_ => 3,
};
OnPropertyChanged(nameof(HasPanes));
if (e.Action == NotifyCollectionChangedAction.Add && e.NewItems?[0] is IMissionControlPane added)
if (e.Action == NotifyCollectionChangedAction.Add && e.NewItems?[0] is ConPtyPaneViewModel added)
FocusedPane = added;
else if (e.Action == NotifyCollectionChangedAction.Remove && ReferenceEquals(FocusedPane, e.OldItems?[0]))
FocusedPane = Panes.LastOrDefault();
@@ -9,7 +9,7 @@ namespace ClaudeDo.Ui.ViewModels.Modals;
public sealed partial class MergeModalViewModel : ViewModelBase
{
private readonly IWorkerClient _worker;
private readonly IMergeCoordinator _merge;
private readonly MergeCoordinator _merge;
public string TaskId { get; set; } = "";
public string TaskTitle { get; set; } = "";
@@ -42,7 +42,7 @@ public sealed partial class MergeModalViewModel : ViewModelBase
/// True once a conflict has been handed off to the resolver — also a cue to close the diff window.
public bool RoutedToResolver { get; private set; }
public MergeModalViewModel(IWorkerClient worker, IMergeCoordinator merge)
public MergeModalViewModel(IWorkerClient worker, MergeCoordinator merge)
{
_worker = worker;
_merge = merge;
@@ -8,7 +8,7 @@ namespace ClaudeDo.Ui.ViewModels.Modals.Settings;
public sealed partial class OnlineInboxSettingsViewModel : ViewModelBase
{
private readonly IWorkerClient _worker;
private readonly IOnlineLoginService _loginService;
private readonly OnlineLoginService _loginService;
[ObservableProperty] private bool _enabled;
[ObservableProperty] private string _apiBaseUrl = "";
@@ -21,7 +21,7 @@ public sealed partial class OnlineInboxSettingsViewModel : ViewModelBase
[ObservableProperty] private bool _isBusy;
[ObservableProperty] private string _statusMessage = "";
public OnlineInboxSettingsViewModel(IWorkerClient worker, IOnlineLoginService loginService)
public OnlineInboxSettingsViewModel(IWorkerClient worker, OnlineLoginService loginService)
{
_worker = worker;
_loginService = loginService;
@@ -73,7 +73,7 @@ public sealed partial class SettingsModalViewModel : ViewModelBase
public Action? CloseAction { get; set; }
public SettingsModalViewModel(IWorkerClient worker, PrimeClaudeTabViewModel prime,
IOnlineLoginService onlineLoginService,
OnlineLoginService onlineLoginService,
ILocalizer localizer, AppSettings appSettings,
IDbContextFactory<ClaudeDoDbContext> dbFactory)
{
@@ -69,7 +69,7 @@ public sealed partial class WorktreesOverviewModalViewModel : ViewModelBase
{
private readonly IWorkerClient _worker;
private readonly Func<DiffViewerViewModel> _diffVmFactory;
private readonly IMergeCoordinator _merge;
private readonly MergeCoordinator _merge;
[ObservableProperty] private string? _listIdFilter;
[ObservableProperty] private string _title = "Worktrees";
@@ -104,7 +104,7 @@ public sealed partial class WorktreesOverviewModalViewModel : ViewModelBase
public Func<MergeModalViewModel>? ResolveMergeVm { get; set; }
public Func<MergeModalViewModel, Task>? ShowMergeAction { get; set; }
public WorktreesOverviewModalViewModel(IWorkerClient worker, Func<DiffViewerViewModel> diffVmFactory, IMergeCoordinator merge)
public WorktreesOverviewModalViewModel(IWorkerClient worker, Func<DiffViewerViewModel> diffVmFactory, MergeCoordinator merge)
{
_worker = worker;
_diffVmFactory = diffVmFactory;
@@ -75,7 +75,7 @@
SelectedItem="{Binding FocusedPane}"
IsVisible="{Binding IsFocusMode}">
<TabControl.ItemTemplate>
<DataTemplate x:DataType="vmm:IMissionControlPane">
<DataTemplate x:DataType="vmm:ConPtyPaneViewModel">
<TextBlock Text="{Binding DisplayTitle}" TextTrimming="CharacterEllipsis" MaxWidth="160" />
</DataTemplate>
</TabControl.ItemTemplate>