fix: default skills search to relevance#802
Conversation
|
Someone is attempting to deploy a commit to the Amantus Machina Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThis PR fixes a result-ordering bug on the The fix is clean and well-reasoned. Key observations:
Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/__tests__/skills-index.test.tsx
Line: 181-204
Comment:
**Consider adding a negative-path test for the guard condition**
The new test only exercises the case where the sort _is_ reset (implicit browse default). The key guard — `prev.dir === undefined` — that prevents resetting an explicitly-chosen `downloads` sort has no corresponding test. If that condition were accidentally removed, existing tests would still pass.
Adding a sibling test like the following would fully validate the invariant:
```ts
it('preserves explicitly user-set downloads sort when entering search', async () => {
searchMock = { sort: 'downloads', dir: 'desc' }
vi.useFakeTimers()
render(<SkillsIndex />)
const input = screen.getByPlaceholderText('Filter by name, slug, or summary…')
await act(async () => {
fireEvent.change(input, { target: { value: 'cli-design-framework' } })
await vi.runAllTimersAsync()
})
expect(navigateMock).toHaveBeenCalled()
const lastCall = navigateMock.mock.calls.at(-1)?.[0] as {
replace?: boolean
search: (prev: Record<string, unknown>) => Record<string, unknown>
}
// dir is explicitly set, so sort must not be cleared
expect(lastCall.search({ sort: 'downloads', dir: 'desc' })).toEqual({
q: 'cli-design-framework',
sort: 'downloads',
dir: 'desc',
})
})
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: 8cbca18 |
|
Just adding some context relative to #778 in case it helps with triage: I took a look at the follow-up there, and it does address the earlier concern about manual sort overrides during search. The remaining difference in this PR is mostly about scope:
If maintainers would prefer to consolidate on #778, I’d be very happy for this narrower guard behavior and the accompanying test coverage to be folded into that PR instead. |
|
Thanks for the context! We intentionally chose to reset sort on every query change rather than only on the first entry — our reasoning is that when a user is actively typing/editing a search query, their primary intent is finding the most relevant result, so relevance sort should be the consistent default. Users can always re-select a different sort after their query settles. That said, your test coverage is great and would be a nice addition either way. Happy to coordinate with maintainers on the best path forward. |
Summary
Show the bug
bug_report_clawhub_01_compressed.mp4
Testing
UI