chatbot enhancements

This commit is contained in:
Bane Stojkovic
2025-04-21 20:09:40 +02:00
parent 39d667f0c9
commit ad81da8d54
6 changed files with 28 additions and 10 deletions
@@ -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.
@@ -80,14 +80,14 @@ public class ChatbotService {
@Override
public EnumSet<EventType> 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()) {
@@ -177,6 +177,7 @@ public class ProjectFileManager {
if (!isBackup) {
this.currentFileName = fileName;
this.modified = false;
messageDispatcher.dispatchMessage(EventType.PROJECT_SAVED, getCurrentFileName());
fireFileStatusChanged();
}
}
@@ -258,9 +258,13 @@
<minor>3</minor>
<build>0</build>
</versionNumber>
<releaseDate>2025-03-27 00:00:00.000 CET</releaseDate>
<releaseDate>2025-04-21 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Improved AI Assistant quality of responses, especially when analyzing a circuit</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>When saving a project to the new file, retain all the AI Assistant chat history for the new project file</description>
@@ -275,7 +279,7 @@
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Output current subscription statistics at the end of the chat for transparency</description>
<description>Output current subscription statistics at the end of the chat for usage transparency</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
@@ -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));
}
}
}
@@ -48,7 +48,7 @@ public class ChatbotPlugin implements IPlugIn {
@Override
public EnumSet<EventType> 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: