fix(winui): guard missing SendMessage deep link handler (#49)

Add null check on actions.SendMessage before invoking in the agent
deep link path. Removes null-forgiving operator that would throw
NullReferenceException inside Task.Run if the handler wasn't wired.
Adds warning log for diagnosability.

Fixes #47
Based on PR #48 by @Alix-007, adapted for current codebase.
This commit is contained in:
Scott Hanselman 2026-03-16 21:56:52 -07:00 committed by GitHub
parent afaaa04447
commit 313e69e483
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -80,13 +80,13 @@ public static class DeepLinkHandler
case "agent":
var agentMessage = OpenClaw.Shared.DeepLinkParser.GetQueryParam(query, "message");
if (!string.IsNullOrEmpty(agentMessage))
if (!string.IsNullOrEmpty(agentMessage) && actions.SendMessage != null)
{
_ = Task.Run(async () =>
{
try
{
await actions.SendMessage!(agentMessage);
await actions.SendMessage(agentMessage);
Logger.Info($"Sent message via deep link: {agentMessage}");
}
catch (Exception ex)
@ -95,6 +95,10 @@ public static class DeepLinkHandler
}
});
}
else if (!string.IsNullOrEmpty(agentMessage))
{
Logger.Warn("Deep link: agent message received but SendMessage handler is not registered");
}
break;
default: