Confirmation dialog before deleting AI Assistant chat history

This commit is contained in:
Bane Stojkovic
2025-04-14 21:31:33 +02:00
parent aae514afcb
commit 2e13cc6a49
2 changed files with 30 additions and 18 deletions
@@ -261,6 +261,10 @@
<releaseDate>2025-03-27 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Confirmation dialog before deleting AI Assistant chat history</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>'Connect to Patreon' option doesn't work if the user name contains a space or another non-alphanumerical character</description>
@@ -416,27 +416,35 @@ public class ChatbotPane extends JPanel {
clearButton.setFocusPainted(false);
clearButton.setBorderPainted(true);
clearButton.addActionListener(e -> {
// Show confirmation dialog
int result = swingUI.showConfirmDialog(
LangUtil.translate("Are you sure you want to clear the chat history for this project? This action cannot be undone!"),
"AI Assistant",
ISwingUI.YES_NO_OPTION,
ISwingUI.WARNING_MESSAGE);
if (result == ISwingUI.YES_OPTION) {
swingUI.executeBackgroundTask(new ITask<Void>() {
swingUI.executeBackgroundTask(new ITask<Void>() {
@Override
public Void doInBackground() throws Exception {
chatbotService.deleteChatHistory();
return null;
}
@Override
public Void doInBackground() throws Exception {
chatbotService.deleteChatHistory();
return null;
}
@Override
public void failed(Exception e) {
appendSection(ChatbotService.SYSTEM, "Failed to delete chat history from the server.");
LOG.error("Failed to delete chat history from the server", e);
getClearButton().setEnabled(true);
}
@Override
public void failed(Exception e) {
appendSection(ChatbotService.SYSTEM, "Failed to delete chat history from the server.");
LOG.error("Failed to delete chat history from the server", e);
getClearButton().setEnabled(true);
}
@Override
public void complete(Void result) {
clearChat();
}
}, false);
@Override
public void complete(Void result) {
clearChat();
}
}, false);
}
});
}
return clearButton;