diff --git a/diylc/diylc-core/src/main/resources/update.xml b/diylc/diylc-core/src/main/resources/update.xml
index fcaa52b9..5bb2476b 100644
--- a/diylc/diylc-core/src/main/resources/update.xml
+++ b/diylc/diylc-core/src/main/resources/update.xml
@@ -265,6 +265,10 @@
IMPROVEMENT
Confirmation dialog before deleting AI Assistant chat history
+
+ IMPROVEMENT
+ Output current subscription statistics at the end of the chat for transparency
+
BUG_FIX
'Connect to Patreon' option doesn't work if the user name contains a space or another non-alphanumerical character
diff --git a/diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/chatbot/ChatbotPane.java b/diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/chatbot/ChatbotPane.java
index f9799198..e9528b36 100644
--- a/diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/chatbot/ChatbotPane.java
+++ b/diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/chatbot/ChatbotPane.java
@@ -58,6 +58,7 @@ public class ChatbotPane extends JPanel {
private boolean loggedIn = false;
private String projectFileName = null;
+ private SubscriptionEntity subscriptionInfo;
public ChatbotPane(ISwingUI swingUI, IPlugInPort plugInPort) {
super();
@@ -235,6 +236,9 @@ public class ChatbotPane extends JPanel {
public void refreshChat(SubscriptionEntity subscriptionInfo) {
boolean currentLoggedIn = plugInPort.getCloudService().isLoggedIn();
String currentProjectFileName = FileUtils.extractFileName(plugInPort.getCurrentFileName());
+ if (subscriptionInfo != null) {
+ this.subscriptionInfo = subscriptionInfo;
+ }
if (this.loggedIn == currentLoggedIn && Objects.equals(currentProjectFileName, this.projectFileName))
return;
@@ -249,21 +253,12 @@ public class ChatbotPane extends JPanel {
getClearButton().setEnabled(false);
getPremiumButton().setVisible(false);
} else {
- if (subscriptionInfo != null) {
- getPremiumButton().setVisible(FREE_TIER.equals(subscriptionInfo.getTier()));
- String subscriptionInfoText = "Your are currently subscribed to the '" + subscriptionInfo.getTier() + "' tier, expiring on " + subscriptionInfo.getEndDate() + ", with " + subscriptionInfo.getRemainingCredits() + " credits remaining.";
-
- if (FREE_TIER.equals(subscriptionInfo.getTier())) {
- subscriptionInfoText +=
- " To subscribe to one of the premium tiers, unlock advanced AI models and get more credits, visit " + GET_PREMIUM_URL + " and become a Patreon supporter. " +
- "All the details about the AI Assistant limits and other benefits will be specified there. " +
- "If you are already a Patreon supporter, make sure to link your account with the DIYLC Cloud account from the 'Cloud' menu.";
- } else {
- subscriptionInfoText += " Thank you for supporting further development of DIYLC!";
- }
+ fetchChatHistory();
+ if (this.subscriptionInfo != null) {
+ getPremiumButton().setVisible(FREE_TIER.equals(this.subscriptionInfo.getTier()));
+ String subscriptionInfoText = getSubscriptionInfoText();
appendSection(ChatbotService.SYSTEM, subscriptionInfoText);
}
- fetchChatHistory();
getAskButton().setEnabled(true);
getClearButton().setEnabled(true);
}
@@ -276,6 +271,25 @@ public class ChatbotPane extends JPanel {
});
}
+ private String getSubscriptionInfoText() {
+ String subscriptionInfoText = String.format(
+ "Your are currently subscribed to the '%s' tier, expiring on %s, with %d credits remaining.",
+ this.subscriptionInfo.getTier(),
+ this.subscriptionInfo.getEndDate(),
+ this.subscriptionInfo.getRemainingCredits());
+
+ if (FREE_TIER.equals(this.subscriptionInfo.getTier())) {
+ subscriptionInfoText += String.format(
+ " To subscribe to one of the premium tiers, unlock advanced AI models and get more credits, visit %s and become a Patreon supporter. " +
+ "All the details about the AI Assistant limits and other benefits will be specified there. " +
+ "If you are already a Patreon supporter, make sure to link your account with the DIYLC Cloud account from the 'Cloud' menu.",
+ GET_PREMIUM_URL, GET_PREMIUM_URL);
+ } else {
+ subscriptionInfoText += " Thank you for supporting further development of DIYLC!";
+ }
+ return subscriptionInfoText;
+ }
+
private void fetchChatHistory() {
try {
List chatHistory = plugInPort.getChatbotService().getChatHistory();