Skip to content

Create new group from selected entries - #16588

Merged
Siedlerchr merged 5 commits into
JabRef:mainfrom
subhramit:rc-group-add
Aug 16, 2026
Merged

Create new group from selected entries#16588
Siedlerchr merged 5 commits into
JabRef:mainfrom
subhramit:rc-group-add

Conversation

@subhramit

@subhramit subhramit commented Aug 16, 2026

Copy link
Copy Markdown
Member

Summary

Finishes #11476
Follow-up to #11453

Steps to test

  1. Open example library
  2. Select some entries
  3. In the groups sidebar, click on the "Add group" button on "All entries"
  4. Give the new group a name.
  5. Under "Collect by -> Explicit Selection", check "Include Selected entries in created group" (edit - changed this preference to be checked by default)
    image
  6. Click OK
  7. See that a new group with that name is created with the initial collection of entries you selected.

Related issues and pull requests

Closes NA
Refs #11449

AI usage

Zed + GPT 5.4 to resolve conflicts. Addressed remaining review comments.

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 a screenshot in the PR description showing a library with a single entry with me as author and as title the issue number
  • I described the change in CHANGELOG.md in a way that can be understood by the average user (if 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

Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
@github-actions github-actions Bot added good first issue An issue intended for project-newcomers. Varies in difficulty. component: ui component: groups labels Aug 16, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Allow creating explicit groups pre-populated with current selection

✨ Enhancement 🧪 Tests 📝 Documentation ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Add dialog option to seed new explicit groups with currently selected entries.
• Persist a new preference to auto-enable the option when entries are selected.
• Keep the newly created group selected and add tests + UX/changelog updates.
Diagram

graph TD
  A["Groups Preferences UI"] --> B["GroupsTabViewModel"] --> C[("Preferences store")]
  D["GroupDialog (FXML/View)"] --> E["GroupDialogViewModel"] --> F["ExplicitGroup"]
  E --> G["StateManager selection"] --> F
  E --> C
  H["GroupTreeViewModel"] --> I["GroupTreeView"]
  E --> H --> I
  subgraph Legend
    direction LR
    _ui["UI component"] ~~~ _vm["ViewModel"] ~~~ _pref[("Persisted preference")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Snapshot selection at dialog open
  • ➕ Avoids race/UX surprises if selection changes while the dialog is open
  • ➕ Makes behavior deterministic for tests and future refactors
  • ➖ Requires storing the snapshot list in the dialog/view model
  • ➖ Slightly more state to manage (refresh rules if selection changes)
2. Handle seeding in GroupTreeViewModel (post-create command)
  • ➕ Centralizes side effects (selection + seeding) near the 'add group' action
  • ➕ Easier to later add undo/redo around a single command
  • ➖ Needs plumbing to pass 'include selection' intent from dialog result
  • ➖ More involved refactor of current dialog result-converter flow

Recommendation: Current approach is reasonable for a UI-driven feature: the dialog owns the option, preferences provide defaults, and the view model seeds the ExplicitGroup directly. The main potential improvement is snapshotting the selected entries when the dialog opens to avoid seeding from a changed selection at OK time; consider this if users frequently change selection while the dialog is open or if flaky UI tests appear.

Files changed (15) +127 / -3

Enhancement (8) +47 / -2
GroupDialogView.javaWire new 'include selected' checkbox into group dialog +5/-0

Wire new 'include selected' checkbox into group dialog

• Adds an FXML-injected checkbox and binds it to the view model. Disables the checkbox when editing an existing group or when no entries are selected.

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

GroupDialogViewModel.javaSeed new explicit groups with selected entries (optional) +26/-1

Seed new explicit groups with selected entries (optional)

• Adds properties to control whether selected entries can be included, and whether the dialog is editing an existing group. When creating an ExplicitGroup and the option is enabled, adds StateManager's selected entries to the new group; also initializes defaults from the new preference and selection availability.

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

GroupTreeView.javaAuto-expand parents when selecting a group node +2/-1

Auto-expand parents when selecting a group node

• Changes the default node selection helper to expand parent nodes, ensuring the newly created group becomes visible/selected in the tree.

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

GroupTreeViewModel.javaSelect newly created subgroup after add +1/-0

Select newly created subgroup after add

• Ensures that after creating a new subgroup, the tree selection is updated to the newly created node (annotated to match the UX requirement).

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

GroupsTab.javaExpose auto-include-selected option in Groups preferences tab +1/-0

Expose auto-include-selected option in Groups preferences tab

• Adds a new checkbox in the Groups preferences UI to control automatically including selected entries when creating a new group.

jabgui/src/main/java/org/jabref/gui/preferences/groups/GroupsTab.java

GroupsTabViewModel.javaBind new auto-include-selected setting to GroupsPreferences +7/-0

Bind new auto-include-selected setting to GroupsPreferences

• Adds a new property, initializes it from GroupsPreferences, and persists it back on save.

jabgui/src/main/java/org/jabref/gui/preferences/groups/GroupsTabViewModel.java

GroupDialog.fxmlAdd 'Include selected entries' checkbox for explicit selection +3/-0

Add 'Include selected entries' checkbox for explicit selection

• Extends the dialog layout to show a new checkbox when 'Explicit selection' is chosen.

jabgui/src/main/resources/org/jabref/gui/groups/GroupDialog.fxml

JabRef_en.propertiesAdd localization strings for new group option and preference +2/-0

Add localization strings for new group option and preference

• Adds English localization keys for the new checkbox in the group dialog and the new preference checkbox in the groups settings tab.

jablib/src/main/resources/l10n/JabRef_en.properties

Tests (3) +51 / -1
GroupDialogViewModelTest.javaAdd tests for include-selected defaulting and explicit-group seeding +48/-0

Add tests for include-selected defaulting and explicit-group seeding

• Adds coverage for (1) defaulting the checkbox from preferences when entries are selected, (2) disabling behavior when editing a group, and (3) creating an ExplicitGroup containing the selected entries.

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

GroupNodeViewModelTest.javaUpdate GroupsPreferences construction for new boolean parameter +1/-0

Update GroupsPreferences construction for new boolean parameter

• Adjusts test setup to pass the new 'auto include selected entries' preference argument.

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

GroupTreeViewModelTest.javaUpdate GroupsPreferences construction and use shared dialogService mock +2/-1

Update GroupsPreferences construction and use shared dialogService mock

• Updates preference construction to include the new boolean and aligns GroupTreeViewModel instantiation to use the existing dialogService mock.

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

Documentation (2) +8 / -0
CHANGELOG.mdDocument new explicit-group creation option in changelog +1/-0

Document new explicit-group creation option in changelog

• Adds a changelog entry noting the new option to include currently selected entries when creating an explicit group. The entry currently contains a placeholder 'TODO' for the reference link/issue.

CHANGELOG.md

ux.mdAdd UX requirement for creating explicit group from selection +7/-0

Add UX requirement for creating explicit group from selection

• Introduces a UX requirement describing reusing current selection when creating an explicit group and keeping the new group selected afterwards.

docs/requirements/ux.md

Other (2) +21 / -0
GroupsPreferences.javaAdd preference for auto-including selected entries in new explicit groups +18/-0

Add preference for auto-including selected entries in new explicit groups

• Introduces a new boolean preference property, includes it in constructors/defaults, and adds getter/setter/property accessors for binding.

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

JabRefGuiPreferences.javaPersist new groups preference key: autoIncludeSelectedEntries +3/-0

Persist new groups preference key: autoIncludeSelectedEntries

• Adds a new preference key constant, loads it when constructing GroupsPreferences, and binds it for persistence alongside other group-related settings.

jabgui/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java

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

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1) 📎 Requirement gaps (0) 📜 Skill insights (0)

Grey Divider


Action required

1. CHANGELOG entry has TODO 📘 Rule violation ⚙ Maintainability
Description
The newly added CHANGELOG entry ends with a literal TODO placeholder instead of a valid issue/PR
link, violating the repository’s changelog linking/formatting rules. If left unchanged, this
unfinished text would ship into user-facing release notes and lead to incomplete or incorrect
release documentation.
Code

CHANGELOG.md[55]

+- We added an option to include currently selected entries when creating a new explicit group. TODO
Evidence
The cited compliance requirements (PR Compliance ID 24 and 31) state that CHANGELOG entries must
follow strict formatting and include valid issue/PR links rather than placeholders like TODO. In
the updated CHANGELOG.md at line 55, the added bullet ends with TODO, which directly
demonstrates that this PR introduces an unfinished placeholder where a proper reference is required,
confirming the formatting/linking violation.

AGENTS.md: CHANGELOG.md entries: only for user-visible changes, end-user wording, strict formatting, and correct issue/PR linking rules
CHANGELOG.md[55-55]
CHANGELOG.md[41-56]
Best Practice: Learned patterns

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 CHANGELOG entry for the new explicit-group-from-selection feature currently ends with a literal `TODO` placeholder instead of a finalized issue/PR reference, which violates the project’s CHANGELOG formatting/linking rules and would ship as unfinished release-note text.

## Issue Context
PR Compliance ID 24 and 31 require strict CHANGELOG formatting and valid issue/PR links (no placeholders). The PR description references https://github.com/JabRef/jabref/issues/11449, so the CHANGELOG entry should link that issue (or the PR number if that is what the project rules require). If an appropriate reference cannot be determined, the entry should be removed/omitted until it can be completed.

## Fix Focus Areas
- CHANGELOG.md[55-55]

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



Remediation recommended

2. Stale selection availability 🐞 Bug ≡ Correctness
Description
GroupDialogViewModel computes selectedEntriesAvailableProperty only once in setValues(), but
resultConverter() later re-reads StateManager.getSelectedEntries() when creating the ExplicitGroup.
If the selection changes between dialog open and OK, the checkbox enablement/defaults can disagree
with which entries are actually added, causing missing or unexpected initial group members.
Code

jabgui/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java[R319-321]

+                if (Boolean.TRUE.equals(explicitIncludeSelectedProperty.getValue())) {
+                    explicitGroup.add(stateManager.getSelectedEntries());
+                }
Evidence
The view model sets selection availability once in setValues(), but adds entries using a fresh read
of the selection on OK; the view disables the checkbox based on the cached property, so UI state can
become stale relative to the actual selection used.

jabgui/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java[305-323]
jabgui/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java[424-443]
jabgui/src/main/java/org/jabref/gui/groups/GroupDialogView.java[219-221]
jabgui/src/main/java/org/jabref/gui/StateManager.java[42-63]
jabsrv/src/main/java/org/jabref/http/SrvStateManager.java[15-22]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`selectedEntriesAvailableProperty` is set once during `setValues()`, but the dialog later uses `stateManager.getSelectedEntries()` again when OK is pressed. This can make the UI state (enabled/disabled + default checkbox value) inconsistent with the entries actually added.

### Issue Context
The dialog uses `selectedEntriesAvailableProperty` to disable the checkbox, but `resultConverter()` uses the current selection list again when adding entries.

### Fix Focus Areas
- jabgui/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java[424-443]
- jabgui/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java[305-323]
- jabgui/src/main/java/org/jabref/gui/groups/GroupDialogView.java[219-221]

### Suggested implementation direction
- Replace the one-time `selectedEntriesAvailableProperty.set(!stateManager.getSelectedEntries().isEmpty())` with a binding/listener that tracks selection changes (e.g., `selectedEntriesAvailableProperty.bind(Bindings.isNotEmpty(stateManager.getSelectedEntries()))`).
- Keep `explicitIncludeSelectedProperty` initialization for new groups, but ensure it doesn’t rely on a stale availability value.
- (Optional) If you want strict consistency, snapshot the selection used for adding entries (e.g., `List.copyOf(stateManager.getSelectedEntries())`) at the same time you decide the checkbox availability/defaults, and use that snapshot in `resultConverter()`.

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


Grey Divider

Context

Grey Divider

Tip of the day
💡 Did you know, you can add REVIEW.md to your repo root and Qodo follows it on every PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread CHANGELOG.md Outdated
@github-actions github-actions Bot added status: changes-required Pull requests that are not yet complete and removed status: no-bot-comments labels Aug 16, 2026
Signed-off-by: subhramit <subhramit.bb@live.in>
@subhramit subhramit added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Aug 16, 2026
@github-actions github-actions Bot added status: no-bot-comments and removed status: changes-required Pull requests that are not yet complete labels Aug 16, 2026
Signed-off-by: subhramit <subhramit.bb@live.in>
@Siedlerchr

Copy link
Copy Markdown
Member

tested, works fine!

@Siedlerchr
Siedlerchr added this pull request to the merge queue Aug 16, 2026
@github-actions github-actions Bot added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label Aug 16, 2026
Merged via the queue into JabRef:main with commit 2f3a00e Aug 16, 2026
87 of 89 checks passed
@Siedlerchr
Siedlerchr deleted the rc-group-add branch August 16, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: groups component: ui good first issue An issue intended for project-newcomers. Varies in difficulty. status: no-bot-comments status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers 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.

2 participants