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: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,8 @@ 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 ActualLab.Rpc;
using Stl.Rpc;

namespace plugin_Relay.Models;

Expand Down
48 changes: 29 additions & 19 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 ActualLab.Rpc;
using Stl.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,29 +169,39 @@ public void Initialize()
// Mark as initialized
IsInitialized = true;

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

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

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

services.AddRpc()
.AddWebSocketClient($"http://{ServerIp}:{ServerPort}/")
.AddClient<IRelayService>();
var services = new ServiceCollection()
.AddLogging(logging => logging.AddConsole());
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.

.AddConsole() requires the Microsoft.Extensions.Logging.Console assembly/package; this project file currently has no explicit reference to it. Either add the appropriate package reference or remove .AddConsole() (fall back to .AddLogging() or the existing logging provider setup) to avoid a missing-method/compile error depending on transitive dependencies.

Suggested change
.AddLogging(logging => logging.AddConsole());
.AddLogging();

Copilot uses AI. Check for mistakes.

ServiceChannel = services.BuildServiceProvider();
Service = ServiceChannel.GetRequiredService<IRelayService>();
services.AddRpc()
.AddWebSocketClient($"http://{ServerIp}:{ServerPort}/")
.AddClient<IRelayService>()
.AddServer<IRelayClient, DataClient>();

SettingsPage.DeviceStatusAppendix = string.Empty;
SettingsPage.StartConnectionTest();
ServiceChannel = services.BuildServiceProvider();
Service = ServiceChannel.GetRequiredService<IRelayService>();

SettingsPage.DeviceStatusAppendix = string.Empty;
SettingsPage.StartConnectionTest();
}
catch (Exception ex)
{
InitException = ex;
Status = RelayDeviceStatus.ServiceError;
return;
}

Host.Log($"Tried to initialize with status: {DeviceStatusString}");
InitException = null;
Expand Down
16 changes: 14 additions & 2 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 ActualLab.Rpc;
using Stl.Rpc;
using IServiceEndpoint = Amethyst.Plugins.Contract.IServiceEndpoint;
using Microsoft.AspNetCore.Builder;
using ActualLab.Rpc.Server;
using Stl.Rpc.Server;
using MemoryPack;
using Microsoft.Extensions.Logging;

Expand Down Expand Up @@ -209,6 +209,18 @@ 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);
Comment on lines +218 to +220
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.

This RpcCallRouter routes IRelayClient calls based on args.Get<Stl.Text.Symbol>(0), but IRelayClient methods don't take a peer id/symbol as their first argument (e.g., OnRequestShutdown(string reason, ...)). As written, routing will likely select the wrong peer or throw due to an argument type mismatch. Consider routing based on the current call context/peer (or explicitly include a peer identifier parameter in the IRelayClient contract and update call sites accordingly).

Suggested change
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);
if (methodDef.Service.Type != typeof(IRelayClient))
return rpcHub.GetClientPeer(RpcPeerRef.Default);
// For IRelayClient calls, route using the default peer reference instead of
// assuming the first argument is a Stl.Text.Symbol peer identifier.
return rpcHub.GetServerPeer(RpcPeerRef.Default);

Copilot uses AI. Check for mistakes.
};
});

var app = builder.Build();
app.Urls.Add($"http://0.0.0.0:{ServerPort}/");
app.UseWebSockets();
Expand Down
10 changes: 3 additions & 7 deletions plugin_Relay/plugin_Relay.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,13 @@
</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="Microsoft.Extensions.Logging" Version="8.0.1" />
<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" />
Comment on lines 26 to +33
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 description says this is a revert of a solution/platform configuration change, but this file swaps RPC packages (ActualLab.* -> Stl.*) and removes Microsoft.Extensions.Logging. If this is intentional, please update the PR title/description; otherwise revert these package changes to keep the revert focused.

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