Fix bulk imports adding entries to navigation history#14575
Conversation
|
Please add a video of the fixed functionality. |
239209f to
a8a68c2
Compare
|
the jablib unit test is failing for a file i haven't changed |
|
also @subhramit i have added the video please review it . |
| .forEach(linkedFile -> | ||
| new LinkedFileViewModel( | ||
| linkedFile, | ||
| entry, | ||
| targetBibDatabaseContext, | ||
| taskExecutor, | ||
| dialogService, |
There was a problem hiding this comment.
please revert all the unrelated formatting changes throughout the PR.
Also, you can run the respective tests locally to check if they are passing (unit, openrewrite, etc) instead of pushing dummy commits for triggering ci. This causes unnecessary noise to those subscribed to the PR.
|
@shubhamk0205 you have pushed some commits but on checking files changed, it appears you have not acted on the last review comment. Can you please be a little more mindful and complete them before requesting another review? |
|
hey @koppor , @subhramit -have changed the point of knowledge , now libraryTab decides that is it a bulk import or not instead of importHandler signal . |
|
Your pull request conflicts with the target branch. Please merge with your code. For a step-by-step guide to resolve merge conflicts, see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line. |
| if (suppressionDepth > 0) { | ||
| suppressionDepth--; |
There was a problem hiding this comment.
Hey, can you explain what the crux of Suppression as a class is? How exactly did you think of this as a solution?
And what does suppressionDepth convey, in simple terms?
It is evident that it works, but we need to brainstorm and ensure that there was no better way to achieve the same thing before going forward with this.
Did you try the two or three solution hints given in the issue? What problems did you face when implementing them?
There was a problem hiding this comment.
hello @subhramit,
thank you for responding and for the questions.
The main crux of Suppression is that during a bulk import it increases suppressionDepth, which prevents entries from being added to the navigation history. I initially used a boolean flag, but switched to a depth-based approach because a boolean can fail in nested scenarios. For example, if importFile1() internally calls importFile2(), the boolean would be reset after importFile2() finishes, while importFile1() is still running.
As for the other approaches:
Clearing the imported entries afterward felt fragile — for example, if the import crashes midway, adding and then removing entries doesn't make sense .
Disabling auto-selection would break the existing behavior of showing the last imported entry.
Given these trade-offs, disabling history updates during bulk import felt like the most robust option. The main challenge I faced was deciding where this suppression should live architecturally , I implemented it as a runWithHistorySuppression() wrapper method in LibraryTab that bulk operation callers use like import handler , drag and drop .
i am open for making any changes and improving this further , if there’s a cleaner direction
There was a problem hiding this comment.
For example, if importFile1() internally calls importFile2(), the boolean would be reset after importFile2() finishes, while importFile1() is still running.
Have you found any concrete examples of that happening in the code?
And if there is, wouldn't switching the boolean flag only at the level of the outermost import call solve it? That is, tracking only the completion of importFile1()?
There was a problem hiding this comment.
where this suppression should live architecturally
History should not suppressed completely, it should "just" be collected into one NamedCompound.
Read on at https://apidia.net/java/OpenJDK/25/?pck=javax.swing.undo&cls=.CompoundEdit for nested undos/redos.
There was a problem hiding this comment.
Maybe, I mixed it up - this PR is about navigation; I thought, it has a strong relation to undo/redo.
There was a problem hiding this comment.
For example, if importFile1() internally calls importFile2(), the boolean would be reset after importFile2() finishes, while importFile1() is still running.
Have you found any concrete examples of that happening in the code? And if there is, wouldn't switching the boolean flag only at the level of the outermost import call solve it? That is, tracking only the completion of
importFile1()?
I checked this and you’re right @subhramit — in ImportHandler, imports are performed in a loop, not in a recursive way.
switching the flag only at the outermost level works. A nesting-aware boolean like this would be enough:
boolean wasAlreadySuppressed = suppressNavigation;
suppressNavigation = true;
try {
action.run();
} finally {
if (!wasAlreadySuppressed) {
suppressNavigation = false;
}
}
This handles cases where multiple import batches might run sequentially - suppression stays on until all batches complete.
I went with the counter mostly as a defensive choice, but I agree the boolean is simpler and does the job here. Happy to switch to that if you prefer.
There was a problem hiding this comment.
Please go ahead with it, let us know if you face issues.
Prevent bulk import operations from polluting the navigation history. When multiple entries are imported at once, automatic selection changes are now suppressed from being recorded in the navigation history. Fixes JabRef#13878
|
@subhramit @koppor can u provide me some feedback on this |
does it work on your system? a fresh video would be great. I am currently a bit low on time. |
yess this works on my device Recording.2026-01-12.102823compressed.mp4 |
| // Only show/select individual entry for single-entry imports. | ||
| // For bulk imports (size > 1), leave all entries selected. |
There was a problem hiding this comment.
This comment is confusing - so selection happens in case of both single and multiple entries?
Where is the code for "leaving all entries selected"? Because it will neither trigger the if nor else case.
The side effect of this can be - check if earlier on bulk import all entries were actually selected, because otherwise now if they are not selected, lets say the user wants to remove all the entries imported just after the import action, they will have to manually select the imported entries again first instead of just clicking delete,
There was a problem hiding this comment.
You’re right — my bad. I forgot to update the comment. I’ll fix it to accurately describe skipping clearAndSelect() for bulk imports.
There was a problem hiding this comment.
check if earlier on bulk import all entries were actually selected, because otherwise now if they are not selected, lets say the user wants to remove all the entries imported just after the import action, they will have to manually select the imported entries again first instead of just clicking delete,
i checked this ,on bulk import all the entries were not selected , only the first entry was selected from the bulk import
There was a problem hiding this comment.
You’re right — my bad. I forgot to update the comment. I’ll fix it to accurately describe skipping clearAndSelect() for bulk imports.
This is a final heads up to not use AI to communicate. You will be blacklisted from the project if you don't respect our guidelines on using AI.
There was a problem hiding this comment.
@subhramit i used ai to refine my speech so i can communicate better , but from going forward i will be writing directly here .
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
|
6 |
Closes #13878
Prevent bulk import operations from polluting the navigation history. When multiple entries are imported at once, automatic selection changes are now suppressed from being recorded in the navigation history. This ensures that only user-driven navigation actions are tracked, keeping the Back/Forward buttons functional and predictable.
Steps to test
Expected behavior: Bulk imports should not enable Back/Forward navigation or add entries to navigation history. Only manual entry selections should affect navigation history.
Mandatory checks
Fixed.issue.mp4