From a5fe8ddc33c5aed03723076f9171f4e0a85e5095 Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Mon, 15 Jun 2026 12:06:03 +0200 Subject: [PATCH] 5.1.4 viewcontext fix --- BeWo/BeWoAppInfo.cs | 2 +- .../View/AI/AiConversationChatViewModel.cs | 32 +++++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/BeWo/BeWoAppInfo.cs b/BeWo/BeWoAppInfo.cs index 923134de0..f36d29bfb 100644 --- a/BeWo/BeWoAppInfo.cs +++ b/BeWo/BeWoAppInfo.cs @@ -15,7 +15,7 @@ namespace BeWo { var baseVersion = new Version(BeWoApp.ShortVersion); var stage = BeWoClientReleaseStage.Sandbox; - var stageVersion = new Version("5.1.3"); + var stageVersion = new Version("5.1.4"); var feature = BeWoClientFeature.AI; #if !DEBUG diff --git a/BeWo/ViewModel/View/AI/AiConversationChatViewModel.cs b/BeWo/ViewModel/View/AI/AiConversationChatViewModel.cs index d45de20a8..41a41e332 100644 --- a/BeWo/ViewModel/View/AI/AiConversationChatViewModel.cs +++ b/BeWo/ViewModel/View/AI/AiConversationChatViewModel.cs @@ -601,26 +601,40 @@ namespace BeWo.ViewModel.View.AI return; } - var msg = routine.Steps.VMList[step].PromptReference.Prompt; - var conv = ListVM.SelectedVM; - var msg_dc = new AiConversationMessageDC(); + var custom_viewContext = new AiViewContextDC + { + References = ViewContext.References, + Primary = ViewContext.Primary + }; - msg_dc.Message = msg; - msg_dc.Role = BS.Shared.AiConversationMessageRole.User; - msg_dc.Created = DateTime.Now; + if (step > 0 && routine.RoutineType == AiRoutineType.Chain) + { + custom_viewContext.Secondary = conv.Messages.VMList.Last().Message; + } + else + { + custom_viewContext.Secondary = ViewContext.Secondary; + } + + var msg = routine.Steps.VMList[step].PromptReference.Prompt; + + var msg_dc = new AiConversationMessageDC + { + Message = msg, + Role = AiConversationMessageRole.User, + Created = DateTime.Now + }; var msg_vm = new AiConversationMessageVM(msg_dc); conv.Messages.VMList.Add(msg_vm); ServiceFacade.DoAiEnhancedServiceAsnyc( - x => x.ExecuteAiConversationWithRoutine(conv.Oid, ViewContext, routine.DataContract.Oid.Value, step), + x => x.ExecuteAiConversationWithRoutine(conv.Oid, custom_viewContext, routine.DataContract.Oid.Value, step), cb => { - ViewContext.Secondary = cb.Last().Message; - conv.Messages.VMList.Remove(msg_vm); conv.AddMessages(cb);