diff --git a/CHANGELOG.md b/CHANGELOG.md index 2343276e747..58f4909db8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,8 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv ### Fixed -We fixed an error on startup when using portable preferences. [#14729](https://github.com/JabRef/jabref/issues/14729) +- We fixed an error on startup when using portable preferences. [#14729](https://github.com/JabRef/jabref/issues/14729) +- We fixed empty entries list when exporting AI chat from a group. [#14647](https://github.com/JabRef/jabref/issues/14647) ### Removed diff --git a/jabgui/src/main/java/org/jabref/gui/ai/components/aichat/AiChatComponent.java b/jabgui/src/main/java/org/jabref/gui/ai/components/aichat/AiChatComponent.java index 9c605860db5..ca827012b0e 100644 --- a/jabgui/src/main/java/org/jabref/gui/ai/components/aichat/AiChatComponent.java +++ b/jabgui/src/main/java/org/jabref/gui/ai/components/aichat/AiChatComponent.java @@ -5,6 +5,7 @@ import java.nio.file.Path; import java.nio.file.StandardOpenOption; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Optional; import java.util.stream.Stream; @@ -109,7 +110,6 @@ public AiChatComponent(AiService aiService, TaskExecutor taskExecutor ) { this.aiService = aiService; - this.entries = stateManager.getSelectedEntries(); this.bibDatabaseContext = bibDatabaseContext; this.aiPreferences = aiPreferences; this.entryTypesManager = entryTypesManager; @@ -119,6 +119,19 @@ public AiChatComponent(AiService aiService, this.aiChatLogic = aiService.getAiChatService().makeChat(name, chatHistory, entries, bibDatabaseContext); + ObservableList currentSelection = stateManager.getSelectedEntries(); + + if (!entries.isEmpty()) { + boolean isSubsetOfSelection = new HashSet<>(currentSelection).containsAll(entries); + if (isSubsetOfSelection) { + this.entries = currentSelection; + } else { + this.entries = entries; + } + } else { + this.entries = currentSelection; + } + aiService.getIngestionService().ingest(name, ListUtil.getLinkedFiles(entries).toList(), bibDatabaseContext); ViewLoader.view(this)