Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ All notable changes will be documented here. The format follows [Keep a Changelo
- `REL-00003` Firefox qualification covers the installed `firefox-bin` runtime, one-row grouping, visible launcher/icon preference, ambiguity safety, and executable fallback.
- `FAD-0301` XDG user-data paths and SQLite startup with versioned, checksummed, transactional schema migrations.
- `FAD-0302` Durable application identity records, allowlisted evidence, and custom name/icon overrides with opaque keys for sensitive fallback identities.
- `FAD-0501` Live Avalonia application rows from immutable mixer snapshots, with per-application volume and mute commands and reconnect-aware controls.

### Changed

Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Fadrio resolves PipeWire playback nodes into stable logical applications and groups every session owned by an application behind one mixer target. Three browser streams should look like one **Brave** or **Firefox** control—not three nodes, renderer processes, or PIDs.

> [!IMPORTANT]
> Fadrio is a source-only public alpha, not an end-user release. No supported binary package is published yet. Packaging, persistence, MIDI control, and the finished interface are not implemented. Initial Steam/Proton identification requires corroborating local process, compatibility-directory, and installed-manifest evidence.
> Fadrio is a source-only public alpha, not an end-user release. No supported binary package is published yet. Basic identity persistence and live application controls exist, but durable mixer policies, MIDI control, output control, and the finished interface are not implemented. Initial Steam/Proton identification requires corroborating local process, compatibility-directory, and installed-manifest evidence.

## What works today

Expand All @@ -35,7 +35,7 @@ Fadrio resolves PipeWire playback nodes into stable logical applications and gro
- Stable fallback identities that never use PID.
- Multi-session application grouping and application-wide volume/mute commands.
- Managed reconnect supervision with generation isolation.
- Diagnostic CLI and minimal Avalonia shell.
- Diagnostic CLI, SQLite-backed identity overrides, and the first live Avalonia application rows with volume and mute controls.

## Architecture

Expand Down Expand Up @@ -89,6 +89,10 @@ dotnet run --project src/Fadrio.Cli -- profile clear xdg:firefox

The override appears in subsequent `apps` output while the canonical ID remains unchanged.

Launch the in-development mixer with `dotnet run --project src/Fadrio.UI`. Its application rows reflect the live PipeWire snapshot and use the same application-wide volume/mute command path as the CLI. Output-device controls, icons, tray behavior, and UI polish remain on the roadmap.

[See the first live-row screenshot](docs/screenshots/fad-0501-live-fixture.png), captured with a controlled, silent PipeWire fixture rather than a user's applications.

Exercise the shared M0 command path:

```bash
Expand Down
2 changes: 1 addition & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Canonical ticket format:

## 0.5 — UI alpha

- [ ] `FAD-0501` `P0` Connect immutable mixer snapshots and commands to the Avalonia view models.
- [x] `FAD-0501` `P0` Connect immutable mixer snapshots and commands to the Avalonia view models.
- [ ] `FAD-0502` `P1` Build accessible output and logical-application rows with mixed-volume state.
- [ ] `FAD-0503` `P1` Add stable sorting, interaction freeze, empty, unavailable, and reconnect states.
- [ ] `FAD-0504` `P1` Implement tray popup, single-instance activation, and clean shutdown.
Expand Down
Binary file added docs/screenshots/fad-0501-live-fixture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 12 additions & 2 deletions src/Fadrio.UI/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using Fadrio.Infrastructure;
using Fadrio.UI.ViewModels;

namespace Fadrio.UI;
Expand All @@ -13,10 +14,19 @@ public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow
var database = new FadrioDatabase(FadrioDataPaths.Resolve().DatabasePath);
MixerUiSession? session = null;
var viewModel = new MainWindowViewModel(
(id, volume) => session!.SetVolumeAsync(id, volume),
(id, muted) => session!.SetMuteAsync(id, muted));
session = new MixerUiSession(viewModel, database);
var window = new MainWindow
{
DataContext = new MainWindowViewModel()
DataContext = viewModel
};
window.Opened += (_, _) => session.Start();
window.Closed += async (_, _) => await session.DisposeAsync();
desktop.MainWindow = window;
}

base.OnFrameworkInitializationCompleted();
Expand Down
25 changes: 23 additions & 2 deletions src/Fadrio.UI/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,34 @@
WindowStartupLocation="CenterScreen">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel Margin="24" Spacing="12">
<TextBlock Text="{Binding Title}" FontSize="20" FontWeight="SemiBold" />
<TextBlock Text="{Binding Title}" FontSize="24" FontWeight="SemiBold" />
<TextBlock Text="{Binding Status}" FontSize="12" Opacity="0.7" />
<Separator />
<TextBlock Text="{Binding OutputHeading}" FontSize="12" FontWeight="SemiBold" />
<TextBlock Text="{Binding EmptyOutputMessage}" Opacity="0.7" />
<Separator Margin="0,8" />
<TextBlock Text="{Binding ApplicationsHeading}" FontSize="12" FontWeight="SemiBold" />
<TextBlock Text="{Binding EmptyApplicationsMessage}" TextWrapping="Wrap" Opacity="0.7" />
<TextBlock Text="{Binding EmptyApplicationsMessage}" IsVisible="{Binding HasNoApplications}" TextWrapping="Wrap" Opacity="0.7" />
<ItemsControl ItemsSource="{Binding Applications}">
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="vm:ApplicationRowViewModel">
<Border Padding="12" Margin="0,0,0,8" CornerRadius="10" Background="{DynamicResource SystemControlBackgroundBaseLowBrush}">
<StackPanel Spacing="6">
<Grid ColumnDefinitions="*,Auto">
<TextBlock Text="{Binding DisplayName}" FontWeight="SemiBold" TextTrimming="CharacterEllipsis" />
<TextBlock Grid.Column="1" Text="{Binding VolumeLabel}" Margin="8,0,0,0" />
</Grid>
<Slider Minimum="0" Maximum="100" Value="{Binding Volume, Mode=TwoWay}"
IsEnabled="{Binding CanControl}" Name="VolumeSlider"
AutomationProperties.Name="{Binding VolumeControlLabel}" />
<Button Content="{Binding MuteLabel}" Command="{Binding ToggleMuteCommand}"
IsEnabled="{Binding CanControl}" HorizontalAlignment="Left"
AutomationProperties.Name="{Binding MuteControlLabel}" />
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</ScrollViewer>
</Window>
77 changes: 77 additions & 0 deletions src/Fadrio.UI/MixerUiSession.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using Avalonia.Threading;
using Fadrio.Application;
using Fadrio.Core;
using Fadrio.Infrastructure;
using Fadrio.NativeInterop;
using Fadrio.Platform.Linux;
using Fadrio.UI.ViewModels;
using ApplicationId = Fadrio.Core.ApplicationId;

namespace Fadrio.UI;

internal sealed class MixerUiSession : IAsyncDisposable
{
private readonly CancellationTokenSource _shutdown = new();
private readonly ReconnectingAudioBackend _backend = new(() => new NativeAudioBackend());
private readonly XdgDesktopApplicationIndex _desktopIndex = new();
private readonly MixerStateCoordinator _coordinator;
private readonly MixerCommands _commands;
private readonly MainWindowViewModel _viewModel;
private Task? _runTask;

public MixerUiSession(MainWindowViewModel viewModel, FadrioDatabase database)
{
_viewModel = viewModel;
IApplicationResolver resolver = new ApplicationResolver(new LinuxProcMetadataProvider(), _desktopIndex,
new SteamApplicationResolver(new SteamApplicationIndex()),
new FlatpakApplicationResolver(_desktopIndex), new SnapApplicationResolver(_desktopIndex));
resolver = new PersistentApplicationResolver(resolver, new ApplicationIdentityStore(database));
_coordinator = new MixerStateCoordinator(resolver);
_commands = new MixerCommands(_backend, _coordinator);
}

public void Start() => _runTask ??= Task.Run(RunAsync);

public ValueTask SetVolumeAsync(ApplicationId id, float volume) =>
_commands.SetApplicationVolumeAsync(id, volume, _shutdown.Token);

public ValueTask SetMuteAsync(ApplicationId id, bool muted) =>
_commands.SetApplicationMuteAsync(id, muted, _shutdown.Token);

private async Task RunAsync()
{
try
{
await foreach (AudioBackendEvent backendEvent in _backend.WatchAsync(_shutdown.Token))
{
await _coordinator.ApplyAsync(backendEvent, _shutdown.Token);
MixerSnapshot snapshot = _coordinator.Current;
bool? available = backendEvent switch
{
BackendReady => true,
BackendDisconnected => false,
_ => null
};
Dispatcher.UIThread.Post(() =>
{
if (available.HasValue) _viewModel.SetBackendAvailable(available.Value);
_viewModel.ApplySnapshot(snapshot);
});
}
}
catch (OperationCanceledException) when (_shutdown.IsCancellationRequested) { }
catch (Exception exception) when (exception is InvalidOperationException or IOException or DllNotFoundException)
{
Dispatcher.UIThread.Post(_viewModel.SetBackendFailed);
}
}

public async ValueTask DisposeAsync()
{
await _shutdown.CancelAsync();
if (_runTask is not null) await _runTask;
await _backend.DisposeAsync();
_desktopIndex.Dispose();
_shutdown.Dispose();
}
}
Loading
Loading