Skip to content

Improve search fallback for single suggestion - #27151

Open
preetham-18-developer wants to merge 4 commits into
jenkinsci:masterfrom
preetham-18-developer:improve-search-fallback
Open

Improve search fallback for single suggestion#27151
preetham-18-developer wants to merge 4 commits into
jenkinsci:masterfrom
preetham-18-developer:improve-search-fallback

Conversation

@preetham-18-developer

@preetham-18-developer preetham-18-developer commented Jul 26, 2026

Copy link
Copy Markdown

Partially addresses #27071

Testing done

Manual testing

Verified the behavior locally by creating the following freestyle projects:

  • job-config-scroll-test
  • job config
  • test
  • test1
  • pipeline-test

Performed the following searches:

  • Searching for job-config-scroll now redirects directly to job-config-scroll-test when there is exactly one suggested match.
  • Verified that exact matches continue to redirect normally.
  • Verified that searches with multiple possible matches continue to display the search results/failure page instead of redirecting.

Automated testing

Added a regression test:

  • SearchTest.shouldRedirectToSingleSuggestedItem()

Executed the Jenkins core test suite successfully.

Screenshots (UI changes only)

Before

Searching for job-config-scroll displayed the Search Failed page even though there was exactly one suggested result.

After

Searching for job-config-scroll automatically redirects to job-config-scroll-test.

Proposed changelog entries

  • Redirect to the single suggested search result when there is no exact match.

Proposed changelog category

/label bug

Proposed upgrade guidelines

N/A

Desired reviewers

@timja

@welcome

welcome Bot commented Jul 26, 2026

Copy link
Copy Markdown

Yay, your first pull request towards Jenkins core was created successfully! Thank you so much!

A contributor will provide feedback soon. Meanwhile, you can join the chats and community forums to connect with other Jenkins users, developers, and maintainers.

@comment-ops-bot comment-ops-bot Bot added the bug For changelog: Minor bug. Will be listed after features label Jul 26, 2026
It is easier to review the code when the differences that do not change
behavior are removed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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.doIndexImpl when 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.

Comment on lines +133 to +137
List<SuggestedItem> suggestions = suggest(index, query, smo);

if (suggestions.size() == 1) {
rsp.sendRedirect2(req.getContextPath() + suggestions.get(0).getUrl());
return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug For changelog: Minor bug. Will be listed after features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants