warm search indexes on search intent#8903
Conversation
Signed-off-by: Elure <ioumih32@gmail.com>
Signed-off-by: Elure <ioumih32@gmail.com>
Signed-off-by: Elure <ioumih32@gmail.com>
Signed-off-by: Elure <ioumih32@gmail.com>
Signed-off-by: Elure <ioumih32@gmail.com>
Signed-off-by: Elure <ioumih32@gmail.com>
Signed-off-by: Elure <ioumih32@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryMedium Risk Overview Propagates an optional Adds unit tests covering URL prefixing, single-flight warmup behavior, and the new modal warmup triggers. Reviewed by Cursor Bugbot for commit c2080fa. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Pull request overview
This PR improves perceived search responsiveness by preloading (warming) the Orama search indexes when the user shows “search intent” (hover/focus/pointerdown or Ctrl/Cmd+K) and by reusing a single cached warm-up promise so index data is only loaded once.
Changes:
- Add
onWarmupplumbing throughSearchBox→SearchModaland trigger warm-up from intent events + globalCtrl/Cmd+K. - Refactor Orama setup into
createOramaClient()that exposes both{ client, warmup }, caching the warm-up promise. - Add unit tests covering warm-up triggers and the “warm only once” cached warm-up path.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ui-components/src/Common/Search/Modal/index.tsx | Adds warm-up triggers (hover/focus/pointerdown + global shortcut) via new onWarmup prop. |
| packages/ui-components/src/Common/Search/Modal/tests/index.test.jsx | Adds tests ensuring warm-up is triggered by intent events and keyboard shortcut. |
| packages/ui-components/src/Common/Search/index.tsx | Wires new onWarmup prop from SearchBox into SearchModal. |
| apps/site/components/withSearch.tsx | Introduces createOramaClient() with cached warmup() and passes warm-up into SearchBox. |
| apps/site/components/tests/withSearch.test.jsx | Adds tests for URL prefixing and ensuring warm-up executes only once. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| global.fetch = mock.fn(async url => ({ | ||
| json: async () => ({ | ||
| docs: { | ||
| docs: { | ||
| [String(url)]: { href: '/result', title: 'Node.js' }, | ||
| }, | ||
| }, | ||
| }), | ||
| })); | ||
|
|
||
| const { client, warmup } = createOramaClient({ | ||
| '/docs': 'https://example.com/docs.json', | ||
| '/learn': 'https://example.com/learn.json', | ||
| }); | ||
|
|
||
| await Promise.all([warmup(), warmup()]); | ||
| await client.search({ term: 'node' }); | ||
|
|
||
| assert.equal(global.fetch.mock.callCount(), 2); | ||
| assert.equal(insertMultipleMock.mock.callCount(), 2); | ||
| assert.equal(searchMock.mock.callCount(), 1); |
avivkeller
left a comment
There was a problem hiding this comment.
Why is this needed? What real difference does this make?
|
I believe search should feel more responsive, so this change starts loading the Orama indexes as soon as the user shows search intent. It makes the first search feel faster on slower networks. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Elure <ioumih32@gmail.com>
Description
Ctrl/Cmd+KValidation
Check List
pnpm formatto ensure the code follows the style guide.pnpm testto check if all tests are passing.pnpm buildto check if the website builds without errors.