diff --git a/src/Microsoft.DotNet.Interactive.Tests/KernelInfoTests.cs b/src/Microsoft.DotNet.Interactive.Tests/KernelInfoTests.cs index c7f4819743..b5facfd8b6 100644 --- a/src/Microsoft.DotNet.Interactive.Tests/KernelInfoTests.cs +++ b/src/Microsoft.DotNet.Interactive.Tests/KernelInfoTests.cs @@ -256,6 +256,42 @@ public async Task ProxyKernels_have_a_remote_uri() .Be(new Uri("kernel://remote/python")); } + [Fact] public async Task ProxyKernels_can_share_values() + { + using var localCompositeKernel = new CompositeKernel + { + (new CSharpKernel()).UseValueSharing() + }; + using var remoteCompositeKernel = new CompositeKernel + { + (new FSharpKernel()).UseValueSharing() + }; + + ConnectHost.ConnectInProcessHost( + localCompositeKernel, + remoteCompositeKernel); + + var proxyKernel = await localCompositeKernel + .Host + .ConnectProxyKernelOnDefaultConnectorAsync( + "fsharp", + new Uri("kernel://remote/fsharp")); + + await remoteCompositeKernel.SendAsync(new SubmitCode("let x = 123")); + + var result = await localCompositeKernel.SendAsync(new SubmitCode(""" + #!set --name x --value @fsharp:x + x + """, targetKernelName:"csharp")); + + result.Events.Should() + .ContainSingle() + .Which + .Value + .Should() + .Be(123); + } + [Fact] public async Task When_kernel_info_is_requested_from_proxy_then_ProxyKernel_kernel_info_is_updated() { diff --git a/src/Microsoft.DotNet.Interactive/Connection/ProxyKernel.cs b/src/Microsoft.DotNet.Interactive/Connection/ProxyKernel.cs index 7ec9a779be..589ea6764a 100644 --- a/src/Microsoft.DotNet.Interactive/Connection/ProxyKernel.cs +++ b/src/Microsoft.DotNet.Interactive/Connection/ProxyKernel.cs @@ -99,12 +99,6 @@ private Task HandleByForwardingToRemoteAsync(KernelCommand command, KernelInvoca } } - var targetKernelName = command.TargetKernelName; - if (command.TargetKernelName == Name) - { - command.TargetKernelName = null; - } - var completionSource = new TaskCompletionSource(); var rootToken = KernelCommand.GetRootToken(token); @@ -126,8 +120,6 @@ private Task HandleByForwardingToRemoteAsync(KernelCommand command, KernelInvoca return completionSource.Task.ContinueWith(te => { - command.TargetKernelName = targetKernelName; - if (te.Result is CommandFailed cf) { context.Fail(command, cf.Exception, cf.Message);