From d3b2593ff2a2b86820efbfda4224dbbbe7c0c0dd Mon Sep 17 00:00:00 2001 From: Stephan Janssen Date: Thu, 20 Jun 2024 16:26:40 +0200 Subject: [PATCH 1/2] Fix #102: Fixed the /help default command --- build.gradle.kts | 2 +- .../devoxx/genie/service/ChatPromptExecutor.java | 5 +++-- .../genie/ui/component/FileEntryComponent.java | 4 ++-- .../genie/ui/panel/ActionButtonsPanel.java | 16 ++++++++++------ .../com/devoxx/genie/ui/panel/HelpPanel.java | 1 + .../genie/ui/renderer/FileListCellRenderer.java | 2 +- .../settings/prompt/PromptSettingsComponent.java | 10 +++++----- src/main/resources/META-INF/plugin.xml | 3 +++ 8 files changed, 26 insertions(+), 17 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 8d77d7d9..ce7ca3b8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { } group = "com.devoxx.genie" -version = "0.1.16" +version = "0.1.17" repositories { mavenCentral() diff --git a/src/main/java/com/devoxx/genie/service/ChatPromptExecutor.java b/src/main/java/com/devoxx/genie/service/ChatPromptExecutor.java index 02327452..2b1cc0c6 100644 --- a/src/main/java/com/devoxx/genie/service/ChatPromptExecutor.java +++ b/src/main/java/com/devoxx/genie/service/ChatPromptExecutor.java @@ -71,10 +71,11 @@ private void webSearchPrompt(@NotNull ChatMessageContext chatMessageContext, * @param chatMessageContext the chat message context * @param promptOutputPanel the prompt output panel */ - public void updatePromptWithCommandIfPresent(@NotNull ChatMessageContext chatMessageContext, - PromptOutputPanel promptOutputPanel) { + public Optional updatePromptWithCommandIfPresent(@NotNull ChatMessageContext chatMessageContext, + PromptOutputPanel promptOutputPanel) { Optional commandFromPrompt = getCommandFromPrompt(chatMessageContext.getUserPrompt(), promptOutputPanel); chatMessageContext.setUserPrompt(commandFromPrompt.orElse(chatMessageContext.getUserPrompt())); + return commandFromPrompt; } /** diff --git a/src/main/java/com/devoxx/genie/ui/component/FileEntryComponent.java b/src/main/java/com/devoxx/genie/ui/component/FileEntryComponent.java index e4cff5e1..b477022d 100644 --- a/src/main/java/com/devoxx/genie/ui/component/FileEntryComponent.java +++ b/src/main/java/com/devoxx/genie/ui/component/FileEntryComponent.java @@ -39,8 +39,8 @@ public FileEntryComponent(Project project, setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - Icon fileTypeIcon = FileTypeIconUtil.getFileTypeIcon(project, virtualFile); - JButton fileNameButton = new JButton(virtualFile.getName(), fileTypeIcon); + // Icon fileTypeIcon = FileTypeIconUtil.getFileTypeIcon(project, virtualFile); + JButton fileNameButton = new JButton(virtualFile.getName()); JButton fileNameBtn = createButton(fileNameButton); fileNameBtn.addActionListener(e -> openFileWithSelectedCode(project, virtualFile)); diff --git a/src/main/java/com/devoxx/genie/ui/panel/ActionButtonsPanel.java b/src/main/java/com/devoxx/genie/ui/panel/ActionButtonsPanel.java index 9b869425..c019736b 100644 --- a/src/main/java/com/devoxx/genie/ui/panel/ActionButtonsPanel.java +++ b/src/main/java/com/devoxx/genie/ui/panel/ActionButtonsPanel.java @@ -29,6 +29,7 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.util.List; +import java.util.Optional; import static com.devoxx.genie.model.Constant.*; import static com.devoxx.genie.model.Constant.ADD_FILE_S_TO_PROMPT_CONTEXT; @@ -150,18 +151,21 @@ private void onSubmitPrompt(ActionEvent actionEvent) { disableButtons(); - chatPromptExecutor.updatePromptWithCommandIfPresent(chatMessageContext, promptOutputPanel); - chatPromptExecutor.executePrompt(chatMessageContext, promptOutputPanel, this::enableButtons); + chatPromptExecutor.updatePromptWithCommandIfPresent(chatMessageContext, promptOutputPanel) + .ifPresentOrElse(command -> chatPromptExecutor.executePrompt(chatMessageContext, promptOutputPanel, this::enableButtons), + this::enableButtons); } /** * Enable the prompt input component and reset the Submit button icon. */ public void enableButtons() { - submitBtn.setIcon(SubmitIcon); - submitBtn.setEnabled(true); - submitBtn.setToolTipText(SUBMIT_THE_PROMPT); - promptInputComponent.setEnabled(true); + SwingUtilities.invokeLater(() -> { + submitBtn.setIcon(SubmitIcon); + submitBtn.setEnabled(true); + submitBtn.setToolTipText(SUBMIT_THE_PROMPT); + promptInputComponent.setEnabled(true); + }); } /** diff --git a/src/main/java/com/devoxx/genie/ui/panel/HelpPanel.java b/src/main/java/com/devoxx/genie/ui/panel/HelpPanel.java index b6739bbf..c5a91ee3 100644 --- a/src/main/java/com/devoxx/genie/ui/panel/HelpPanel.java +++ b/src/main/java/com/devoxx/genie/ui/panel/HelpPanel.java @@ -15,6 +15,7 @@ public HelpPanel(String helpMsg) { super("helpPanel"); setLayout(new BorderLayout()); withPreferredHeight(80); + withPreferredHeight(175); add(new JBLabel(helpMsg), BorderLayout.CENTER); } } diff --git a/src/main/java/com/devoxx/genie/ui/renderer/FileListCellRenderer.java b/src/main/java/com/devoxx/genie/ui/renderer/FileListCellRenderer.java index dbd3d766..125ba556 100644 --- a/src/main/java/com/devoxx/genie/ui/renderer/FileListCellRenderer.java +++ b/src/main/java/com/devoxx/genie/ui/renderer/FileListCellRenderer.java @@ -24,7 +24,7 @@ public Component getListCellRendererComponent(JList list, JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof VirtualFile file) { - label.setIcon(FileTypeIconUtil.getFileTypeIcon(project, file)); + // label.setIcon(FileTypeIconUtil.getFileTypeIcon(project, file)); label.setText(file.getName()); } diff --git a/src/main/java/com/devoxx/genie/ui/settings/prompt/PromptSettingsComponent.java b/src/main/java/com/devoxx/genie/ui/settings/prompt/PromptSettingsComponent.java index 09bfcf0a..65b9a031 100644 --- a/src/main/java/com/devoxx/genie/ui/settings/prompt/PromptSettingsComponent.java +++ b/src/main/java/com/devoxx/genie/ui/settings/prompt/PromptSettingsComponent.java @@ -33,29 +33,29 @@ public JPanel createSettingsPanel() { .addComponent(new JXTitledSeparator("Prompts")) .addVerticalGap(5) .addLabeledComponentFillVertically( - "System Prompt", + "System prompt", systemPromptField ) .addLabeledComponent( - new JBLabel("Test Prompt"), + new JBLabel("Test prompt"), testPromptField, 10, true ) .addLabeledComponent( - new JBLabel("Explain Prompt"), + new JBLabel("Explain prompt"), explainPromptField, 10, true ) .addLabeledComponent( - new JBLabel("Review Prompt"), + new JBLabel("Review prompt"), reviewPromptField, 10, true ) .addLabeledComponent( - new JBLabel("Custom Prompt"), + new JBLabel("Custom prompt"), customPromptField, 10, true diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index cf0e0a38..0d82a5c2 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -32,6 +32,9 @@ ]]> v0.1.17 +
  • Fix #102: /help also runs the actual prompt
  • +

    v0.1.16

    • Feat #90: Include System Prompt in Settings page
    • From cc8092b80a2f1daeb7c5a77d000c3ebd85cc9b7d Mon Sep 17 00:00:00 2001 From: Stephan Janssen Date: Thu, 20 Jun 2024 16:27:55 +0200 Subject: [PATCH 2/2] Updated change notes --- src/main/resources/META-INF/plugin.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 0d82a5c2..ebf41a4c 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -33,8 +33,10 @@ v0.1.17 +
        +
      • Feat: Split settings into different panels underneath Tools menu
      • Fix #102: /help also runs the actual prompt
      • - +

      v0.1.16

      • Feat #90: Include System Prompt in Settings page