diff --git a/diylc/diylc-core/src/main/java/org/diylc/common/EventType.java b/diylc/diylc-core/src/main/java/org/diylc/common/EventType.java index 87a57fcb..0600b408 100644 --- a/diylc/diylc-core/src/main/java/org/diylc/common/EventType.java +++ b/diylc/diylc-core/src/main/java/org/diylc/common/EventType.java @@ -45,6 +45,10 @@ public enum EventType { * has been either reloaded or loaded with undo/redo operations. */ PROJECT_LOADED, + /** + * Called when the current project is saved to a file. The first parameter is the current file name. + */ + PROJECT_SAVED, /** * Called when either current file name or modified flag are changed. The first parameter is the * current file name, the second one is a boolean modified flag. diff --git a/diylc/diylc-core/src/main/java/org/diylc/plugins/chatbot/service/ChatbotService.java b/diylc/diylc-core/src/main/java/org/diylc/plugins/chatbot/service/ChatbotService.java index bae36f28..78936d54 100644 --- a/diylc/diylc-core/src/main/java/org/diylc/plugins/chatbot/service/ChatbotService.java +++ b/diylc/diylc-core/src/main/java/org/diylc/plugins/chatbot/service/ChatbotService.java @@ -80,14 +80,14 @@ public class ChatbotService { @Override public EnumSet getSubscribedEventTypes() { - return EnumSet.of(EventType.PROJECT_LOADED, EventType.FILE_STATUS_CHANGED); + return EnumSet.of(EventType.PROJECT_LOADED, EventType.PROJECT_SAVED); } @Override public void processMessage(EventType eventType, Object... objects) { if (eventType == EventType.PROJECT_LOADED) { ChatbotService.this.currentProjectName = extractFileName((String)objects[2]); - } else if (eventType == EventType.FILE_STATUS_CHANGED) { + } else if (eventType == EventType.PROJECT_SAVED) { String newProjectName = extractFileName((String)objects[0]); if (!Objects.equals(ChatbotService.this.currentProjectName, newProjectName)) { if (plugInPort.getCloudService().isLoggedIn()) { diff --git a/diylc/diylc-core/src/main/java/org/diylc/serialization/ProjectFileManager.java b/diylc/diylc-core/src/main/java/org/diylc/serialization/ProjectFileManager.java index 380646af..f9cb406e 100644 --- a/diylc/diylc-core/src/main/java/org/diylc/serialization/ProjectFileManager.java +++ b/diylc/diylc-core/src/main/java/org/diylc/serialization/ProjectFileManager.java @@ -177,6 +177,7 @@ public class ProjectFileManager { if (!isBackup) { this.currentFileName = fileName; this.modified = false; + messageDispatcher.dispatchMessage(EventType.PROJECT_SAVED, getCurrentFileName()); fireFileStatusChanged(); } } diff --git a/diylc/diylc-core/src/main/resources/update.xml b/diylc/diylc-core/src/main/resources/update.xml index 34bbb716..54f2ff31 100644 --- a/diylc/diylc-core/src/main/resources/update.xml +++ b/diylc/diylc-core/src/main/resources/update.xml @@ -258,9 +258,13 @@ 3 0 - 2025-03-27 00:00:00.000 CET + 2025-04-21 00:00:00.000 CET + + IMPROVEMENT + Improved AI Assistant quality of responses, especially when analyzing a circuit + IMPROVEMENT When saving a project to the new file, retain all the AI Assistant chat history for the new project file @@ -275,7 +279,7 @@ IMPROVEMENT - Output current subscription statistics at the end of the chat for transparency + Output current subscription statistics at the end of the chat for usage transparency IMPROVEMENT 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 5a37d58c..1faa7512 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 @@ -294,6 +294,9 @@ public class ChatbotPane extends JPanel { // Scroll to the end of the chat pane SwingUtilities.invokeLater(() -> { + if (getChatEditorPane().getParent() == null) { + return; + } JScrollPane scrollPane = (JScrollPane) getChatEditorPane().getParent().getParent(); JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar(); verticalScrollBar.setValue(verticalScrollBar.getMaximum()); @@ -474,7 +477,6 @@ public class ChatbotPane extends JPanel { styleButton(premiumButton); premiumButton.setVisible(false); premiumButton.addActionListener(e -> { - try { java.awt.Desktop.getDesktop().browse(new java.net.URI("http://diy-fever.com/get-premium")); } catch (Exception ex) { @@ -516,8 +518,15 @@ public class ChatbotPane extends JPanel { } }); - // Set minimum and preferred size - button.setMinimumSize(new Dimension(80, 25)); - button.setPreferredSize(new Dimension(80, 25)); + // Set minimum and preferred size based on button type + if (button == premiumButton) { + // Wider size for Premium button + button.setMinimumSize(new Dimension(120, 25)); + button.setPreferredSize(new Dimension(120, 25)); + } else { + // Standard size for other buttons + button.setMinimumSize(new Dimension(80, 25)); + button.setPreferredSize(new Dimension(80, 25)); + } } } diff --git a/diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/chatbot/ChatbotPlugin.java b/diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/chatbot/ChatbotPlugin.java index df4afb2b..b9ab601a 100644 --- a/diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/chatbot/ChatbotPlugin.java +++ b/diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/chatbot/ChatbotPlugin.java @@ -48,7 +48,7 @@ public class ChatbotPlugin implements IPlugIn { @Override public EnumSet getSubscribedEventTypes() { - return EnumSet.of(EventType.FILE_STATUS_CHANGED, EventType.PROJECT_LOADED, + return EnumSet.of(EventType.PROJECT_SAVED, EventType.PROJECT_LOADED, EventType.CLOUD_LOGGED_IN, EventType.CLOUD_LOGGED_OUT); } @@ -56,7 +56,7 @@ public class ChatbotPlugin implements IPlugIn { @Override public void processMessage(EventType eventType, Object... params) { switch (eventType) { - case FILE_STATUS_CHANGED: + case PROJECT_SAVED: case PROJECT_LOADED: case CLOUD_LOGGED_IN: case CLOUD_LOGGED_OUT: