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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ BenchmarkDotNet.Artifacts/

# .NET Core
project.lock.json
RelayTestServer/
project.fragment.lock.json
artifacts/
publish_ms_out/
publish_out/
*.zip

# StyleCop
StyleCopReport.xml
Expand Down
2 changes: 1 addition & 1 deletion plugin_Relay/Models/Contract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Amethyst.Plugins.Contract;
using MemoryPack;
using Microsoft.Extensions.Logging;
using Stl.Rpc;
using ActualLab.Rpc;

namespace plugin_Relay.Models;

Expand Down
48 changes: 19 additions & 29 deletions plugin_Relay/RelayDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
using plugin_Relay.Models;
using plugin_Relay.Pages;
using Microsoft.Extensions.Logging;
using Stl.Rpc;
using ActualLab.Rpc;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
Expand Down Expand Up @@ -169,39 +169,29 @@ public void Initialize()
// Mark as initialized
IsInitialized = true;

try
{
MemoryPackFormatterProvider.Register(new TrackingDeviceFormatter());
MemoryPackFormatterProvider.Register(new TrackedJointFormatter());
MemoryPackFormatterProvider.Register(new TrackingDeviceFormatter());
MemoryPackFormatterProvider.Register(new TrackedJointFormatter());

if (RelayService.Instance?.IsBackfeed ?? false)
{
Status = RelayDeviceStatus.BackFeedDetected;
SettingsPage.DeviceStatusAppendix = string.Empty;
InitException = null;
return; // Don't proceed further
}
if (RelayService.Instance?.IsBackfeed ?? false)
{
Status = RelayDeviceStatus.BackFeedDetected;
SettingsPage.DeviceStatusAppendix = string.Empty;
InitException = null;
return; // Don't proceed further
}

var services = new ServiceCollection()
.AddLogging(logging => logging.AddConsole());
var services = new ServiceCollection()
.AddLogging();

services.AddRpc()
.AddWebSocketClient($"http://{ServerIp}:{ServerPort}/")
.AddClient<IRelayService>()
.AddServer<IRelayClient, DataClient>();
services.AddRpc()
.AddWebSocketClient($"http://{ServerIp}:{ServerPort}/")
.AddClient<IRelayService>();
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The client-side RPC setup has removed the server registration for IRelayClient. Previously, the client registered both .AddClient() and .AddServer<IRelayClient, DataClient>() to handle bidirectional communication. With this change, the client can only call the server but cannot receive calls from the server. The DataClient class (lines 333-346) is still defined and implements IRelayClient with methods like OnRequestShutdown and OnRefreshInterface, but it will never be invoked since it's no longer registered. If bidirectional communication is still needed, the .AddServer<IRelayClient, DataClient>() line should be restored. If bidirectional communication from server to client is no longer required, the DataClient class and IRelayClient interface should be removed from the client-side code.

Suggested change
.AddClient<IRelayService>();
.AddClient<IRelayService>()
.AddServer<IRelayClient, DataClient>();

Copilot uses AI. Check for mistakes.

ServiceChannel = services.BuildServiceProvider();
Service = ServiceChannel.GetRequiredService<IRelayService>();
ServiceChannel = services.BuildServiceProvider();
Service = ServiceChannel.GetRequiredService<IRelayService>();

SettingsPage.DeviceStatusAppendix = string.Empty;
SettingsPage.StartConnectionTest();
}
catch (Exception ex)
{
InitException = ex;
Status = RelayDeviceStatus.ServiceError;
return;
}
SettingsPage.DeviceStatusAppendix = string.Empty;
SettingsPage.StartConnectionTest();
Comment on lines +172 to +194
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The try-catch block that wraps the initialization logic has been removed. This means that any exceptions thrown during MemoryPackFormatterProvider registration, service collection setup, or service provider building will now propagate up unhandled instead of being caught and properly handled with status updates (Status = RelayDeviceStatus.ServiceError). The removed error handling was important because InitException is used throughout the codebase to display meaningful error messages to users (see lines 119, 121, 123 in DeviceStatusString). Without this try-catch, initialization failures will not be properly communicated to the user interface. Consider restoring the try-catch block or implementing equivalent error handling.

Copilot uses AI. Check for mistakes.

Host.Log($"Tried to initialize with status: {DeviceStatusString}");
InitException = null;
Expand Down
16 changes: 2 additions & 14 deletions plugin_Relay/RelayService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using plugin_Relay.Models;
using Stl.Rpc;
using ActualLab.Rpc;
using IServiceEndpoint = Amethyst.Plugins.Contract.IServiceEndpoint;
using Microsoft.AspNetCore.Builder;
using Stl.Rpc.Server;
using ActualLab.Rpc.Server;
using MemoryPack;
using Microsoft.Extensions.Logging;

Expand Down Expand Up @@ -209,18 +209,6 @@ public int Initialize()
rpc.AddServer<IRelayService, DataService>()
.AddClient<IRelayClient>();

builder.Services.AddSingleton<RpcCallRouter>(c =>
{
RpcHub rpcHub = null; // Necessary because of IRelayClient, which requires call routing
return (methodDef, args) =>
{
rpcHub ??= c.RpcHub(); // We can't resolve it earlier, coz otherwise it will trigger recursion
if (methodDef.Service.Type != typeof(IRelayClient)) return rpcHub.GetClientPeer(RpcPeerRef.Default);
var peerRef = new RpcPeerRef(args.Get<Stl.Text.Symbol>(0), true);
return rpcHub.GetServerPeer(peerRef);
};
});

var app = builder.Build();
app.Urls.Add($"http://0.0.0.0:{ServerPort}/");
app.UseWebSockets();
Expand Down
10 changes: 7 additions & 3 deletions plugin_Relay/plugin_Relay.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="ActualLab.Generators" Version="12.1.51">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="ActualLab.Rpc" Version="12.1.51" />
<PackageReference Include="ActualLab.Rpc.Server" Version="12.1.51" />
<PackageReference Include="Amethyst.Plugins.Contract" Version="1.3.0" />
<PackageReference Include="MemoryPack" Version="1.21.4" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
<PackageReference Include="Stl.Generators" Version="6.8.11" />
<PackageReference Include="Stl.Rpc" Version="6.8.11" />
<PackageReference Include="Stl.Rpc.Server" Version="6.8.11" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
Comment on lines +27 to +37
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title and description mention removing the RelayTestServer project and platform configurations from the solution file, but the actual changes in this PR are a migration from Stl.* RPC packages (v6.8.11) to ActualLab.* packages (v12.1.51). This is a significant discrepancy. The solution file (plugin_Relay.sln) already appears to be in the desired state (no RelayTestServer, only x64 configurations). Please update the PR title and description to accurately reflect that this is an RPC library migration rather than solution file cleanup.

Copilot uses AI. Check for mistakes.
<PackageReference Include="System.ComponentModel.Composition" Version="8.0.0" />
<PackageReference Include="System.ComponentModel.Composition.Registration" Version="8.0.0" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.7.250606001" />
Expand Down
Loading