Skip to content
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -119,6 +119,19 @@ public AiChatComponent(AiService aiService,

this.aiChatLogic = aiService.getAiChatService().makeChat(name, chatHistory, entries, bibDatabaseContext);

ObservableList<BibEntry> 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)
Expand Down