From bfcdc10176910b98972f9717aa0e32d0b49400e7 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 7 Oct 2026 15:25:40 -0700 Subject: [PATCH] fix(chat): handle Enter before multiline input consumes it --- src/OpenClaw.Tray.WinUI/Chat/ReactorChatComposer.cs | 4 +++- .../ReactorChatLayoutProofTests.cs | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/OpenClaw.Tray.WinUI/Chat/ReactorChatComposer.cs b/src/OpenClaw.Tray.WinUI/Chat/ReactorChatComposer.cs index f212d5149..1713d7c1f 100644 --- a/src/OpenClaw.Tray.WinUI/Chat/ReactorChatComposer.cs +++ b/src/OpenClaw.Tray.WinUI/Chat/ReactorChatComposer.cs @@ -407,7 +407,9 @@ Element EffortIconButton() PlaceholderFor(inputs.ConnectionState)) .AutomationId("ChatComposerInput") .AutomationName(PlaceholderFor(inputs.ConnectionState)) - .OnKeyDown((sender, args) => + // Multiline TextBox consumes Enter before bubbling KeyDown. Handle + // composer shortcuts in preview so only Shift+Enter inserts a newline. + .OnPreviewKeyDown((sender, args) => { if (slashDisplay.IsVisible) { diff --git a/tests/OpenClaw.Tray.UITests/ReactorChatLayoutProofTests.cs b/tests/OpenClaw.Tray.UITests/ReactorChatLayoutProofTests.cs index f65e9740c..4f5a57ec9 100644 --- a/tests/OpenClaw.Tray.UITests/ReactorChatLayoutProofTests.cs +++ b/tests/OpenClaw.Tray.UITests/ReactorChatLayoutProofTests.cs @@ -506,6 +506,17 @@ await ui.RunOnUIAsync(() => Assert.Empty(input.Text); Assert.Empty(session.ViewModel.Draft); }); + // A second Enter must neither send again nor add a newline to the + // empty draft, including after the send has re-rendered the input. + await PressAsync(global::Windows.System.VirtualKey.Enter); + await ui.RunOnUIAsync(() => + { + Assert.Single(provider.SentMessages); + Assert.Empty(input.Text); + Assert.Empty(session.ViewModel.Draft); + }); + if (start == 5 && length == 0) + await CaptureAsync(surface, "Composer-keyboard-enter-sent"); }, interactiveKeyboard: true); }