-
Notifications
You must be signed in to change notification settings - Fork 10
feat: cross-platform rewrite with Avalonia UI + Linux support #162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ibetitsmike
wants to merge
13
commits into
main
Choose a base branch
from
cross-platform-61zw
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Retarget Vpn/Vpn.csproj from net8.0-windows to net8.0 - Create IRpcTransport.cs in Vpn/ with IRpcServerTransport and IRpcClientTransport interfaces - Create Vpn.Windows/ project (net8.0-windows): - Move RegistryConfigurationSource.cs from Vpn/ - Add NamedPipeServerTransport and NamedPipeClientTransport - Create Vpn.Linux/ project (net8.0): - Add UnixSocketServerTransport and UnixSocketClientTransport - Create App.Windows/ project (net8.0-windows) placeholder - Create App.Linux/ project (net8.0) placeholder - Add all new projects to Coder.Desktop.sln All cross-platform projects build successfully on Linux: Vpn, Vpn.Linux, App.Linux, Vpn.Proto, CoderSdk, MutagenSdk
Phase 1: Retarget Vpn.Service from net8.0-windows to net8.0 and add
platform-conditional code for Windows/Linux support.
Changes:
- Vpn.Service.csproj: retarget to net8.0, add EnableWindowsTargeting,
conditional Windows/Linux package references and project references,
WINDOWS preprocessor constant on Windows builds
- Program.cs: platform-conditional hosting (AddWindowsService vs
AddSystemd), config (Registry vs JSON file), transport registration
(NamedPipeServerTransport vs UnixSocketServerTransport), log paths
- ManagerConfig.cs: add ServiceRpcSocketPath for Linux, platform-
conditional defaults for TunnelBinaryPath and SignatureSigner
- ManagerRpc.cs: replace direct named pipe code with IRpcServerTransport
abstraction, inject transport via constructor
- TelemetryEnricher.cs: cross-platform device ID (Windows Registry vs
/etc/machine-id), platform-conditional DeviceOs string
- Downloader.cs: wrap AuthenticodeDownloadValidator in #if WINDOWS
- Manager.cs: platform-conditional binary download URL
(coder-linux-{arch} vs coder-windows-{arch}.exe), guard Authenticode
validator instantiation with #if WINDOWS
- Delete packages.lock.json (RestorePackagesWithLockFile=false)
…ging Phase 3: App.Linux/ — Linux platform service implementations: - LinuxSecretServiceBackend: secret-tool CLI for credential storage - LinuxXdgStartupManager: XDG autostart desktop entry - LinuxNotifySendNotifier: notify-send for notifications - LinuxRdpConnector: xfreerdp/remmina fallback chain - LinuxSingleInstance: Unix domain socket lock Phase 4: MutagenSdk cross-platform: - MutagenClient detects Named Pipe vs Unix Domain Socket transport - Windows: existing NamedPipesConnectionFactory - Linux: direct Socket + NetworkStream to UDS Phase 5: Packaging.Linux/ — Linux packaging: - systemd unit file (Type=notify, root for TUN) - .desktop file with coder:// URI handler - postinst/prerm scripts for service lifecycle - build-deb.sh for amd64/arm64 .deb creation - Default config.json template
Phase 6: Cross-platform test infrastructure:
- Tests.Vpn: net8.0-windows → net8.0
- Tests.Vpn.Service: net8.0-windows → net8.0 with EnableWindowsTargeting
- AuthenticodeDownloadValidatorTest wrapped in #if WINDOWS
- AssemblyVersionDownloadValidatorTest marked [Platform("Win")]
- TelemetryEnricherTest updated for platform-conditional DeviceOs
- Vpn.DebugClient: net8.0-windows → net8.0
- Platform-conditional connect (Named Pipe vs Unix Socket)
- App.csproj and Tests.App.csproj: added EnableWindowsTargeting
All cross-platform tests pass on Linux:
- Tests.Vpn: 24 passed
- Tests.Vpn.Proto: 9 passed
- Tests.CoderSdk: 8 passed
- Tests.Vpn.Service: 16 passed (Windows-only tests skipped)
Phase 2.0 (partial): Foundation for Avalonia UI migration. App.Shared/ (net8.0) contains: - Models: all 5 model files (CredentialModel, RpcModel, Settings, SyncSessionControllerStateModel, SyncSessionModel) - Service interfaces: IRpcController, ICredentialManager, ICredentialBackend, IUserNotifier, INotificationHandler, IStartupManager, IRdpConnector, IHostnameSuffixGetter, ISyncSessionController, IUpdateController, ISettingsManager, IUriHandler - New abstractions: IDispatcher (replaces DispatcherQueue), IClipboardService (replaces Windows Clipboard), ILauncherService (replaces Windows.System.Launcher), IWindowService (abstracts window creation for ViewModels) - Utils: ModelUpdate, FriendlyByteConverter (static utility) Builds with 0 errors on Linux. Next: copy cross-platform service implementations and ViewModels.
Copy and adapt service implementations from App/: - CredentialManager.cs (without WindowsCredentialBackend) - RpcController.cs (refactored: IRpcClientTransport replaces NamedPipeClientStream) - HostnameSuffixGetter.cs (as-is, cross-platform) - SettingsManager.cs (as-is, JSON file storage) - UriHandler.cs (as-is, business logic only) RpcController now injects IRpcClientTransport for platform-agnostic RPC connections (Named Pipes on Windows, Unix Sockets on Linux). Builds with 0 errors on Linux.
Add SettingsViewModel and TrayWindowDisconnectedViewModel - the only ViewModels with zero WinUI dependencies. The remaining 10 ViewModels are deeply coupled to WinUI types (DispatcherQueue, ImageSource, FrameworkElement, ContentDialog, etc.) and will be adapted during the Avalonia UI conversion phase when the actual UI framework types are available to replace them with. This commit establishes the pattern: cross-platform ViewModels live in App.Shared/, WinUI-coupled code stays in App/ until Avalonia equivalents are ready.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cross-Platform Rewrite: Avalonia UI + Linux Support
This PR rewrites the Coder Desktop application to run on both Windows and Linux using Avalonia 11 for the GUI and .NET 8 for the service layer. The existing WinUI 3
App/project is preserved unchanged.Architecture
What changed (13 commits)
Infrastructure (Phases 0-1):
Vpn/fromnet8.0-windows→net8.0IRpcServerTransport/IRpcClientTransportabstractionsVpn.Servicecross-platform: conditionalAddWindowsService()/AddSystemd(),IRpcServerTransportinjection, platform-conditional config (Registry vs JSON)Linux Platform (Phases 3-5):
App.Linux/: LinuxSecretServiceBackend, LinuxXdgStartupManager, LinuxNotifySendNotifier, LinuxRdpConnector, LinuxSingleInstanceMutagenSdk: Cross-platform transport (Named Pipes on Windows, Unix Domain Sockets on Linux)Packaging.Linux/: systemd unit, .desktop file, postinst/prerm scripts, build-deb.shAvalonia UI (Phase 2):
App.Shared/: 5 Models, 16 service interfaces, 5 cross-platform service impls, 12 ViewModelsApp.Avalonia/: 11 pages, 9 windows, TrayIcon, 5 converters, 3 custom controls, platform servicesTests (Phase 6):
net8.0with platform-conditional guardsBuild Verification (Linux)
Key design decisions
App/(WinUI) preserved.App.Avalonia/is the new cross-platform default.IDispatcher,IClipboardService,ILauncherService,IWindowService,IRpcClientTransport#if WINDOWSfor Authenticode, MSBuild OS conditions for packagesFollow-up work
App.axaml.cs(connect real RPC/credential/Mutagen services)App.Windows/