Improve search fallback for single suggestion - #27151
Improve search fallback for single suggestion#27151preetham-18-developer wants to merge 4 commits into
Conversation
|
Yay, your first pull request towards Jenkins core was created successfully! Thank you so much! |
It is easier to review the code when the differences that do not change behavior are removed.
There was a problem hiding this comment.
🟡 Not ready to approve
The new redirect logic can trigger expensive suggestion computation multiple times per request (and again during view rendering), creating a likely performance regression and inconsistent redirect decisions vs the suggestion list shown in the UI.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR updates Jenkins core search behavior so that when there is no exact match but the suggestion engine yields exactly one candidate, the user is redirected directly to that item rather than seeing the “Search Failed” page. This aligns the Enter-key search behavior more closely with the suggestion UX described in #27071.
Changes:
- Add a redirect path in
Search.doIndexImplwhen there is a single suggested result. - Add a regression test covering the single-suggestion redirect behavior.
File summaries
| File | Description |
|---|---|
| core/src/main/java/hudson/search/Search.java | Redirects to the single suggested item when no exact match is found. |
| test/src/test/java/hudson/search/SearchTest.java | Adds a test to validate redirect-on-single-suggestion behavior. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
| List<SuggestedItem> suggestions = suggest(index, query, smo); | ||
|
|
||
| if (suggestions.size() == 1) { | ||
| rsp.sendRedirect2(req.getContextPath() + suggestions.get(0).getUrl()); | ||
| return; |
Partially addresses #27071
Testing done
Manual testing
Verified the behavior locally by creating the following freestyle projects:
Performed the following searches:
job-config-scrollnow redirects directly tojob-config-scroll-testwhen there is exactly one suggested match.Automated testing
Added a regression test:
SearchTest.shouldRedirectToSingleSuggestedItem()Executed the Jenkins core test suite successfully.
Screenshots (UI changes only)
Before
Searching for
job-config-scrolldisplayed the Search Failed page even though there was exactly one suggested result.After
Searching for
job-config-scrollautomatically redirects tojob-config-scroll-test.Proposed changelog entries
Proposed changelog category
/label bug
Proposed upgrade guidelines
N/A
Desired reviewers
@timja