Skip to content
Closed
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: 2 additions & 2 deletions src/OpenClaw.Shared/ChannelsSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public sealed class IMessageChannelStatus

// ─── Web login (QR linking) ──────────────────────────────────────────────────

/// <summary>Result of <c>web.login.start</c> a QR or status for a channel.</summary>
/// <summary>Result of <c>web.login.start</c> - a QR or status for a channel.</summary>
public sealed class WebLoginStartResult
{
public string? Message { get; init; }
Expand All @@ -248,7 +248,7 @@ public sealed class WebLoginStartResult
public string? RawResponse { get; init; }
}

/// <summary>Result of <c>web.login.wait</c> long-poll outcome.</summary>
/// <summary>Result of <c>web.login.wait</c> - long-poll outcome.</summary>
public sealed class WebLoginWaitResult
{
public string? Message { get; init; }
Expand Down
29 changes: 21 additions & 8 deletions src/OpenClaw.Shared/OpenClawGatewayClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1219,12 +1219,13 @@ public async Task<bool> LogoutChannelAsync(string channelName, int timeoutMs = 1
"web.login.start",
new { force, timeoutMs },
timeoutMs + 5000);
var result = ParseWebLoginResponse(response);
return new WebLoginStartResult
{
Message = response.ValueKind == JsonValueKind.Object && response.TryGetProperty("message", out var m) && m.ValueKind == JsonValueKind.String ? m.GetString() : null,
QrDataUrl = response.ValueKind == JsonValueKind.Object && response.TryGetProperty("qrDataUrl", out var q) && q.ValueKind == JsonValueKind.String ? q.GetString() : null,
Connected = response.ValueKind == JsonValueKind.Object && response.TryGetProperty("connected", out var c) && c.ValueKind == JsonValueKind.True,
RawResponse = response.ValueKind != JsonValueKind.Undefined ? response.GetRawText() : null,
Message = result.Message,
QrDataUrl = result.QrDataUrl,
Connected = result.Connected,
RawResponse = result.RawResponse,
};
}
catch (Exception ex)
Expand All @@ -1251,12 +1252,13 @@ public async Task<bool> LogoutChannelAsync(string channelName, int timeoutMs = 1
"web.login.wait",
new { currentQrDataUrl, timeoutMs },
timeoutMs + 5000);
var result = ParseWebLoginResponse(response);
return new WebLoginWaitResult
{
Message = response.ValueKind == JsonValueKind.Object && response.TryGetProperty("message", out var m) && m.ValueKind == JsonValueKind.String ? m.GetString() : null,
QrDataUrl = response.ValueKind == JsonValueKind.Object && response.TryGetProperty("qrDataUrl", out var q) && q.ValueKind == JsonValueKind.String ? q.GetString() : null,
Connected = response.ValueKind == JsonValueKind.Object && response.TryGetProperty("connected", out var c) && c.ValueKind == JsonValueKind.True,
RawResponse = response.ValueKind != JsonValueKind.Undefined ? response.GetRawText() : null,
Message = result.Message,
QrDataUrl = result.QrDataUrl,
Connected = result.Connected,
RawResponse = result.RawResponse,
};
}
catch (Exception ex)
Expand All @@ -1270,6 +1272,17 @@ public async Task<bool> LogoutChannelAsync(string channelName, int timeoutMs = 1
}
}

private static WebLoginResponse ParseWebLoginResponse(JsonElement response)
{
return new WebLoginResponse(
response.ValueKind == JsonValueKind.Object && response.TryGetProperty("message", out var m) && m.ValueKind == JsonValueKind.String ? m.GetString() : null,
response.ValueKind == JsonValueKind.Object && response.TryGetProperty("qrDataUrl", out var q) && q.ValueKind == JsonValueKind.String ? q.GetString() : null,
response.ValueKind == JsonValueKind.Object && response.TryGetProperty("connected", out var c) && c.ValueKind == JsonValueKind.True,
response.ValueKind != JsonValueKind.Undefined ? response.GetRawText() : null);
}

private readonly record struct WebLoginResponse(string? Message, string? QrDataUrl, bool Connected, string? RawResponse);

private async Task SendConnectMessageAsync(string? nonce = null)
{
var requestId = Guid.NewGuid().ToString();
Expand Down