Route dropped bibliography files to import dialog#15754
Conversation
Review Summary by QodoRoute dropped bibliography files to import dialog
WalkthroughsDescription• Routes dropped bibliography files (RIS, BibTeX, etc.) to import dialog • Separates importable files from PDFs and other non-bibliography files • Maintains existing behavior for PDFs and non-importable files • Adds comprehensive tests for dropped file classification logic Diagramflowchart LR
A["Dropped Files"] --> B["planDroppedFiles"]
B --> C{"isImportableBibliographyFile?"}
C -->|Yes| D["Bibliography Files"]
C -->|No| E["Remaining Files"]
D --> F["importBibliographyFilesWithDialog"]
E --> G["handleDropOfFiles"]
F --> H["ImportEntriesDialog"]
G --> I["Link to Entry or Import"]
File Changes1. jabgui/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
|
Code Review by Qodo
1.
|
|
Note that your PR will not be reviewed/accepted until you have gone through the mandatory checks in the description and marked each of them them exactly in the format of |
| .map(File::toPath) | ||
| .map(FileUtil::resolveIfShortcut) | ||
| .collect(Collectors.toList()); | ||
| ImportHandler.DroppedFileImportPlan droppedFileImportPlan = importHandler.planDroppedFiles(files); | ||
|
|
There was a problem hiding this comment.
2. Ui-thread file parsing 🐞 Bug ➹ Performance
EntryEditor/MainTable drag-and-drop handlers call ImportHandler.planDroppedFiles on the JavaFX event thread, but planDroppedFiles classifies files by running ImportFormatReader.importWithAutoDetection (full file I/O + parsing) per file. This can freeze drag-and-drop responsiveness and also wastes work by parsing twice (classification + dialog parsing).
Agent Prompt
## Issue description
Drag-and-drop currently blocks the JavaFX event thread by calling `ImportHandler.planDroppedFiles(...)`, which synchronously parses each dropped file via `ImportFormatReader.importWithAutoDetection(...)` to decide whether it is a bibliography file. This can cause UI freezes for large files or multi-file drops, and it also causes double work because the same files are parsed again when the import dialog runs.
## Issue Context
- `planDroppedFiles` is invoked directly inside JavaFX drag-drop handlers (EntryEditor + MainTable).
- `planDroppedFiles` calls `isImportableBibliographyFile` for each file.
- `isImportableBibliographyFile` creates a new `ImportFormatReader` and runs `importWithAutoDetection`, which iterates through many importers and reads file contents.
- The import dialog later triggers parsing again (`parseBibliographyFiles`).
## Fix Focus Areas
- jabgui/src/main/java/org/jabref/gui/maintable/MainTable.java[537-600]
- jabgui/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java[214-248]
- jabgui/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java[119-143]
- jabgui/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java[123-136]
- jabgui/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java[263-315]
## Suggested implementation direction
- Make dropped-file classification non-blocking:
- Option A (preferred): classify by extension using available importers’ `FileType`/extensions (no file I/O) and let the import dialog/background task handle actual parsing + errors.
- Option B: run `planDroppedFiles` in a `BackgroundTask` executed via `taskExecutor`, then open the dialog on the FX thread once classification completes.
- Avoid repeated work:
- Reuse a single `ImportFormatReader` instance per drop operation (instead of constructing one per file).
- If you keep content-based detection, consider caching `ImportResult`/`ParserResult` from classification and passing it into the dialog to avoid re-parsing.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
You do no tneed to close and recreate a new pr, just push to your existing branch |
Thank you for the suggestion. I realized the previous PR included some unintended changes and was not as clean as it should be. In addition, I cannot fully understand those changes. Thus, to avoid confusion, I opened a new PR with a cleaner branch that only contains the focused fix for this issue. |
|
Your pull request conflicts with the target branch. Please merge with your code. For a step-by-step guide to resolve merge conflicts, see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line. |
force push is allowed in this case. |
Reviewed and exploratory tested with @kramosss
Related issues and pull requests
Closes #15391
PR Description
Fixes #15391
This PR updates drag-and-drop handling so that dropped importable bibliography files, such as
.risand.bib, open JabRef’s standard import dialog instead of being imported or linked immediately. This makes drag-and-drop consistent with the normal import workflow while keeping the existing behavior for PDFs and other non-importable files unchanged. This change does not affect invalidation behavior elsewhere, and no additional invalidation logic was introduced.Steps to test
.risfile containing multiple entries into the main table..bibfile and verify that it also opens the import dialog..risfile and verify that JabRef does not import it as a bibliography file..risfile and a.bibfile, and verify that all parsed entries appear in the import dialog.Screenshots





Example
.risfile for testing:Example
.bibfile for testing:Example
.enwfile for testing:Note
You can also use demo file
Chocolate.bibfrom jabref-demonstration-libraries to test the drag-and-drop behavior.AI usage
GitHub Copilot (GPT-5.4)
ChatGPT (GPT-5.5 Thinking)
Checklist
CHANGELOG.mdin a way that can be understood by the average user (if change is visible to the user)