Skip to content

Commit 53ef3bb

Browse files
committed
fix(dotnet): Add AOT-safe SetForegroundSessionRequest for SetForegroundSessionIdAsync()
- Replace the anonymous `new { sessionId }` with `new SetForegroundSessionRequest(sessionId)` This fixes the runtime `System.Text.Json` metadata failure when `SetForegroundSessionIdAsync()` is used with source-generated serialization.
1 parent dd2dcbc commit 53ef3bb

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

dotnet/src/Client.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ public async Task SetForegroundSessionIdAsync(string sessionId, CancellationToke
942942
var connection = await EnsureConnectedAsync(cancellationToken);
943943

944944
var response = await InvokeRpcAsync<SetForegroundSessionResponse>(
945-
connection.Rpc, "session.setForeground", [new { sessionId }], cancellationToken);
945+
connection.Rpc, "session.setForeground", [new SetForegroundSessionRequest(sessionId)], cancellationToken);
946946

947947
if (!response.Success)
948948
{
@@ -1753,6 +1753,9 @@ internal record GetSessionMetadataRequest(
17531753
internal record GetSessionMetadataResponse(
17541754
SessionMetadata? Session);
17551755

1756+
internal record SetForegroundSessionRequest(
1757+
string SessionId);
1758+
17561759
internal record UserInputRequestResponse(
17571760
string Answer,
17581761
bool WasFreeform);
@@ -1871,6 +1874,7 @@ private static LogLevel MapLevel(TraceEventType eventType)
18711874
[JsonSerializable(typeof(SessionCapabilities))]
18721875
[JsonSerializable(typeof(SessionUiCapabilities))]
18731876
[JsonSerializable(typeof(SessionMetadata))]
1877+
[JsonSerializable(typeof(SetForegroundSessionRequest))]
18741878
[JsonSerializable(typeof(SystemMessageConfig))]
18751879
[JsonSerializable(typeof(SystemMessageTransformRpcResponse))]
18761880
[JsonSerializable(typeof(CommandWireDefinition))]

0 commit comments

Comments
 (0)