From e6bfff81c24db58cb84ef99673fa83ed0363e787 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 25 Mar 2026 15:24:49 +0800 Subject: [PATCH] feat: improve error handling and cancellation behavior in AI assistant - Display error (include exception) in current window - Improve cancellation behavior to preserve current `IsGenerating` state for proper UI updates Signed-off-by: leo --- src/ViewModels/AIAssistant.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ViewModels/AIAssistant.cs b/src/ViewModels/AIAssistant.cs index 66160067..d6eff19d 100644 --- a/src/ViewModels/AIAssistant.cs +++ b/src/ViewModels/AIAssistant.cs @@ -57,11 +57,16 @@ namespace SourceGit.ViewModels } catch (OperationCanceledException) { - // Do nothing + // Do nothing and leave `IsGenerating` to current (may already changed), so that the UI can update accordingly. + return; } catch (Exception e) { - App.RaiseException(_repo, e.Message); + builder + .AppendLine() + .AppendLine("[ERROR]") + .Append(e.Message); + Text = builder.ToString(); } IsGenerating = false;