Repository navigation
Conversation
`sortResults` scored a title by how many of its tokens match the search query, divided by the title's total token count. That normalization marks a long title down for being long, and it cannot see where in the title the match sits. Searching "coffee" ranked "Our Coffee" above "Coffee Roasting Guide For Beginners", even though only the second one begins with what was typed. Rank a title that is exactly what was typed, then a title that begins with it, above everything else. The existing score is kept as the tiebreak within a tier, so nothing it already ordered correctly is disturbed: all three existing `sortResults` tests pass unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VbpgaY282xpLjwA8aQv3x9
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
🤖 PR meta 🤖🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. 📦 Bundle sizeSize Change: +51 B (0%) Total Size: 8.21 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsShow the failuresSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. As a site builder, I want to insert a core navigation overlay pattern with CTA and see it on the frontend (Site Editor v2) in
|
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VbpgaY282xpLjwA8aQv3x9
The prefix ranking landed here rather than in #83287, which is closed. Its entry travelled with the file when this branch was split out, leaving two entries describing one change, one of them pointing at nothing. Also records that the suggestions shown before anything is typed keep their limit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VbpgaY282xpLjwA8aQv3x9
The prefix ranking landed here rather than in #83287, which is closed. Its entry travelled with the file when this branch was split out, leaving two entries describing one change, one of them pointing at nothing. Also records that the suggestions shown before anything is typed keep their limit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VbpgaY282xpLjwA8aQv3x9
What?
Ranks a link suggestion whose title is what was typed, or begins with it, above the rest.
Why?
sortResultsscores a title by how many of its tokens match the search query, divided by the title's total token count:That normalization marks a long title down for being long, and it cannot see where in the title the match sits. Searching
coffeeover these four results:gives this order:
The one title that actually begins with what was typed finishes last. "Coffee Roasting Guide For Beginners" matches
coffeeperfectly, but across 5 tokens, so it scores1/5 * 10 = 2.00. "Our Coffee" matches equally well across 2 tokens, so it scores1/2 * 10 = 5.00. Position in the title counts for nothing.How?
A tier is computed per result, above the existing score:
2— the title is exactly what was typed1— the title begins with what was typed0— anything elseThe tier sorts first and the existing score is the tiebreak within a tier, so anything the score already ordered correctly is left alone. Same results, same search:
The bottom two keep their relative order from the score (5.00 above 2.50).
A prefix match counts from the first character typed, with no minimum length. On short queries the effect is small, because a one- or two-character search matches too much to have a confident order either way.
Notes for review
sortResultstests pass unchanged, and the tier reinforces two of them. The change is a refinement of the existing ranking rather than a replacement.__experimentalFetchLinkSuggestions, so everyLinkControlin the editor — paragraph links, image links, the Navigation Link UI. That is deliberate; the flaw is not specific to any one of them.Testing Instructions
The change is to a JavaScript API, so this is exercised from the browser console.
Coffee Roasting Guide For Beginnersand a page titledOur Coffee.coffee:Coffee Roasting Guide For Beginnerscomes beforeOur Coffee. On trunk it comes after.coffee. The same order should appear in the suggestions list.Automated coverage
🤖 Generated with Claude Code
https://claude.ai/code/session_01VbpgaY282xpLjwA8aQv3x9