Skip to content

Fix subgroups disappearing when added from the All entries context menu - #17803

Merged
Siedlerchr merged 2 commits into
JabRef:mainfrom
doraem-on:fix/group-context-menu-subgroup
Nov 23, 2026
Merged

Siedlerchr merged 2 commits into
JabRef:mainfrom
doraem-on:fix/group-context-menu-subgroup

Conversation

@doraem-on

@doraem-on doraem-on commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

In a new library, right-clicking All entries and choosing Add subgroup could show a success message even though the subgroup was missing from the tree and the saved library. The action now adds the subgroup to the current All entries node after the dialog closes.

Steps to test

  1. Create a new library, add the example entry, and select it.

  2. Right-click All entries and choose Add subgroup. Enter a and leave Include selected entries in created group checked.

    Add subgroup dialog with the name a and the selected entry included

  3. Click OK. The subgroup should appear under All entries with one entry.

    The subgroup a appears with one entry

  4. Save the library, close the tab, and reopen the file. The subgroup should still contain one entry.

    The reopened library shows the subgroup a with one entry

Verified on macOS. The group tree regression test and GUI Checkstyle checks passed. The test passes the old root to the action after rebuilding the tree and checks the children of the current root.

Related issues and pull requests

Closes #17764.

AI usage

OpenAI GPT-6 assisted with the implementation, regression test under my direction. I ran local verification. I manually reviewed and verified the code

Checklist

  • I own the copyright of the code submitted and I license it under the MIT license
  • If AI tools were used, I disclosed them in the "AI usage" section and reviewed, understood, and take full ownership of all AI-generated code
  • 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 one sentence (max 20 words) to CHANGELOG.md describing the change from the user's point of view (if the 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

@jabref-machine jabref-machine added the dev: send-to-black-forest Port to the black-forest branch of JabRef/jabref-black-forest after merging (ADR-0073) label Nov 12, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Preserve subgroups added from the All entries context menu

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 10-20 Minutes

Grey Divider

AI Description

• Add new subgroups to the current All entries root when a context menu holds an outdated node.
• Stop subgroup creation if the active library changes while the dialog is open.
• Add a regression test and document the user-visible fix.
Diagram

sequenceDiagram
    actor User
    participant Menu as Context menu
    participant Tree as Group tree VM
    participant Dialog as Group dialog
    participant Root as Current root
    participant Meta as Group metadata
    User->>Menu: Add subgroup
    Menu->>Tree: addNewSubgroup(old root)
    Tree->>Dialog: Show group form
    Dialog-->>Tree: Return new group
    Tree->>Root: Resolve root and add
    Tree->>Meta: Record and persist tree
Loading
High-Level Assessment

Resolving the All entries root after the dialog is appropriate because opening the dialog can leave the context menu holding an outdated view model. Rebuilding the entire tree or changing context-menu ownership would broaden this focused fix without a clear benefit.

Files changed (3) +29 / -3

Bug fix (1) +9 / -3
GroupTreeViewModel.javaAttach new subgroups to the current All entries root +9/-3

Attach new subgroups to the current All entries root

• After the group dialog closes, aborts if the active library has changed. For an All entries parent, it uses the current root for subgroup creation and lookup so the change reaches the displayed tree and library metadata.

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

Tests (1) +19 / -0
GroupTreeViewModelTest.javaCover subgroup creation with an outdated root +19/-0

Cover subgroup creation with an outdated root

• Adds a JavaFX regression test that rebuilds the tree, invokes subgroup creation with the previous root, and checks that the current metadata tree contains the child.

jabgui/src/test/java/org/jabref/gui/groups/GroupTreeViewModelTest.java

Documentation (1) +1 / -0
CHANGELOG.mdDocument the All entries subgroup fix +1/-0

Document the All entries subgroup fix

• Adds a user-facing note that subgroups created from the All entries context menu no longer disappear in new libraries.

CHANGELOG.md

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

qodo-free-for-open-source-projects Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (1)

Grey Divider


Remediation recommended

1. Subgroups added under a stale parent vanish from the tree 🐞 Bug
Description
addNewSubgroup only re-resolves the parent when it is the All entries node
(parent.isAllEntriesGroup() ? rootGroup.get() : parent), so any other context-menu parent is still
the view model captured before the tree was rebuilt, and addSubgroup mutates a detached node. If
the group root is replaced while the Add subgroup dialog is open (for example by a shared-metadata
update that triggers refresh() from listen(GroupUpdatedEvent)), the new subgroup is written into
an orphaned node and the success notification still fires, which is the same silent loss this PR
fixes for All entries.
Code

jabgui/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java[265]

+            GroupNodeViewModel currentParent = parent.isAllEntriesGroup() ? rootGroup.get() : parent;

Grey Divider

Tip of the day
💡 Did you know, you can keep summaries lean with Findings visible per group, which tucks the rest behind a View link

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Nov 12, 2026
@ThiloteE

Copy link
Copy Markdown
Member

Have you found a way how to reproduce the original issue? All the steps explained in #17803 (comment) and in #17764 (comment) work for me on main, but I know that the bug is real. Siedlerchr showed it to me in a videoconference real quick. Sometimes it was working, sometimes not and he failed to identify the exact steps.

@doraem-on

doraem-on commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

I did make it disappear...
In a new library, I right-clicked All entries, chose Add subgroup and typed Probe. I left the dialog open and used a direct import to create the librarys first group, Imported. Once Imported appeared ,clicked OK

On main JabRef said it had added Probe but the sidebar only showed Imported. The import had rebuilt the group tree and the dialog added Probe to the old tree. With this PR both groups appeared

@ThiloteE but I also found a separate case that still happens with this PR. When I opened two empty libraries and added a subgroup in the second, JabRef put it in the first. I only noticed after switching tabs. @Siedlerchr, do you remember if another empty library was open during the screen share? In my test the subgroup appeared when I clicked OK but after switching tabs I found it in the other library
03-with-fix
02-without-fix

@ThiloteE

Copy link
Copy Markdown
Member

What is a "direct import"? For me, opening the "add group" window locks the rest of the UI.

@Siedlerchr

Siedlerchr commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Hm, I don't know how or why it was that weird. It seems to no longer occur. but I now can reproduce the issue that he group is landing in the wrong library as you wrote

@doraem-on

doraem-on commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

@Siedlerchr yuss , the second case can happen through ordinary JabRef GUI use....
@ThiloteE correct , I meant you can send BibTeX entry to JabRef’s local API like from Postman or terminal while the dialog was still open
for the first case
If someone sends the import request from a terminal, or a coding agent could do it , then its a bug and can be reproduced , what matters is the timing . the request creates the first group in the same library while the Probe dialog is still open, before the user clicks OK

jabref-postman-request-233725 02-dialog 03-base 04-pr

@doraem-on

doraem-on commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

@ThiloteE te as above I type Probe in Add subgroup, left the dialog open and used Postman to import an entry into the same library. That created its first group... Imported.

At that point we expect to see only Imported, since I hadnt clicked OK yet. The issue shows up when I clicked OK. JabRef said it added Probe but the sidebar still showed only Imported. With this PR both groups appears , can review from your end , thanks

@github-actions

Copy link
Copy Markdown
Contributor

The requested changes were not addressed for 3 days. Please follow-up in the next 7 days or your PR will be automatically closed. You can check the contributing guidelines for hints on the pull request process.

@github-actions github-actions Bot added the status: stale Issues marked by a bot as "stale". All issues need to be investigated manually. label Nov 16, 2026
@github-actions github-actions Bot added component: ui status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers and removed component: ui status: changes-required Pull requests that are not yet complete status: stale Issues marked by a bot as "stale". All issues need to be investigated manually. labels Nov 22, 2026

@Siedlerchr Siedlerchr 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.

I think this is better than nothing so good to go

@Siedlerchr
Siedlerchr added this pull request to the merge queue Nov 23, 2026
@github-actions github-actions Bot added status: to-be-merged PRs which are accepted and should go into the merge-queue. and removed status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Nov 23, 2026
Merged via the queue into JabRef:main with commit 9d5bd28 Nov 23, 2026
75 checks passed
@jabref-machine

Copy link
Copy Markdown
Collaborator

@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Nov 23, 2026
Siedlerchr added a commit that referenced this pull request Nov 23, 2026
* main:
  Re-architect OpenOffice backend (#17673)
  Fix subgroups disappearing when added from the All entries context menu (#17803)
  Fix page ranges in HTML table journal and proceedings cells (#17893)
  Update dependency org.postgresql:postgresql to v42.7.15 (#17915)
  Update dependency org.hibernate.validator:hibernate-validator to v9.2.0.Final (#17914)
  Chore(deps): Bump com.dlsc.gemsfx:gemsfx from 4.16.0 to 4.17.0 in /versions (#17913)
  Chore(deps): Bump io.zonky.test.postgres:embedded-postgres-binaries-bom from 18.7.0 to 19.0.0 in /versions (#17910)
  Chore(deps): Bump io.zonky.test:embedded-postgres from 2.2.2 to 2.2.3 in /versions (#17909)
  Chore(deps): Bump org.hibernate.validator:hibernate-validator from 9.1.6.Final to 9.2.0.Final in /versions (#17912)
  Chore(deps): Bump com.konghq:unirest-java-bom from 4.11.10 to 4.11.11 in /versions (#17911)
  Chore(deps): Bump io.github.kusoroadeolu:veneer from 1.3.2 to 1.3.3 in /versions (#17908)
  Chore(deps): Bump gradle-wrapper from 9.9.1 to 9.9.2 (#17907)
  Update dependency textlint to v16.1.3 (#17905)
  Fix rule-based citation parser for Springer-style author-year references (#17901)
  New Crowdin updates (#17904)
  Fix RIS import overwriting journal issue number with accession number (#17838)
  Add 'Get more Jstyles' hyperlink to StyleSelectDialog (#17886)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: groups component: ui dev: send-to-black-forest Port to the black-forest branch of JabRef/jabref-black-forest after merging (ADR-0073) size: small 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.

Add subgroup broken via right click in new library

4 participants