Skip to content

Commit e6bfff8

Browse files
committed
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 <longshuang@msn.cn>
1 parent 446c806 commit e6bfff8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/ViewModels/AIAssistant.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,16 @@ await agent.GenerateCommitMessageAsync(_repo, _changeList, message =>
5757
}
5858
catch (OperationCanceledException)
5959
{
60-
// Do nothing
60+
// Do nothing and leave `IsGenerating` to current (may already changed), so that the UI can update accordingly.
61+
return;
6162
}
6263
catch (Exception e)
6364
{
64-
App.RaiseException(_repo, e.Message);
65+
builder
66+
.AppendLine()
67+
.AppendLine("[ERROR]")
68+
.Append(e.Message);
69+
Text = builder.ToString();
6570
}
6671

6772
IsGenerating = false;

0 commit comments

Comments
 (0)