Skip to content

Invalidate groups binding after import#14944

Merged
koppor merged 3 commits into
JabRef:mainfrom
Priyanshug254:fix-groups-sidebar-refresh
Jan 30, 2026
Merged

Invalidate groups binding after import#14944
koppor merged 3 commits into
JabRef:mainfrom
Priyanshug254:fix-groups-sidebar-refresh

Conversation

@Priyanshug254

@Priyanshug254 Priyanshug254 commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

User description

Closes #13684

When importing a .bib file into an existing library, group metadata was merged
correctly but the Groups sidebar was not updated.

This fix explicitly invalidates the groups binding after merging groups,
ensuring the Groups sidebar refreshes immediately after import.

Steps to test

  1. Create A.bib with one entry belonging to group A
  2. Create B.bib with one entry belonging to group B
  3. Open B.bib in JabRef → verify Group B is visible
  4. Use File → Import into current library and select A.bib
  5. Verify that Group A appears alongside Group B

Mandatory checks

  • 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 refresh via binding invalidation)
  • [/] I added screenshots in the PR description (not applicable)
  • I described the change in CHANGELOG.md
  • [/] I checked the user documentation (no documentation change required)

PR Type

Bug fix


Description

  • Invalidate groups binding after merging groups during import

  • Ensures Groups sidebar refreshes immediately after importing entries

  • Fixes issue where group metadata was merged but UI not updated


Diagram Walkthrough

flowchart LR
  A["Import .bib file"] --> B["Merge group metadata"]
  B --> C["Invalidate groups binding"]
  C --> D["Groups sidebar refreshes"]
Loading

File Walkthrough

Relevant files
Bug fix
DatabaseMerger.java
Add groups binding invalidation after merge                           

jablib/src/main/java/org/jabref/logic/database/DatabaseMerger.java

  • Added explicit call to target.groupsBinding().invalidate() after
    merging groups
  • Ensures UI binding is refreshed when groups are merged during import
  • Placed after the group merge logic completes
+1/-0     

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

qodo-free-for-open-source-projects Bot commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@github-actions github-actions Bot added the good second issue Issues that involve a tour of two or three interweaved components in JabRef label Jan 28, 2026
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Avoid creating duplicate import groups

To avoid creating duplicate groups, check if a group for the imported file
already exists. If it does, add the new entries to the existing group;
otherwise, create a new one.

jablib/src/main/java/org/jabref/logic/database/DatabaseMerger.java [110-122]

 try {
     // This will cause a bug if the group already exists
     // There will be group where the two groups are merged
-    ExplicitGroup group = new ExplicitGroup(
-            "Imported " + otherFilename,
-            GroupHierarchyType.INDEPENDENT,
-            keywordDelimiter);
-    newGroups.setGroup(group);
-    group.add(allOtherEntries);
+    String groupName = "Imported " + otherFilename;
+    Optional<ExplicitGroup> existingGroup = target.getGroups()
+                                                  .flatMap(root -> root.getGroupByName(groupName))
+                                                  .map(g -> (ExplicitGroup) g.getGroup());
+
+    if (existingGroup.isPresent()) {
+        newGroups.setGroup(existingGroup.get());
+        existingGroup.get().add(allOtherEntries);
+    } else {
+        ExplicitGroup group = new ExplicitGroup(
+                groupName,
+                GroupHierarchyType.INDEPENDENT,
+                keywordDelimiter);
+        newGroups.setGroup(group);
+        group.add(allOtherEntries);
+    }
 } catch (IllegalArgumentException e) {
     LOGGER.error("Problem appending entries to group", e);
 }

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies and proposes a fix for a pre-existing bug, acknowledged in the code comments, where importing the same file multiple times creates duplicate groups. This is a significant functional improvement.

Medium
  • Update

@koppor koppor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CHANGELOG.md entry - see content of CHANGELOG.md how to add

@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Jan 28, 2026
Comment thread CHANGELOG.md Outdated
- We fixed an issue where JaRef would not correctly remember the opened side panels in the preferences [#14818](https://github.com/JabRef/jabref/issues/14818)
- Updates of the pre-selected fetchers are now followed at the Web fetchers. [#14768](https://github.com/JabRef/jabref/pull/14768)
- Restart search button in citation-relation panel now refreshes using external services. [#14757](https://github.com/JabRef/jabref/issues/14757)
- Fixed groups sidebar not refreshing after importing a library. [#13684]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the CHANGELOG entry and added the proper link to the issue #13684

@Priyanshug254 Priyanshug254 requested a review from koppor January 29, 2026 17:07
@koppor koppor added this pull request to the merge queue Jan 30, 2026
@github-actions github-actions Bot added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label Jan 30, 2026
Merged via the queue into JabRef:main with commit 1063aeb Jan 30, 2026
59 of 60 checks passed
@Priyanshug254 Priyanshug254 deleted the fix-groups-sidebar-refresh branch January 30, 2026 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

good second issue Issues that involve a tour of two or three interweaved components in JabRef Review effort 2/5 status: changes-required Pull requests that are not yet complete 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.

Groups not visible in the vertical left bar even if correctly visibile in the groups field in each record

2 participants