Skip to content

Restore full-text results in the entry editor - #17367

Merged
Siedlerchr merged 4 commits into
JabRef:mainfrom
Siedlerchr:fix/fulltext-search-results-tab
Oct 4, 2026
Merged

Siedlerchr merged 4 commits into
JabRef:mainfrom
Siedlerchr:fix/fulltext-search-results-tab

Conversation

@Siedlerchr

@Siedlerchr Siedlerchr commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

Summary

Restore linked-file full-text matches in the entry editor after the main table began searching a query snapshot. The results tab now consumes the accepted per-library search results, including after library switches. jabref-contrib-policy:4.2:reviewed​:ok

grafik

Analogies

Like honey retaining its source, the result view follows its library; like chocolate, it presents the useful part of the search; unlike the moon, it should not disappear when the view changes.

Steps to test

  1. Open a library containing an entry with a linked PDF that contains a known word.
  2. Select the entry and search for that word with linked-file full-text search enabled.
  3. Open the Fulltext search results entry-editor tab. The matching PDF text and page links should appear. Screenshot: TODO — upload the maintainer's cropped screenshot.
  4. Switch to another library and back. Results should follow the active library, with no stale matches from the previous one.

Automated focused search tests, :jablib:check, style checks, modernizer, rewrite dry run, and Javadoc passed. :jabgui:check remains red because the unrelated NativeDesktopTest.openBrowserPassesFullUrlToCustomBrowser() fails even in isolation.

Related issues and pull requests

No matching issue identified. This follows the search-result snapshot change in commit b3fa1c98b0.

Closes N/A

AI usage

OpenAI Codex assisted with investigation, implementation, and tests (AIL3). The maintainer reports having reviewed the changes and manually tested the result. Exact model ID: TODO — confirm from the client before marking ready.

AI CHECKLIST.md walkthrough

Code checklist

1. Code self-review

Nullability and control flow

  • No new == null / != null checks — JSpecify annotations used instead.
  • No Objects.requireNonNull(...) added.
  • New SearchDisplay record annotated with @NullMarked.
  • [/] No new packages.
  • Optional consumed with ifPresent / ifPresentOrElse / map / flatMap / orElseThrow.
  • [/] No new string-blank check.

Exceptions

  • No catch (Exception e) added.
  • No unchecked exception thrown.
  • [/] No exception logging added.

Style and idioms

  • New BibEntry in tests is created without setField.
  • Modern Java collection factories used where needed.
  • [/] No new regex.
  • Added declarations follow local ordering conventions.
  • Background search continues to use BackgroundTask.
  • No commented-out code, trivial comments, or AI-disclosure comments added to source.
  • [/] No new Javadoc.

User-facing text

  • Existing localized result messages reused; no new UI string.
  • No new title-case, exclamation-mark, or colon-ended label.
  • [/] No new variable UI text.

Security

  • [/] No HTML response generated or changed.

Tests

  • [/] No linked issue with a concrete example was identified.
  • [/] No model or logic code changed.
  • Regression tests use JUnit assertions and no caught exceptions or manual temp directories.
  • [/] No fetcher test changed.

2. Verification commands

  • ./gradlew :jablib:check passed.
  • ./gradlew checkstyleMain checkstyleTest checkstyleJmh passed.
  • ./gradlew modernizer passed.
  • ./gradlew --no-configuration-cache :rewriteDryRun passed without changes.
  • ./gradlew javadoc passed.
  • npx markdownlint-cli2 "docs/**/*.md" "*.md" passed.
  • npm ci && npm run textlint: npm run textlint passed; npm ci was not run.
  • [/] IntelliJ formatter not needed.

3. Documentation

  • User-facing CHANGELOG.md entry added near search fixes; PR link pending draft PR number.
  • Searched JabRef and jabref-koppor issues; no confident match found.
  • Confirm whether this regression requires a new traced requirement before marking ready.
  • Confirm whether developer documentation needs an update before marking ready.

4. Pull request

  • PR body built from .github/PULL_REQUEST_TEMPLATE.md, with pending items explicit.
  • All checklist items kept and marked.
  • Cropped screenshot must be uploaded to the PR description.
  • All HTML comments removed from the PR body.
  • PR created with gh pr create --body-file.
  • Replaced the changelog TODO with the PR link, committed and pushed; PR remains draft until pending items are complete.

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 — exact model ID pending maintainer confirmation.
  • I manually tested my changes in running JabRef (maintainer confirmation).
  • I added JUnit tests for changes.
  • I added screenshots in the PR description — cropped screenshot upload pending.
  • I added one sentence (max 20 words) to CHANGELOG.md describing the change from the user's point of view.
  • I checked the user documentation for up to dateness and submitted a pull request to our user documentation repository.

@Siedlerchr
Siedlerchr marked this pull request as ready for review October 4, 2026 14:41
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Restore linked-file full-text results in the entry editor

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

Grey Divider

AI Description

• Show accepted, per-library full-text matches in the entry editor instead of reading results from
 the query.
• Clear and refresh displayed matches as searches complete or the active library changes.
• Add regression tests and document the user-visible fix.
Diagram

graph TD
    A["Search context"] --> B["Main table model"] --> C["Library tab"] --> D["Results tab"]
    E["State manager"] --> D
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Own results in a separate per-library search session
  • ➕ Decouples result consumers from the main table model.
  • ➖ Requires another owner and synchronization path for search completion, cancellation, and library lifecycle.

Recommendation: Keep the PR's approach: the main table already determines which asynchronous result is current, so exposing that accepted result avoids duplicate searches and stale query-owned results. A separate search session would be a broader architectural change than this regression requires.

Files changed (6) +190 / -37

Bug fix (3) +91 / -37
LibraryTab.javaExpose search results for each library +12/-0

Expose search results for each library

• Binds a read-only results property to the library's main table model and unbinds it when the library closes. Rebinds it when the table model is recreated.

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

FulltextSearchResultsTab.javaRender results from the active library +64/-33

Render results from the active library

• Reads accepted results from the active library rather than from the search query. Observes result and library changes, clears outdated content, and removes its listeners on disposal.

jabgui/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FulltextSearchResultsTab.java

MainTableDataModel.javaPublish accepted asynchronous search results +15/-4

Publish accepted asynchronous search results

• Adds a read-only results property that clears when a search starts and receives results only from the current search sequence. This makes the results used by the table available to the editor.

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

Tests (2) +98 / -0
FulltextSearchResultsTabTest.javaTest editor result updates and library switching +94/-0

Test editor result updates and library switching

• Tests that completed results update an open editor tab and that changes to a previously active library no longer alter its content.

jabgui/src/test/java/org/jabref/gui/entryeditor/fileannotationtab/FulltextSearchResultsTabTest.java

MainTableDataModelTest.javaVerify published results follow accepted searches +4/-0

Verify published results follow accepted searches

• Extends search tests to assert the exposed matches, including when an older overlapping search finishes after the newer one.

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

Documentation (1) +1 / -0
CHANGELOG.mdDocument restored full-text results +1/-0

Document restored full-text results

• Adds a user-facing changelog entry for linked-file full-text matches missing from the entry editor.

CHANGELOG.md

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

qodo-free-for-open-source-projects Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Linked-file matches remain untested ✓ Resolved
Description
Both FulltextSearchResultsTabTest cases publish empty SearchResults and check only the count or
identity of displayed nodes. The tests would still pass if renderResults stopped showing a
matching file’s text or page link, which is the behavior this PR aims to restore.
Code

jabgui/src/test/java/org/jabref/gui/entryeditor/fileannotationtab/FulltextSearchResultsTabTest.java[R55-57]

+        results.set(Optional.of(new SearchResults()));
+
+        assertEquals(1, content.getChildren().size());
Evidence
The checklist requires tests for changed behavior. The first new test supplies an empty result and
checks one node; the second likewise supplies empty results. The changed rendering path for file
matches is therefore not exercised.

AGENTS.md: Add Reliable Tests for Changed Behavior: AGENTS.md: Add Reliable Tests for Changed Behavior: AGENTS.md: Add Reliable Tests for Changed Behavior: AGENTS.md: Add Reliable Tests for Changed Behavior: AGENTS.md: Add Reliable Tests for Changed Behavior: AGENTS.md: Add Reliable Tests for Changed Behavior: AGENTS.md: Add Reliable Tests for Changed Behavior: AGENTS.md: Add Reliable Tests for Changed Behavior
jabgui/src/test/java/org/jabref/gui/entryeditor/fileannotationtab/FulltextSearchResultsTabTest.java[55-57]
jabgui/src/test/java/org/jabref/gui/entryeditor/fileannotationtab/FulltextSearchResultsTabTest.java[85-91]
jabgui/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FulltextSearchResultsTab.java[136-150]

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 regression tests use empty search results, so they do not verify the restored linked-file display.
## Fix Focus Areas
- jabgui/src/test/java/org/jabref/gui/entryeditor/fileannotationtab/FulltextSearchResultsTabTest.java[33-59]
- jabgui/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FulltextSearchResultsTab.java[136-150]
## Recommended Fix
Add a linked file and a matching full-text search result to a test fixture. Assert that the rendered content includes the matching text and its page link.

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


2. New results-tab test skips nullness ✓ Resolved
Description
The new FulltextSearchResultsTabTest class lacks @NullMarked. Its declarations have no JSpecify
non-null default when fixture fields or helpers are added to these tests.
Code

jabgui/src/test/java/org/jabref/gui/entryeditor/fileannotationtab/FulltextSearchResultsTabTest.java[R31-32]

+@ExtendWith(JavaFxExtension.class)
+class FulltextSearchResultsTabTest {
Evidence
The checklist requires every new class to be annotated @NullMarked; the added test class has only
@ExtendWith.

AGENTS.md: Express Optional and Nullability Explicitly: AGENTS.md: Express Optional and Nullability Explicitly: AGENTS.md: Express Optional and Nullability Explicitly: AGENTS.md: Express Optional and Nullability Explicitly: AGENTS.md: Express Optional and Nullability Explicitly: AGENTS.md: Express Optional and Nullability Explicitly: AGENTS.md: Express Optional and Nullability Explicitly: AGENTS.md: Express Optional and Nullability Explicitly
jabgui/src/test/java/org/jabref/gui/entryeditor/fileannotationtab/FulltextSearchResultsTabTest.java[23-32]

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 test class is missing the required JSpecify nullness annotation.
## Fix Focus Areas
- jabgui/src/test/java/org/jabref/gui/entryeditor/fileannotationtab/FulltextSearchResultsTabTest.java[23-32]
## Recommended Fix
Import `org.jspecify.annotations.NullMarked` and annotate `FulltextSearchResultsTabTest` with `@NullMarked`.

ⓘ 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 describe a rule in plain language on the Rules page and Qodo drafts it for you

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment on lines +116 to +118
if (updateSequence == searchUpdateSequence.get()) {
searchResults.set(Optional.empty());
}

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.

Please a small Java comment on the why.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

added comment

Comment on lines +130 to +131
searchResults.set(results);
results.ifPresentOrElse(this::setSearchMatches, this::clearSearchMatches);

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.

Strange that both (.set and .setSearchMatchees) is needed - maybe small Java comment why searchResults and searchMatches need to be updated? IDK.

Should we creae/link requirements on the various places?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

added a comment and requirements

@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Oct 4, 2026
@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Oct 4, 2026
@Siedlerchr

Copy link
Copy Markdown
Member Author

Follow-up commit dc27413 addresses the review feedback: the regression test now verifies linked-file match text and its page link, the new test class is null-marked, and the search model comments explain the FX-thread clear and why detailed editor results and table row flags are updated separately. It also adds one traced requirement and applies the CI formatting change. The focused entry-editor, main-table, and global-search tests, requirement tracing, Java style checks, rewrite dry run, Markdown lint, and text lint passed locally.

@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Oct 4, 2026
@github-actions github-actions Bot added dev: build-system and removed status: changes-required Pull requests that are not yet complete labels Oct 4, 2026
@Siedlerchr
Siedlerchr added this pull request to the merge queue Oct 4, 2026
@github-actions github-actions Bot added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label Oct 4, 2026
Merged via the queue into JabRef:main with commit 091e889 Oct 4, 2026
@Siedlerchr
Siedlerchr deleted the fix/fulltext-search-results-tab branch October 4, 2026 20:15
@jabref-machine

Copy link
Copy Markdown
Collaborator

Created backport PR for stable:

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

git fetch origin port-17367-to-stable
git worktree add --checkout .worktree/port-17367-to-stable port-17367-to-stable
cd .worktree/port-17367-to-stable
git reset --hard HEAD^
git cherry-pick -x 091e8897bcd9f7dcecbb499ae6e48332ffefec21

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: 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.

4 participants