Skip to content
Draft
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
1 change: 1 addition & 0 deletions src/OpenClaw.Shared/Models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public class OpenClawNotification
{
public string Title { get; set; } = "";
public string Message { get; set; } = "";
public string? FullMessage { get; set; }
public string Type { get; set; } = "";
public bool IsChat { get; set; } = false; // True if from chat response

Expand Down
1 change: 1 addition & 0 deletions src/OpenClaw.Shared/OpenClawGatewayClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3248,6 +3248,7 @@ private void EmitChatNotification(string text, string? sessionKey = null)
var notification = new OpenClawNotification
{
Message = displayText,
FullMessage = text,
IsChat = true,
SessionKey = sessionKey
};
Expand Down
4 changes: 3 additions & 1 deletion src/OpenClaw.Tray.WinUI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2672,6 +2672,8 @@ private void OnGatewayNotificationReceived(object? sender, OpenClawNotification
// if the user enabled "Read responses aloud".
if (notification.IsChat && !string.IsNullOrEmpty(notification.Message))
{
var speechText = notification.FullMessage ?? notification.Message;

// Suppress TTS/voice overlay when the user has aborted the response.
if (ChatProvider?.IsResponseSuppressed == true)
return;
Expand All @@ -2692,7 +2694,7 @@ private void OnGatewayNotificationReceived(object? sender, OpenClawNotification
// TTS: read response aloud whenever the toggle is on (any chat surface).
if (_settings?.VoiceTtsEnabled == true)
{
_ = (_chatCoordinator?.SpeakResponseAsync(notification.Message) ?? Task.CompletedTask);
_ = (_chatCoordinator?.SpeakResponseAsync(speechText) ?? Task.CompletedTask);
}
}

Expand Down
31 changes: 31 additions & 0 deletions tests/OpenClaw.Shared.Tests/OpenClawGatewayClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,37 @@ public void ProcessRawMessage_SessionMessageAssistantNotification_DependsOnFinal
}
}

[Fact]
public void ProcessRawMessage_SessionMessageAssistantNotification_PreservesFullMessage()
{
var helper = new GatewayClientTestHelper();
OpenClawNotification? notification = null;
helper.Client.NotificationReceived += (_, value) => notification = value;

var fullMessage = new string('x', 240);

helper.ProcessRawMessage($$"""
{
"type": "event",
"event": "session.message",
"payload": {
"sessionKey": "agent:main:whatsapp:direct:+15551234567",
"message": {
"role": "assistant",
"content": "{{fullMessage}}",
"timestamp": 1781631280633
},
"state": "final"
}
}
""");

Assert.NotNull(notification);
Assert.True(notification!.IsChat);
Assert.Equal(fullMessage[..200] + "…", notification.Message);
Assert.Equal(fullMessage, notification.FullMessage);
}

[Fact]
public void ProcessRawMessage_AgentEventLogsRawLengthWithoutPayloadContent()
{
Expand Down