Skip to content

Fix group color updates not notifying descendants - #17797

Merged
Siedlerchr merged 10 commits into
JabRef:mainfrom
gourprince222:fix-group-color-descendant-notification
Nov 29, 2026
Merged

Siedlerchr merged 10 commits into
JabRef:mainfrom
gourprince222:fix-group-color-descendant-notification

Conversation

@gourprince222

@gourprince222 gourprince222 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR fixes the issue where changing a group's color does not update the visual marking of all affected entries. Descendant-change notifications are triggered when a group is updated, allowing the parent tree and related bindings to refresh. A regression test verifies that updating a child group notifies the root.

Analogies

Like honey, the notification flows smoothly through the group hierarchy; like chocolate, the fix brings consistency; and like the moon, it helps illuminate the affected entries.

jabref-contrib-policy:4.2​

Steps to test

  1. Open JabRef with a library containing entries assigned to groups.
  2. Open the group tree and assign a color to a group.
  3. Update or replace the group configuration.
  4. Verify that all affected entries display the correct group color.
  5. Verify that entries belonging to unrelated groups remain unaffected.

Related issues and pull requests

Closes #7325

AI usage

ChatGPT (model GPT-6) was used for debugging assistance, implementation guidance, regression-test suggestions, and PR description drafting. The contributor reviewed, understood, and takes ownership of the submitted code.

AIL: To be determined by the contributor based on the AI Influence Level framework.

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](https://docs.jabref.org/) for up to dateness and submitted a pull request to our [user documentation repository](https://github.com/JabRef/user-documentation/tree/main/en).

@github-actions

Copy link
Copy Markdown
Contributor

Hey @gourprince222! 👋

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.

@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 11, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Notify group ancestors when a group's color changes

🐞 Bug fix 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Notify group-tree ancestors when a group is replaced, refreshing bindings used for entry color
 marking.
• Add a regression test confirming that replacing a child group notifies its root.
Diagram

graph TD
  Edit["Group edit"] --> Node["GroupTreeNode"] --> Signal["Descendant notification"] --> Ancestors["Ancestor listeners"] --> Metadata["MetaData listeners"] --> Binding["Groups binding"] --> Marking["Entry marking"]
  Metadata --> Event["Group update event"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Observe the group property centrally
  • ➕ Would also notify ancestors for changes made directly through getGroupProperty().
  • ➖ Adds listener lifecycle considerations and could notify during initial node construction.

Recommendation: Using the existing TreeNode notification mechanism in both setGroup overloads is the smaller, consistent fix. Consider property-level observation only if direct property writes must also trigger tree notifications.

Files changed (2) +24 / -2

Bug fix (1) +4 / -2
GroupTreeNode.javaPropagate group replacements to tree listeners +4/-2

Propagate group replacements to tree listeners

• Both setGroup overloads now notify the node and its ancestors after replacing the group property. This allows root subscribers to invalidate group bindings and publish update events.

jablib/src/main/java/org/jabref/model/groups/GroupTreeNode.java

Tests (1) +20 / -0
GroupTreeNodeTest.javaTest parent notification after child group replacement +20/-0

Test parent notification after child group replacement

• Adds a regression test that subscribes at the root, replaces a child group using the assignment-aware overload, and asserts that the root receives one descendant-change notification.

jablib/src/test/java/org/jabref/model/groups/GroupTreeNodeTest.java

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

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

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (2)

Grey Divider


Action required

1. Entries keep their old group colors 🐞 Bug
Description
The new notifyAboutDescendantChange invalidates the groups binding, but
createMatchedGroupsBinding produces lists whose elements still compare equal after a color-only
change because AbstractGroup.equals ignores color. When an existing group's color is edited, the
main-table cells do not receive a changed value that rebuilds their color bars, and the group-tree
listener also skips rebuilding an equal tree.
Code

jablib/src/main/java/org/jabref/model/groups/GroupTreeNode.java[95]

+        notifyAboutDescendantChange(this);
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 color-only group replacement emits the new notification, but equal-valued group lists do not cause the main-table color graphics to rebuild, and the group-tree listener skips an equal root.
## Fix Focus Areas
- jablib/src/main/java/org/jabref/model/groups/GroupTreeNode.java[92-96]
- jabgui/src/main/java/org/jabref/gui/maintable/BibEntryTableViewModel.java[105-113]
- jabgui/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java[130-148]
## Recommended Fix
Make color and icon changes observable to the table cells and group-tree display independently of group membership equality. Add a regression test that changes only a group's color and checks the resulting displayed color.

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



Remediation recommended

2. Group changes trigger redundant listener work 🐞 Bug
Description
setGroup now emits a tree-change event for every replacement, while a normal group edit emits
another event when it writes the same root through MetaData.setGroups. migrateGroupSeparators
also calls the setter for every affected node, causing a cached-chat scan and a queued group-tree
callback per node rather than once for the migration.
Code

jablib/src/main/java/org/jabref/model/groups/GroupTreeNode.java[63]

+    notifyAboutDescendantChange(this);
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 new per-setter notification duplicates the event already emitted by normal group-edit write-back and emits one event per node in separator migration.
## Fix Focus Areas
- jablib/src/main/java/org/jabref/model/groups/GroupTreeNode.java[61-78]
- jablib/src/main/java/org/jabref/logic/formatter/bibtexfields/KeywordSeparatorMigration.java[41-48]
- jablib/src/main/java/org/jabref/model/metadata/MetaData.java[140-148]
## Recommended Fix
Coordinate notification with write-back and batch migrations so each logical operation notifies listeners once, while direct group replacements still notify when no write-back follows.

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


Grey Divider

Resolved findings
1. Changing separators can discard nested chats ✓ Resolved High
Description
setGroup now notifies metadata listeners during migrateGroupSeparators, but the chat cache's
existence check uses containsGroup, which searches only the root and its immediate children. When
a library has a cached chat for a deeper group, changing the keyword separator treats that group as
deleted and removeGroup discards its cached history and pending edits without saving them.

2. Group listeners see stale assignments ✓ Resolved Medium
Description
The assignment-changing setGroup overload calls notifyAboutDescendantChange(this) before
removing old assignments or adding new ones. When either assignment flag is enabled, synchronous
listeners receive the updated group while entries still have their old fields, and this overload
sends no notification after those fields change.

Grey Divider

Tip of the day
💡 Did you know, you can switch off images and animations for a plain-text comment

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@Eng-YasminKotb

Copy link
Copy Markdown
Contributor

Hi, @gourprince222,

I think the PR description could be shorter and closer to the Jabref's PULL_REQUEST template.

The additional sections (Code self-review, Tests, Verification, Documentation, and Pull request) seem unnecessary since the template already provides a general checklist for these aspects.

Also, Screenshot: TODO — ... could be removed if there's no screenshot available yet

Keeping it simple and focused would make the PR easier for maintainers to review

@github-actions github-actions Bot added size: small and removed status: changes-required Pull requests that are not yet complete labels Nov 11, 2026
@gourprince222

Copy link
Copy Markdown
Contributor Author

Hi @Eng-YasminKotb

Noted your point and made some changes in PR description. Please review and provide feedback.

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

Copy link
Copy Markdown
Collaborator

@gourprince222

Copy link
Copy Markdown
Contributor Author

Hi @Eng-YasminKotb @faneeshh

changes are done. Now you can proceed for the review.

@Eng-YasminKotb

Copy link
Copy Markdown
Contributor

@gourprince222
Please keep the 7 checklist items and just mark them using the required format (- [x], - [ ], or - [/]), rather than removing the unchecked items

@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Nov 15, 2026
@gourprince222

Copy link
Copy Markdown
Contributor Author

Hi @Eng-YasminKotb @faneeshh,

Could you please proceed with the review of my PR at your convenience? I would appreciate your feedback.

Thank you!

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

@faneeshh faneeshh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Add a changelog entry as well

List<BibEntry> entriesInDatabase) {
AbstractGroup oldGroup = getGroup();
groupProperty.set(newGroup);
notifyAboutDescendantChange(this);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Move this notification to just before return changes

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.

Requested changes have been done.

AtomicInteger descendantChanges = new AtomicInteger();
root.subscribeToDescendantChanged(_ -> descendantChanges.incrementAndGet());

child.setGroup(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm unsure about this test

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use the 1-arg child.setGroup(newGroup)

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.

Requested changes have been done.

@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Nov 18, 2026
@gourprince222

Copy link
Copy Markdown
Contributor Author

Hi @faneeshh , I've implemented all the requested changes. Could you please proceed with reviewing the PR?

@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Nov 18, 2026
@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 22, 2026
@github-actions github-actions Bot removed 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
@github-actions github-actions Bot added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Nov 22, 2026
faneeshh
faneeshh previously approved these changes Nov 22, 2026
* main: (58 commits)
  Keep organization authors containing "and" intact in RIS export. (JabRef#17876)
  Fix author and editor name export in MODS format (JabRef#17936)
  Fix LaTeX conversion in exported PDF metadata (JabRef#17810)
  Fix preferences menu text (JabRef#17966)
  Skip forced full-text index merges on shutdown (JabRef#17961)
  Fix wrong bibo namespace in RDF export (JabRef#17842)
  New Crowdin updates (JabRef#17956)
  chore(deps): update dependency com.konghq:unirest-modules-gson to v4.12.4 (JabRef#17955)
  Let Renovate update JavaFX in the jabsrv launcher (JabRef#17954)
  chore(deps): update dependency com.konghq:unirest-modules-gson to v4.12.3 (JabRef#17953)
  Import the RIS serial number of books and chapters as ISBN (JabRef#17891)
  Share nested LaTeX conversion with Writer (JabRef#17921)
  Render BST preview italics and bold as text, not math letters (JabRef#17902)
  Chore(deps): Bump com.konghq:unirest-java-bom from 4.11.11 to 4.12.0 in /versions (JabRef#17951)
  Inject NativeDesktop into its callers and remove the deprecated static helpers (JabRef#17947)
  New Crowdin updates (JabRef#17945)
  Chore(deps): Bump org.graalvm.sdk:nativeimage from 25.5.5.0.3 to 25.6.5.1 in /versions (JabRef#17944)
  Chore(deps): Bump com.googlecode.plist:dd-plist from 1.30 to 1.31 in /versions (JabRef#17943)
  Chore(deps): Bump JetBrains/junie-github-action from 1.10.1 to 1.10.2 (JabRef#17942)
  Chore(deps): Bump softprops/action-gh-release from 3.0.3 to 3.0.4 (JabRef#17941)
  ...
@Siedlerchr

Siedlerchr commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Group color performance

Compared base commit 8080099db1 with the fix in da961371fd using JabRef’s group-color column in a headless JavaFX table. The fixture had 100,000 entries and the table rendered 38 cells. Measurements are medians over 25 edits after 10 warm-up edits on an Apple silicon MacBook Pro with Temurin 25.0.5 and JavaFX 27.

Scenario Base With the fix
Regex group color edit through table layout 0.37 ms, color stayed stale 2.52 ms, color updated
Same edit with all 100,000 row bindings already initialized 0.62 ms, color stayed stale 4.16 ms, color updated
Explicit group color edit with 1,000 assignments and all row bindings initialized 287 ms 286 ms
Forced reread of all 100,000 row bindings after an explicit group edit 5.7 ms, 1.8 MiB allocated 99 ms, 130 MiB allocated

The fixed regex group edits reached table layout within 5 ms at the 95th percentile. The explicit-group run spent about 282 ms scanning and rewriting assignments. The full-table reread was a separate stress test. Ordinary repainting leaves offscreen bindings to recompute when read.

Each edit emitted one group-update event with the fix. The benchmark covers the model edit, metadata writeback, and table layout. It excludes the dialog, group sidebar rebuild, and screen rendering. The targeted group-node, metadata, and group editor test suites passed (83 tests).

Follow-up after skipping unchanged assignments

Commit a75b95cb0a skips scanning and rewriting entries when the assignment rule stays the same, including color, icon, and description edits. The explicit-group benchmark was repeated on the same 100,000-entry fixture, with 1,000 group members and all row bindings initialized.

Measurement Color fix alone (da961371fd) With assignment optimization (a75b95cb0a)
Median edit through table layout 288 ms 4.3 ms
95th percentile edit through table layout 305 ms 5.7 ms
Median assignment processing 284 ms under 0.01 ms
Mean JavaFX-thread allocation through table layout 5.40 MiB 0.31 MiB

The color bar still repainted and each edit emitted one group-update event. The new regression test verifies that changing color and icon leaves entry fields untouched and never accesses the entries list. All 84 targeted tests and requirements tracing passed.

Keyword-separator migration

Commit a8b0ba1205 preserves pending messages in nested group chats during keyword-separator migration. The cache checks the group node's ancestry, so membership checks scale with group depth. All 40 targeted chat-cache and separator-migration tests passed, along with requirements tracing.

Migration still emits a group-update event for each affected group. We’re deferring batching because changing the library’s keyword separator is an infrequent operation, and the extra work grows with the number of affected groups and cached chats. The chat data-loss issue is fixed. Batching can be revisited if users report noticeable stalls during migration.

@github-actions github-actions Bot removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Nov 29, 2026
@Siedlerchr
Siedlerchr enabled auto-merge November 29, 2026 18:30
@Siedlerchr
Siedlerchr added this pull request to the merge queue Nov 29, 2026
@github-actions github-actions Bot added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label Nov 29, 2026
Merged via the queue into JabRef:main with commit 12ba8f5 Nov 29, 2026
78 of 80 checks passed
@jabref-machine

Copy link
Copy Markdown
Collaborator

Created backport PR for black-forest:

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin port-17797-to-black-forest
git worktree add --checkout .worktree/port-17797-to-black-forest port-17797-to-black-forest
cd .worktree/port-17797-to-black-forest
git reset --hard HEAD^
git cherry-pick -x 12ba8f54c09dfca3d22c15ecfe064e3621ef86bd

@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Nov 29, 2026
Siedlerchr added a commit that referenced this pull request Nov 30, 2026
…x/ris-spec-followup

* upstream/fix/ris-spec-followup:
  Refresh Citations tab when entry DOI changes (#17717)
  Ask before converting libraries written by older JabRef versions (#16941)
  Chore(deps): Bump gradle-wrapper from 9.9.2 to 9.9.3 (#17985)
  Fix group color updates not notifying descendants (#17797)
  Keep JavaFX and OpenFastTrace versions aligned in Dependabot (#17993)
  Chore(deps): Bump ruby/setup-ruby from 1.344.0 to 1.345.0 (#17984)
  Chore(deps): Bump zauguin/install-texlive from 4.5.0 to 4.5.1 (#17983)
  Chore(deps): Bump com.autonomousapps:dependency-analysis-gradle-plugin from 3.20.4 to 3.21.0 in /build-logic (#17986)
  Chore(deps): Bump com.autonomousapps:dependency-analysis-gradle-plugin from 3.20.4 to 3.21.0 (#17979)
  Chore(deps): Bump anthropics/claude-code-action from 1.0.289 to 1.0.290 (#17981)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

When assigning a group color to a group, not all entries are marked

5 participants