Skip to content

Identifier selection on fresh start in New Entry Dialog#15286

Merged
Siedlerchr merged 12 commits into
JabRef:mainfrom
andrea02polimi:fix-15000-identifier
Mar 9, 2026
Merged

Identifier selection on fresh start in New Entry Dialog#15286
Siedlerchr merged 12 commits into
JabRef:mainfrom
andrea02polimi:fix-15000-identifier

Conversation

@andrea02polimi

Copy link
Copy Markdown
Contributor

Closes #15000

PR Description

Automatically detects the identifier type on fresh start.

Previously, when opening "Add entry using identifier" with an identifier already in the clipboard, the identifier field was pre-filled but the identifier type was not automatically selected and remained empty.

Steps to test

  1. Copy https://arxiv.org/abs/2205.01163 to your clipboard
  2. Start JabRef
  3. Create a new library
  4. Click on "Add entry using..."
  5. Verify that the correct identifier type is automatically selected

Note: it works for all types present in the Identifier class, namely:

  • 10.1145/3368089.3409749 (DOI)
  • arXiv:1706.03762
  • 9780262033848 (ISBN)
  • https://ssrn.com/abstract=123456
Screenshot 2026-03-07 alle 01 07 22 image

Checklist

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef
  • [/] I added JUnit tests for changes (not applicable, UI-only change)
  • I added screenshots in the PR description (if change is visible to the user)
  • I added a screenshot in the PR description showing a library with a single entry with me as author and as title the issue number
  • I described the change in CHANGELOG.md
  • [/] I checked the user documentation for up to dateness (not required for this small UI improvement)

andreazhang added 3 commits March 7, 2026 00:29
Automatically selects the appropriate fetcher when entering an identifier
(DOI, arXiv, ISBN, SSRN, etc. only those supported in Identifier interface) in the Lookup identifier tab.

Fixes JabRef#15000
Ensure the correct identifier fetcher is selected when initializing the dialog from clipboard content and when parsing the identifier text. Refactors updateFetcherFromIdentifierText to use the Identifier API more clearly and updates the fetcher accordingly.

Fixes JabRef#15000
@github-actions

github-actions Bot commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

Hey @andrea02polimi! 👋

Thank you for contributing to JabRef!

We have automated checks in place, based on which you will soon get feedback if any of them are failing. We also use Qodo for review assistance. It will update your pull request description with a review help and offer suggestions to improve the pull request.

After all automated checks pass, a maintainer will also review your contribution. Once that happens, you can go through their comments in the "Files changed" tab and act on them, or reply to the conversation if you have further inputs. You can read about the whole pull request process in our contribution guide.

Please ensure that your pull request is in line with our AI Usage Policy and make necessary disclosures.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Auto-detect identifier type on fresh start in New Entry dialog

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Auto-detect identifier type when opening New Entry dialog with clipboard content
• Refactored identifier detection logic to use Identifier API consistently
• Fixed text field binding to use correct field for identifier input
• Improved fetcher initialization and null-safety checks
Diagram
flowchart LR
  A["Dialog Initialization"] --> B["Check Clipboard Content"]
  B --> C["Detect Identifier Type"]
  C --> D["Set Appropriate Fetcher"]
  D --> E["Pre-fill Identifier Field"]
  B --> F["User Types in Field"]
  F --> G["Update Fetcher on Text Change"]
Loading

Grey Divider

File Changes

1. jabgui/src/main/java/org/jabref/gui/newentry/NewEntryView.java 🐞 Bug fix +32/-35

Fix identifier auto-detection and field binding issues

• Moved getDialogPane().disableProperty().bind() from constructor to initialize() method to
 ensure proper initialization order
• Fixed clipboard text handling in finalizeTabs() to set text on idText field instead of
 interpretText field
• Removed duplicate clipboard extraction logic from initializeLookupIdentifier() method
• Refactored updateFetcherFromIdentifierText() to add null-safety check and improved readability
• Removed extractIdentifierFromClipboard() helper method as logic is now integrated into main flow
• Added clipboard content initialization in initializeLookupIdentifier() with proper null and
 newline checks
• Improved idFetcher.setOnAction() callback with null-safety check before accessing fetcher value

jabgui/src/main/java/org/jabref/gui/newentry/NewEntryView.java


2. CHANGELOG.md 📝 Documentation +1/-0

Document identifier selection bug fix

• Added entry documenting the fix for identifier selection not working on fresh start
• References issue #15000

CHANGELOG.md


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Remediation recommended

1. Overeager clipboard prefill🐞 Bug ⛯ Reliability
Description
The identifier field is now pre-filled with any single-line clipboard text, even when it is not a
recognized identifier. Because lookup validation only checks for non-blank input, users can
accidentally trigger fetch attempts (network calls) with arbitrary clipboard content, leading to
confusing errors and unnecessary requests.
Code

jabgui/src/main/java/org/jabref/gui/newentry/NewEntryView.java[R331-338]

+        String clipboard = ClipBoardManager.getContents().trim();
+
+        if (!StringUtil.isBlank(clipboard) && !clipboard.contains("\n")) {
+            idText.setText(clipboard);
+            idText.selectAll();
+
+            Platform.runLater(() -> updateFetcherFromIdentifierText(clipboard));
+        }
Evidence
NewEntryView pre-fills the identifier text field for any single-line clipboard content; lookup
execution does not validate that the text is a real Identifier (it only checks non-blank), so
arbitrary clipboard content can be sent to fetchers/composite fetcher.

jabgui/src/main/java/org/jabref/gui/newentry/NewEntryView.java[331-338]
jabgui/src/main/java/org/jabref/gui/newentry/NewEntryViewModel.java[118-123]
jabgui/src/main/java/org/jabref/gui/newentry/NewEntryViewModel.java[248-259]
jabgui/src/main/java/org/jabref/gui/newentry/NewEntryViewModel.java[262-282]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`NewEntryView.initializeLookupIdentifier()` currently pre-fills the identifier input (`idText`) from *any* single-line clipboard content. However, identifier lookup execution accepts any non-blank string, so users can unintentionally trigger network lookups with random clipboard text (e.g., a sentence), leading to confusing failure dialogs and unnecessary requests.
### Issue Context
- The prefill is guarded only by `!blank` and `!contains("\n")`.
- Lookup workers (`WorkerLookupId`, `WorkerLookupTypedId`) do not validate that `idText` is a syntactically valid `Identifier`; they only check non-blank.
### Fix Focus Areas
- jabgui/src/main/java/org/jabref/gui/newentry/NewEntryView.java[331-338]
- jabgui/src/main/java/org/jabref/gui/newentry/NewEntryViewModel.java[118-123]
- jabgui/src/main/java/org/jabref/gui/newentry/NewEntryViewModel.java[248-282]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@github-actions github-actions Bot added the good first issue An issue intended for project-newcomers. Varies in difficulty. label Mar 7, 2026
@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

@github-actions github-actions Bot added status: changes-required Pull requests that are not yet complete and removed status: no-bot-comments labels Mar 7, 2026
@testlens-app

This comment has been minimized.

@github-actions github-actions Bot added status: no-bot-comments and removed status: changes-required Pull requests that are not yet complete labels Mar 7, 2026
@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

@testlens-app

testlens-app Bot commented Mar 7, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 6954dd9
▶️ Tests: 10126 executed
⚪️ Checks: 60/60 completed


Learn more about TestLens at testlens.app.

@Siedlerchr Siedlerchr added this pull request to the merge queue Mar 9, 2026
@github-actions github-actions Bot added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label Mar 9, 2026
@calixtus calixtus changed the title Fix 15000 identifier Identifier selection on fresh start in New Entry Dialog Mar 9, 2026
Merged via the queue into JabRef:main with commit 26d6f95 Mar 9, 2026
60 checks passed
Siedlerchr added a commit to statxc/jabref that referenced this pull request Mar 10, 2026
* upstream/main: (59 commits)
  Fix 15000 identifier (JabRef#15286)
  Chore(deps): Bump dev.langchain4j:langchain4j-bom in /versions (JabRef#15305)
  Supress JavaFX VirtualFlow Info log noise for large libraries (10k+). (JabRef#15298)
  Chore(deps): Bump commons-logging:commons-logging in /versions (JabRef#15304)
  Fix merge dialog closing immediately when only one PDF importer returns metadata (JabRef#15127) (JabRef#15287)
  Fixed nullable eventhandlers (JabRef#15288)
  New Crowdin updates (JabRef#15285)
  Fix the ESC key for GlobalSearchResultDialog (JabRef#15259)
  Remove jbang plugin banner (JabRef#15282)
  Chore(deps): Bump org.apache.httpcomponents.core5:httpcore5 in /versions (JabRef#15281)
  Udpate to latest gradle master (JabRef#15279)
  Migrate to GemsFX Notifications (JabRef#14762)
  Chore(deps): Bump JetBrains/junie-github-action from 0 to 1 (JabRef#15272)
  Chore(deps): Bump docker/setup-qemu-action from 3 to 4 (JabRef#15269)
  Feature/citation count dropdown (JabRef#15216)
  Update dependency org.apache.maven.plugins:maven-resources-plugin to v3.5.0 (JabRef#15275)
  Chore(deps): Bump jablib/src/main/resources/csl-styles (JabRef#15273)
  Fix more security
  Fix pr_body leakage
  Chore: add dependency-management.md (JabRef#15278)
  ...
FynnianB pushed a commit to FynnianB/jabref that referenced this pull request Mar 14, 2026
* Auto-detect identifier type in New Entry dialog

Automatically selects the appropriate fetcher when entering an identifier
(DOI, arXiv, ISBN, SSRN, etc. only those supported in Identifier interface) in the Lookup identifier tab.

Fixes JabRef#15000

* Auto-detect identifier type in New Entry dialog

Ensure the correct identifier fetcher is selected when initializing the dialog from clipboard content and when parsing the identifier text. Refactors updateFetcherFromIdentifierText to use the Identifier API more clearly and updates the fetcher accordingly.

Fixes JabRef#15000

* Update changelog for auto identifier detection on fresh start

* bug fix: overeager clipboard prefill

* Link implementation to requirement newentry.clipboard.autofocus

* Apply javadoc formatter

* Link implementation to requirement newentry.clipboard.autofocus

* Link implementation to requirement newentry.clipboard.autofocus

* Use correct requirement newentry.clipboard.autofocus

---------

Co-authored-by: andreazhang <andrea.zhang@polimi.mail.com>
FynnianB pushed a commit to FynnianB/jabref that referenced this pull request Mar 19, 2026
* Auto-detect identifier type in New Entry dialog

Automatically selects the appropriate fetcher when entering an identifier
(DOI, arXiv, ISBN, SSRN, etc. only those supported in Identifier interface) in the Lookup identifier tab.

Fixes JabRef#15000

* Auto-detect identifier type in New Entry dialog

Ensure the correct identifier fetcher is selected when initializing the dialog from clipboard content and when parsing the identifier text. Refactors updateFetcherFromIdentifierText to use the Identifier API more clearly and updates the fetcher accordingly.

Fixes JabRef#15000

* Update changelog for auto identifier detection on fresh start

* bug fix: overeager clipboard prefill

* Link implementation to requirement newentry.clipboard.autofocus

* Apply javadoc formatter

* Link implementation to requirement newentry.clipboard.autofocus

* Link implementation to requirement newentry.clipboard.autofocus

* Use correct requirement newentry.clipboard.autofocus

---------

Co-authored-by: andreazhang <andrea.zhang@polimi.mail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first contrib good first issue An issue intended for project-newcomers. Varies in difficulty. status: no-bot-comments status: to-be-merged PRs which are accepted and should go into the merge-queue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Identifier selection does not work on fresh start

2 participants