diff --git a/BeWo/View/Detail/AI/AiConversationChatView.xaml b/BeWo/View/Detail/AI/AiConversationChatView.xaml
index 0fea681ba..590a82043 100644
--- a/BeWo/View/Detail/AI/AiConversationChatView.xaml
+++ b/BeWo/View/Detail/AI/AiConversationChatView.xaml
@@ -133,7 +133,7 @@
-
+
@@ -207,6 +207,7 @@
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
AcceptsReturn="True"
+ IsEnabled="{Binding IsSending, Converter={StaticResource BoolReverseConverter}}"
Text="{Binding MessageInput, UpdateSourceTrigger=PropertyChanged}" />
+ Visibility="Visible" />
diff --git a/BeWo/View/Detail/AI/AiConversationChatView.xaml.cs b/BeWo/View/Detail/AI/AiConversationChatView.xaml.cs
index fcdd384f1..9f968eb01 100644
--- a/BeWo/View/Detail/AI/AiConversationChatView.xaml.cs
+++ b/BeWo/View/Detail/AI/AiConversationChatView.xaml.cs
@@ -65,5 +65,31 @@ namespace BeWo.View.Detail.AI
{
BeWoWpfUtils.ScrollToBottom(listbox_messages_clone);
}
+
+ private void Grid_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Enter)
+ {
+ if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
+ {
+ // Shift + Enter gedrückt
+ Console.WriteLine("Shift + Enter erkannt");
+ }
+ else
+ {
+ // Nur Enter gedrückt
+ // Console.WriteLine("Enter erkannt");
+
+ object p = null;
+ if(ViewModel.SendNewMessageCommand.CanExecute(p))
+ ViewModel.SendNewMessageCommand.Execute(p);
+
+ e.Handled = true;
+ }
+
+ // Optional: Event als behandelt markieren, wenn du die Standardaktion unterdrücken willst
+ // e.Handled = true;
+ }
+ }
}
}
diff --git a/BeWo/ViewModel/ListViewModel/AiConversationListVM.cs b/BeWo/ViewModel/ListViewModel/AiConversationListVM.cs
index 3c12c9a9c..d88586dee 100644
--- a/BeWo/ViewModel/ListViewModel/AiConversationListVM.cs
+++ b/BeWo/ViewModel/ListViewModel/AiConversationListVM.cs
@@ -27,6 +27,7 @@ namespace BeWo.ViewModel.ListViewModel
{
private bool _IsSettingsOpen;
private bool _IsCloneOpen;
+ private bool _IsSending;
private string _MessageInput;
private string _ContextInput;
@@ -46,7 +47,7 @@ namespace BeWo.ViewModel.ListViewModel
{
Models = new ObservableSortCollection();
- SendNewMessageCommand = new DelegateCommand(SendNewMessage, () => SelectedVM is object && !string.IsNullOrWhiteSpace(MessageInput));
+ SendNewMessageCommand = new DelegateCommand(SendNewMessage, () => SelectedVM is object && !string.IsNullOrWhiteSpace(MessageInput) && !IsSending);
RequestNewConversationCommand = new DelegateCommand(RequestNewConversation, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleChatAdd));
//TestCommand = new DelegateCommand(Test);
@@ -142,6 +143,15 @@ namespace BeWo.ViewModel.ListViewModel
FirePropertyChanged(nameof(IsCloneOpen));
}
}
+ public bool IsSending
+ {
+ get => _IsSending;
+ set
+ {
+ _IsSending = value;
+ FirePropertyChanged(nameof(IsSending));
+ }
+ }
public int UIContext { get; set; }
public long? ReferenceObjectOid { get; set; }
@@ -158,36 +168,52 @@ namespace BeWo.ViewModel.ListViewModel
}
private void SendNewMessage()
{
- var conv = SelectedVM;
+ if (IsSending)
+ throw new InvalidOperationException("Sendet bereits");
- var msg_dc = new AiConversationMessageDC();
-
- msg_dc.Message = MessageInput;
- msg_dc.Role = BS.Shared.AiConversationMessageRole.User;
- msg_dc.Created = DateTime.Now;
-
- var msg_vm = new AiConversationMessageVM(msg_dc);
-
- conv.Messages.VMList.Add(msg_vm);
-
- ServiceFacade.DoAiEnhancedServiceAsnyc(
- x => x.SendNewMessage(conv.DataContract.Oid.Value, MessageInput),
- (messages) =>
+ IsSending = true;
+ try
{
- if (messages.Count != 2)
- throw new InvalidOperationException("message count: " + messages.Count);
+ var conv = SelectedVM;
- msg_vm.DataContract = messages[0];
+ var msg_dc = new AiConversationMessageDC();
- conv.Messages.VMList.Add(new AiConversationMessageVM(messages[1]));
+ msg_dc.Message = MessageInput;
+ msg_dc.Role = BS.Shared.AiConversationMessageRole.User;
+ msg_dc.Created = DateTime.Now;
- MessageInput = string.Empty;
- },
- (exception) =>
- {
- conv.Messages.VMList.Remove(msg_vm);
+ var msg_vm = new AiConversationMessageVM(msg_dc);
+
+ conv.Messages.VMList.Add(msg_vm);
+
+ ServiceFacade.DoAiEnhancedServiceAsnyc(
+ x => x.SendNewMessage(conv.DataContract.Oid.Value, MessageInput),
+ (messages) =>
+ {
+ if (messages.Count != 2)
+ throw new InvalidOperationException("message count: " + messages.Count);
+
+ msg_vm.DataContract = messages[0];
+
+ conv.Messages.VMList.Add(new AiConversationMessageVM(messages[1]));
+
+ MessageInput = string.Empty;
+
+ IsSending = false;
+ },
+ (exception) =>
+ {
+ conv.Messages.VMList.Remove(msg_vm);
+
+ IsSending = false;
+ }
+ );
}
- );
+ catch (Exception ex) {
+ IsSending = false;
+ }
+
+
}
private void Test()
{