Skip to content

Fix reset and import for Library, DOI, Owner, Timestamp and Remote Preferences#15514

Merged
calixtus merged 15 commits into
mainfrom
pref-reset-library
Apr 8, 2026
Merged

Fix reset and import for Library, DOI, Owner, Timestamp and Remote Preferences#15514
calixtus merged 15 commits into
mainfrom
pref-reset-library

Conversation

@calixtus

@calixtus calixtus commented Apr 8, 2026

Copy link
Copy Markdown
Member

Related issues and pull requests

Follow-up to #15503

PR Description

See qodo comment and title

Best be reviewed commit by commit

Steps to test

Run, open preferences, text reset and import

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 (always required)
  • [.] I added JUnit tests for changes (if applicable)
  • [.] 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 in a way that can be understood by the average user (if change is visible to the user)
  • [.] I checked the user documentation for up to dateness and submitted a pull request to our user documentation repository

@calixtus calixtus added status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers dev: code-quality Issues related to code or architecture decisions component: preferences labels Apr 8, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Fix reset and import for Library, DOI, Owner, Timestamp and Remote Preferences with consistent naming

✨ Enhancement 🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Rename preference methods to follow consistent naming conventions
  - isUseCustom()shouldUseCustom() for DOIPreferences
  - isUseOwner()shouldUseOwner() for OwnerPreferences
  - isAddImportedEntriesEnabled()shouldAddImportedEntries() for LibraryPreferences
  - useRemoteServer()shouldEnableRemoteServer() for RemotePreferences
• Add getDefault() and setAll() methods to preference classes
  - Enables proper reset and import functionality for preferences
  - Implemented for LibraryPreferences, DOIPreferences, OwnerPreferences, TimestampPreferences, and
  RemotePreferences
• Refactor RemotePreferences with clearer naming and parameter reordering
  - Rename portremoteServerPort, httpPorthttpServerPort
  - Rename useRemoteServerenableRemoteServer, enableLanguageServershouldEnableLanguageServer()
  - Reorder constructor parameters for consistency
• Consolidate timestamp cleanup classes into single generic class
  - Merge TimeStampToCreationDate and TimeStampToModificationDate into TimeStampToDateField
  - Reduces code duplication and improves maintainability
• Reorganize preference constants in JabRefCliPreferences with region markers
  - Group related constants by preference type (Library, DOI, Owner, Timestamp, Remote)
  - Rename constants to follow naming pattern (e.g., LIBRARY_*, DOI_*, OWNER_*)
Diagram
flowchart LR
  A["Preference Classes"] -->|Add getDefault| B["Default Instances"]
  A -->|Add setAll| C["Import/Reset Support"]
  D["Method Renaming"] -->|is* to should*| E["Consistent Naming"]
  F["RemotePreferences"] -->|Refactor Parameters| G["Clearer Structure"]
  H["Timestamp Cleanup"] -->|Consolidate Classes| I["TimeStampToDateField"]
  J["JabRefCliPreferences"] -->|Reorganize Constants| K["Region-Grouped Constants"]
Loading

Grey Divider

File Changes

1. jabgui/src/main/java/org/jabref/Launcher.java ✨ Enhancement +3/-3

Update RemotePreferences method calls to new naming

jabgui/src/main/java/org/jabref/Launcher.java


2. jabgui/src/main/java/org/jabref/gui/JabRefGUI.java ✨ Enhancement +3/-3

Update RemotePreferences and LibraryPreferences method calls

jabgui/src/main/java/org/jabref/gui/JabRefGUI.java


3. jabgui/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java ✨ Enhancement +1/-1

Update LibraryPreferences method call to new naming

jabgui/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java


View more (23)
4. jabgui/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java ✨ Enhancement +1/-1

Update LibraryPreferences method call to new naming

jabgui/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java


5. jabgui/src/main/java/org/jabref/gui/maintable/OpenUrlAction.java ✨ Enhancement +1/-1

Update DOIPreferences method call to new naming

jabgui/src/main/java/org/jabref/gui/maintable/OpenUrlAction.java


6. jabgui/src/main/java/org/jabref/gui/preferences/entry/EntryTabViewModel.java ✨ Enhancement +2/-2

Update OwnerPreferences method calls to new naming

jabgui/src/main/java/org/jabref/gui/preferences/entry/EntryTabViewModel.java


7. jabgui/src/main/java/org/jabref/gui/preferences/general/GeneralTabViewModel.java ✨ Enhancement +15/-15

Update RemotePreferences and related method calls

jabgui/src/main/java/org/jabref/gui/preferences/general/GeneralTabViewModel.java


8. jabgui/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java ✨ Enhancement +2/-2

Update LibraryPreferences and DOIPreferences method calls

jabgui/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java


9. jabgui/src/test/java/org/jabref/gui/entryeditor/citationrelationtab/CitationsRelationsTabViewModelTest.java 🧪 Tests +1/-1

Update LibraryPreferences mock method call

jabgui/src/test/java/org/jabref/gui/entryeditor/citationrelationtab/CitationsRelationsTabViewModelTest.java


10. jablib/src/main/java/org/jabref/logic/LibraryPreferences.java ✨ Enhancement +23/-1

Add getDefault and setAll methods, rename method

jablib/src/main/java/org/jabref/logic/LibraryPreferences.java


11. jablib/src/main/java/org/jabref/logic/cleanup/CleanupWorker.java ✨ Enhancement +3/-2

Update cleanup job instantiation for timestamp migration

jablib/src/main/java/org/jabref/logic/cleanup/CleanupWorker.java


12. jablib/src/main/java/org/jabref/logic/cleanup/TimeStampToDateField.java ✨ Enhancement +16/-16

Consolidate timestamp cleanup into generic reusable class

jablib/src/main/java/org/jabref/logic/cleanup/TimeStampToDateField.java


13. jablib/src/main/java/org/jabref/logic/cleanup/TimeStampToModificationDate.java ✨ Enhancement +0/-81

Remove duplicate class merged into TimeStampToDateField

jablib/src/main/java/org/jabref/logic/cleanup/TimeStampToModificationDate.java


14. jablib/src/main/java/org/jabref/logic/importer/fetcher/DoiResolution.java ✨ Enhancement +1/-1

Update DOIPreferences method call to new naming

jablib/src/main/java/org/jabref/logic/importer/fetcher/DoiResolution.java


15. jablib/src/main/java/org/jabref/logic/layout/format/DOICheck.java ✨ Enhancement +1/-1

Update DOIPreferences method call to new naming

jablib/src/main/java/org/jabref/logic/layout/format/DOICheck.java


16. jablib/src/main/java/org/jabref/logic/preferences/DOIPreferences.java ✨ Enhancement +18/-2

Add getDefault and setAll methods, rename method

jablib/src/main/java/org/jabref/logic/preferences/DOIPreferences.java


17. jablib/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java ✨ Enhancement +124/-106

Reorganize constants with regions, add preference import/reset support

jablib/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java


18. jablib/src/main/java/org/jabref/logic/preferences/OwnerPreferences.java ✨ Enhancement +23/-2

Add getDefault and setAll methods, rename methods

jablib/src/main/java/org/jabref/logic/preferences/OwnerPreferences.java


19. jablib/src/main/java/org/jabref/logic/preferences/TimestampPreferences.java ✨ Enhancement +32/-3

Add getDefault and setAll methods, mark legacy fields deprecated

jablib/src/main/java/org/jabref/logic/preferences/TimestampPreferences.java


20. jablib/src/main/java/org/jabref/logic/remote/RemotePreferences.java ✨ Enhancement +74/-42

Refactor with clearer naming and parameter reordering

jablib/src/main/java/org/jabref/logic/remote/RemotePreferences.java


21. jablib/src/main/java/org/jabref/logic/util/UpdateField.java ✨ Enhancement +2/-2

Update OwnerPreferences method calls to new naming

jablib/src/main/java/org/jabref/logic/util/UpdateField.java


22. jablib/src/test/java/org/jabref/logic/cleanup/TimeStampToDateFieldTest.java 🧪 Tests +5/-20

Rename and refactor test for consolidated timestamp cleanup class

jablib/src/test/java/org/jabref/logic/cleanup/TimeStampToDateFieldTest.java


23. jablib/src/test/java/org/jabref/logic/cleanup/TimeStampToModificationDateTest.java 🧪 Tests +0/-85

Remove duplicate test file merged into TimeStampToDateFieldTest

jablib/src/test/java/org/jabref/logic/cleanup/TimeStampToModificationDateTest.java


24. jablib/src/test/java/org/jabref/logic/importer/fetcher/DoiResolutionTest.java 🧪 Tests +1/-1

Update DOIPreferences mock method call

jablib/src/test/java/org/jabref/logic/importer/fetcher/DoiResolutionTest.java


25. jablib/src/test/java/org/jabref/logic/layout/format/DOICheckTest.java 🧪 Tests +1/-1

Update DOIPreferences mock method call

jablib/src/test/java/org/jabref/logic/layout/format/DOICheckTest.java


26. jablib/src/test/java/org/jabref/logic/remote/RemotePreferencesTest.java 🧪 Tests +20/-20

Update RemotePreferences test for refactored class

jablib/src/test/java/org/jabref/logic/remote/RemotePreferencesTest.java


Grey Divider

Qodo Logo

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

qodo-free-for-open-source-projects Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0)   📘 Rule violations (3)   📎 Requirement gaps (0)   🎨 UX Issues (0)
📘\ ☼ Reliability (2) ⚙ Maintainability (1)

Grey Divider


Action required

1. RemotePreferences API renamed 📘
Description
RemotePreferences changes public constructor and method names (e.g.,
getPort/setPort/useRemoteServer) which breaks any external callers still using the old API.
This is a backward-incompatible change without an explicit compatibility bridge (deprecated
wrappers).
Code

jablib/src/main/java/org/jabref/logic/remote/RemotePreferences.java[R33-47]

+    public RemotePreferences(boolean enableRemoteServer,
+                             int remoteServerPort,
+                             boolean enableHttpServer,
+                             int httpServerPort,
+                             boolean enableLanguageServer,
+                             int languageServerPort,
+                             boolean directHttpImport) {
+        this.enableRemoteServer = new SimpleBooleanProperty(enableRemoteServer);
+        this.remoteServerPort = new SimpleIntegerProperty(remoteServerPort);
this.enableHttpServer = new SimpleBooleanProperty(enableHttpServer);
+        this.httpServerPort = new SimpleIntegerProperty(httpServerPort);
this.enableLanguageServer = new SimpleBooleanProperty(enableLanguageServer);
this.languageServerPort = new SimpleIntegerProperty(languageServerPort);
this.directHttpImport = new SimpleBooleanProperty(directHttpImport);
}
Evidence
PR Compliance ID 2 requires preserving backward compatibility unless explicitly instructed; the diff
shows a public API rename/restructure in RemotePreferences (constructor signature and accessors
renamed to getRemoteServerPort, shouldEnableRemoteServer, etc.), removing the previous
method/field names used by callers.

AGENTS.md
jablib/src/main/java/org/jabref/logic/remote/RemotePreferences.java[22-101]
jabgui/src/main/java/org/jabref/Launcher.java[79-80]

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

## Issue description
`RemotePreferences` introduces backward-incompatible public API changes by renaming/removing existing methods and changing the public constructor signature.
## Issue Context
Downstream code (including plugins/consumers) may still call legacy methods like `getPort()`, `setPort(int)`, `useRemoteServer()`, etc. Removing these without deprecated delegating wrappers breaks backward compatibility.
## Fix Focus Areas
- jablib/src/main/java/org/jabref/logic/remote/RemotePreferences.java[22-158]

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


2. Preference getters renamed 📘
Description
Public preference classes rename/remove established boolean getters (e.g., isUseCustom,
isUseOwner, isOverwriteOwner, isAddImportedEntriesEnabled) which is a breaking change for any
external callers. These should keep deprecated compatibility methods or a migration strategy.
Code

jablib/src/main/java/org/jabref/logic/preferences/DOIPreferences.java[L17-19]

-    public boolean isUseCustom() {
+    private DOIPreferences() {
+        this(
+                false,            // useCustom
+                "https://doi.org" // defaultBaseURI
+        );
+    }
+
+    public static DOIPreferences getDefault() {
+        return new DOIPreferences();
+    }
+
+    public void setAll(DOIPreferences preferences) {
+        this.useCustom.set(preferences.shouldUseCustom());
+        this.defaultBaseURI.set(preferences.getDefaultBaseURI());
+    }
+
+    public boolean shouldUseCustom() {
return useCustom.get();
}
Evidence
PR Compliance ID 2 requires preserving public behavior/APIs; the diff removes/renames public getters
across multiple preference classes (e.g., isUseCustom() -> shouldUseCustom(), isUseOwner() ->
shouldUseOwner(), etc.), which is a direct source-level breaking change.

AGENTS.md
jablib/src/main/java/org/jabref/logic/preferences/DOIPreferences.java[17-35]
jablib/src/main/java/org/jabref/logic/preferences/OwnerPreferences.java[21-67]
jablib/src/main/java/org/jabref/logic/LibraryPreferences.java[68-92]

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

## Issue description
Multiple preference classes rename/remove existing public getters, breaking existing callers.
## Issue Context
These are public classes in `org.jabref.logic...` and are likely used outside the immediate module.
## Fix Focus Areas
- jablib/src/main/java/org/jabref/logic/LibraryPreferences.java[66-100]
- jablib/src/main/java/org/jabref/logic/preferences/DOIPreferences.java[12-43]
- jablib/src/main/java/org/jabref/logic/preferences/OwnerPreferences.java[35-76]

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


3. Timestamp migration reads wrong field🐞
Description
TimeStampToDateField.cleanup() checks/parses/clears the *targetField* instead of the legacy
*sourceField*, so timestamp migration usually won’t run (when the target field is absent) and can
act on the wrong field while leaving the legacy timestamp untouched. Additionally, the FieldChange
for the target field captures the “oldValue” after the entry has been mutated, making the change
list incorrect (breaks undo/auditing expectations).
Code

jablib/src/main/java/org/jabref/logic/cleanup/TimeStampToDateField.java[R62-76]

+        if (entry.getField(targetField).isPresent()) {
+            Optional<String> formattedTimeStamp = formatTimeStamp(entry.getField(targetField).get());
   if (formattedTimeStamp.isEmpty()) {
       // In case the timestamp could not be parsed, do nothing to not lose data
       return List.of();
   }
   // Setting the EventSource is necessary to circumvent the update of the modification date during timestamp migration
-            entry.clearField(timeStampField, EntriesEventSource.CLEANUP_TIMESTAMP);
+            entry.clearField(targetField, EntriesEventSource.CLEANUP_TIMESTAMP);
   List<FieldChange> changeList = new ArrayList<>();
   FieldChange changeTo;
   // Add removal of timestamp field
-            changeList.add(new FieldChange(entry, StandardField.TIMESTAMP, formattedTimeStamp.get(), ""));
-            entry.setField(StandardField.CREATIONDATE, formattedTimeStamp.get(), EntriesEventSource.CLEANUP_TIMESTAMP);
-            changeTo = new FieldChange(entry, StandardField.CREATIONDATE, entry.getField(StandardField.CREATIONDATE).orElse(""), formattedTimeStamp.get());
+            changeList.add(new FieldChange(entry, sourceField, formattedTimeStamp.get(), ""));
+            entry.setField(targetField, formattedTimeStamp.get(), EntriesEventSource.CLEANUP_TIMESTAMP);
+            changeTo = new FieldChange(entry, targetField, entry.getField(targetField).orElse(""), formattedTimeStamp.get());
   changeList.add(changeTo);
Evidence
CleanupWorker constructs TimeStampToDateField with (source=timestampPreferences.getTimestampField(),
target=CREATIONDATE/MODIFICATIONDATE), but TimeStampToDateField.cleanup() reads and clears
targetField (so it will skip migration when target is empty, which is the common case). The unit
test expects TIMESTAMP to be migrated into CREATIONDATE, which cannot happen with the current
targetField check. FieldChange’s constructor is (oldValue, newValue), but the code computes the
target field’s “oldValue” after calling setField, so it records the new value as the old one.

jablib/src/main/java/org/jabref/logic/cleanup/TimeStampToDateField.java[59-79]
jablib/src/main/java/org/jabref/logic/cleanup/CleanupWorker.java[80-106]
jablib/src/test/java/org/jabref/logic/cleanup/TimeStampToDateFieldTest.java[22-46]
jablib/src/main/java/org/jabref/model/FieldChange.java[13-25]

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

## Issue description
`TimeStampToDateField.cleanup()` currently migrates based on `targetField` presence/value and clears `targetField`, but the migration is supposed to read/clear the *legacy timestamp* (`sourceField`) and write into the *date field* (`targetField`). Also, `FieldChange` objects are built with incorrect `oldValue` because the code reads values after mutating the entry.
### Issue Context
`CleanupWorker` passes `(timestampPreferences.getTimestampField(), StandardField.CREATIONDATE/MODIFICATIONDATE)` to `TimeStampToDateField`, so `sourceField` is the legacy timestamp field.
### Fix Focus Areas
- jablib/src/main/java/org/jabref/logic/cleanup/TimeStampToDateField.java[59-80]
- jablib/src/main/java/org/jabref/logic/cleanup/CleanupWorker.java[100-106]
### Implementation notes
- Trigger migration when `entry.getField(sourceField).isPresent()`.
- Parse the value from `sourceField`.
- Capture `String oldSource = entry.getField(sourceField).orElse("")` and `String oldTarget = entry.getField(targetField).orElse("")` **before** modifying the entry.
- Clear `sourceField` (not `targetField`) with `EntriesEventSource.CLEANUP_TIMESTAMP`.
- Set `targetField` with the formatted timestamp.
- Create `FieldChange(sourceField, oldSource, "")` and `FieldChange(targetField, oldTarget, formatted)` using the captured old values.
- Ensure existing unit tests in `TimeStampToDateFieldTest` pass.

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



Remediation recommended

4. shouldEnableHttpServer is setter📘
Description
RemotePreferences.shouldEnableHttpServer(boolean) is a setter but is named like a boolean
predicate, which breaks established naming conventions and makes call sites misleading. This harms
readability and maintainability in changed code paths.
Code

jablib/src/main/java/org/jabref/logic/remote/RemotePreferences.java[R111-113]

+    public void shouldEnableHttpServer(boolean enableHttpServer) {
this.enableHttpServer.setValue(enableHttpServer);
}
Evidence
PR Compliance ID 1 requires following existing style/conventions; introducing a setter method named
shouldEnableHttpServer violates common Java/JabRef naming patterns (setters should be set...,
predicates should be should... without parameters).

AGENTS.md
jablib/src/main/java/org/jabref/logic/remote/RemotePreferences.java[111-113]
jabgui/src/main/java/org/jabref/gui/preferences/general/GeneralTabViewModel.java[316-322]

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

## Issue description
A setter was renamed to `shouldEnableHttpServer(boolean)` which reads like a predicate and is misleading.
## Issue Context
Call sites now read like a query but actually mutate state.
## Fix Focus Areas
- jablib/src/main/java/org/jabref/logic/remote/RemotePreferences.java[103-125]
- jabgui/src/main/java/org/jabref/gui/preferences/general/GeneralTabViewModel.java[314-323]

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


5. getFirst() replaced by index 📘
Description
formatData.getFirst() was replaced with formatData.get(EXPORTER_NAME_INDEX), moving away from
modern SequencedCollection APIs available in current Java. This reduces clarity and conflicts with
the project’s preference for modern Java idioms.
Code

jablib/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java[R1823-1827]

for (String toImport : getSeries(CUSTOM_EXPORT_FORMAT)) {
   List<String> formatData = convertStringToList(toImport);
   TemplateExporter format = new TemplateExporter(
-                    formatData.getFirst(),
+                    formatData.get(EXPORTER_NAME_INDEX),
           formatData.get(EXPORTER_FILENAME_INDEX),
Evidence
PR Compliance ID 5 asks to prefer modern Java best practices; the changed code replaces a modern
getFirst() usage with older index-based access for the first element.

AGENTS.md
jablib/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java[1823-1827]

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

## Issue description
Modern `SequencedCollection` method `getFirst()` was replaced with index-based access.
## Issue Context
This code already uses other sequenced methods (e.g., `addFirst`), so using `getFirst()` is consistent and clearer.
## Fix Focus Areas
- jablib/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java[1823-1827]

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


6. Duplicate remote port update📘
Description
storeSettings() contains two identical blocks updating the remote server port,
introducing/retaining unnecessary duplication in modified code. This increases maintenance cost and
risk of inconsistent future edits.
Code

jabgui/src/main/java/org/jabref/gui/preferences/general/GeneralTabViewModel.java[R279-289]

getPortAsInt(remotePortProperty.getValue()).ifPresent(newPort -> {
-            if (remotePreferences.isDifferentPort(newPort)) {
-                remotePreferences.setPort(newPort);
+            if (remotePreferences.isDifferentRemoteServerPort(newPort)) {
+                remotePreferences.setRemoteServerPort(newPort);
   }
});
getPortAsInt(remotePortProperty.getValue()).ifPresent(newPort -> {
-            if (remotePreferences.isDifferentPort(newPort)) {
-                remotePreferences.setPort(newPort);
+            if (remotePreferences.isDifferentRemoteServerPort(newPort)) {
+                remotePreferences.setRemoteServerPort(newPort);
   }
});
Evidence
PR Compliance ID 6 requires avoiding duplication; the changed region includes two consecutive
identical getPortAsInt(remotePortProperty.getValue())...setRemoteServerPort(newPort) blocks.

AGENTS.md
jabgui/src/main/java/org/jabref/gui/preferences/general/GeneralTabViewModel.java[279-289]

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

## Issue description
There are two identical remote port update blocks back-to-back.
## Issue Context
This duplication is in the modified area and should be consolidated to a single update.
## Fix Focus Areas
- jabgui/src/main/java/org/jabref/gui/preferences/general/GeneralTabViewModel.java[279-289]

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


View more (1)
7. Default group name not localized🐞
Description
LibraryPreferences.getDefault() hardcodes the “Imported entries” group name, and
JabRefCliPreferences uses that default when loading from an empty backing store and during reset,
bypassing the localized default stored in the defaults map.
Code

jablib/src/main/java/org/jabref/logic/LibraryPreferences.java[R32-39]

+    private LibraryPreferences() {
+        this(
+                BibDatabaseMode.BIBTEX,
+                false,               // alwaysReformatOnSave
+                false,               // autoSave
+                false,                // addImportedEntries
+                "Imported entries"); // addImportedEntriesGroupName
+    }
Evidence
JabRefCliPreferences sets a localized default for LIBRARY_ADD_IMPORTED_ENTRIES_GROUP_NAME in
defaults, but getLibraryPreferencesFromBackingStore calls `get(key,
defaults.getAddImportedEntriesGroupName()) and passes LibraryPreferences.getDefault()` as
defaults—which returns the hardcoded English string. Since get(String key, String def) bypasses
the defaults map, fresh/cleared preferences will default to the hardcoded value rather than the
localized one.

jablib/src/main/java/org/jabref/logic/LibraryPreferences.java[32-43]
jablib/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java[511-522]
jablib/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java[765-785]
jablib/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java[1205-1228]

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

## Issue description
The default value for the “Imported entries” group name is localized in `JabRefCliPreferences.defaults`, but the library preferences loader bypasses that and falls back to `LibraryPreferences.getDefault()` which hardcodes English.
### Issue Context
`getLibraryPreferencesFromBackingStore(...)` uses `get(key, def)` which does **not** consult `defaults` map, so the localization is skipped for empty backing stores and preference resets.
### Fix Focus Areas
- jablib/src/main/java/org/jabref/logic/LibraryPreferences.java[32-39]
- jablib/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java[511-522]
- jablib/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java[765-785]
- jablib/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java[1221-1228]
### Suggested fixes (pick one)
1) In `getLibraryPreferencesFromBackingStore`, fetch the group name using the defaults-map-aware getter:
- use `get(LIBRARY_ADD_IMPORTED_ENTRIES_GROUP_NAME)` (ensures `defaults` map is applied), or
- use `get(LIBRARY_ADD_IMPORTED_ENTRIES_GROUP_NAME, (String) defaultsMapValue)` where `defaultsMapValue` is `Localization.lang("Imported entries")`.
2) Alternatively, make `LibraryPreferences.getDefault()` accept an injected default group name from the preferences layer (so logic stays locale-agnostic).
### Acceptance criteria
- With an empty preferences backing store (fresh install / after clear), the default group name matches `Localization.lang("Imported entries")`.

ⓘ 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

Comment thread jablib/src/main/java/org/jabref/logic/remote/RemotePreferences.java
Comment thread jablib/src/main/java/org/jabref/logic/cleanup/TimeStampToDateField.java Outdated
Comment thread jablib/src/main/java/org/jabref/logic/cleanup/TimeStampToDateField.java Outdated
@calixtus calixtus enabled auto-merge April 8, 2026 19:10
@calixtus calixtus added this pull request to the merge queue Apr 8, 2026
@github-actions github-actions Bot added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label Apr 8, 2026
Merged via the queue into main with commit 59f1797 Apr 8, 2026
56 checks passed
@calixtus calixtus deleted the pref-reset-library branch April 8, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: preferences dev: code-quality Issues related to code or architecture decisions status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers 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.

2 participants