Skip to content

Fix stale inherited entry table values - #18016

Open
ollehaakansson wants to merge 6 commits into
JabRef:mainfrom
ollehaakansson:fix/7730-crossref-table-updates
Open

ollehaakansson wants to merge 6 commits into
JabRef:mainfrom
ollehaakansson:fix/7730-crossref-table-updates

Conversation

@ollehaakansson

@ollehaakansson ollehaakansson commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fix stale inherited values in the main table when entries referenced through crossref or xdata change. Dependent rows now refresh without reopening the library, while explicitly defined child fields retain their own values.

Steps to test

  1. Save the following example as crossref-update.bib and open it in JabRef:

    @Book{aParent,
      author    = {Alpha, Alice},
      title     = {Parent A - original},
      publisher = {Test Press},
      year      = {2020},
    }
    
    @InBook{aChildOne,
      title    = {Direct child one},
      pages    = {1--10},
      crossref = {aParent},
    }
    
    @InBook{aChildTwo,
      title    = {Direct child two},
      pages    = {11--20},
      crossref = {aParent},
    }
    
    @InBook{aOwnValue,
      author   = {Own, Olivia},
      title    = {Child with own values},
      year     = {1999},
      crossref = {aParent},
    }
  2. Check the Author/Editor, Year and Journal/Booktitle columns. Both direct children should display Alpha, Alice, 2020 and Parent A - original. The entry aOwnValue should retain its own author and year.

    Before editing the parent:

01-crossref-before

Open the child's BibLaTeX source tab and confirm that the inherited fields are not stored in the child.

Child source before editing:

01-crossref-child-before
  1. Select aParent, open its BibLaTeX source tab, and change only these fields:

    author = {Delta, Diana},
    title  = {Parent A - revised},
    year   = {2025},

    Click Main to apply the edit. Observe the child rows directly, without reopening the library, changing the table sort order, or selecting the children first.

  2. Both direct children should immediately display Delta, Diana, 2025 and Parent A - revised. Their own titles and pages should remain unchanged. The entry aOwnValue should retain Own, Olivia and 1999, while its inherited book title updates.

    After editing the parent:

02-crossref-after

Inspect the child's source again. It should still contain its own fields and crossref, without copying the inherited values into the entry.

Child source after editing:

02-crossref-child-after

Automated coverage: all 44 cases in MainTableCrossrefTest pass, including reference changes, missing or removed parents, child overrides, inherited name values, xdata chains and cycles, batched updates, and cleanup.

Full check reports 13 failures on this branch; all 13 also occur on unmodified main (730511d217), with no additional failing tests introduced by this change.

Performance validation

Added an opt-in profile, run with:

.\gradlew.bat :jabgui:test -PcrossrefProfile --console=plain

Both datasets contain 100,000 entries. Each workload uses three warmup iterations and 20 measured iterations. Times below are milliseconds per batch.

Parents Children Affected children Edits per batch Median p95 Maximum
10,000 90,000 9 1 13.394 15.025 15.885
10,000 90,000 9 100 64.625 67.137 69.920
1 99,999 99,999 1 275.222 303.093 307.557
1 99,999 99,999 100 319.256 337.568 349.024

Environment: Windows 11, Intel Core i7-12700H (14 cores / 20 logical processors), 15.7 GiB RAM, Corretto 25.0.4.1, and a 4 GiB test heap.

Both test cases passed assertions for final inherited values and exactly one change notification per affected child per batch. Every child retains an eagerly observed year binding, including off-screen rows.

Fixture and binding setup is measured separately: 82.61 seconds for the distributed dataset and 1.45 seconds for the shared-parent dataset. Setup is excluded from update timings. These are headless table-model measurements; GUI rendering is not included.

The profile exposed expensive repeated index lookups. Dependent rows are now selected in a single pass per batch.

Related issues and pull requests

Closes #7730

AI usage

OpenAI Codex (model: GPT-6.1 Sol) AIL3. Codex assisted with the problem investigation, solution suggestion and checklist preparation. I reviewed and understood the change and tested it manually. I take full responsibility for the contribution.

AI CHECKLIST.md walkthrough

1. Code self-review

Nullability and control flow

  • No == null / != null checks - JSpecify annotations (@NullMarked, @Nullable, @NonNull) used instead.
  • No Objects.requireNonNull(...) - nullability expressed via JSpecify annotations.
  • New classes annotated with @NullMarked (org.jspecify.annotations.NullMarked).
  • [/] New packages annotated with @NullMarked (org.jspecify.annotations.NullMarked). No new packages.
  • Optional consumed with ifPresent / ifPresentOrElse / map / orElseThrow - never orElse(unusedValue) nor an isPresent() + get() block.
  • [/] StringUtil.isBlank(...) used instead of s == null || s.isBlank(). No new blank-string checks.

Exceptions

  • No catch (Exception e) - only specific exceptions are caught.
  • No throw new RuntimeException(...) / IllegalStateException(...) - these tear down the whole application.
  • [/] Logged exceptions are passed as the last logger argument (LOGGER.info("...", e)), not concatenated into the message string. No new exception logging.

Style and idioms

  • New BibEntry objects built with withers (withField, not setField).
  • Modern Java used: List.of() / Map.of() / Set.of(), Path.of(), SequencedCollection / SequencedSet, text blocks.
  • [/] Regexes use a precompiled Pattern.compile(...) constant, not String.matches(...). No new regex matching.
  • [/] Keep alphabetical ordering when adding variables or enum items. No existing alphabetically ordered variable or enum list extended.
  • [/] Background work uses org.jabref.logic.util.BackgroundTask, not new Thread(). No new production background task; UI invalidation is scheduled on the JavaFX thread.
  • No commented-out code, no trivial comments restating the code, no AI-disclosure comments in source.
  • Markdown Javadoc (///) uses Markdown syntax, not JavaDoc inline tags: code instead of {@code}, [ClassName] instead of {@link}.

User-facing text

  • [/] All user-facing text localized (Localization.lang in Java, % prefix in FXML). No new UI strings.
  • [/] Sentence case (not Title Case); no trailing !; labels do not end with :. No new UI labels.
  • [/] Variance expressed with placeholders ("...: %0"), not string concatenation. No new variable UI messages.

Security

  • [/] User-controlled data (request params, entry fields, file contents) is HTML-escaped before being written into any text/html response - including exception/error messages, not just the success body (XSS). No HTML response changes.

Tests

  • In case issue lists an example, this concrete example is covered by a test case.
  • [/] Behavior changes in org.jabref.model / org.jabref.logic have added or updated tests. Production changes are confined to the GUI main-table model and covered by GUI regression tests.
  • Tests assert object contents (assertEquals), use plain JUnit asserts (not AssertJ), have no @DisplayName, do not catch exceptions (let them propagate so JUnit reports setup/teardown failures directly), and use @TempDir instead of manual temp directories.
  • [/] Fetcher tests hit the live endpoints - the remote API is not mocked or stubbed (automated-review suggestions to mock it are rejected on purpose). No fetcher changes.

2. Verification commands

  • ./gradlew :jablib:check (or ./gradlew check for all modules).
  • ./gradlew checkstyleMain checkstyleTest checkstyleJmh.
  • ./gradlew modernizer.
  • ./gradlew --no-configuration-cache :rewriteDryRun reports no changes (run ./gradlew rewriteRun to fix).
  • ./gradlew javadoc.
  • npx markdownlint-cli2 "docs/**/*.md" "*.md" (only if Markdown changed).
  • npm ci && npm run textlint reports no misspellings (only if Markdown changed).
  • [/] Only if formatting is still off after rewriteRun: docker run -v $(pwd):/github/workspace ghcr.io/leventebajczi/intellij-format:master "*.java" "" ".idea/codeStyles/Project.xml".

Rewrite verification remains incomplete because of missing recipe classes in the earlier run. Javadoc could not be verified in the agent environment because of destination-directory permissions.

3. Documentation

  • CHANGELOG.md entry added if the change is visible to the user (end-user wording, no extra blank lines, sorted in next to existing entries about the same component/feature). Link the issue if one exists; link the PR only when no issue exists. Use TODO as the placeholder when neither is known yet - never a fake number. No entry for fixes to changes that were themselves introduced after the last release (feature only in ## [Unreleased]) - update the existing unreleased entry instead if needed.
  • Searched jabref/issues and jabref-koppor/issues for a related issue; linked only on a confident match, otherwise kept TODO (no closes/fixes for merely-similar issues).
  • Requirement added to docs/requirements/<area>.md if the change is a new feature or significant bug fix (skip for refactors, minor fixes, and internal changes).
  • Developer documentation under docs/ updated if behavior or architecture changed.

4. Pull request

  • PR body built from .github/PULL_REQUEST_TEMPLATE.md, every section filled.
  • All checklist items kept and marked [x], [ ], or [/].
  • "Steps to test" is a numbered list with a cropped screenshot of the result for every visible change; no video (only allowed when another program is involved, e.g. drag and drop or push to an external application).
  • All HTML comments removed from the PR body.
  • [/] PR created with gh pr create --body-file <file> (not --body). Submission through the GitHub web interface.
  • [/] If CHANGELOG.md used a TODO placeholder (no issue confidently identified yet - an existing issue link always stays), the PR was opened as draft, the placeholder was replaced with the real PR-number link after PR creation, committed and pushed, and only then was the PR marked ready for review. If an issue is identified or created later, the link is switched to the issue. The changelog links directly to Entry with crossref does not update immediately #7730.

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. This fix restores automatic updates without changing the documented workflow; no user-documentation PR is needed.

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

qodo-free-for-open-source-projects Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (5) 📘 Rule violations (1)

Grey Divider


Action required

1. Background parent inserts can leave stale cells 🐞 Bug
Description
updateReferencingEntries assumes a second JavaFX callback runs after the database has indexed an
inserted entry, but the list-change callback can release the inserting thread before indexing
starts. When a parent is inserted off the JavaFX thread, invalidation can query the reverse citation
index too early and miss children that already have cached inherited values.
Code

jabgui/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java[R146-148]

+        // The entry list changes before citation indices and mapped table rows have finished updating.
+        Platform.runLater(() -> {
+            Set<String> citationKeys = Set.copyOf(pendingReferencedEntryUpdates);
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 background parent insertion can trigger the deferred inherited-value refresh before the database has populated its reverse citation index, leaving cached child cells stale.
## Fix Focus Areas
- jabgui/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java[127-153]
- jablib/src/main/java/org/jabref/model/database/BibDatabase.java[195-206]
## Recommended Fix
Arrange for the refresh to be triggered or retried after database insertion and citation indexing have completed, rather than assuming one JavaFX queue turn establishes that ordering. Add a regression test that inserts a previously missing parent from a background thread while its child's inherited cell binding is already observed.

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



Remediation recommended

2. Children stay misplaced after parent edits 🐞 Bug ⭐ New
Description
invalidateReferencingEntries refreshes affected rows’ field bindings without notifying the sorted
list that their sort values changed. When the table is sorted by an inherited field and a parent
edit moves a child’s value past another row, the child displays the new value at its old position
until a separate list or sort change occurs.
Code

jabgui/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java[R185-187]

+                        .forEach(row -> bibDatabaseContext.getDatabase().getEntryById(row.getEntry().getId())
+                                                          .filter(entry -> entry == row.getEntry())
+                                                          .ifPresent(_ -> row.invalidateResolvedFieldValues()));
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Refreshing inherited cell bindings does not update the active sorted order, leaving changed child rows in their old positions.

## Fix Focus Areas
- jabgui/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java[181-187]
- jabgui/src/main/java/org/jabref/gui/maintable/BibEntryTableViewModel.java[239-251]

## Recommended Fix
After invalidating affected rows, make the sorted-list source report their changed sort values or otherwise trigger a resort for the batch. Add a regression test with an active inherited-field sort and an unaffected row between the child’s old and new values.

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


View medium (4)
3. Children keep stale values after key edits 🐞 Bug
Description
updateReferencingEntries queues only the updated entry's current citation key, while citation-key
propagation leaves whitespace-padded xdata references unchanged. When a referenced entry is
renamed or loses its key, those children still point to the old key but never receive an
invalidation, so their cached inherited values remain visible.
Code

jabgui/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java[R137-138]

+                change.getList().subList(change.getFrom(), change.getTo())
+                      .forEach(entry -> entry.getCitationKey().ifPresent(pendingReferencedEntryUpdates::add));
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Renaming or clearing a referenced entry's citation key can leave cached inherited values in children whose `xdata` reference contains surrounding whitespace. The reference remains indexed under the old key, but the new listener queues only the updated entry's current key.
## Fix Focus Areas
- jabgui/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java[133-153]
- jablib/src/main/java/org/jabref/model/database/CitationKeyListener.java[54-63]
## Recommended Fix
Ensure key changes invalidate dependents of both the old and new keys, including when the new key is absent. Add a regression test using a whitespace-padded `xdata` reference that checks the existing cell binding after a rename or key removal.

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


4. Unrelated links slow parent edits 🐞 Bug
Description
invalidateReferencingEntries traverses every entry returned by the citation index even though that
index also includes links that cannot supply inherited values, such as related. When many entries
link to an edited key only through such fields, the JavaFX callback parses and checks every one
despite having no dependent rows to refresh.
Code

jabgui/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java[R165-168]

+            for (BibEntry entry : bibDatabaseContext.getDatabase().getEntriesForCitationKey(citationKey)) {
+                boolean inheritsXdata = entry.getField(StandardField.XDATA).stream()
+                                             .flatMap(value -> Arrays.stream(value.split(BibEntry.ENTRY_LINK_SEPARATOR)))
+                                             .map(String::trim).anyMatch(citationKey::equals);
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 reverse citation index includes entry-link fields unrelated to inheritance. Editing a key with many `related` links makes the new JavaFX traversal inspect those entries even when no inherited values depend on the edit.
## Fix Focus Areas
- jabgui/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java[156-176]
- jablib/src/main/java/org/jabref/model/database/BibDatabase.java[322-351]
## Recommended Fix
Select reverse dependencies from `crossref` and `xdata` links rather than the general entry-link index, while retaining xdata-chain traversal and cycle protection. Add a performance case with many unrelated links to one edited key.

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


5. Small parent edits scan the whole table 🐞 Bug
Description
invalidateReferencingEntries scans every unfiltered table row after the citation index has
identified the affected entry IDs. Editing a parent with only a few children therefore adds a
full-library pass on the JavaFX thread, including rows hidden by table filters.
Code

jabgui/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java[R182-184]

+        entriesViewModel.stream()
+                        .filter(row -> affectedEntries.contains(row.getEntry().getId()))
+                        .toList()
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Each dependent-row refresh scans every table row even when the reverse citation index identifies only a few affected entries.
## Fix Focus Areas
- jabgui/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java[110-129]
- jabgui/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java[156-187]
## Recommended Fix
Maintain a row lookup keyed by entry ID alongside changes to the mapped entry list, then select rows using the affected ID set. Preserve the existing checks that a row still represents the database's current entry before invalidating its bindings.

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


6. Tests build real preferences, not mocks 📘 Rule violation
Description
start constructs a real SearchPreferences and returns real GroupsPreferences and
NameDisplayPreferences defaults through the GuiPreferences mock, instead of mocking them. Any
change to those classes' constructors or default values can break this test even when the table
logic is unchanged.
Code

jabgui/src/test/java/org/jabref/gui/maintable/MainTableCrossrefTest.java[R68-70]

+        when(preferences.getSearchPreferences()).thenReturn(
+                new SearchPreferences(SearchDisplayMode.FILTER, false, false, false, false, false, false, 0, 0, 0));
+        when(preferences.getNameDisplayPreferences()).thenReturn(NameDisplayPreferences.getDefault());
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
In `MainTableCrossrefTest.start`, the test constructs real preference objects: `new SearchPreferences(...)`, `GroupsPreferences.getDefault()` and `NameDisplayPreferences.getDefault()`. The compliance rule requires tests to mock `*Preferences` classes instead of constructing real instances.
## Fix Focus Areas
- jabgui/src/test/java/org/jabref/gui/maintable/MainTableCrossrefTest.java[66-76]
## Recommended Fix
Replace the real instances with mocks. Create `SearchPreferences`, `GroupsPreferences` and `NameDisplayPreferences` with `mock(...)`, and stub only the getters that `MainTableDataModel` reads on the tested path. Return those mocks from the `GuiPreferences` mock, and keep the rest of the setup unchanged.

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


Grey Divider

Tip of the day
💡 Did you know, you can move or hide resolved findings to focus on what still needs action

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

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

qodo-free-for-open-source-projects Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Refresh main table inherited values when crossref or xdata entries change

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Main table rows now refresh inherited values when a crossref or xdata parent changes.
• A deferred, coalesced invalidation re-resolves only the affected child rows, without reopening the
 library.
• Child rows keep their own explicit fields, and the stored BibTeX of children is unchanged.
• Adds 44 MainTableCrossrefTest cases covering reference changes, xdata chains, cycles, and
 unbinding.
Merge Risk 🟡 Medium

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • This is one bounded end-to-end table capability: database entry changes are observed by MainTableDataModel, resolved values are invalidated on BibEntryTableViewModel rows, and the table displays or sorts the resulting inherited values.
  • The changed code does not write database state or feed independent exporters or editors.
Sources

jabgui/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java[146-153]

        // The entry list changes before citation indices and mapped table rows have finished updating.
        Platform.runLater(() -> {
            Set<String> citationKeys = Set.copyOf(pendingReferencedEntryUpdates);
            pendingReferencedEntryUpdates.clear();
            if (bound) {
                invalidateReferencingEntries(citationKeys);
            }
        });
Behavioral complexity 🔴 High 🧩 Interacting branches, Concurrent ordering

  • Before, row bindings reacted primarily to direct entry observables.
  • After, the model tracks added, updated, and removed entries, defers invalidation until JavaFX list/index updates complete, coalesces repeated changes, traverses crossref and xdata dependencies, detects cycles, and suppresses work after unbind.
  • The new correctness conditions are that deferred processing observes the final citation-index and row state, follows only actual crossref/xdata relationships, terminates for cycles, and does not notify removed or unbound rows.
  • The JavaFX queue and existing binding infrastructure are reused, but their ordering now interacts with dependency traversal and lifecycle state.
Sources

jabgui/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java[146-153]

        // The entry list changes before citation indices and mapped table rows have finished updating.
        Platform.runLater(() -> {
            Set<String> citationKeys = Set.copyOf(pendingReferencedEntryUpdates);
            pendingReferencedEntryUpdates.clear();
            if (bound) {
                invalidateReferencingEntries(citationKeys);
            }
        });
Potential damage 🟡 Medium 🩹 Incorrect results

  • Conditionally, if the changed refresh logic regresses, the main table can show stale or incorrect inherited values or name sort values.
  • The effect is limited to presentation and cached table bindings; the production code does not persist the resolved value or modify the referenced entries.
  • The deferred JavaFX update and dependency traversal are the principal correctness boundaries.
  • Recreating or refreshing the table model can recompute the values, and reverting the code restores the prior table behavior.
  • No persistent database repair or external compensation is supported as necessary.
Sources

jabgui/src/main/java/org/jabref/gui/maintable/MainTableDataModel.java[146-153]

        // The entry list changes before citation indices and mapped table rows have finished updating.
        Platform.runLater(() -> {
            Set<String> citationKeys = Set.copyOf(pendingReferencedEntryUpdates);
            pendingReferencedEntryUpdates.clear();
            if (bound) {
                invalidateReferencingEntries(citationKeys);
            }
        });
Assessed commit 067769d
Diagram

graph TD
  A["Parent BibEntry edit"] --> B["MainTableDataModel listener"] --> C["Pending key batch"] --> D["Resolve crossref and xdata"] --> E["Row version bump"] --> F["Cell bindings refresh"]
  G[(BibDatabase)] --> D
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Subscribe each row to its resolved parent's observables
  • ➕ Uses JavaFX dependency tracking directly, with no manual invalidation
  • ➕ No database scan on each change
  • ➖ Every crossref or xdata edit must rebind the row's dependencies
  • ➖ Xdata chains and cycles need the same resolution logic in the binding setup
2. Rebuild the affected table rows on any entry change
  • ➕ Simplest to reason about and very hard to get stale
  • ➖ Costly on large libraries and causes visible flicker and loss of selection
  • ➖ Does not solve the sort-order staleness case by itself

Recommendation: The PR's approach is reasonable, since it adds a targeted invalidation path without changing how cells resolve values. Its main weakness is that dependency tracking is re-derived from citation keys on every change, which duplicates crossref and xdata semantics. Parent-observable binding at row creation would avoid that, but it requires rebinding whenever crossref or xdata changes, which is the case that is hardest to get right. Keep the current approach unless profiling shows the per-change scan is costly on large libraries.

Files changed (6) +711 / -1

Bug fix (2) +77 / -1
BibEntryTableViewModel.javaAdd version property to invalidate cached inherited values +9/-1

Add version property to invalidate cached inherited values

• Introduces referencedEntryVersion as an extra dependency of field value bindings, and adds invalidateResolvedFieldValues() to bump it. This lets a row recompute inherited values without replacing its cached bindings.

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

MainTableDataModel.javaRefresh dependent rows when crossref or xdata targets change +68/-0

Refresh dependent rows when crossref or xdata targets change

• Listens to entry list changes and collects affected citation keys. A single Platform.runLater batch then resolves crossref and xdata dependents, following xdata chains with a visited set so cycles terminate, and invalidates only rows that still match their entry. unbind() cancels pending work and the listener subscription.

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

Tests (1) +615 / -0
MainTableCrossrefTest.javaAdd 44 cases for crossref and xdata main table updates +615/-0

Add 44 cases for crossref and xdata main table updates

• Tests inherited year, text, name, and sort values across parent edits, reference changes, missing and inserted parents, xdata chains, cycles, and unbinding. Also checks that cells are not invalidated for unrelated or removed rows, and that updates are coalesced and applied on the JavaFX thread.

jabgui/src/test/java/org/jabref/gui/maintable/MainTableCrossrefTest.java

Documentation (3) +19 / -0
CHANGELOG.mdAdd changelog entry for inherited table values +1/-0

Add changelog entry for inherited table values

• Adds one user-facing line under the unreleased fixes, linking to issue #7730 for stale inherited values after crossref or xdata changes.

CHANGELOG.md

testing.mdDocument testing approach for cross-referenced main table values +7/-0

Document testing approach for cross-referenced main table values

• Describes what MainTableCrossrefTest covers and warns that tests must drain JavaFX events before asserting inherited updates, because invalidation is deferred.

docs/code-howtos/testing.md

ux.mdAdd requirement for inherited main table updates +11/-0

Add requirement for inherited main table updates

• Adds req~maintable.crossref.updates~1 covering parent field changes, crossref reassignment, xdata chains, and cycle termination, linked to issue #7730.

docs/requirements/ux.md

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

Copy link
Copy Markdown
Contributor

Code Review by Qodo

📘 Rule violations (1)

Grey Divider


Remediation recommended

1. Tests build real preferences, not mocks 📘 Rule violation
Description
start constructs a real SearchPreferences and returns real GroupsPreferences and
NameDisplayPreferences defaults through the GuiPreferences mock, instead of mocking them. Any
change to those classes' constructors or default values can break this test even when the table
logic is unchanged.
Code

jabgui/src/test/java/org/jabref/gui/maintable/MainTableCrossrefTest.java[R68-70]

+        when(preferences.getSearchPreferences()).thenReturn(
+                new SearchPreferences(SearchDisplayMode.FILTER, false, false, false, false, false, false, 0, 0, 0));
+        when(preferences.getNameDisplayPreferences()).thenReturn(NameDisplayPreferences.getDefault());
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
In `MainTableCrossrefTest.start`, the test constructs real preference objects: `new SearchPreferences(...)`, `GroupsPreferences.getDefault()` and `NameDisplayPreferences.getDefault()`. The compliance rule requires tests to mock `*Preferences` classes instead of constructing real instances.

## Fix Focus Areas
- jabgui/src/test/java/org/jabref/gui/maintable/MainTableCrossrefTest.java[66-76]

## Recommended Fix
Replace the real instances with mocks. Create `SearchPreferences`, `GroupsPreferences` and `NameDisplayPreferences` with `mock(...)`, and stub only the getters that `MainTableDataModel` reads on the tested path. Return those mocks from the `GuiPreferences` mock, and keep the rest of the setup unchanged.

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


Grey Divider

Tip of the day
💡 Did you know, you can pick a display mode instead of tweaking every Display option by hand

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 Dec 1, 2026
@Siedlerchr

Copy link
Copy Markdown
Member

need a performance test with 100,000 entries and many crossref entries

@github-actions github-actions Bot added dev: build-system component: entry-editor status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers and removed component: entry-editor status: changes-required Pull requests that are not yet complete labels Dec 1, 2026
@github-actions github-actions Bot added component: entry-editor status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers and removed component: entry-editor status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Dec 1, 2026
@github-actions github-actions Bot added component: entry-editor status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers and removed component: entry-editor status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Dec 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: entry-editor component: maintable dev: build-system dev: send-to-black-forest Port to the black-forest branch of JabRef/jabref-black-forest after merging (ADR-0073) size: big status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Entry with crossref does not update immediately

3 participants